Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/media/audio/cast_audio_manager.h" | 5 #include "chromecast/media/audio/cast_audio_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "chromecast/media/audio/cast_audio_mixer.h" | 11 #include "chromecast/media/audio/cast_audio_mixer.h" |
| 12 #include "chromecast/media/audio/cast_audio_output_stream.h" | 12 #include "chromecast/media/audio/cast_audio_output_stream.h" |
| 13 #include "chromecast/media/cma/backend/media_pipeline_backend_manager.h" | 13 #include "chromecast/media/cma/backend/media_pipeline_backend_manager.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 // TODO(alokp): Query the preferred value from media backend. | 16 // TODO(alokp): Query the preferred value from media backend. |
| 17 const int kDefaultSampleRate = 48000; | 17 const int kDefaultSampleRate = 48000; |
| 18 | 18 |
| 19 // Define bounds for the output buffer size (in frames). | 19 // Define bounds for the output buffer size (in frames). |
| 20 // Note: These values are copied from AudioManagerPulse implementation. | 20 // Note: These values are copied from AudioManagerPulse implementation. |
| 21 // TODO(alokp): Query the preferred value from media backend. | 21 // TODO(alokp): Query the preferred value from media backend. |
| 22 static const int kMinimumOutputBufferSize = 512; | 22 static const int kMinimumOutputBufferSize = 512; |
| 23 static const int kMaximumOutputBufferSize = 8192; | 23 static const int kMaximumOutputBufferSize = 8192; |
| 24 static const int kDefaultOutputBufferSize = 2048; | 24 static const int kDefaultOutputBufferSize = 2048; |
| 25 | |
| 26 const char kAudioManagerName[] = "Cast"; | |
|
DaleCurtis
2016/12/01 17:49:38
If there's only a single user of this it's general
Henrik Grunell
2016/12/02 08:40:27
Done.
| |
| 25 } // namespace | 27 } // namespace |
| 26 | 28 |
| 27 namespace chromecast { | 29 namespace chromecast { |
| 28 namespace media { | 30 namespace media { |
| 29 | 31 |
| 30 CastAudioManager::CastAudioManager( | 32 CastAudioManager::CastAudioManager( |
| 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 32 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 34 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
| 33 ::media::AudioLogFactory* audio_log_factory, | 35 ::media::AudioLogFactory* audio_log_factory, |
| 34 MediaPipelineBackendManager* backend_manager) | 36 MediaPipelineBackendManager* backend_manager) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 | 78 |
| 77 ::media::AudioParameters CastAudioManager::GetInputStreamParameters( | 79 ::media::AudioParameters CastAudioManager::GetInputStreamParameters( |
| 78 const std::string& device_id) { | 80 const std::string& device_id) { |
| 79 LOG(WARNING) << "No support for input audio devices"; | 81 LOG(WARNING) << "No support for input audio devices"; |
| 80 // Need to send a valid AudioParameters object even when it will unused. | 82 // Need to send a valid AudioParameters object even when it will unused. |
| 81 return ::media::AudioParameters( | 83 return ::media::AudioParameters( |
| 82 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 84 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 83 ::media::CHANNEL_LAYOUT_STEREO, 48000, 16, 1024); | 85 ::media::CHANNEL_LAYOUT_STEREO, 48000, 16, 1024); |
| 84 } | 86 } |
| 85 | 87 |
| 88 const char* CastAudioManager::GetName() { | |
| 89 return kAudioManagerName; | |
| 90 } | |
| 91 | |
| 86 std::unique_ptr<MediaPipelineBackend> | 92 std::unique_ptr<MediaPipelineBackend> |
| 87 CastAudioManager::CreateMediaPipelineBackend( | 93 CastAudioManager::CreateMediaPipelineBackend( |
| 88 const MediaPipelineDeviceParams& params) { | 94 const MediaPipelineDeviceParams& params) { |
| 89 return backend_manager_->CreateMediaPipelineBackend(params); | 95 return backend_manager_->CreateMediaPipelineBackend(params); |
| 90 } | 96 } |
| 91 | 97 |
| 92 void CastAudioManager::ReleaseOutputStream(::media::AudioOutputStream* stream) { | 98 void CastAudioManager::ReleaseOutputStream(::media::AudioOutputStream* stream) { |
| 93 // If |stream| is |mixer_output_stream_|, we should not use | 99 // If |stream| is |mixer_output_stream_|, we should not use |
| 94 // AudioManagerBase::ReleaseOutputStream as we do not want the release | 100 // AudioManagerBase::ReleaseOutputStream as we do not want the release |
| 95 // function to decrement |AudioManagerBase::num_output_streams_|. This is | 101 // function to decrement |AudioManagerBase::num_output_streams_|. This is |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 DCHECK(!mixer_output_stream_); // Only allow 1 |mixer_output_stream_|. | 181 DCHECK(!mixer_output_stream_); // Only allow 1 |mixer_output_stream_|. |
| 176 | 182 |
| 177 // Keep a reference to this stream for proper behavior on | 183 // Keep a reference to this stream for proper behavior on |
| 178 // CastAudioManager::ReleaseOutputStream. | 184 // CastAudioManager::ReleaseOutputStream. |
| 179 mixer_output_stream_.reset(new CastAudioOutputStream(params, this)); | 185 mixer_output_stream_.reset(new CastAudioOutputStream(params, this)); |
| 180 return mixer_output_stream_.get(); | 186 return mixer_output_stream_.get(); |
| 181 } | 187 } |
| 182 | 188 |
| 183 } // namespace media | 189 } // namespace media |
| 184 } // namespace chromecast | 190 } // namespace chromecast |
| OLD | NEW |