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

Side by Side Diff: media/audio/mac/audio_manager_mac.cc

Issue 236123002: Allow pass through buffer sizes on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Rebase. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/mac/audio_manager_mac.h" 5 #include "media/audio/mac/audio_manager_mac.h"
6 6
7 #include <CoreAudio/AudioHardware.h> 7 #include <CoreAudio/AudioHardware.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 const AudioDeviceID device = GetAudioDeviceIdByUId(false, output_device_id); 665 const AudioDeviceID device = GetAudioDeviceIdByUId(false, output_device_id);
666 if (device == kAudioObjectUnknown) { 666 if (device == kAudioObjectUnknown) {
667 DLOG(ERROR) << "Invalid output device " << output_device_id; 667 DLOG(ERROR) << "Invalid output device " << output_device_id;
668 return input_params.IsValid() ? input_params : AudioParameters( 668 return input_params.IsValid() ? input_params : AudioParameters(
669 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, 669 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
670 kFallbackSampleRate, 16, ChooseBufferSize(kFallbackSampleRate)); 670 kFallbackSampleRate, 16, ChooseBufferSize(kFallbackSampleRate));
671 } 671 }
672 672
673 const bool has_valid_input_params = input_params.IsValid(); 673 const bool has_valid_input_params = input_params.IsValid();
674 const int hardware_sample_rate = HardwareSampleRateForDevice(device); 674 const int hardware_sample_rate = HardwareSampleRateForDevice(device);
675 const int buffer_size = ChooseBufferSize(hardware_sample_rate); 675
676 // Allow pass through buffer sizes. If concurrent input and output streams
677 // exist, they will use the smallest buffer size amongst them. As such, each
678 // stream must be able to FIFO requests appropriately when this happens.
679 int buffer_size = ChooseBufferSize(hardware_sample_rate);
680 if (has_valid_input_params)
681 buffer_size = std::max(input_params.frames_per_buffer(), buffer_size);
676 682
677 int hardware_channels; 683 int hardware_channels;
678 if (!GetDeviceChannels(device, kAudioDevicePropertyScopeOutput, 684 if (!GetDeviceChannels(device, kAudioDevicePropertyScopeOutput,
679 &hardware_channels)) { 685 &hardware_channels)) {
680 hardware_channels = 2; 686 hardware_channels = 2;
681 } 687 }
682 688
683 // Use the input channel count and channel layout if possible. Let OSX take 689 // Use the input channel count and channel layout if possible. Let OSX take
684 // care of remapping the channels; this lets user specified channel layouts 690 // care of remapping the channels; this lets user specified channel layouts
685 // work correctly. 691 // work correctly.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 void AudioManagerMac::ReleaseInputStream(AudioInputStream* stream) { 782 void AudioManagerMac::ReleaseInputStream(AudioInputStream* stream) {
777 input_streams_.remove(stream); 783 input_streams_.remove(stream);
778 AudioManagerBase::ReleaseInputStream(stream); 784 AudioManagerBase::ReleaseInputStream(stream);
779 } 785 }
780 786
781 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { 787 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
782 return new AudioManagerMac(audio_log_factory); 788 return new AudioManagerMac(audio_log_factory);
783 } 789 }
784 790
785 } // namespace media 791 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698