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() {
// 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
......@@ -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_
......@@ -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 {
......
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