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

Unified Diff: content/renderer/pepper/pepper_audio_controller.cc

Issue 2755613002: Support audio output device enumeration and selection in PPAPI (Closed)
Patch Set: Should not include local change to ppapi/generators/idl_outfile.py Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/pepper_audio_controller.cc
diff --git a/content/renderer/pepper/pepper_audio_controller.cc b/content/renderer/pepper/pepper_audio_controller.cc
index 88d80f11bd02c441888e1403291875582f4b4e00..5043273830268a3ea281ec34b262eabacbaaa4ea 100644
--- a/content/renderer/pepper/pepper_audio_controller.cc
+++ b/content/renderer/pepper/pepper_audio_controller.cc
@@ -4,6 +4,7 @@
#include "content/renderer/pepper/pepper_audio_controller.h"
+#include "content/renderer/pepper/pepper_audio_output_host.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/ppb_audio_impl.h"
#include "content/renderer/render_frame_impl.h"
@@ -27,7 +28,9 @@ void PepperAudioController::AddInstance(PPB_Audio_Impl* audio) {
if (ppb_audios_.count(audio))
return;
- if (ppb_audios_.empty()) {
+ // Starts playback iff this |PPB_Audio_Impl| object is the
+ // first instance.
+ if (audio_output_hosts_.empty() && ppb_audios_.empty()) {
RenderFrameImpl* render_frame = instance_->render_frame();
if (render_frame)
render_frame->PepperStartsPlayback(instance_);
@@ -36,6 +39,23 @@ void PepperAudioController::AddInstance(PPB_Audio_Impl* audio) {
ppb_audios_.insert(audio);
}
+void PepperAudioController::AddInstance(PepperAudioOutputHost* audio_output) {
+ if (!instance_)
+ return;
+ if (audio_output_hosts_.count(audio_output))
+ return;
+
+ // Starts playback iff this |PepperAudioOutputHost| object is the
+ // first instance.
+ if (audio_output_hosts_.empty() && ppb_audios_.empty()) {
+ RenderFrameImpl* render_frame = instance_->render_frame();
+ if (render_frame)
+ render_frame->PepperStartsPlayback(instance_);
+ }
+
+ audio_output_hosts_.insert(audio_output);
+}
+
void PepperAudioController::RemoveInstance(PPB_Audio_Impl* audio) {
if (!instance_)
return;
@@ -44,7 +64,24 @@ void PepperAudioController::RemoveInstance(PPB_Audio_Impl* audio) {
ppb_audios_.erase(audio);
- if (ppb_audios_.empty())
+ // Stops playback iff this |PPB_Audio_Impl| object is the
+ // last instance
+ if (audio_output_hosts_.empty() && ppb_audios_.empty())
+ NotifyPlaybackStopsOnEmpty();
+}
+
+void PepperAudioController::RemoveInstance(
+ PepperAudioOutputHost* audio_output) {
+ if (!instance_)
+ return;
+ if (!audio_output_hosts_.count(audio_output))
+ return;
+
+ audio_output_hosts_.erase(audio_output);
+
+ // Stops playback iff this |PepperAudioOutputHost| object is the
+ // last instance
+ if (audio_output_hosts_.empty() && ppb_audios_.empty())
NotifyPlaybackStopsOnEmpty();
}
@@ -54,15 +91,19 @@ void PepperAudioController::SetVolume(double volume) {
for (auto* ppb_audio : ppb_audios_)
ppb_audio->SetVolume(volume);
+
+ for (auto* audio_output_host : audio_output_hosts_)
+ audio_output_host->SetVolume(volume);
}
void PepperAudioController::OnPepperInstanceDeleted() {
DCHECK(instance_);
- if (!ppb_audios_.empty())
+ if (!audio_output_hosts_.empty() || !ppb_audios_.empty())
NotifyPlaybackStopsOnEmpty();
ppb_audios_.clear();
+ audio_output_hosts_.clear();
instance_ = nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698