Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: media/audio/mac/audio_manager_mac.cc

Issue 127363002: Provide fake audio parameters when devices don't exist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/mac/audio_manager_mac.cc
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc
index be7dddd5bb68c23c830f0fd3592cd75ce274ae32..c096b73bb73bcbeb0be46f1649e27d0ad0c955d6 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -401,16 +401,12 @@ void AudioManagerMac::GetAudioOutputDeviceNames(
AudioParameters AudioManagerMac::GetInputStreamParameters(
const std::string& device_id) {
- // Due to the sharing of the input and output buffer sizes, we need to choose
- // the input buffer size based on the output sample rate. See
- // http://crbug.com/154352.
- const int buffer_size = ChooseBufferSize(
- AUAudioOutputStream::HardwareSampleRate());
-
AudioDeviceID device = GetAudioDeviceIdByUId(true, device_id);
if (device == kAudioObjectUnknown) {
DLOG(ERROR) << "Invalid device " << device_id;
- return AudioParameters();
+ return AudioParameters(
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
+ kFallbackSampleRate, 16, ChooseBufferSize(kFallbackSampleRate));
}
int channels = 0;
@@ -427,6 +423,11 @@ AudioParameters AudioManagerMac::GetInputStreamParameters(
if (!sample_rate)
sample_rate = kFallbackSampleRate;
+ // Due to the sharing of the input and output buffer sizes, we need to choose
+ // the input buffer size based on the output sample rate. See
+ // http://crbug.com/154352.
+ const int buffer_size = ChooseBufferSize(sample_rate);
+
// TODO(xians): query the native channel layout for the specific device.
return AudioParameters(
AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
@@ -646,7 +647,9 @@ AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters(
AudioDeviceID device = GetAudioDeviceIdByUId(false, output_device_id);
if (device == kAudioObjectUnknown) {
DLOG(ERROR) << "Invalid output device " << output_device_id;
- return AudioParameters();
+ return input_params.IsValid() ? input_params : AudioParameters(
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
+ kFallbackSampleRate, 16, ChooseBufferSize(kFallbackSampleRate));
}
int hardware_channels = 2;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698