| OLD | NEW |
| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 case AudioParameters::AUDIO_PCM_LINEAR: | 159 case AudioParameters::AUDIO_PCM_LINEAR: |
| 160 DCHECK(AudioDeviceDescription::IsDefaultDevice(device_id)) | 160 DCHECK(AudioDeviceDescription::IsDefaultDevice(device_id)) |
| 161 << "AUDIO_PCM_LINEAR supports only the default device."; | 161 << "AUDIO_PCM_LINEAR supports only the default device."; |
| 162 stream = MakeLinearOutputStream(params, log_callback); | 162 stream = MakeLinearOutputStream(params, log_callback); |
| 163 break; | 163 break; |
| 164 case AudioParameters::AUDIO_PCM_LOW_LATENCY: | 164 case AudioParameters::AUDIO_PCM_LOW_LATENCY: |
| 165 stream = MakeLowLatencyOutputStream(params, device_id, log_callback); | 165 stream = MakeLowLatencyOutputStream(params, device_id, log_callback); |
| 166 break; | 166 break; |
| 167 case AudioParameters::AUDIO_BITSTREAM_AC3: | 167 case AudioParameters::AUDIO_BITSTREAM_AC3: |
| 168 case AudioParameters::AUDIO_BITSTREAM_EAC3: | 168 case AudioParameters::AUDIO_BITSTREAM_EAC3: |
| 169 // TODO(tsunghung): create passthrough output stream. | 169 stream = MakeBitstreamOutputStream(params, device_id, log_callback); |
| 170 NOTREACHED(); | |
| 171 stream = nullptr; | |
| 172 break; | 170 break; |
| 173 case AudioParameters::AUDIO_FAKE: | 171 case AudioParameters::AUDIO_FAKE: |
| 174 stream = FakeAudioOutputStream::MakeFakeStream(this, params); | 172 stream = FakeAudioOutputStream::MakeFakeStream(this, params); |
| 175 break; | 173 break; |
| 176 default: | 174 default: |
| 177 stream = NULL; | 175 stream = NULL; |
| 178 break; | 176 break; |
| 179 } | 177 } |
| 180 | 178 |
| 181 if (stream) { | 179 if (stream) { |
| 182 ++num_output_streams_; | 180 ++num_output_streams_; |
| 183 } | 181 } |
| 184 | 182 |
| 185 return stream; | 183 return stream; |
| 186 } | 184 } |
| 187 | 185 |
| 186 AudioOutputStream* AudioManagerBase::MakeBitstreamOutputStream( |
| 187 const AudioParameters& params, |
| 188 const std::string& device_id, |
| 189 const LogCallback& log_callback) { |
| 190 return nullptr; |
| 191 } |
| 192 |
| 188 AudioInputStream* AudioManagerBase::MakeAudioInputStream( | 193 AudioInputStream* AudioManagerBase::MakeAudioInputStream( |
| 189 const AudioParameters& params, | 194 const AudioParameters& params, |
| 190 const std::string& device_id, | 195 const std::string& device_id, |
| 191 const LogCallback& log_callback) { | 196 const LogCallback& log_callback) { |
| 192 CHECK(GetTaskRunner()->BelongsToCurrentThread()); | 197 CHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 193 | 198 |
| 194 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || | 199 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || |
| 195 device_id.empty()) { | 200 device_id.empty()) { |
| 196 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; | 201 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; |
| 197 return NULL; | 202 return NULL; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 output_device_id); | 284 output_device_id); |
| 280 | 285 |
| 281 auto it = std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(), | 286 auto it = std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(), |
| 282 CompareByParams(dispatcher_params.get())); | 287 CompareByParams(dispatcher_params.get())); |
| 283 if (it != output_dispatchers_.end()) | 288 if (it != output_dispatchers_.end()) |
| 284 return (*it)->dispatcher->CreateStreamProxy(); | 289 return (*it)->dispatcher->CreateStreamProxy(); |
| 285 | 290 |
| 286 const base::TimeDelta kCloseDelay = | 291 const base::TimeDelta kCloseDelay = |
| 287 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); | 292 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); |
| 288 std::unique_ptr<AudioOutputDispatcher> dispatcher; | 293 std::unique_ptr<AudioOutputDispatcher> dispatcher; |
| 289 if (output_params.format() != AudioParameters::AUDIO_FAKE) { | 294 if (output_params.format() != AudioParameters::AUDIO_FAKE && |
| 295 !output_params.IsBitstreamFormat()) { |
| 290 // Using unretained for |debug_recording_manager_| is safe since it | 296 // Using unretained for |debug_recording_manager_| is safe since it |
| 291 // outlives the dispatchers (cleared in ShutdownOnAudioThread()). | 297 // outlives the dispatchers (cleared in ShutdownOnAudioThread()). |
| 292 dispatcher = base::MakeUnique<AudioOutputResampler>( | 298 dispatcher = base::MakeUnique<AudioOutputResampler>( |
| 293 this, params, output_params, output_device_id, kCloseDelay, | 299 this, params, output_params, output_device_id, kCloseDelay, |
| 294 debug_recording_manager_ | 300 debug_recording_manager_ |
| 295 ? base::BindRepeating( | 301 ? base::BindRepeating( |
| 296 &AudioDebugRecordingManager::RegisterDebugRecordingSource, | 302 &AudioDebugRecordingManager::RegisterDebugRecordingSource, |
| 297 base::Unretained(debug_recording_manager_.get()), | 303 base::Unretained(debug_recording_manager_.get()), |
| 298 FILE_PATH_LITERAL("output")) | 304 FILE_PATH_LITERAL("output")) |
| 299 : base::BindRepeating(&GetNullptrAudioDebugRecorder)); | 305 : base::BindRepeating(&GetNullptrAudioDebugRecorder)); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 return base::MakeUnique<AudioDebugRecordingManager>(std::move(task_runner)); | 483 return base::MakeUnique<AudioDebugRecordingManager>(std::move(task_runner)); |
| 478 } | 484 } |
| 479 | 485 |
| 480 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input, | 486 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input, |
| 481 int max_output) { | 487 int max_output) { |
| 482 max_num_output_streams_ = max_output; | 488 max_num_output_streams_ = max_output; |
| 483 max_num_input_streams_ = max_input; | 489 max_num_input_streams_ = max_input; |
| 484 } | 490 } |
| 485 | 491 |
| 486 } // namespace media | 492 } // namespace media |
| OLD | NEW |