| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ | 6 #define PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 12 |
| 11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
| 16 #include "base/sync_socket.h" | 17 #include "base/sync_socket.h" |
| 17 #include "base/threading/simple_thread.h" | 18 #include "base/threading/simple_thread.h" |
| 18 #include "ppapi/proxy/device_enumeration_resource_helper.h" | 19 #include "ppapi/proxy/device_enumeration_resource_helper.h" |
| 19 #include "ppapi/proxy/plugin_resource.h" | 20 #include "ppapi/proxy/plugin_resource.h" |
| 20 #include "ppapi/shared_impl/scoped_pp_resource.h" | 21 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 21 #include "ppapi/thunk/ppb_audio_input_api.h" | 22 #include "ppapi/thunk/ppb_audio_input_api.h" |
| 22 | 23 |
| 23 namespace media { | 24 namespace media { |
| 24 class AudioBus; | 25 class AudioBus; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void* user_data, | 98 void* user_data, |
| 98 scoped_refptr<TrackedCallback> callback); | 99 scoped_refptr<TrackedCallback> callback); |
| 99 | 100 |
| 100 OpenState open_state_; | 101 OpenState open_state_; |
| 101 | 102 |
| 102 // True if capturing the stream. | 103 // True if capturing the stream. |
| 103 bool capturing_; | 104 bool capturing_; |
| 104 | 105 |
| 105 // Socket used to notify us when new samples are available. This pointer is | 106 // Socket used to notify us when new samples are available. This pointer is |
| 106 // created in SetStreamInfo(). | 107 // created in SetStreamInfo(). |
| 107 scoped_ptr<base::CancelableSyncSocket> socket_; | 108 std::unique_ptr<base::CancelableSyncSocket> socket_; |
| 108 | 109 |
| 109 // Sample buffer in shared memory. This pointer is created in | 110 // Sample buffer in shared memory. This pointer is created in |
| 110 // SetStreamInfo(). The memory is only mapped when the audio thread is | 111 // SetStreamInfo(). The memory is only mapped when the audio thread is |
| 111 // created. | 112 // created. |
| 112 scoped_ptr<base::SharedMemory> shared_memory_; | 113 std::unique_ptr<base::SharedMemory> shared_memory_; |
| 113 | 114 |
| 114 // The size of the sample buffer in bytes. | 115 // The size of the sample buffer in bytes. |
| 115 size_t shared_memory_size_; | 116 size_t shared_memory_size_; |
| 116 | 117 |
| 117 // When the callback is set, this thread is spawned for calling it. | 118 // When the callback is set, this thread is spawned for calling it. |
| 118 scoped_ptr<base::DelegateSimpleThread> audio_input_thread_; | 119 std::unique_ptr<base::DelegateSimpleThread> audio_input_thread_; |
| 119 | 120 |
| 120 // Callback to call when new samples are available. | 121 // Callback to call when new samples are available. |
| 121 PPB_AudioInput_Callback_0_3 audio_input_callback_0_3_; | 122 PPB_AudioInput_Callback_0_3 audio_input_callback_0_3_; |
| 122 PPB_AudioInput_Callback audio_input_callback_; | 123 PPB_AudioInput_Callback audio_input_callback_; |
| 123 | 124 |
| 124 // User data pointer passed verbatim to the callback function. | 125 // User data pointer passed verbatim to the callback function. |
| 125 void* user_data_; | 126 void* user_data_; |
| 126 | 127 |
| 127 // The callback is not directly passed to OnPluginMsgOpenReply() because we | 128 // The callback is not directly passed to OnPluginMsgOpenReply() because we |
| 128 // would like to be able to cancel it early in Close(). | 129 // would like to be able to cancel it early in Close(). |
| 129 scoped_refptr<TrackedCallback> open_callback_; | 130 scoped_refptr<TrackedCallback> open_callback_; |
| 130 | 131 |
| 131 // Owning reference to the current config object. This isn't actually used, | 132 // Owning reference to the current config object. This isn't actually used, |
| 132 // we just dish it out as requested by the plugin. | 133 // we just dish it out as requested by the plugin. |
| 133 ScopedPPResource config_; | 134 ScopedPPResource config_; |
| 134 | 135 |
| 135 DeviceEnumerationResourceHelper enumeration_helper_; | 136 DeviceEnumerationResourceHelper enumeration_helper_; |
| 136 | 137 |
| 137 // The data size (in bytes) of one second of audio input. Used to calculate | 138 // The data size (in bytes) of one second of audio input. Used to calculate |
| 138 // latency. | 139 // latency. |
| 139 size_t bytes_per_second_; | 140 size_t bytes_per_second_; |
| 140 | 141 |
| 141 // AudioBus for shuttling data across the shared memory. | 142 // AudioBus for shuttling data across the shared memory. |
| 142 scoped_ptr<media::AudioBus> audio_bus_; | 143 std::unique_ptr<media::AudioBus> audio_bus_; |
| 143 int sample_frame_count_; | 144 int sample_frame_count_; |
| 144 | 145 |
| 145 // Internal buffer for client's integer audio data. | 146 // Internal buffer for client's integer audio data. |
| 146 int client_buffer_size_bytes_; | 147 int client_buffer_size_bytes_; |
| 147 scoped_ptr<uint8_t[]> client_buffer_; | 148 std::unique_ptr<uint8_t[]> client_buffer_; |
| 148 | 149 |
| 149 DISALLOW_COPY_AND_ASSIGN(AudioInputResource); | 150 DISALLOW_COPY_AND_ASSIGN(AudioInputResource); |
| 150 }; | 151 }; |
| 151 | 152 |
| 152 } // namespace proxy | 153 } // namespace proxy |
| 153 } // namespace ppapi | 154 } // namespace ppapi |
| 154 | 155 |
| 155 #endif // PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ | 156 #endif // PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ |
| OLD | NEW |