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

Side by Side Diff: media/audio/cras/audio_manager_cras.cc

Issue 235723003: Use larger buffer sizes for lower power on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test on other platforms. 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 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/cras/audio_manager_cras.h" 5 #include "media/audio/cras/audio_manager_cras.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"
(...skipping 12 matching lines...) Expand all
23 AudioDeviceName(AudioManagerBase::kDefaultDeviceName, 23 AudioDeviceName(AudioManagerBase::kDefaultDeviceName,
24 AudioManagerBase::kDefaultDeviceId)); 24 AudioManagerBase::kDefaultDeviceId));
25 } 25 }
26 26
27 // Maximum number of output streams that can be open simultaneously. 27 // Maximum number of output streams that can be open simultaneously.
28 static const int kMaxOutputStreams = 50; 28 static const int kMaxOutputStreams = 50;
29 29
30 // Default sample rate for input and output streams. 30 // Default sample rate for input and output streams.
31 static const int kDefaultSampleRate = 48000; 31 static const int kDefaultSampleRate = 48000;
32 32
33 // Define bounds for the output buffer size.
34 static const int kMinimumOutputBufferSize = 512;
35 static const int kMaximumOutputBufferSize = 8192;
36
33 bool AudioManagerCras::HasAudioOutputDevices() { 37 bool AudioManagerCras::HasAudioOutputDevices() {
34 return true; 38 return true;
35 } 39 }
36 40
37 bool AudioManagerCras::HasAudioInputDevices() { 41 bool AudioManagerCras::HasAudioInputDevices() {
38 return true; 42 return true;
39 } 43 }
40 44
41 AudioManagerCras::AudioManagerCras(AudioLogFactory* audio_log_factory) 45 AudioManagerCras::AudioManagerCras(AudioLogFactory* audio_log_factory)
42 : AudioManagerBase(audio_log_factory) { 46 : AudioManagerBase(audio_log_factory) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 const AudioParameters& params, const std::string& device_id) { 100 const AudioParameters& params, const std::string& device_id) {
97 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); 101 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
98 return MakeInputStream(params, device_id); 102 return MakeInputStream(params, device_id);
99 } 103 }
100 104
101 AudioParameters AudioManagerCras::GetPreferredOutputStreamParameters( 105 AudioParameters AudioManagerCras::GetPreferredOutputStreamParameters(
102 const std::string& output_device_id, 106 const std::string& output_device_id,
103 const AudioParameters& input_params) { 107 const AudioParameters& input_params) {
104 // TODO(tommi): Support |output_device_id|. 108 // TODO(tommi): Support |output_device_id|.
105 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!"; 109 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!";
106 static const int kDefaultOutputBufferSize = 512;
107
108 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; 110 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
109 int sample_rate = kDefaultSampleRate; 111 int sample_rate = kDefaultSampleRate;
110 int buffer_size = kDefaultOutputBufferSize; 112 int buffer_size = kMinimumOutputBufferSize;
111 int bits_per_sample = 16; 113 int bits_per_sample = 16;
112 int input_channels = 0; 114 int input_channels = 0;
113 if (input_params.IsValid()) { 115 if (input_params.IsValid()) {
114 sample_rate = input_params.sample_rate(); 116 sample_rate = input_params.sample_rate();
115 bits_per_sample = input_params.bits_per_sample(); 117 bits_per_sample = input_params.bits_per_sample();
116 channel_layout = input_params.channel_layout(); 118 channel_layout = input_params.channel_layout();
117 input_channels = input_params.input_channels(); 119 input_channels = input_params.input_channels();
118 buffer_size = input_params.frames_per_buffer(); 120 buffer_size =
121 std::min(kMaximumOutputBufferSize,
122 std::max(buffer_size, input_params.frames_per_buffer()));
119 } 123 }
120 124
121 int user_buffer_size = GetUserBufferSize(); 125 int user_buffer_size = GetUserBufferSize();
122 if (user_buffer_size) 126 if (user_buffer_size)
123 buffer_size = user_buffer_size; 127 buffer_size = user_buffer_size;
124 128
125 return AudioParameters( 129 return AudioParameters(
126 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, 130 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels,
127 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS); 131 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS);
128 } 132 }
(...skipping 17 matching lines...) Expand all
146 case 24: 150 case 24:
147 return SND_PCM_FORMAT_S24; 151 return SND_PCM_FORMAT_S24;
148 case 32: 152 case 32:
149 return SND_PCM_FORMAT_S32; 153 return SND_PCM_FORMAT_S32;
150 default: 154 default:
151 return SND_PCM_FORMAT_UNKNOWN; 155 return SND_PCM_FORMAT_UNKNOWN;
152 } 156 }
153 } 157 }
154 158
155 } // namespace media 159 } // namespace media
OLDNEW
« no previous file with comments | « content/renderer/media/audio_renderer_mixer_manager.cc ('k') | media/audio/pulse/audio_manager_pulse.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698