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

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

Issue 285233005: add audio-buffer-size command line flag support to the input audio for all the platforms (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 6 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 | « media/audio/mac/audio_manager_mac.h ('k') | media/audio/openbsd/audio_manager_openbsd.h » ('j') | 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 970720679abf418b9cd2ef11f49d017d75c60084..71af5e654966b788649cf6aaa8e88c0d2cd4e6c2 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -432,8 +432,9 @@ void AudioManagerMac::GetAudioOutputDeviceNames(
GetAudioDeviceInfo(false, device_names);
}
-AudioParameters AudioManagerMac::GetInputStreamParameters(
- const std::string& device_id) {
+AudioParameters AudioManagerMac::GetPreferredInputStreamParameters(
+ const std::string& input_device_id,
+ const AudioParameters& input_params) {
AudioDeviceID device = GetAudioDeviceIdByUId(true, device_id);
if (device == kAudioObjectUnknown) {
DLOG(ERROR) << "Invalid device " << device_id;
@@ -442,29 +443,41 @@ AudioParameters AudioManagerMac::GetInputStreamParameters(
kFallbackSampleRate, 16, ChooseBufferSize(kFallbackSampleRate));
}
+ const bool has_valid_input_params = input_params.IsValid();
+
int channels = 0;
- ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
+ ChannelLayout channel_layout = has_valid_input_params ?
+ input_params.channel_layout() : CHANNEL_LAYOUT_STEREO;
if (GetDeviceChannels(device, kAudioDevicePropertyScopeInput, &channels) &&
channels <= 2) {
+ // Use the native channel layout of the device.
channel_layout = GuessChannelLayout(channels);
} else {
DLOG(ERROR) << "Failed to get the device channels, use stereo as default "
<< "for device " << device_id;
}
+ // Use the native sample rate of the device if it can.
int sample_rate = HardwareSampleRateForDevice(device);
- if (!sample_rate)
- sample_rate = kFallbackSampleRate;
+ if (!sample_rate) {
+ sample_rate = has_valid_input_params ?
+ input_params.sample_rate() : kFallbackSampleRate;
+ }
+
+ int buffer_size = ChooseBufferSize(sample_rate);
+
+ if (has_valid_input_params) {
+ buffer_size =
+ std::min(kMaximumInputOutputBufferSize,
+ std::max(input_params.frames_per_buffer(), buffer_size));
+ }
- // 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);
+ const int bits_per_sample = has_valid_input_params ?
+ input_params.bits_per_sample() : 16;
- // TODO(xians): query the native channel layout for the specific device.
return AudioParameters(
AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
- sample_rate, 16, buffer_size);
+ sample_rate, bits_per_sample, buffer_size);
}
std::string AudioManagerMac::GetAssociatedOutputDeviceID(
« no previous file with comments | « media/audio/mac/audio_manager_mac.h ('k') | media/audio/openbsd/audio_manager_openbsd.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698