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

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

Issue 1184473002: Add support for the audio-output-device switching IPC mechanism to the renderer lower layers (media… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build dependencies for audio_unittests 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
« no previous file with comments | « media/base/audio_renderer_mixer.h ('k') | media/base/audio_renderer_mixer_input.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) 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.h" 5 #include "media/base/audio_renderer_mixer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (it->Equals(error_cb)) { 64 if (it->Equals(error_cb)) {
65 error_callbacks_.erase(it); 65 error_callbacks_.erase(it);
66 return; 66 return;
67 } 67 }
68 } 68 }
69 69
70 // An error callback should always exist when called. 70 // An error callback should always exist when called.
71 NOTREACHED(); 71 NOTREACHED();
72 } 72 }
73 73
74 void AudioRendererMixer::SwitchOutputDevice(
75 const std::string& device_id,
76 const GURL& security_origin,
77 const SwitchOutputDeviceCB& callback) {
78 DVLOG(1) << __FUNCTION__ << "(" << device_id << ", " << security_origin
79 << ")";
80 base::AutoLock auto_lock(lock_);
81 audio_sink_->SwitchOutputDevice(device_id, security_origin, callback);
82 }
83
74 int AudioRendererMixer::Render(AudioBus* audio_bus, 84 int AudioRendererMixer::Render(AudioBus* audio_bus,
75 int audio_delay_milliseconds) { 85 int audio_delay_milliseconds) {
76 base::AutoLock auto_lock(lock_); 86 base::AutoLock auto_lock(lock_);
77 87
78 // If there are no mixer inputs and we haven't seen one for a while, pause the 88 // If there are no mixer inputs and we haven't seen one for a while, pause the
79 // sink to avoid wasting resources when media elements are present but remain 89 // sink to avoid wasting resources when media elements are present but remain
80 // in the pause state. 90 // in the pause state.
81 const base::TimeTicks now = base::TimeTicks::Now(); 91 const base::TimeTicks now = base::TimeTicks::Now();
82 if (!audio_converter_.empty()) { 92 if (!audio_converter_.empty()) {
83 last_play_time_ = now; 93 last_play_time_ = now;
84 } else if (now - last_play_time_ >= pause_delay_ && playing_) { 94 } else if (now - last_play_time_ >= pause_delay_ && playing_) {
85 audio_sink_->Pause(); 95 audio_sink_->Pause();
86 playing_ = false; 96 playing_ = false;
87 } 97 }
88 98
89 audio_converter_.ConvertWithDelay( 99 audio_converter_.ConvertWithDelay(
90 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds), audio_bus); 100 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds), audio_bus);
91 return audio_bus->frames(); 101 return audio_bus->frames();
92 } 102 }
93 103
94 void AudioRendererMixer::OnRenderError() { 104 void AudioRendererMixer::OnRenderError() {
95 // Call each mixer input and signal an error. 105 // Call each mixer input and signal an error.
96 base::AutoLock auto_lock(lock_); 106 base::AutoLock auto_lock(lock_);
97 for (const auto& cb : error_callbacks_) 107 for (const auto& cb : error_callbacks_)
98 cb.Run(); 108 cb.Run();
99 } 109 }
100 110
101 } // namespace media 111 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer.h ('k') | media/base/audio_renderer_mixer_input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698