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

Side by Side Diff: media/audio/audio_output_dispatcher_impl.cc

Issue 23466008: Wire up the output device id and provide an implementation on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update comments Created 7 years, 3 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/audio/audio_output_dispatcher_impl.h ('k') | media/audio/audio_output_proxy_unittest.cc » ('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/audio/audio_output_dispatcher_impl.h" 5 #include "media/audio/audio_output_dispatcher_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "media/audio/audio_io.h" 13 #include "media/audio/audio_io.h"
14 #include "media/audio/audio_output_proxy.h" 14 #include "media/audio/audio_output_proxy.h"
15 #include "media/audio/audio_util.h" 15 #include "media/audio/audio_util.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 AudioOutputDispatcherImpl::AudioOutputDispatcherImpl( 19 AudioOutputDispatcherImpl::AudioOutputDispatcherImpl(
20 AudioManager* audio_manager, 20 AudioManager* audio_manager,
21 const AudioParameters& params, 21 const AudioParameters& params,
22 const std::string& output_device_id,
22 const std::string& input_device_id, 23 const std::string& input_device_id,
23 const base::TimeDelta& close_delay) 24 const base::TimeDelta& close_delay)
24 : AudioOutputDispatcher(audio_manager, params, input_device_id), 25 : AudioOutputDispatcher(audio_manager, params, output_device_id,
26 input_device_id),
25 pause_delay_(base::TimeDelta::FromMicroseconds( 27 pause_delay_(base::TimeDelta::FromMicroseconds(
26 2 * params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / 28 2 * params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
27 static_cast<float>(params.sample_rate()))), 29 static_cast<float>(params.sample_rate()))),
28 paused_proxies_(0), 30 paused_proxies_(0),
29 weak_this_(this), 31 weak_this_(this),
30 close_timer_(FROM_HERE, 32 close_timer_(FROM_HERE,
31 close_delay, 33 close_delay,
32 this, 34 this,
33 &AudioOutputDispatcherImpl::ClosePendingStreams) { 35 &AudioOutputDispatcherImpl::ClosePendingStreams) {
34 } 36 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 163
162 it = pausing_streams_.begin(); 164 it = pausing_streams_.begin();
163 for (; it != pausing_streams_.end(); ++it) 165 for (; it != pausing_streams_.end(); ++it)
164 (*it)->Close(); 166 (*it)->Close();
165 pausing_streams_.clear(); 167 pausing_streams_.clear();
166 } 168 }
167 169
168 bool AudioOutputDispatcherImpl::CreateAndOpenStream() { 170 bool AudioOutputDispatcherImpl::CreateAndOpenStream() {
169 DCHECK_EQ(base::MessageLoop::current(), message_loop_); 171 DCHECK_EQ(base::MessageLoop::current(), message_loop_);
170 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream( 172 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream(
171 params_, "", input_device_id_); 173 params_, output_device_id_, input_device_id_);
172 if (!stream) 174 if (!stream)
173 return false; 175 return false;
174 176
175 if (!stream->Open()) { 177 if (!stream->Open()) {
176 stream->Close(); 178 stream->Close();
177 return false; 179 return false;
178 } 180 }
179 idle_streams_.push_back(stream); 181 idle_streams_.push_back(stream);
180 return true; 182 return true;
181 } 183 }
(...skipping 13 matching lines...) Expand all
195 // This method is called by |close_timer_|. 197 // This method is called by |close_timer_|.
196 void AudioOutputDispatcherImpl::ClosePendingStreams() { 198 void AudioOutputDispatcherImpl::ClosePendingStreams() {
197 DCHECK_EQ(base::MessageLoop::current(), message_loop_); 199 DCHECK_EQ(base::MessageLoop::current(), message_loop_);
198 while (!idle_streams_.empty()) { 200 while (!idle_streams_.empty()) {
199 idle_streams_.back()->Close(); 201 idle_streams_.back()->Close();
200 idle_streams_.pop_back(); 202 idle_streams_.pop_back();
201 } 203 }
202 } 204 }
203 205
204 } // namespace media 206 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_dispatcher_impl.h ('k') | media/audio/audio_output_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698