Commit 0474f0f5 authored by enal@chromium.org's avatar enal@chromium.org

Move decision if we need to use WASAPI or wave out into separate function.

Minor Windows-only code cleanup. That also fixes broken sound on Windows Server 2003.

BUG=none

Review URL: http://codereview.chromium.org/8777003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112860 0039d316-1c4b-4281-b951-d872f2087c98
parent a3a4a580
...@@ -243,7 +243,7 @@ double GetAudioHardwareSampleRate() { ...@@ -243,7 +243,7 @@ double GetAudioHardwareSampleRate() {
// Hardware sample-rate on the Mac can be configured, so we must query. // Hardware sample-rate on the Mac can be configured, so we must query.
return AUAudioOutputStream::HardwareSampleRate(); return AUAudioOutputStream::HardwareSampleRate();
#elif defined(OS_WIN) #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 // Fall back to Windows Wave implementation on Windows XP or lower
// and use 48kHz as default input sample rate. // and use 48kHz as default input sample rate.
return 48000.0; return 48000.0;
...@@ -265,7 +265,7 @@ double GetAudioInputHardwareSampleRate() { ...@@ -265,7 +265,7 @@ double GetAudioInputHardwareSampleRate() {
// Hardware sample-rate on the Mac can be configured, so we must query. // Hardware sample-rate on the Mac can be configured, so we must query.
return AUAudioInputStream::HardwareSampleRate(); return AUAudioInputStream::HardwareSampleRate();
#elif defined(OS_WIN) #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 // Fall back to Windows Wave implementation on Windows XP or lower
// and use 48kHz as default input sample rate. // and use 48kHz as default input sample rate.
return 48000.0; return 48000.0;
...@@ -293,7 +293,7 @@ size_t GetAudioHardwareBufferSize() { ...@@ -293,7 +293,7 @@ size_t GetAudioHardwareBufferSize() {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
return 128; return 128;
#elif defined(OS_WIN) #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 // Fall back to Windows Wave implementation on Windows XP or lower
// and assume 48kHz as default sample rate. // and assume 48kHz as default sample rate.
return 2048; return 2048;
...@@ -363,4 +363,14 @@ bool IsUnknownDataSize(base::SharedMemory* shared_memory, ...@@ -363,4 +363,14 @@ bool IsUnknownDataSize(base::SharedMemory* shared_memory,
return actual_data_size == kUnknownDataSize; 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 } // namespace media
...@@ -105,6 +105,14 @@ MEDIA_EXPORT void SetUnknownDataSize(base::SharedMemory* shared_memory, ...@@ -105,6 +105,14 @@ MEDIA_EXPORT void SetUnknownDataSize(base::SharedMemory* shared_memory,
MEDIA_EXPORT bool IsUnknownDataSize(base::SharedMemory* shared_memory, MEDIA_EXPORT bool IsUnknownDataSize(base::SharedMemory* shared_memory,
uint32 shared_memory_size); 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 } // namespace media
#endif // MEDIA_AUDIO_AUDIO_UTIL_H_ #endif // MEDIA_AUDIO_AUDIO_UTIL_H_
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "base/process_util.h" #include "base/process_util.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/string_util.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_input_stream.h"
#include "media/audio/fake_audio_output_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_input_win.h"
...@@ -100,7 +100,7 @@ static string16 GetDeviceAndDriverInfo(HDEVINFO device_info, ...@@ -100,7 +100,7 @@ static string16 GetDeviceAndDriverInfo(HDEVINFO device_info,
AudioManagerWin::AudioManagerWin() AudioManagerWin::AudioManagerWin()
: num_output_streams_(0) { : 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. // Use the Wave API for device enumeration if XP or lower.
enumeration_type_ = kWaveEnumeration; enumeration_type_ = kWaveEnumeration;
} else { } else {
...@@ -141,7 +141,7 @@ AudioOutputStream* AudioManagerWin::MakeAudioOutputStream( ...@@ -141,7 +141,7 @@ AudioOutputStream* AudioManagerWin::MakeAudioOutputStream(
return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER); return new PCMWaveOutAudioOutputStream(this, params, 3, WAVE_MAPPER);
} else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
num_output_streams_++; 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. // Fall back to Windows Wave implementation on Windows XP or lower.
DLOG(INFO) << "Using WaveOut since WASAPI requires at least Vista."; DLOG(INFO) << "Using WaveOut since WASAPI requires at least Vista.";
return new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); return new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER);
...@@ -167,7 +167,7 @@ AudioInputStream* AudioManagerWin::MakeAudioInputStream( ...@@ -167,7 +167,7 @@ AudioInputStream* AudioManagerWin::MakeAudioInputStream(
return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
WAVE_MAPPER); WAVE_MAPPER);
} else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { } 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. // Fall back to Windows Wave implementation on Windows XP or lower.
DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista.";
// TODO(xians): Handle the non-default device. // TODO(xians): Handle the non-default device.
...@@ -272,7 +272,7 @@ bool AudioManagerWin::CanShowAudioInputSettings() { ...@@ -272,7 +272,7 @@ bool AudioManagerWin::CanShowAudioInputSettings() {
void AudioManagerWin::ShowAudioInputSettings() { void AudioManagerWin::ShowAudioInputSettings() {
std::wstring program; std::wstring program;
std::string argument; std::string argument;
if (base::win::GetVersion() <= base::win::VERSION_XP) { if (!media::IsWASAPISupported()) {
program = L"sndvol32.exe"; program = L"sndvol32.exe";
argument = "-R"; argument = "-R";
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment