Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: ppapi/shared_impl/ppb_audio_shared.h

Issue 22320004: Add a new parameter |latency| to PPB_Audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/shared_impl/ppb_audio_config_shared.h ('k') | ppapi/shared_impl/ppb_audio_shared.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d7faa5b5b2865f3ab51ec388e9a05c21f9f0845b 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 AudioCallbackCombined {
+ public:
+ AudioCallbackCombined();
+ explicit AudioCallbackCombined(PPB_Audio_Callback_1_0 callback_1_0);
+ explicit AudioCallbackCombined(PPB_Audio_Callback callback);
+
+ ~AudioCallbackCombined();
+
+ 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 AudioCallbackCombined& 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_;
+ AudioCallbackCombined 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);
};
« no previous file with comments | « ppapi/shared_impl/ppb_audio_config_shared.h ('k') | ppapi/shared_impl/ppb_audio_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698