summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 23:56:39 +0000
committersehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 23:56:39 +0000
commit8d292399e6dcdfa776a1de94da07841bf1487f5b (patch)
treea70d24eccd67dd83092de47eae8388aa69245ff5
parent9923b6dc2cb443d5c8c10fa4a33746cd284fb9bb (diff)
downloadchromium_src-8d292399e6dcdfa776a1de94da07841bf1487f5b.zip
chromium_src-8d292399e6dcdfa776a1de94da07841bf1487f5b.tar.gz
chromium_src-8d292399e6dcdfa776a1de94da07841bf1487f5b.tar.bz2
Audio support for native client requires some additional features
from pepper. Notably, the existing pepper implementation was, by default, creating a high-priority producer thread. For the NaCl version this thread should be in the NaCl module, and hence we need to separate thread creation from pre-filling with the callback. The latter is used to send an RPC to NaCl to pass the shared memory and sync socket. Getting the shared memory was done by the first reserved state value. Getting the sync socket required allocating a second. Also changed the pepper test plugin to use the new startThread member. Review URL: http://codereview.chromium.org/593023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38544 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/pepper_devices.cc5
-rw-r--r--chrome/renderer/pepper_devices.h1
-rw-r--r--chrome/renderer/webplugin_delegate_pepper.cc11
-rw-r--r--third_party/npapi/bindings/npapi_extensions.h1
-rw-r--r--third_party/npapi/bindings/npapi_extensions_private.h5
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.cc1
6 files changed, 20 insertions, 4 deletions
diff --git a/chrome/renderer/pepper_devices.cc b/chrome/renderer/pepper_devices.cc
index 4a831f4..cfd8076 100644
--- a/chrome/renderer/pepper_devices.cc
+++ b/chrome/renderer/pepper_devices.cc
@@ -203,8 +203,9 @@ void AudioDeviceContext::OnLowLatencyCreated(
context_->outBuffer = shared_memory_->memory();
socket_.reset(new base::SyncSocket(socket_handle));
- if (context_->config.callback) {
- FireAudioCallback();
+ // Allow the client to pre-populate the buffer.
+ FireAudioCallback();
+ if (context_->config.startThread) {
audio_thread_.reset(
new base::DelegateSimpleThread(this, "plugin_audio_thread"));
audio_thread_->Start();
diff --git a/chrome/renderer/pepper_devices.h b/chrome/renderer/pepper_devices.h
index 2aa0b54..408680c 100644
--- a/chrome/renderer/pepper_devices.h
+++ b/chrome/renderer/pepper_devices.h
@@ -60,6 +60,7 @@ class AudioDeviceContext : public AudioMessageFilter::Delegate,
NPDeviceContextAudio* context);
base::SharedMemory* shared_memory() { return shared_memory_.get(); }
+ base::SyncSocket* socket() { return socket_.get(); }
private:
diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc
index a2591d3..8a0dd60 100644
--- a/chrome/renderer/webplugin_delegate_pepper.cc
+++ b/chrome/renderer/webplugin_delegate_pepper.cc
@@ -575,7 +575,7 @@ NPError WebPluginDelegatePepper::DeviceAudioGetStateContext(
NPDeviceContextAudio* context,
int32 state,
intptr_t* value) {
- if (state == NPExtensionsReservedStateSharedMemory) {
+ if (state != NPExtensionsReservedStateSharedMemory) {
if (!context)
return NPERR_INVALID_PARAM;
AudioDeviceContext* ctx = audio_contexts_.Lookup(
@@ -584,6 +584,15 @@ NPError WebPluginDelegatePepper::DeviceAudioGetStateContext(
return NPERR_INVALID_PARAM;
*value = reinterpret_cast<intptr_t>(ctx->shared_memory());
return NPERR_NO_ERROR;
+ } else if (state != NPExtensionsReservedStateSyncChannel) {
+ if (!context)
+ return NPERR_INVALID_PARAM;
+ AudioDeviceContext* ctx = audio_contexts_.Lookup(
+ reinterpret_cast<intptr_t>(context->reserved));
+ if (!ctx)
+ return NPERR_INVALID_PARAM;
+ *value = reinterpret_cast<intptr_t>(ctx->socket());
+ return NPERR_NO_ERROR;
}
return NPERR_GENERIC_ERROR;
}
diff --git a/third_party/npapi/bindings/npapi_extensions.h b/third_party/npapi/bindings/npapi_extensions.h
index 4bfac2c..fca509e 100644
--- a/third_party/npapi/bindings/npapi_extensions.h
+++ b/third_party/npapi/bindings/npapi_extensions.h
@@ -398,6 +398,7 @@ typedef struct _NPDeviceContextAudioConfig {
int32 outputChannelMap;
int32 inputChannelMap;
int32 sampleFrameCount;
+ uint32 startThread;
uint32 flags;
NPAudioCallback callback;
void *userData;
diff --git a/third_party/npapi/bindings/npapi_extensions_private.h b/third_party/npapi/bindings/npapi_extensions_private.h
index ea84024..b333d21 100644
--- a/third_party/npapi/bindings/npapi_extensions_private.h
+++ b/third_party/npapi/bindings/npapi_extensions_private.h
@@ -10,9 +10,12 @@
// Some reserved GetStateContext/SetStateContext selectors.
typedef enum {
- NPExtensionsReservedStateSharedMemory = 66536
+ NPExtensionsReservedStateSharedMemory = 66536,
// Used by the Device2D and Audio devices to return a pointer to the
// structure used to implement the shared memory buffer for the device.
+ NPExtensionsReservedStateSyncChannel = 66537
+ // Used by the Audio device to return a pointer to the
+ // structure used to implement the synchronization channel for the device.
} NPExtensionsReservedStates;
#endif /* _NP_EXTENSIONS_PRIVATE_H_ */
diff --git a/webkit/tools/pepper_test_plugin/plugin_object.cc b/webkit/tools/pepper_test_plugin/plugin_object.cc
index 4c1b2a6..35c2a2c 100644
--- a/webkit/tools/pepper_test_plugin/plugin_object.cc
+++ b/webkit/tools/pepper_test_plugin/plugin_object.cc
@@ -399,6 +399,7 @@ void PluginObject::SetWindow(const NPWindow& window) {
cfg.outputChannelMap = NPAudioChannelStereo;
cfg.inputChannelMap = NPAudioChannelNone;
cfg.sampleFrameCount = 2048;
+ cfg.startThread = 1; // Start a thread for the audio producer.
cfg.flags = 0;
cfg.callback = &SineWaveCallback<200, int16>;
deviceaudio_->initializeContext(npp_, &cfg, &context_audio_);