Chromium Code Reviews| Index: media/audio/win/audio_manager_win.cc |
| diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc |
| index 7ee2a769f169fe4545c3e3ca922852df50a12009..ba619620d8dcd3e271cd9a2a672411d68477939d 100644 |
| --- a/media/audio/win/audio_manager_win.cc |
| +++ b/media/audio/win/audio_manager_win.cc |
| @@ -19,8 +19,6 @@ |
| #include "base/string_number_conversions.h" |
| #include "base/string_util.h" |
| #include "media/audio/audio_util.h" |
| -#include "media/audio/fake_audio_input_stream.h" |
| -#include "media/audio/fake_audio_output_stream.h" |
| #include "media/audio/win/audio_low_latency_input_win.h" |
| #include "media/audio/win/audio_low_latency_output_win.h" |
| #include "media/audio/win/audio_manager_win.h" |
| @@ -41,7 +39,7 @@ DEFINE_GUID(AM_KSCATEGORY_AUDIO, 0x6994ad04, 0x93ef, 0x11d0, |
| 0xa3, 0xcc, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96); |
| // Maximum number of output streams that can be open simultaneously. |
| -static const size_t kMaxOutputStreams = 50; |
| +static const int kMaxOutputStreams = 50; |
| // Up to 8 channels can be passed to the driver. |
| // This should work, given the right drivers, but graceful error handling is |
| @@ -98,8 +96,7 @@ static string16 GetDeviceAndDriverInfo(HDEVINFO device_info, |
| return device_and_driver_info; |
| } |
| -AudioManagerWin::AudioManagerWin() |
| - : num_output_streams_(0) { |
| +AudioManagerWin::AudioManagerWin() { |
| if (!media::IsWASAPISupported()) { |
| // Use the Wave API for device enumeration if XP or lower. |
| enumeration_type_ = kWaveEnumeration; |
| @@ -110,8 +107,6 @@ AudioManagerWin::AudioManagerWin() |
| } |
| AudioManagerWin::~AudioManagerWin() { |
| - // All output streams should be released upon termination. |
| - DCHECK_EQ(0, num_output_streams_); |
| } |
| bool AudioManagerWin::HasAudioOutputDevices() { |
| @@ -122,75 +117,6 @@ bool AudioManagerWin::HasAudioInputDevices() { |
| return (::waveInGetNumDevs() != 0); |
| } |
| -// Factory for the implementations of AudioOutputStream. Two implementations |
| -// should suffice most windows user's needs. |
| -// - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
| -// - WASAPIAudioOutputStream: Based on Core Audio (WASAPI) API. |
| -AudioOutputStream* AudioManagerWin::MakeAudioOutputStream( |
| - const AudioParameters& params) { |
| - if (!params.IsValid() || (params.channels > kWinMaxChannels)) |
| - return NULL; |
| - |
| - // Limit the number of audio streams opened. |
| - if (num_output_streams_ >= kMaxOutputStreams) { |
| - return NULL; |
| - } |
| - |
| - if (params.format == AudioParameters::AUDIO_MOCK) { |
| - return FakeAudioOutputStream::MakeFakeStream(params); |
| - } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { |
| - num_output_streams_++; |
| - return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER); |
| - } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
| - num_output_streams_++; |
| - if (!media::IsWASAPISupported()) { |
| - // Fall back to Windows Wave implementation on Windows XP or lower. |
| - DLOG(INFO) << "Using WaveOut since WASAPI requires at least Vista."; |
| - return new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); |
| - } else { |
| - // TODO(henrika): improve possibility to specify audio endpoint. |
| - // Use the default device (same as for Wave) for now to be compatible. |
| - return new WASAPIAudioOutputStream(this, params, eConsole); |
| - } |
| - } |
| - return NULL; |
| -} |
| - |
| -// Factory for the implementations of AudioInputStream. |
| -AudioInputStream* AudioManagerWin::MakeAudioInputStream( |
| - const AudioParameters& params, const std::string& device_id) { |
| - if (!params.IsValid() || (params.channels > kWinMaxInputChannels) || |
| - device_id.empty()) |
| - return NULL; |
| - |
| - if (params.format == AudioParameters::AUDIO_MOCK) { |
| - return FakeAudioInputStream::MakeFakeStream(params); |
| - } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { |
| - return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| - AudioManagerBase::kDefaultDeviceId); |
| - } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
| - if (!media::IsWASAPISupported()) { |
| - // Fall back to Windows Wave implementation on Windows XP or lower. |
| - DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; |
| - return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| - device_id); |
| - } else { |
| - return new WASAPIAudioInputStream(this, params, device_id); |
| - } |
| - } |
| - return NULL; |
| -} |
| - |
| -void AudioManagerWin::ReleaseOutputStream(AudioOutputStream* stream) { |
| - DCHECK(stream); |
| - num_output_streams_--; |
| - delete stream; |
| -} |
| - |
| -void AudioManagerWin::ReleaseInputStream(AudioInputStream* stream) { |
| - delete stream; |
| -} |
| - |
| void AudioManagerWin::MuteAll() { |
| } |
| @@ -305,6 +231,80 @@ void AudioManagerWin::GetAudioInputDeviceNames( |
| } |
| } |
| +int AudioManagerWin::GetMaxAudioOutputStreamsAllowed() { |
| + return kMaxOutputStreams; |
| +} |
| + |
| +// Factory for the implementations of AudioOutputStream for AUDIO_PCM_LINEAR |
| +// mode. |
| +// - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
| +AudioOutputStream* AudioManagerWin::MakeAudioLinearOutputStream( |
| + const AudioParameters& params) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); |
| + if (params.channels > kWinMaxChannels) |
| + return NULL; |
| + |
| + return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER); |
| +} |
| + |
| +// Factory for the implementations of AudioOutputStream for |
| +// AUDIO_PCM_LOW_LATENCY mode. Two implementations should suffice most |
| +// windows user's needs. |
| +// - PCMWaveOutAudioOutputStream: Based on the waveOut API. |
| +// - WASAPIAudioOutputStream: Based on Core Audio (WASAPI) API. |
| +AudioOutputStream* AudioManagerWin::MakeAudioLowLatencyOutputStream( |
| + const AudioParameters& params) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); |
| + if (params.channels > kWinMaxChannels) |
| + return NULL; |
| + |
| + AudioOutputStream* stream = NULL; |
| + if (!media::IsWASAPISupported()) { |
| + // Fall back to Windows Wave implementation on Windows XP or lower. |
| + DLOG(INFO) << "Using WaveOut since WASAPI requires at least Vista."; |
|
tommi (sloooow) - chröme
2012/03/05 14:28:28
DVLOG(1)
(same for any other DLOG(INFO))
no longer working on chromium
2012/03/06 15:27:07
Done.
|
| + stream = new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); |
| + } else { |
| + // TODO(henrika): improve possibility to specify audio endpoint. |
| + // Use the default device (same as for Wave) for now to be compatible. |
| + stream = new WASAPIAudioOutputStream(this, params, eConsole); |
| + } |
| + |
| + return stream; |
| +} |
| + |
| +// Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR |
| +// mode. |
| +AudioInputStream* AudioManagerWin::MakeAudioLinearInputStream( |
| + const AudioParameters& params, const std::string& device_id) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); |
| + if (params.channels > kWinMaxInputChannels) |
| + return NULL; |
| + |
| + return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| + AudioManagerBase::kDefaultDeviceId); |
| +} |
| + |
| +// Factory for the implementations of AudioInputStream for |
| +// AUDIO_PCM_LOW_LATENCY mode. |
| +AudioInputStream* AudioManagerWin::MakeAudioLowLatencyInputStream( |
| + const AudioParameters& params, const std::string& device_id) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); |
| + if (params.channels > kWinMaxInputChannels) |
| + return NULL; |
| + |
| + AudioInputStream* stream = NULL; |
| + if (!media::IsWASAPISupported()) { |
| + // Fall back to Windows Wave implementation on Windows XP or lower. |
| + DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; |
| + stream = new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| + device_id); |
| + } else { |
| + stream = new WASAPIAudioInputStream(this, params, device_id); |
| + } |
| + |
| + return stream; |
| +} |
| + |
| /// static |
| AudioManager* CreateAudioManager() { |
| return new AudioManagerWin(); |