| OLD | NEW |
| 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/location.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "media/base/audio_renderer_mixer.h" | 10 #include "media/base/audio_renderer_mixer.h" |
| 10 | 11 |
| 11 namespace media { | 12 namespace media { |
| 12 | 13 |
| 13 AudioRendererMixerInput::AudioRendererMixerInput( | 14 AudioRendererMixerInput::AudioRendererMixerInput( |
| 14 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb) | 15 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb) |
| 15 : playing_(false), | 16 : playing_(false), |
| 16 initialized_(false), | 17 initialized_(false), |
| 17 volume_(1.0f), | 18 volume_(1.0f), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 88 |
| 88 mixer_->RemoveMixerInput(this); | 89 mixer_->RemoveMixerInput(this); |
| 89 playing_ = false; | 90 playing_ = false; |
| 90 } | 91 } |
| 91 | 92 |
| 92 bool AudioRendererMixerInput::SetVolume(double volume) { | 93 bool AudioRendererMixerInput::SetVolume(double volume) { |
| 93 volume_ = volume; | 94 volume_ = volume; |
| 94 return true; | 95 return true; |
| 95 } | 96 } |
| 96 | 97 |
| 98 void AudioRendererMixerInput::SwitchOutputDevice( |
| 99 const std::string& device_id, |
| 100 const GURL& security_origin, |
| 101 const SwitchOutputDeviceCB& callback) { |
| 102 DVLOG(1) << __FUNCTION__ |
| 103 << "(" << device_id << ", " << security_origin << ")"; |
| 104 if (mixer_) { |
| 105 mixer_->SwitchOutputDevice(device_id, security_origin, callback); |
| 106 } else { |
| 107 callback.Run(SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED); |
| 108 } |
| 109 } |
| 110 |
| 97 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus, | 111 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus, |
| 98 base::TimeDelta buffer_delay) { | 112 base::TimeDelta buffer_delay) { |
| 99 int frames_filled = callback_->Render( | 113 int frames_filled = callback_->Render( |
| 100 audio_bus, static_cast<int>(buffer_delay.InMillisecondsF() + 0.5)); | 114 audio_bus, static_cast<int>(buffer_delay.InMillisecondsF() + 0.5)); |
| 101 | 115 |
| 102 // AudioConverter expects unfilled frames to be zeroed. | 116 // AudioConverter expects unfilled frames to be zeroed. |
| 103 if (frames_filled < audio_bus->frames()) { | 117 if (frames_filled < audio_bus->frames()) { |
| 104 audio_bus->ZeroFramesPartial( | 118 audio_bus->ZeroFramesPartial( |
| 105 frames_filled, audio_bus->frames() - frames_filled); | 119 frames_filled, audio_bus->frames() - frames_filled); |
| 106 } | 120 } |
| 107 | 121 |
| 108 return frames_filled > 0 ? volume_ : 0; | 122 return frames_filled > 0 ? volume_ : 0; |
| 109 } | 123 } |
| 110 | 124 |
| 111 void AudioRendererMixerInput::OnRenderError() { | 125 void AudioRendererMixerInput::OnRenderError() { |
| 112 callback_->OnRenderError(); | 126 callback_->OnRenderError(); |
| 113 } | 127 } |
| 114 | 128 |
| 115 } // namespace media | 129 } // namespace media |
| OLD | NEW |