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

Side by Side Diff: media/audio/audio_manager_base.cc

Issue 2466463005: Support (E)AC3 passthrough
Patch Set: Improve CastMediaClient::IsSupportedPassthroughAudio() Created 4 years, 1 month 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
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/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 AudioOutputStream* stream; 129 AudioOutputStream* stream;
130 switch (params.format()) { 130 switch (params.format()) {
131 case AudioParameters::AUDIO_PCM_LINEAR: 131 case AudioParameters::AUDIO_PCM_LINEAR:
132 DCHECK(AudioDeviceDescription::IsDefaultDevice(device_id)) 132 DCHECK(AudioDeviceDescription::IsDefaultDevice(device_id))
133 << "AUDIO_PCM_LINEAR supports only the default device."; 133 << "AUDIO_PCM_LINEAR supports only the default device.";
134 stream = MakeLinearOutputStream(params, log_callback); 134 stream = MakeLinearOutputStream(params, log_callback);
135 break; 135 break;
136 case AudioParameters::AUDIO_PCM_LOW_LATENCY: 136 case AudioParameters::AUDIO_PCM_LOW_LATENCY:
137 stream = MakeLowLatencyOutputStream(params, device_id, log_callback); 137 stream = MakeLowLatencyOutputStream(params, device_id, log_callback);
138 break; 138 break;
139 case AudioParameters::AUDIO_RAW_AC3:
140 case AudioParameters::AUDIO_RAW_EAC3:
141 stream = MakeRawOutputStream(params, device_id, log_callback);
142 break;
139 case AudioParameters::AUDIO_FAKE: 143 case AudioParameters::AUDIO_FAKE:
140 stream = FakeAudioOutputStream::MakeFakeStream(this, params); 144 stream = FakeAudioOutputStream::MakeFakeStream(this, params);
141 break; 145 break;
142 default: 146 default:
143 stream = NULL; 147 stream = NULL;
144 break; 148 break;
145 } 149 }
146 150
147 if (stream) { 151 if (stream) {
148 ++num_output_streams_; 152 ++num_output_streams_;
149 } 153 }
150 154
151 return stream; 155 return stream;
152 } 156 }
153 157
158 AudioOutputStream* AudioManagerBase::MakeRawOutputStream(
159 const AudioParameters& params,
160 const std::string& device_id,
161 const LogCallback& log_callback) {
162 return nullptr;
163 }
164
154 AudioInputStream* AudioManagerBase::MakeAudioInputStream( 165 AudioInputStream* AudioManagerBase::MakeAudioInputStream(
155 const AudioParameters& params, 166 const AudioParameters& params,
156 const std::string& device_id, 167 const std::string& device_id,
157 const LogCallback& log_callback) { 168 const LogCallback& log_callback) {
158 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 169 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
159 170
160 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || 171 if (!params.IsValid() || (params.channels() > kMaxInputChannels) ||
161 device_id.empty()) { 172 device_id.empty()) {
162 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; 173 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id;
163 return NULL; 174 return NULL;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(), 258 std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(),
248 CompareByParams(dispatcher_params)); 259 CompareByParams(dispatcher_params));
249 if (it != output_dispatchers_.end()) { 260 if (it != output_dispatchers_.end()) {
250 delete dispatcher_params; 261 delete dispatcher_params;
251 return new AudioOutputProxy((*it)->dispatcher.get()); 262 return new AudioOutputProxy((*it)->dispatcher.get());
252 } 263 }
253 264
254 const base::TimeDelta kCloseDelay = 265 const base::TimeDelta kCloseDelay =
255 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); 266 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds);
256 scoped_refptr<AudioOutputDispatcher> dispatcher; 267 scoped_refptr<AudioOutputDispatcher> dispatcher;
257 if (output_params.format() != AudioParameters::AUDIO_FAKE) { 268 if (output_params.format() != AudioParameters::AUDIO_FAKE &&
269 !output_params.IsRawFormat()) {
258 dispatcher = new AudioOutputResampler(this, params, output_params, 270 dispatcher = new AudioOutputResampler(this, params, output_params,
259 output_device_id, 271 output_device_id,
260 kCloseDelay); 272 kCloseDelay);
261 } else { 273 } else {
262 dispatcher = new AudioOutputDispatcherImpl(this, output_params, 274 dispatcher = new AudioOutputDispatcherImpl(this, output_params,
263 output_device_id, 275 output_device_id,
264 kCloseDelay); 276 kCloseDelay);
265 } 277 }
266 278
267 dispatcher_params->dispatcher = dispatcher; 279 dispatcher_params->dispatcher = dispatcher;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 394
383 return 0; 395 return 0;
384 } 396 }
385 397
386 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog( 398 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog(
387 AudioLogFactory::AudioComponent component) { 399 AudioLogFactory::AudioComponent component) {
388 return audio_log_factory_->CreateAudioLog(component); 400 return audio_log_factory_->CreateAudioLog(component);
389 } 401 }
390 402
391 } // namespace media 403 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698