Chromium Code Reviews| Index: ppapi/shared_impl/ppb_audio_shared.h |
| diff --git a/ppapi/shared_impl/ppb_audio_shared.h b/ppapi/shared_impl/ppb_audio_shared.h |
| index cccfbfacd23975c27bb120a9e94693fff74f300a..c8af131b4a7c6d9ca6b08b9405250766a71e0349 100644 |
| --- a/ppapi/shared_impl/ppb_audio_shared.h |
| +++ b/ppapi/shared_impl/ppb_audio_shared.h |
| @@ -11,6 +11,7 @@ |
| #include "base/threading/simple_thread.h" |
| #include "media/base/audio_bus.h" |
| #include "ppapi/c/ppb_audio.h" |
| +#include "ppapi/c/ppb_audio_config.h" |
| #include "ppapi/shared_impl/resource.h" |
| #include "ppapi/thunk/ppb_audio_api.h" |
| @@ -20,6 +21,26 @@ |
| namespace ppapi { |
| +class PPAPI_SHARED_EXPORT AudioCallback { |
|
dmichael (off chromium)
2013/08/06 19:43:25
We used the suffix "Combined" in another place whe
yzshen1
2013/08/07 20:51:06
Done.
|
| + public: |
| + AudioCallback(); |
| + AudioCallback(PPB_Audio_Callback_1_0 callback_1_0); |
| + AudioCallback(PPB_Audio_Callback callback); |
|
dmichael (off chromium)
2013/08/06 19:43:25
nit: explicit for both of these
yzshen1
2013/08/07 20:51:06
Done.
|
| + |
| + ~AudioCallback(); |
| + |
| + bool IsValid() const; |
| + |
| + void Run(void* sample_buffer, |
| + uint32_t buffer_size_in_bytes, |
| + PP_TimeDelta latency, |
| + void* user_data) const; |
| + |
| + private: |
| + PPB_Audio_Callback_1_0 callback_1_0_; |
| + PPB_Audio_Callback callback_; |
| +}; |
| + |
| // Implements the logic to map shared memory and run the audio thread signaled |
| // from the sync socket. Both the proxy and the renderer implementation use |
| // this code. |
| @@ -36,7 +57,7 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared |
| // is optional. Without a callback, the thread will not be run. This |
| // non-callback mode is used in the renderer with the proxy, since the proxy |
| // handles the callback entirely within the plugin process. |
| - void SetCallback(PPB_Audio_Callback callback, void* user_data); |
| + void SetCallback(const AudioCallback& callback, void* user_data); |
| // Configures the current state to be playing or not. The caller is |
| // responsible for ensuring the new state is the opposite of the current one. |
| @@ -55,6 +76,7 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared |
| base::SharedMemoryHandle shared_memory_handle, |
| size_t shared_memory_size, |
| base::SyncSocket::Handle socket_handle, |
| + PP_AudioSampleRate sample_rate, |
| int sample_frame_count); |
| #if defined(OS_NACL) |
| @@ -99,7 +121,7 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared |
| #endif |
| // Callback to call when audio is ready to accept new samples. |
| - PPB_Audio_Callback callback_; |
| + AudioCallback callback_; |
| // User data pointer passed verbatim to the callback function. |
| void* user_data_; |
| @@ -111,6 +133,9 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared |
| int client_buffer_size_bytes_; |
| scoped_ptr<uint8_t[]> client_buffer_; |
| + // The size (in bytes) of one second of audio data. Used to calculate latency. |
| + size_t bytes_per_second_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Shared); |
| }; |