| 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_SHARED_IMPL_PPB_AUDIO_SHARED_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PPB_AUDIO_SHARED_H_ |
| 6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_SHARED_H_ | 6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_SHARED_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/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
| 14 #include "base/sync_socket.h" | 15 #include "base/sync_socket.h" |
| 15 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
| 16 #include "media/base/audio_bus.h" | 17 #include "media/base/audio_bus.h" |
| 17 #include "ppapi/c/ppb_audio.h" | 18 #include "ppapi/c/ppb_audio.h" |
| 18 #include "ppapi/c/ppb_audio_config.h" | 19 #include "ppapi/c/ppb_audio_config.h" |
| 19 #include "ppapi/shared_impl/resource.h" | 20 #include "ppapi/shared_impl/resource.h" |
| 20 #include "ppapi/thunk/ppb_audio_api.h" | 21 #include "ppapi/thunk/ppb_audio_api.h" |
| 21 | 22 |
| 22 struct PP_ThreadFunctions; | 23 struct PP_ThreadFunctions; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void StopThread(); | 105 void StopThread(); |
| 105 | 106 |
| 106 // DelegateSimpleThread::Delegate implementation. Run on the audio thread. | 107 // DelegateSimpleThread::Delegate implementation. Run on the audio thread. |
| 107 virtual void Run(); | 108 virtual void Run(); |
| 108 | 109 |
| 109 // True if playing the stream. | 110 // True if playing the stream. |
| 110 bool playing_; | 111 bool playing_; |
| 111 | 112 |
| 112 // Socket used to notify us when audio is ready to accept new samples. This | 113 // Socket used to notify us when audio is ready to accept new samples. This |
| 113 // pointer is created in StreamCreated(). | 114 // pointer is created in StreamCreated(). |
| 114 scoped_ptr<base::CancelableSyncSocket> socket_; | 115 std::unique_ptr<base::CancelableSyncSocket> socket_; |
| 115 | 116 |
| 116 // Sample buffer in shared memory. This pointer is created in | 117 // Sample buffer in shared memory. This pointer is created in |
| 117 // StreamCreated(). The memory is only mapped when the audio thread is | 118 // StreamCreated(). The memory is only mapped when the audio thread is |
| 118 // created. | 119 // created. |
| 119 scoped_ptr<base::SharedMemory> shared_memory_; | 120 std::unique_ptr<base::SharedMemory> shared_memory_; |
| 120 | 121 |
| 121 // The size of the sample buffer in bytes. | 122 // The size of the sample buffer in bytes. |
| 122 size_t shared_memory_size_; | 123 size_t shared_memory_size_; |
| 123 | 124 |
| 124 // When the callback is set, this thread is spawned for calling it. | 125 // When the callback is set, this thread is spawned for calling it. |
| 125 scoped_ptr<base::DelegateSimpleThread> audio_thread_; | 126 std::unique_ptr<base::DelegateSimpleThread> audio_thread_; |
| 126 uintptr_t nacl_thread_id_; | 127 uintptr_t nacl_thread_id_; |
| 127 bool nacl_thread_active_; | 128 bool nacl_thread_active_; |
| 128 | 129 |
| 129 static void CallRun(void* self); | 130 static void CallRun(void* self); |
| 130 | 131 |
| 131 // Callback to call when audio is ready to accept new samples. | 132 // Callback to call when audio is ready to accept new samples. |
| 132 AudioCallbackCombined callback_; | 133 AudioCallbackCombined callback_; |
| 133 | 134 |
| 134 // User data pointer passed verbatim to the callback function. | 135 // User data pointer passed verbatim to the callback function. |
| 135 void* user_data_; | 136 void* user_data_; |
| 136 | 137 |
| 137 // AudioBus for shuttling data across the shared memory. | 138 // AudioBus for shuttling data across the shared memory. |
| 138 scoped_ptr<media::AudioBus> audio_bus_; | 139 std::unique_ptr<media::AudioBus> audio_bus_; |
| 139 | 140 |
| 140 // Internal buffer for client's integer audio data. | 141 // Internal buffer for client's integer audio data. |
| 141 int client_buffer_size_bytes_; | 142 int client_buffer_size_bytes_; |
| 142 scoped_ptr<uint8_t[]> client_buffer_; | 143 std::unique_ptr<uint8_t[]> client_buffer_; |
| 143 | 144 |
| 144 // The size (in bytes) of one second of audio data. Used to calculate latency. | 145 // The size (in bytes) of one second of audio data. Used to calculate latency. |
| 145 size_t bytes_per_second_; | 146 size_t bytes_per_second_; |
| 146 | 147 |
| 147 // Buffer index used to coordinate with the browser side audio receiver. | 148 // Buffer index used to coordinate with the browser side audio receiver. |
| 148 uint32_t buffer_index_; | 149 uint32_t buffer_index_; |
| 149 | 150 |
| 150 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Shared); | 151 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Shared); |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 } // namespace ppapi | 154 } // namespace ppapi |
| 154 | 155 |
| 155 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_SHARED_H_ | 156 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_SHARED_H_ |
| OLD | NEW |