diff options
-rw-r--r-- | media/audio/audio_util.cc | 16 | ||||
-rw-r--r-- | media/audio/audio_util.h | 8 | ||||
-rw-r--r-- | media/audio/win/audio_manager_win.cc | 10 |
3 files changed, 26 insertions, 8 deletions
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc index 48be2db..9e1c818 100644 --- a/media/audio/audio_util.cc +++ b/media/audio/audio_util.cc @@ -243,7 +243,7 @@ double GetAudioHardwareSampleRate() { // Hardware sample-rate on the Mac can be configured, so we must query. return AUAudioOutputStream::HardwareSampleRate(); #elif defined(OS_WIN) - if (base::win::GetVersion() <= base::win::VERSION_XP) { + if (!IsWASAPISupported()) { // Fall back to Windows Wave implementation on Windows XP or lower // and use 48kHz as default input sample rate. return 48000.0; @@ -265,7 +265,7 @@ double GetAudioInputHardwareSampleRate() { // Hardware sample-rate on the Mac can be configured, so we must query. return AUAudioInputStream::HardwareSampleRate(); #elif defined(OS_WIN) - if (base::win::GetVersion() <= base::win::VERSION_XP) { + if (!IsWASAPISupported()) { // Fall back to Windows Wave implementation on Windows XP or lower // and use 48kHz as default input sample rate. return 48000.0; @@ -293,7 +293,7 @@ size_t GetAudioHardwareBufferSize() { #if defined(OS_MACOSX) return 128; #elif defined(OS_WIN) - if (base::win::GetVersion() <= base::win::VERSION_XP) { + if (!IsWASAPISupported()) { // Fall back to Windows Wave implementation on Windows XP or lower // and assume 48kHz as default sample rate. return 2048; @@ -363,4 +363,14 @@ bool IsUnknownDataSize(base::SharedMemory* shared_memory, return actual_data_size == kUnknownDataSize; } +#if defined(OS_WIN) + +bool IsWASAPISupported() { + // Note: that function correctly returns that Windows Server 2003 does not + // support WASAPI. + return base::win::GetVersion() >= base::win::VERSION_VISTA; +} + +#endif + } // namespace media diff --git a/media/audio/audio_util.h b/media/audio/audio_util.h index 05896af..22aa19b 100644 --- a/media/audio/audio_util.h +++ b/media/audio/audio_util.h @@ -105,6 +105,14 @@ MEDIA_EXPORT void SetUnknownDataSize(base::SharedMemory* shared_memory, MEDIA_EXPORT bool IsUnknownDataSize(base::SharedMemory* shared_memory, uint32 shared_memory_size); +#if defined(OS_WIN) + +// Does Windows support WASAPI? We are checking in lot of places, and +// sometimes check was written incorrectly, so move into separate function. +MEDIA_EXPORT bool IsWASAPISupported(); + +#endif // defined(OS_WIN) + } // namespace media #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc index 80d0d9d..9d38588 100644 --- a/media/audio/win/audio_manager_win.cc +++ b/media/audio/win/audio_manager_win.cc @@ -18,7 +18,7 @@ #include "base/process_util.h" #include "base/string_number_conversions.h" #include "base/string_util.h" -#include "base/win/windows_version.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" @@ -100,7 +100,7 @@ static string16 GetDeviceAndDriverInfo(HDEVINFO device_info, AudioManagerWin::AudioManagerWin() : num_output_streams_(0) { - if (base::win::GetVersion() <= base::win::VERSION_XP) { + if (!media::IsWASAPISupported()) { // Use the Wave API for device enumeration if XP or lower. enumeration_type_ = kWaveEnumeration; } else { @@ -141,7 +141,7 @@ AudioOutputStream* AudioManagerWin::MakeAudioOutputStream( return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER); } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { num_output_streams_++; - if (base::win::GetVersion() <= base::win::VERSION_XP) { + 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); @@ -167,7 +167,7 @@ AudioInputStream* AudioManagerWin::MakeAudioInputStream( return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, WAVE_MAPPER); } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { - if (base::win::GetVersion() <= base::win::VERSION_XP) { + if (!media::IsWASAPISupported()) { // Fall back to Windows Wave implementation on Windows XP or lower. DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; // TODO(xians): Handle the non-default device. @@ -272,7 +272,7 @@ bool AudioManagerWin::CanShowAudioInputSettings() { void AudioManagerWin::ShowAudioInputSettings() { std::wstring program; std::string argument; - if (base::win::GetVersion() <= base::win::VERSION_XP) { + if (!media::IsWASAPISupported()) { program = L"sndvol32.exe"; argument = "-R"; } else { |