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

Side by Side Diff: chrome/renderer/pepper_plugin_delegate_impl.cc

Issue 5202002: changes for proxy audio (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/c/dev/ppb_audio_trusted_dev.h » ('j') | ppapi/c/dev/ppb_audio_trusted_dev.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <cmath> 5 #include <cmath>
6 6
7 #include "chrome/renderer/pepper_plugin_delegate_impl.h" 7 #include "chrome/renderer/pepper_plugin_delegate_impl.h"
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/surface/transport_dib.h" 10 #include "app/surface/transport_dib.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 private: 117 private:
118 WebKit::WebView* web_view_; 118 WebKit::WebView* web_view_;
119 ggl::Context* context_; 119 ggl::Context* context_;
120 }; 120 };
121 121
122 #endif // ENABLE_GPU 122 #endif // ENABLE_GPU
123 123
124 class PlatformAudioImpl 124 class PlatformAudioImpl
125 : public pepper::PluginDelegate::PlatformAudio, 125 : public pepper::PluginDelegate::PlatformAudio,
126 public AudioMessageFilter::Delegate { 126 public AudioMessageFilter::Delegate,
127 public base::RefCountedThreadSafe<PlatformAudioImpl> {
127 public: 128 public:
128 explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter) 129 explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter)
129 : client_(NULL), filter_(filter), stream_id_(0) { 130 : client_(NULL), filter_(filter), stream_id_(0),
131 main_message_loop_(MessageLoop::current()) {
130 DCHECK(filter_); 132 DCHECK(filter_);
131 } 133 }
132 134
133 virtual ~PlatformAudioImpl() { 135 virtual ~PlatformAudioImpl() {
134 // Make sure we have been shut down. 136 // Make sure we have been shut down.
135 DCHECK_EQ(0, stream_id_); 137 DCHECK_EQ(0, stream_id_);
136 DCHECK(!client_); 138 DCHECK(!client_);
137 } 139 }
138 140
139 // Initialize this audio context. StreamCreated() will be called when the 141 // Initialize this audio context. StreamCreated() will be called when the
(...skipping 30 matching lines...) Expand all
170 172
171 virtual void OnVolume(double volume) { } 173 virtual void OnVolume(double volume) { }
172 174
173 // The client to notify when the stream is created. 175 // The client to notify when the stream is created.
174 pepper::PluginDelegate::PlatformAudio::Client* client_; 176 pepper::PluginDelegate::PlatformAudio::Client* client_;
175 // MessageFilter used to send/receive IPC. 177 // MessageFilter used to send/receive IPC.
176 scoped_refptr<AudioMessageFilter> filter_; 178 scoped_refptr<AudioMessageFilter> filter_;
177 // Our ID on the MessageFilter. 179 // Our ID on the MessageFilter.
178 int32 stream_id_; 180 int32 stream_id_;
179 181
182 MessageLoop* main_message_loop_;
183
180 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); 184 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl);
181 }; 185 };
182 186
183 #ifdef ENABLE_GPU 187 #ifdef ENABLE_GPU
184 188
185 bool PlatformContext3DImpl::Init() { 189 bool PlatformContext3DImpl::Init() {
186 // Ignore initializing more than once. 190 // Ignore initializing more than once.
187 if (context_) 191 if (context_)
188 return true; 192 return true;
189 193
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 uint32 length) { 294 uint32 length) {
291 #if defined(OS_WIN) 295 #if defined(OS_WIN)
292 DCHECK(handle); 296 DCHECK(handle);
293 DCHECK(socket_handle); 297 DCHECK(socket_handle);
294 #else 298 #else
295 DCHECK_NE(-1, handle.fd); 299 DCHECK_NE(-1, handle.fd);
296 DCHECK_NE(-1, socket_handle); 300 DCHECK_NE(-1, socket_handle);
297 #endif 301 #endif
298 DCHECK(length); 302 DCHECK(length);
299 303
300 client_->StreamCreated(handle, length, socket_handle); 304 if (MessageLoop::current() == main_message_loop_) {
305 if (client_) {
306 client_->StreamCreated(handle, length, socket_handle);
307 }
308 } else {
309 main_message_loop_->PostTask(FROM_HERE,
310 NewRunnableMethod(this, &PlatformAudioImpl::OnLowLatencyCreated,
311 handle, socket_handle, length));
312 }
301 } 313 }
302 314
303 void PlatformAudioImpl::ShutDown() { 315 void PlatformAudioImpl::ShutDown() {
304 // Make sure we don't call shutdown more than once. 316 // Make sure we don't call shutdown more than once.
305 if (!stream_id_) { 317 if (!stream_id_) {
306 return; 318 return;
307 } 319 }
308 filter_->Send(new ViewHostMsg_CloseAudioStream(0, stream_id_)); 320 filter_->Send(new ViewHostMsg_CloseAudioStream(0, stream_id_));
309 filter_->RemoveDelegate(stream_id_); 321 filter_->RemoveDelegate(stream_id_);
310 stream_id_ = 0; 322 stream_id_ = 0;
311 client_ = NULL; 323 client_ = NULL;
324 // Release on the IO thread so that we avoid race problems with
darin (slow to review) 2010/11/24 20:34:35 As Brett commented on the other file, please put a
nfullagar 2010/11/24 23:01:05 Done.
325 // OnLowLatencyCreated.
326 filter_->message_loop()->ReleaseSoon(FROM_HERE, this);
312 } 327 }
313 328
314 // Implements the VideoDecoder. 329 // Implements the VideoDecoder.
315 class PlatformVideoDecoderImpl 330 class PlatformVideoDecoderImpl
316 : public pepper::PluginDelegate::PlatformVideoDecoder { 331 : public pepper::PluginDelegate::PlatformVideoDecoder {
317 public: 332 public:
318 PlatformVideoDecoderImpl() 333 PlatformVideoDecoderImpl()
319 : input_buffer_size_(0), 334 : input_buffer_size_(0),
320 next_dib_id_(0), 335 next_dib_id_(0),
321 dib_(NULL) { 336 dib_(NULL) {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 568
554 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier, 569 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier,
555 int index) { 570 int index) {
556 render_view_->reportFindInPageSelection( 571 render_view_->reportFindInPageSelection(
557 identifier, index + 1, WebKit::WebRect()); 572 identifier, index + 1, WebKit::WebRect());
558 } 573 }
559 574
560 pepper::PluginDelegate::PlatformAudio* PepperPluginDelegateImpl::CreateAudio( 575 pepper::PluginDelegate::PlatformAudio* PepperPluginDelegateImpl::CreateAudio(
561 uint32_t sample_rate, uint32_t sample_count, 576 uint32_t sample_rate, uint32_t sample_count,
562 pepper::PluginDelegate::PlatformAudio::Client* client) { 577 pepper::PluginDelegate::PlatformAudio::Client* client) {
563 scoped_ptr<PlatformAudioImpl> audio( 578 scoped_refptr<PlatformAudioImpl> audio(
564 new PlatformAudioImpl(render_view_->audio_message_filter())); 579 new PlatformAudioImpl(render_view_->audio_message_filter()));
565 if (audio->Initialize(sample_rate, sample_count, client)) { 580 if (audio->Initialize(sample_rate, sample_count, client)) {
566 return audio.release(); 581 return audio.release();
darin (slow to review) 2010/11/24 20:34:35 I recommend inserting a comment here indicating th
nfullagar 2010/11/24 23:01:05 Done.
567 } else { 582 } else {
568 return NULL; 583 return NULL;
569 } 584 }
570 } 585 }
571 586
572 bool PepperPluginDelegateImpl::RunFileChooser( 587 bool PepperPluginDelegateImpl::RunFileChooser(
573 const WebKit::WebFileChooserParams& params, 588 const WebKit::WebFileChooserParams& params,
574 WebKit::WebFileChooserCompletion* chooser_completion) { 589 WebKit::WebFileChooserCompletion* chooser_completion) {
575 return render_view_->runFileChooser(params, chooser_completion); 590 return render_view_->runFileChooser(params, chooser_completion);
576 } 591 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 839 }
825 840
826 void PepperPluginDelegateImpl::DidStopLoading() { 841 void PepperPluginDelegateImpl::DidStopLoading() {
827 render_view_->DidStopLoadingForPlugin(); 842 render_view_->DidStopLoadingForPlugin();
828 } 843 }
829 844
830 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) { 845 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) {
831 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions( 846 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions(
832 render_view_->routing_id(), restrictions)); 847 render_view_->routing_id(), restrictions));
833 } 848 }
OLDNEW
« no previous file with comments | « no previous file | ppapi/c/dev/ppb_audio_trusted_dev.h » ('j') | ppapi/c/dev/ppb_audio_trusted_dev.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698