Chromium Code Reviews| Index: content/renderer/pepper/ppb_audio_impl.cc |
| diff --git a/content/renderer/pepper/ppb_audio_impl.cc b/content/renderer/pepper/ppb_audio_impl.cc |
| index 98bf7637f4ad96792b72cb90d7a995c0ca7ff284..513c53c5b1d32aa84480061d0a88ae36fd7e7fd5 100644 |
| --- a/content/renderer/pepper/ppb_audio_impl.cc |
| +++ b/content/renderer/pepper/ppb_audio_impl.cc |
| @@ -5,11 +5,11 @@ |
| #include "content/renderer/pepper/ppb_audio_impl.h" |
| #include "base/logging.h" |
| +#include "content/renderer/pepper/pepper_audio_controller.h" |
| #include "content/renderer/pepper/pepper_platform_audio_output.h" |
| #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| #include "content/renderer/pepper/plugin_instance_throttler_impl.h" |
| #include "content/renderer/render_frame_impl.h" |
| -#include "content/renderer/render_view_impl.h" |
| #include "media/audio/audio_output_controller.h" |
| #include "ppapi/c/pp_completion_callback.h" |
| #include "ppapi/c/ppb_audio.h" |
| @@ -47,6 +47,8 @@ PPB_Audio_Impl::~PPB_Audio_Impl() { |
| if (instance && instance->throttler()) { |
| instance->throttler()->RemoveObserver(this); |
| } |
| + if (instance) |
| + instance->audio_controller().RemoveInstance(this); |
|
mlamouri (slow - plz ping)
2016/06/23 13:04:13
nit: you could do:
```
if (instance) {
if (insta
Zhiqiang Zhang (Slow)
2016/06/23 14:50:29
Done.
|
| // Calling ShutDown() makes sure StreamCreated cannot be called anymore and |
| // releases the audio data associated with the pointer. Note however, that |
| @@ -83,6 +85,9 @@ PP_Bool PPB_Audio_Impl::StartPlayback() { |
| return PP_TRUE; |
| } |
| + if (instance) |
| + instance->audio_controller().AddInstance(this); |
| + |
| SetStartPlaybackState(); |
| return PP_FromBool(audio_->StartPlayback()); |
| } |
| @@ -97,6 +102,11 @@ PP_Bool PPB_Audio_Impl::StopPlayback() { |
| StartDeferredPlayback(); |
| } |
| + PepperPluginInstanceImpl* instance = static_cast<PepperPluginInstanceImpl*>( |
| + PepperPluginInstance::Get(pp_instance())); |
| + if (instance) |
| + instance->audio_controller().RemoveInstance(this); |
| + |
| if (!playing()) |
| return PP_TRUE; |
| if (!audio_->StopPlayback()) |
| @@ -173,8 +183,17 @@ void PPB_Audio_Impl::StartDeferredPlayback() { |
| DCHECK(playback_throttled_); |
| playback_throttled_ = false; |
| + PepperPluginInstanceImpl* instance = static_cast<PepperPluginInstanceImpl*>( |
| + PepperPluginInstance::Get(pp_instance())); |
| + if (instance) |
| + instance->audio_controller().RemoveInstance(this); |
|
mlamouri (slow - plz ping)
2016/06/23 13:04:13
Shouldn't that be AddInstance?
Zhiqiang Zhang (Slow)
2016/06/23 14:50:29
Thanks! Done.
|
| + |
| SetStartPlaybackState(); |
| audio_->StartPlayback(); |
| } |
| +void PPB_Audio_Impl::SetVolume(double volume) { |
| + if (audio_) |
| + audio_->SetVolume(volume); |
| +} |
| } // namespace content |