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

Side by Side Diff: media/audio/win/audio_manager_win.cc

Issue 8491044: Link things together and enable the device selection for linux and mac. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: rebase2 Created 9 years, 1 month 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 | « media/audio/win/audio_manager_win.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_io.h" 5 #include "media/audio/audio_io.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <objbase.h> // This has to be before initguid.h 8 #include <objbase.h> // This has to be before initguid.h
9 #include <initguid.h> 9 #include <initguid.h>
10 #include <mmsystem.h> 10 #include <mmsystem.h>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // TODO(henrika): improve possibility to specify audio endpoint. 141 // TODO(henrika): improve possibility to specify audio endpoint.
142 // Use the default device (same as for Wave) for now to be compatible. 142 // Use the default device (same as for Wave) for now to be compatible.
143 return new WASAPIAudioOutputStream(this, params, eConsole); 143 return new WASAPIAudioOutputStream(this, params, eConsole);
144 } 144 }
145 } 145 }
146 return NULL; 146 return NULL;
147 } 147 }
148 148
149 // Factory for the implementations of AudioInputStream. 149 // Factory for the implementations of AudioInputStream.
150 AudioInputStream* AudioManagerWin::MakeAudioInputStream( 150 AudioInputStream* AudioManagerWin::MakeAudioInputStream(
151 const AudioParameters& params) { 151 const AudioParameters& params, const std::string& device_id) {
152 if (!params.IsValid() || (params.channels > kWinMaxInputChannels)) 152 if (!params.IsValid() || (params.channels > kWinMaxInputChannels) ||
153 device_id.empty())
153 return NULL; 154 return NULL;
154 155
155 if (params.format == AudioParameters::AUDIO_MOCK) { 156 if (params.format == AudioParameters::AUDIO_MOCK) {
156 return FakeAudioInputStream::MakeFakeStream(params); 157 return FakeAudioInputStream::MakeFakeStream(params);
157 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { 158 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) {
158 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 159 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
159 WAVE_MAPPER); 160 WAVE_MAPPER);
160 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { 161 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
161 if (base::win::GetVersion() <= base::win::VERSION_XP) { 162 if (base::win::GetVersion() <= base::win::VERSION_XP) {
162 // Fall back to Windows Wave implementation on Windows XP or lower. 163 // Fall back to Windows Wave implementation on Windows XP or lower.
163 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; 164 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista.";
164 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 165 // TODO(xians): Handle the non-default device.
165 WAVE_MAPPER); 166 if (device_id == AudioManagerBase::kDefaultDeviceId)
167 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
168 WAVE_MAPPER);
166 } else { 169 } else {
167 // TODO(henrika): improve possibility to specify audio endpoint. 170 // TODO(henrika): improve possibility to specify audio endpoint.
168 // Use the default device (same as for Wave) for now to be compatible. 171 // Use the default device (same as for Wave) for now to be compatible.
169 return new WASAPIAudioInputStream(this, params, eConsole); 172 // TODO(xians): Handle the non-default device.
173 if (device_id == AudioManagerBase::kDefaultDeviceId)
174 return new WASAPIAudioInputStream(this, params, eConsole);
170 } 175 }
171 } 176 }
172 return NULL; 177 return NULL;
173 } 178 }
174 179
175 void AudioManagerWin::ReleaseOutputStream(AudioOutputStream* stream) { 180 void AudioManagerWin::ReleaseOutputStream(AudioOutputStream* stream) {
176 DCHECK(stream); 181 DCHECK(stream);
177 num_output_streams_--; 182 num_output_streams_--;
178 delete stream; 183 delete stream;
179 } 184 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 280
276 void AudioManagerWin::GetAudioInputDeviceNames( 281 void AudioManagerWin::GetAudioInputDeviceNames(
277 media::AudioDeviceNames* device_names) { 282 media::AudioDeviceNames* device_names) {
278 // TODO(xians): query a full list of valid devices. 283 // TODO(xians): query a full list of valid devices.
279 if (HasAudioInputDevices()) { 284 if (HasAudioInputDevices()) {
280 // Add the default device to the list. 285 // Add the default device to the list.
281 // We use index 0 to make up the unique_id to identify the 286 // We use index 0 to make up the unique_id to identify the
282 // default devices. 287 // default devices.
283 media::AudioDeviceName name; 288 media::AudioDeviceName name;
284 name.device_name = AudioManagerBase::kDefaultDeviceName; 289 name.device_name = AudioManagerBase::kDefaultDeviceName;
285 name.unique_id = "0"; 290 name.unique_id = AudioManagerBase::kDefaultDeviceId;
286 device_names->push_back(name); 291 device_names->push_back(name);
287 } 292 }
288 } 293 }
289 294
290 // static 295 // static
291 AudioManager* AudioManager::CreateAudioManager() { 296 AudioManager* AudioManager::CreateAudioManager() {
292 return new AudioManagerWin(); 297 return new AudioManagerWin();
293 } 298 }
OLDNEW
« no previous file with comments | « media/audio/win/audio_manager_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698