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

Side by Side Diff: webkit/plugins/ppapi/ppb_audio_impl.cc

Issue 6282007: First pass at making the proxy handle multiple renderers. This associates the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/plugin_module.cc ('k') | webkit/plugins/ppapi/ppb_flash_impl.h » ('j') | no next file with comments »
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 "webkit/plugins/ppapi/ppb_audio_impl.h" 5 #include "webkit/plugins/ppapi/ppb_audio_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/c/pp_completion_callback.h" 8 #include "ppapi/c/pp_completion_callback.h"
9 #include "ppapi/c/ppb_audio.h" 9 #include "ppapi/c/ppb_audio.h"
10 #include "ppapi/c/ppb_audio_config.h" 10 #include "ppapi/c/ppb_audio_config.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 scoped_refptr<PPB_AudioConfig_Impl> config( 43 scoped_refptr<PPB_AudioConfig_Impl> config(
44 new PPB_AudioConfig_Impl(instance, sample_rate, sample_frame_count)); 44 new PPB_AudioConfig_Impl(instance, sample_rate, sample_frame_count));
45 return config->GetReference(); 45 return config->GetReference();
46 } 46 }
47 47
48 uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate, 48 uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
49 uint32_t requested_sample_frame_count) { 49 uint32_t requested_sample_frame_count) {
50 // TODO(brettw) Currently we don't actually query to get a value from the 50 // TODO(brettw) Currently we don't actually query to get a value from the
51 // hardware, so we always return the input for in-range values. 51 // hardware, so we always return the input for in-range values.
52 //
53 // Danger: this code is duplicated in the audio config proxy.
52 if (requested_sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT) 54 if (requested_sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
53 return PP_AUDIOMINSAMPLEFRAMECOUNT; 55 return PP_AUDIOMINSAMPLEFRAMECOUNT;
54 if (requested_sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT) 56 if (requested_sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT)
55 return PP_AUDIOMAXSAMPLEFRAMECOUNT; 57 return PP_AUDIOMAXSAMPLEFRAMECOUNT;
56 return requested_sample_frame_count; 58 return requested_sample_frame_count;
57 } 59 }
58 60
59 PP_Bool IsAudioConfig(PP_Resource resource) { 61 PP_Bool IsAudioConfig(PP_Resource resource) {
60 scoped_refptr<PPB_AudioConfig_Impl> config = 62 scoped_refptr<PPB_AudioConfig_Impl> config =
61 Resource::GetAs<PPB_AudioConfig_Impl>(resource); 63 Resource::GetAs<PPB_AudioConfig_Impl>(resource);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 214
213 PPB_Audio_Impl::PPB_Audio_Impl(PluginInstance* instance) 215 PPB_Audio_Impl::PPB_Audio_Impl(PluginInstance* instance)
214 : Resource(instance), 216 : Resource(instance),
215 audio_(NULL), 217 audio_(NULL),
216 create_callback_pending_(false) { 218 create_callback_pending_(false) {
217 create_callback_ = PP_MakeCompletionCallback(NULL, NULL); 219 create_callback_ = PP_MakeCompletionCallback(NULL, NULL);
218 } 220 }
219 221
220 PPB_Audio_Impl::~PPB_Audio_Impl() { 222 PPB_Audio_Impl::~PPB_Audio_Impl() {
221 // Calling ShutDown() makes sure StreamCreated cannot be called anymore. 223 // Calling ShutDown() makes sure StreamCreated cannot be called anymore.
222 audio_->ShutDown(); 224 if (audio_) {
223 audio_ = NULL; 225 audio_->ShutDown();
226 audio_ = NULL;
227 }
224 228
225 // If the completion callback hasn't fired yet, do so here 229 // If the completion callback hasn't fired yet, do so here
226 // with an error condition. 230 // with an error condition.
227 if (create_callback_pending_) { 231 if (create_callback_pending_) {
228 PP_RunCompletionCallback(&create_callback_, PP_ERROR_ABORTED); 232 PP_RunCompletionCallback(&create_callback_, PP_ERROR_ABORTED);
229 create_callback_pending_ = false; 233 create_callback_pending_ = false;
230 } 234 }
231 } 235 }
232 236
233 const PPB_Audio* PPB_Audio_Impl::GetInterface() { 237 const PPB_Audio* PPB_Audio_Impl::GetInterface() {
(...skipping 22 matching lines...) Expand all
256 config_->sample_frame_count(), 260 config_->sample_frame_count(),
257 this); 261 this);
258 return audio_ != NULL; 262 return audio_ != NULL;
259 } 263 }
260 264
261 PP_Resource PPB_Audio_Impl::GetCurrentConfig() { 265 PP_Resource PPB_Audio_Impl::GetCurrentConfig() {
262 return config_->GetReference(); 266 return config_->GetReference();
263 } 267 }
264 268
265 bool PPB_Audio_Impl::StartPlayback() { 269 bool PPB_Audio_Impl::StartPlayback() {
270 if (!audio_)
271 return false;
266 if (playing()) 272 if (playing())
267 return true; 273 return true;
268 SetStartPlaybackState(); 274 SetStartPlaybackState();
269 return audio_->StartPlayback(); 275 return audio_->StartPlayback();
270 } 276 }
271 277
272 bool PPB_Audio_Impl::StopPlayback() { 278 bool PPB_Audio_Impl::StopPlayback() {
279 if (!audio_)
280 return false;
273 if (!playing()) 281 if (!playing())
274 return true; 282 return true;
275 if (!audio_->StopPlayback()) 283 if (!audio_->StopPlayback())
276 return false; 284 return false;
277 SetStopPlaybackState(); 285 SetStopPlaybackState();
278 return true; 286 return true;
279 } 287 }
280 288
281 int32_t PPB_Audio_Impl::Open(PluginDelegate* plugin_delegate, 289 int32_t PPB_Audio_Impl::Open(PluginDelegate* plugin_delegate,
282 PP_Resource config_id, 290 PP_Resource config_id,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // the I/O thread and back, but this extra complexity doesn't seem worth it 363 // the I/O thread and back, but this extra complexity doesn't seem worth it
356 // just to clean up these handles faster. 364 // just to clean up these handles faster.
357 } else { 365 } else {
358 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); 366 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle);
359 } 367 }
360 } 368 }
361 369
362 } // namespace ppapi 370 } // namespace ppapi
363 } // namespace webkit 371 } // namespace webkit
364 372
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/plugin_module.cc ('k') | webkit/plugins/ppapi/ppb_flash_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698