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

Side by Side Diff: media/audio/pulse/audio_manager_pulse.cc

Issue 2973763002: Revert of Make OS audio buffer size limits visible. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « media/audio/mac/audio_manager_mac.cc ('k') | media/base/audio_latency.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/pulse/audio_manager_pulse.h" 5 #include "media/audio/pulse/audio_manager_pulse.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/nix/xdg_util.h" 10 #include "base/nix/xdg_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #if defined(USE_ALSA) 12 #if defined(USE_ALSA)
13 #include "media/audio/alsa/audio_manager_alsa.h" 13 #include "media/audio/alsa/audio_manager_alsa.h"
14 #endif 14 #endif
15 #include "media/audio/audio_device_description.h" 15 #include "media/audio/audio_device_description.h"
16 #include "media/audio/pulse/pulse_input.h" 16 #include "media/audio/pulse/pulse_input.h"
17 #include "media/audio/pulse/pulse_output.h" 17 #include "media/audio/pulse/pulse_output.h"
18 #include "media/audio/pulse/pulse_util.h" 18 #include "media/audio/pulse/pulse_util.h"
19 #include "media/base/audio_parameters.h" 19 #include "media/base/audio_parameters.h"
20 #include "media/base/channel_layout.h" 20 #include "media/base/channel_layout.h"
21 #include "media/base/limits.h"
22 21
23 namespace media { 22 namespace media {
24 23
25 using pulse::AutoPulseLock; 24 using pulse::AutoPulseLock;
26 using pulse::WaitForOperationCompletion; 25 using pulse::WaitForOperationCompletion;
27 26
28 // Maximum number of output streams that can be open simultaneously. 27 // Maximum number of output streams that can be open simultaneously.
29 static const int kMaxOutputStreams = 50; 28 static const int kMaxOutputStreams = 50;
30 29
30 // Define bounds for the output buffer size.
31 static const int kMinimumOutputBufferSize = 512;
32 static const int kMaximumOutputBufferSize = 8192;
33
31 // Default input buffer size. 34 // Default input buffer size.
32 static const int kDefaultInputBufferSize = 1024; 35 static const int kDefaultInputBufferSize = 1024;
33 36
34 AudioManagerPulse::AudioManagerPulse(std::unique_ptr<AudioThread> audio_thread, 37 AudioManagerPulse::AudioManagerPulse(std::unique_ptr<AudioThread> audio_thread,
35 AudioLogFactory* audio_log_factory, 38 AudioLogFactory* audio_log_factory,
36 pa_threaded_mainloop* pa_mainloop, 39 pa_threaded_mainloop* pa_mainloop,
37 pa_context* pa_context) 40 pa_context* pa_context)
38 : AudioManagerBase(std::move(audio_thread), audio_log_factory), 41 : AudioManagerBase(std::move(audio_thread), audio_log_factory),
39 input_mainloop_(pa_mainloop), 42 input_mainloop_(pa_mainloop),
40 input_context_(pa_context), 43 input_context_(pa_context),
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); 157 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
155 return MakeInputStream(params, device_id); 158 return MakeInputStream(params, device_id);
156 } 159 }
157 160
158 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters( 161 AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters(
159 const std::string& output_device_id, 162 const std::string& output_device_id,
160 const AudioParameters& input_params) { 163 const AudioParameters& input_params) {
161 // TODO(tommi): Support |output_device_id|. 164 // TODO(tommi): Support |output_device_id|.
162 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!"; 165 VLOG_IF(0, !output_device_id.empty()) << "Not implemented!";
163 166
164 int buffer_size = limits::kMinAudioBufferSize; 167 int buffer_size = kMinimumOutputBufferSize;
165 int bits_per_sample = 16; 168 int bits_per_sample = 16;
166 169
167 // Query native parameters where applicable; Pulse does not require these to 170 // Query native parameters where applicable; Pulse does not require these to
168 // be respected though, so prefer the input parameters for channel count. 171 // be respected though, so prefer the input parameters for channel count.
169 UpdateNativeAudioHardwareInfo(); 172 UpdateNativeAudioHardwareInfo();
170 int sample_rate = native_input_sample_rate_; 173 int sample_rate = native_input_sample_rate_;
171 ChannelLayout channel_layout = GuessChannelLayout(native_channel_count_); 174 ChannelLayout channel_layout = GuessChannelLayout(native_channel_count_);
172 175
173 if (input_params.IsValid()) { 176 if (input_params.IsValid()) {
174 bits_per_sample = input_params.bits_per_sample(); 177 bits_per_sample = input_params.bits_per_sample();
175 channel_layout = input_params.channel_layout(); 178 channel_layout = input_params.channel_layout();
176 buffer_size = 179 buffer_size =
177 std::min(static_cast<int>(limits::kMaxAudioBufferSize), 180 std::min(kMaximumOutputBufferSize,
178 std::max(buffer_size, input_params.frames_per_buffer())); 181 std::max(buffer_size, input_params.frames_per_buffer()));
179 } 182 }
180 183
181 int user_buffer_size = GetUserBufferSize(); 184 int user_buffer_size = GetUserBufferSize();
182 if (user_buffer_size) 185 if (user_buffer_size)
183 buffer_size = user_buffer_size; 186 buffer_size = user_buffer_size;
184 187
185 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 188 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
186 sample_rate, bits_per_sample, buffer_size); 189 sample_rate, bits_per_sample, buffer_size);
187 } 190 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 const pa_server_info* info, 248 const pa_server_info* info,
246 void* user_data) { 249 void* user_data) {
247 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data); 250 AudioManagerPulse* manager = reinterpret_cast<AudioManagerPulse*>(user_data);
248 251
249 manager->native_input_sample_rate_ = info->sample_spec.rate; 252 manager->native_input_sample_rate_ = info->sample_spec.rate;
250 manager->native_channel_count_ = info->sample_spec.channels; 253 manager->native_channel_count_ = info->sample_spec.channels;
251 pa_threaded_mainloop_signal(manager->input_mainloop_, 0); 254 pa_threaded_mainloop_signal(manager->input_mainloop_, 0);
252 } 255 }
253 256
254 } // namespace media 257 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/mac/audio_manager_mac.cc ('k') | media/base/audio_latency.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698