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 "chromecast/base/task_runner_impl.h" | |
8 #include "chromecast/media/audio/cast_audio_output_stream.h" | 7 #include "chromecast/media/audio/cast_audio_output_stream.h" |
9 #include "chromecast/media/base/media_message_loop.h" | 8 #include "chromecast/media/base/media_message_loop.h" |
10 #include "chromecast/public/cast_media_shlib.h" | 9 #include "chromecast/public/cast_media_shlib.h" |
11 #include "chromecast/public/media/media_pipeline_backend.h" | 10 #include "chromecast/public/media/media_pipeline_backend.h" |
12 #include "chromecast/public/media/media_pipeline_device_params.h" | |
13 | 11 |
14 namespace { | 12 namespace { |
15 // TODO(alokp): Query the preferred value from media backend. | 13 // TODO(alokp): Query the preferred value from media backend. |
16 const int kDefaultSampleRate = 48000; | 14 const int kDefaultSampleRate = 48000; |
17 | 15 |
18 // Define bounds for the output buffer size (in frames). | 16 // Define bounds for the output buffer size (in frames). |
19 // Note: These values are copied from AudioManagerPulse implementation. | 17 // Note: These values are copied from AudioManagerPulse implementation. |
20 // TODO(alokp): Query the preferred value from media backend. | 18 // TODO(alokp): Query the preferred value from media backend. |
21 static const int kMinimumOutputBufferSize = 512; | 19 static const int kMinimumOutputBufferSize = 512; |
22 static const int kMaximumOutputBufferSize = 8192; | 20 static const int kMaximumOutputBufferSize = 8192; |
(...skipping 30 matching lines...) Expand all Loading... |
53 | 51 |
54 ::media::AudioParameters CastAudioManager::GetInputStreamParameters( | 52 ::media::AudioParameters CastAudioManager::GetInputStreamParameters( |
55 const std::string& device_id) { | 53 const std::string& device_id) { |
56 LOG(WARNING) << "No support for input audio devices"; | 54 LOG(WARNING) << "No support for input audio devices"; |
57 // Need to send a valid AudioParameters object even when it will unused. | 55 // Need to send a valid AudioParameters object even when it will unused. |
58 return ::media::AudioParameters( | 56 return ::media::AudioParameters( |
59 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 57 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
60 ::media::CHANNEL_LAYOUT_STEREO, 48000, 16, 1024); | 58 ::media::CHANNEL_LAYOUT_STEREO, 48000, 16, 1024); |
61 } | 59 } |
62 | 60 |
63 scoped_ptr<MediaPipelineBackend> | 61 scoped_ptr<MediaPipelineBackend> CastAudioManager::CreateMediaPipelineBackend( |
64 CastAudioManager::CreateMediaPipelineBackend() { | 62 const MediaPipelineDeviceParams& params) { |
65 DCHECK(media::MediaMessageLoop::GetTaskRunner()->BelongsToCurrentThread()); | 63 DCHECK(media::MediaMessageLoop::GetTaskRunner()->BelongsToCurrentThread()); |
66 | 64 |
67 if (!backend_task_runner_) | |
68 backend_task_runner_.reset(new TaskRunnerImpl()); | |
69 | |
70 MediaPipelineDeviceParams device_params( | |
71 MediaPipelineDeviceParams::kModeIgnorePts, backend_task_runner_.get()); | |
72 return scoped_ptr<MediaPipelineBackend>( | 65 return scoped_ptr<MediaPipelineBackend>( |
73 CastMediaShlib::CreateMediaPipelineBackend(device_params)); | 66 CastMediaShlib::CreateMediaPipelineBackend(params)); |
74 } | 67 } |
75 | 68 |
76 ::media::AudioOutputStream* CastAudioManager::MakeLinearOutputStream( | 69 ::media::AudioOutputStream* CastAudioManager::MakeLinearOutputStream( |
77 const ::media::AudioParameters& params) { | 70 const ::media::AudioParameters& params) { |
78 DCHECK_EQ(::media::AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 71 DCHECK_EQ(::media::AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
79 return new CastAudioOutputStream(params, this); | 72 return new CastAudioOutputStream(params, this); |
80 } | 73 } |
81 | 74 |
82 ::media::AudioOutputStream* CastAudioManager::MakeLowLatencyOutputStream( | 75 ::media::AudioOutputStream* CastAudioManager::MakeLowLatencyOutputStream( |
83 const ::media::AudioParameters& params, | 76 const ::media::AudioParameters& params, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 112 } |
120 | 113 |
121 ::media::AudioParameters output_params( | 114 ::media::AudioParameters output_params( |
122 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, | 115 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
123 sample_rate, bits_per_sample, buffer_size); | 116 sample_rate, bits_per_sample, buffer_size); |
124 return output_params; | 117 return output_params; |
125 } | 118 } |
126 | 119 |
127 } // namespace media | 120 } // namespace media |
128 } // namespace chromecast | 121 } // namespace chromecast |
OLD | NEW |