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

Side by Side Diff: media/base/audio_renderer_mixer_input.cc

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/audio_renderer_mixer_input.h" 5 #include "media/base/audio_renderer_mixer_input.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/base/audio_renderer_mixer.h" 9 #include "media/base/audio_renderer_mixer.h"
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 mixer_->RemoveMixerInput(this); 88 mixer_->RemoveMixerInput(this);
89 playing_ = false; 89 playing_ = false;
90 } 90 }
91 91
92 bool AudioRendererMixerInput::SetVolume(double volume) { 92 bool AudioRendererMixerInput::SetVolume(double volume) {
93 volume_ = volume; 93 volume_ = volume;
94 return true; 94 return true;
95 } 95 }
96 96
97 void AudioRendererMixerInput::SwitchOutputDevice(
98 const std::string& device_id,
99 const GURL& security_origin,
100 const base::Callback<void(int)>& callback) {
101 DVLOG(1) << __FUNCTION__ << "(" << device_id << ", "
102 << security_origin << ")";
103 if (mixer_)
104 mixer_->SwitchOutputDevice(device_id, security_origin, callback);
105 }
106
97 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus, 107 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus,
98 base::TimeDelta buffer_delay) { 108 base::TimeDelta buffer_delay) {
99 int frames_filled = callback_->Render( 109 int frames_filled = callback_->Render(
100 audio_bus, static_cast<int>(buffer_delay.InMillisecondsF() + 0.5)); 110 audio_bus, static_cast<int>(buffer_delay.InMillisecondsF() + 0.5));
101 111
102 // AudioConverter expects unfilled frames to be zeroed. 112 // AudioConverter expects unfilled frames to be zeroed.
103 if (frames_filled < audio_bus->frames()) { 113 if (frames_filled < audio_bus->frames()) {
104 audio_bus->ZeroFramesPartial( 114 audio_bus->ZeroFramesPartial(
105 frames_filled, audio_bus->frames() - frames_filled); 115 frames_filled, audio_bus->frames() - frames_filled);
106 } 116 }
107 117
108 return frames_filled > 0 ? volume_ : 0; 118 return frames_filled > 0 ? volume_ : 0;
109 } 119 }
110 120
111 void AudioRendererMixerInput::OnRenderError() { 121 void AudioRendererMixerInput::OnRenderError() {
112 callback_->OnRenderError(); 122 callback_->OnRenderError();
113 } 123 }
114 124
115 } // namespace media 125 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698