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

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

Issue 12102004: Renderer side audio device change wip... Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/test/webrtc_audio_device_test.cc ('k') | media/audio/audio_output_controller.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/audio/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 params.format() == AudioParameters::AUDIO_FAKE || 116 params.format() == AudioParameters::AUDIO_FAKE ||
117 !HasAudioOutputDevices(); 117 !HasAudioOutputDevices();
118 118
119 AudioOutputStream* stream = NULL; 119 AudioOutputStream* stream = NULL;
120 if (virtual_audio_input_stream_) { 120 if (virtual_audio_input_stream_) {
121 #if defined(OS_IOS) 121 #if defined(OS_IOS)
122 // We do not currently support iOS. It does not link. 122 // We do not currently support iOS. It does not link.
123 NOTIMPLEMENTED(); 123 NOTIMPLEMENTED();
124 return NULL; 124 return NULL;
125 #else 125 #else
126 LOG(ERROR) << "CREATED VIRTUAL OUTPUT STREAM";
126 stream = new VirtualAudioOutputStream( 127 stream = new VirtualAudioOutputStream(
127 params, message_loop_, virtual_audio_input_stream_, 128 params, message_loop_, virtual_audio_input_stream_,
128 base::Bind(&AudioManagerBase::ReleaseVirtualOutputStream, 129 base::Bind(&AudioManagerBase::ReleaseVirtualOutputStream,
129 base::Unretained(this))); 130 base::Unretained(this)));
130 #endif 131 #endif
131 } else if (audio_output_disabled) { 132 } else if (audio_output_disabled) {
132 stream = FakeAudioOutputStream::MakeFakeStream(this, params); 133 stream = FakeAudioOutputStream::MakeFakeStream(this, params);
133 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) { 134 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) {
134 stream = MakeLinearOutputStream(params); 135 stream = MakeLinearOutputStream(params);
135 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { 136 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
(...skipping 19 matching lines...) Expand all
155 } 156 }
156 157
157 if (num_input_streams_ >= max_num_input_streams_) { 158 if (num_input_streams_ >= max_num_input_streams_) {
158 DLOG(ERROR) << "Number of opened input audio streams " 159 DLOG(ERROR) << "Number of opened input audio streams "
159 << num_input_streams_ 160 << num_input_streams_
160 << " exceed the max allowed number " << max_num_input_streams_; 161 << " exceed the max allowed number " << max_num_input_streams_;
161 return NULL; 162 return NULL;
162 } 163 }
163 164
164 AudioInputStream* stream = NULL; 165 AudioInputStream* stream = NULL;
165 if (params.format() == AudioParameters::AUDIO_VIRTUAL) { 166 if (CommandLine::ForCurrentProcess()->HasSwitch(
167 switches::kForceAudioMirroring) ||
168 params.format() == AudioParameters::AUDIO_VIRTUAL) {
166 #if defined(OS_IOS) 169 #if defined(OS_IOS)
167 // We do not currently support iOS. 170 // We do not currently support iOS.
168 NOTIMPLEMENTED(); 171 NOTIMPLEMENTED();
169 return NULL; 172 return NULL;
170 #else 173 #else
171 // TODO(justinlin): Currently, audio mirroring will only work for the first 174 // TODO(justinlin): Currently, audio mirroring will only work for the first
172 // request. Subsequent requests will not get audio. 175 // request. Subsequent requests will not get audio.
173 if (!virtual_audio_input_stream_) { 176 if (!virtual_audio_input_stream_) {
177
178 LOG(ERROR) << "CREATED VIRTUAL INPUT STREAM";
174 virtual_audio_input_stream_ = new VirtualAudioInputStream( 179 virtual_audio_input_stream_ = new VirtualAudioInputStream(
175 params, message_loop_, 180 params, message_loop_,
176 base::Bind(&AudioManagerBase::ReleaseVirtualInputStream, 181 base::Bind(&AudioManagerBase::ReleaseVirtualInputStream,
177 base::Unretained(this))); 182 base::Unretained(this)));
178 stream = virtual_audio_input_stream_; 183 stream = virtual_audio_input_stream_;
179 DVLOG(1) << "Virtual audio input stream created."; 184 DVLOG(1) << "Virtual audio input stream created.";
180 185
181 // Make all current output streams recreate themselves as 186 // Make all current output streams recreate themselves as
182 // VirtualAudioOutputStreams that will attach to the above 187 // VirtualAudioOutputStreams that will attach to the above
183 // VirtualAudioInputStream. 188 // VirtualAudioInputStream.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 403
399 AudioParameters AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters( 404 AudioParameters AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters(
400 const AudioParameters& input_params) { 405 const AudioParameters& input_params) {
401 #if defined(OS_IOS) 406 #if defined(OS_IOS)
402 // IOS implements audio input only. 407 // IOS implements audio input only.
403 NOTIMPLEMENTED(); 408 NOTIMPLEMENTED();
404 return AudioParameters(); 409 return AudioParameters();
405 #else 410 #else
406 // TODO(dalecurtis): This should include bits per channel and channel layout 411 // TODO(dalecurtis): This should include bits per channel and channel layout
407 // eventually. 412 // eventually.
413 // TODO(dalecurtis): GetAudio*() methods should be cached by each platform
414 // specific audio manager to avoid system calls to retrieve the values, the
415 // cache should be updated on device changes.
408 return AudioParameters( 416 return AudioParameters(
409 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), 417 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(),
410 GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize()); 418 GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize());
411 #endif // defined(OS_IOS) 419 #endif // defined(OS_IOS)
412 } 420 }
413 421
414 void AudioManagerBase::AddOutputDeviceChangeListener( 422 void AudioManagerBase::AddOutputDeviceChangeListener(
415 AudioDeviceListener* listener) { 423 AudioDeviceListener* listener) {
416 DCHECK(message_loop_->BelongsToCurrentThread()); 424 DCHECK(message_loop_->BelongsToCurrentThread());
417 output_listeners_.AddObserver(listener); 425 output_listeners_.AddObserver(listener);
418 } 426 }
419 427
420 void AudioManagerBase::RemoveOutputDeviceChangeListener( 428 void AudioManagerBase::RemoveOutputDeviceChangeListener(
421 AudioDeviceListener* listener) { 429 AudioDeviceListener* listener) {
422 DCHECK(message_loop_->BelongsToCurrentThread()); 430 DCHECK(message_loop_->BelongsToCurrentThread());
423 output_listeners_.RemoveObserver(listener); 431 output_listeners_.RemoveObserver(listener);
424 } 432 }
425 433
426 void AudioManagerBase::NotifyAllOutputDeviceChangeListeners() { 434 void AudioManagerBase::NotifyAllOutputDeviceChangeListeners() {
427 DCHECK(message_loop_->BelongsToCurrentThread()); 435 DCHECK(message_loop_->BelongsToCurrentThread());
428 DVLOG(1) << "Firing OnDeviceChange() notifications."; 436 DVLOG(1) << "Firing OnDeviceChange() notifications.";
429 FOR_EACH_OBSERVER(AudioDeviceListener, output_listeners_, OnDeviceChange()); 437 FOR_EACH_OBSERVER(AudioDeviceListener, output_listeners_, OnDeviceChange());
430 } 438 }
431 439
432 } // namespace media 440 } // namespace media
OLDNEW
« no previous file with comments | « content/test/webrtc_audio_device_test.cc ('k') | media/audio/audio_output_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698