summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/pepper_plugin_delegate_impl.cc
diff options
context:
space:
mode:
authornfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-25 00:29:25 +0000
committernfullagar@google.com <nfullagar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-25 00:29:25 +0000
commit06417271819fc46ae45a76ed0d2e2bb18b5dad01 (patch)
treea13c12ada2e5c4875f3a7de54a8464785744b3ba /chrome/renderer/pepper_plugin_delegate_impl.cc
parentf68e75ab0e1215c0f3446efc0586a4be02798878 (diff)
downloadchromium_src-06417271819fc46ae45a76ed0d2e2bb18b5dad01.zip
chromium_src-06417271819fc46ae45a76ed0d2e2bb18b5dad01.tar.gz
chromium_src-06417271819fc46ae45a76ed0d2e2bb18b5dad01.tar.bz2
changes for proxy audio
- includes Darin's changes to move StreamCreated() to main thread - callback for delivering handles to proxy - changes to trusted interface BUG=none TEST=chrome/src/ppapi/examples/audio/audio.cc Review URL: http://codereview.chromium.org/5202002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/pepper_plugin_delegate_impl.cc')
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc26
1 files changed, 22 insertions, 4 deletions
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index c7aa4b0..3cf9183 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -123,10 +123,12 @@ class PlatformContext3DImpl : public pepper::PluginDelegate::PlatformContext3D {
class PlatformAudioImpl
: public pepper::PluginDelegate::PlatformAudio,
- public AudioMessageFilter::Delegate {
+ public AudioMessageFilter::Delegate,
+ public base::RefCountedThreadSafe<PlatformAudioImpl> {
public:
explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter)
- : client_(NULL), filter_(filter), stream_id_(0) {
+ : client_(NULL), filter_(filter), stream_id_(0),
+ main_message_loop_(MessageLoop::current()) {
DCHECK(filter_);
}
@@ -177,6 +179,8 @@ class PlatformAudioImpl
// Our ID on the MessageFilter.
int32 stream_id_;
+ MessageLoop* main_message_loop_;
+
DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl);
};
@@ -297,7 +301,15 @@ void PlatformAudioImpl::OnLowLatencyCreated(
#endif
DCHECK(length);
- client_->StreamCreated(handle, length, socket_handle);
+ if (MessageLoop::current() == main_message_loop_) {
+ if (client_) {
+ client_->StreamCreated(handle, length, socket_handle);
+ }
+ } else {
+ main_message_loop_->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &PlatformAudioImpl::OnLowLatencyCreated,
+ handle, socket_handle, length));
+ }
}
void PlatformAudioImpl::ShutDown() {
@@ -309,6 +321,10 @@ void PlatformAudioImpl::ShutDown() {
filter_->RemoveDelegate(stream_id_);
stream_id_ = 0;
client_ = NULL;
+
+ // Release on the IO thread so that we avoid race problems with
+ // OnLowLatencyCreated.
+ filter_->message_loop()->ReleaseSoon(FROM_HERE, this);
}
// Implements the VideoDecoder.
@@ -560,9 +576,11 @@ void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier,
pepper::PluginDelegate::PlatformAudio* PepperPluginDelegateImpl::CreateAudio(
uint32_t sample_rate, uint32_t sample_count,
pepper::PluginDelegate::PlatformAudio::Client* client) {
- scoped_ptr<PlatformAudioImpl> audio(
+ scoped_refptr<PlatformAudioImpl> audio(
new PlatformAudioImpl(render_view_->audio_message_filter()));
if (audio->Initialize(sample_rate, sample_count, client)) {
+
+ // Also note ReleaseSoon invoked in PlatformAudioImpl::ShutDown().
return audio.release();
} else {
return NULL;