summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-23 02:06:11 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-23 02:06:11 +0000
commit8bd87b55064a5125d1adedb694d259532e3a2f4a (patch)
treeaabda59bf22ca1ac5fac999a6f8127b53fbebf2b /media
parentd73649fd195d81a12bbecd07acde8d7b7a237d1d (diff)
downloadchromium_src-8bd87b55064a5125d1adedb694d259532e3a2f4a.zip
chromium_src-8bd87b55064a5125d1adedb694d259532e3a2f4a.tar.gz
chromium_src-8bd87b55064a5125d1adedb694d259532e3a2f4a.tar.bz2
Fix custom buffer size support for WASAPI.
This allows any user buffer size which is an even divisor of the endpoint buffer size. I want this so I can play with more buffer sizes on my home computer to try and address glitching under load on Windows. audio_parameters_are_valid_ wasn't really getting us anything that we weren't already verifying during Open(). BUG=179058 TEST=compiles. Review URL: https://codereview.chromium.org/117713004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/win/audio_low_latency_output_win.cc48
-rw-r--r--media/audio/win/audio_low_latency_output_win.h5
2 files changed, 6 insertions, 47 deletions
diff --git a/media/audio/win/audio_low_latency_output_win.cc b/media/audio/win/audio_low_latency_output_win.cc
index a10e67a..cd53e12 100644
--- a/media/audio/win/audio_low_latency_output_win.cc
+++ b/media/audio/win/audio_low_latency_output_win.cc
@@ -25,19 +25,6 @@ using base::win::ScopedCoMem;
namespace media {
-// Compare two sets of audio parameters and return true if they are equal.
-// Note that bits_per_sample() is excluded from this comparison since Core
-// Audio can deal with most bit depths. As an example, if the native/mixing
-// bit depth is 32 bits (default), opening at 16 or 24 still works fine and
-// the audio engine will do the required conversion for us. Channel count is
-// excluded since Open() will fail anyways and it doesn't impact buffering.
-static bool CompareAudioParametersNoBitDepthOrChannels(
- const media::AudioParameters& a, const media::AudioParameters& b) {
- return (a.format() == b.format() &&
- a.sample_rate() == b.sample_rate() &&
- a.frames_per_buffer() == b.frames_per_buffer());
-}
-
// static
AUDCLNT_SHAREMODE WASAPIAudioOutputStream::GetShareMode() {
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
@@ -73,7 +60,6 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager,
manager_(manager),
format_(),
opened_(false),
- audio_parameters_are_valid_(false),
volume_(1.0),
packet_size_frames_(0),
packet_size_bytes_(0),
@@ -89,23 +75,6 @@ WASAPIAudioOutputStream::WASAPIAudioOutputStream(AudioManagerWin* manager,
VLOG_IF(1, share_mode_ == AUDCLNT_SHAREMODE_EXCLUSIVE)
<< "Core Audio (WASAPI) EXCLUSIVE MODE is enabled.";
- if (share_mode_ == AUDCLNT_SHAREMODE_SHARED) {
- // Verify that the input audio parameters are identical (bit depth and
- // channel count are excluded) to the preferred (native) audio parameters.
- // Open() will fail if this is not the case.
- AudioParameters preferred_params;
- HRESULT hr = device_id_.empty() ?
- CoreAudioUtil::GetPreferredAudioParameters(eRender, device_role,
- &preferred_params) :
- CoreAudioUtil::GetPreferredAudioParameters(device_id_,
- &preferred_params);
- audio_parameters_are_valid_ = SUCCEEDED(hr) &&
- CompareAudioParametersNoBitDepthOrChannels(params, preferred_params);
- LOG_IF(WARNING, !audio_parameters_are_valid_)
- << "Input and preferred parameters are not identical. "
- << "Device id: " << device_id_;
- }
-
// Load the Avrt DLL if not already loaded. Required to support MMCSS.
bool avrt_init = avrt::Initialize();
DCHECK(avrt_init) << "Failed to load the avrt.dll";
@@ -159,15 +128,6 @@ bool WASAPIAudioOutputStream::Open() {
if (opened_)
return true;
- // Audio parameters must be identical to the preferred set of parameters
- // if shared mode (default) is utilized.
- if (share_mode_ == AUDCLNT_SHAREMODE_SHARED) {
- if (!audio_parameters_are_valid_) {
- LOG(ERROR) << "Audio parameters are not valid.";
- return false;
- }
- }
-
// Create an IAudioClient interface for the default rendering IMMDevice.
ScopedComPtr<IAudioClient> audio_client;
if (device_id_.empty()) {
@@ -186,6 +146,7 @@ bool WASAPIAudioOutputStream::Open() {
if (!CoreAudioUtil::IsFormatSupported(audio_client,
share_mode_,
&format_)) {
+ LOG(ERROR) << "Audio parameters are not supported.";
return false;
}
@@ -201,10 +162,13 @@ bool WASAPIAudioOutputStream::Open() {
// We know from experience that the best possible callback sequence is
// achieved when the packet size (given by the native device period)
- // is an even multiple of the endpoint buffer size.
+ // is an even divisor of the endpoint buffer size.
// Examples: 48kHz => 960 % 480, 44.1kHz => 896 % 448 or 882 % 441.
if (endpoint_buffer_size_frames_ % packet_size_frames_ != 0) {
- LOG(ERROR) << "Bailing out due to non-perfect timing.";
+ LOG(ERROR)
+ << "Bailing out due to non-perfect timing. Buffer size of "
+ << packet_size_frames_ << " is not an even divisor of "
+ << endpoint_buffer_size_frames_;
return false;
}
} else {
diff --git a/media/audio/win/audio_low_latency_output_win.h b/media/audio/win/audio_low_latency_output_win.h
index 2baf6f1..c118947 100644
--- a/media/audio/win/audio_low_latency_output_win.h
+++ b/media/audio/win/audio_low_latency_output_win.h
@@ -190,11 +190,6 @@ class MEDIA_EXPORT WASAPIAudioOutputStream :
// Set to true when stream is successfully opened.
bool opened_;
- // We check if the input audio parameters are identical (bit depth is
- // excluded) to the preferred (native) audio parameters during construction.
- // Open() will fail if |audio_parameters_are_valid_| is false.
- bool audio_parameters_are_valid_;
-
// Volume level from 0 to 1.
float volume_;