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_output_stream.h" | 5 #include "chromecast/media/audio/cast_audio_output_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "chromecast/base/metrics/cast_metrics_test_helper.h" | 16 #include "chromecast/base/metrics/cast_metrics_test_helper.h" |
17 #include "chromecast/media/audio/cast_audio_manager.h" | 17 #include "chromecast/media/audio/cast_audio_manager.h" |
18 #include "chromecast/public/media/cast_decoder_buffer.h" | 18 #include "chromecast/public/media/cast_decoder_buffer.h" |
19 #include "chromecast/public/media/media_pipeline_backend.h" | 19 #include "chromecast/public/media/media_pipeline_backend.h" |
| 20 #include "media/audio/test_audio_thread.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 using ::testing::Invoke; | 24 using ::testing::Invoke; |
24 using ::testing::_; | 25 using ::testing::_; |
25 | 26 |
26 namespace chromecast { | 27 namespace chromecast { |
27 namespace media { | 28 namespace media { |
28 namespace { | 29 namespace { |
29 const char kDefaultDeviceId[] = ""; | 30 const char kDefaultDeviceId[] = ""; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 : public ::media::AudioOutputStream::AudioSourceCallback { | 174 : public ::media::AudioOutputStream::AudioSourceCallback { |
174 public: | 175 public: |
175 // ::media::AudioOutputStream::AudioSourceCallback overrides. | 176 // ::media::AudioOutputStream::AudioSourceCallback overrides. |
176 MOCK_METHOD4(OnMoreData, | 177 MOCK_METHOD4(OnMoreData, |
177 int(base::TimeDelta, base::TimeTicks, int, ::media::AudioBus*)); | 178 int(base::TimeDelta, base::TimeTicks, int, ::media::AudioBus*)); |
178 MOCK_METHOD1(OnError, void(::media::AudioOutputStream*)); | 179 MOCK_METHOD1(OnError, void(::media::AudioOutputStream*)); |
179 }; | 180 }; |
180 | 181 |
181 class FakeAudioManager : public CastAudioManager { | 182 class FakeAudioManager : public CastAudioManager { |
182 public: | 183 public: |
183 explicit FakeAudioManager( | 184 FakeAudioManager() |
184 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 185 : CastAudioManager(base::MakeUnique<::media::TestAudioThread>(), |
185 : CastAudioManager(task_runner, task_runner, nullptr, nullptr, nullptr), | 186 nullptr, |
| 187 nullptr, |
| 188 nullptr), |
186 media_pipeline_backend_(nullptr) {} | 189 media_pipeline_backend_(nullptr) {} |
187 ~FakeAudioManager() override {} | 190 ~FakeAudioManager() override {} |
188 | 191 |
189 // CastAudioManager overrides. | 192 // CastAudioManager overrides. |
190 std::unique_ptr<MediaPipelineBackend> CreateMediaPipelineBackend( | 193 std::unique_ptr<MediaPipelineBackend> CreateMediaPipelineBackend( |
191 const MediaPipelineDeviceParams& params) override { | 194 const MediaPipelineDeviceParams& params) override { |
192 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 195 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
193 DCHECK(!media_pipeline_backend_); | 196 DCHECK(!media_pipeline_backend_); |
194 | 197 |
195 std::unique_ptr<FakeMediaPipelineBackend> backend( | 198 std::unique_ptr<FakeMediaPipelineBackend> backend( |
(...skipping 25 matching lines...) Expand all Loading... |
221 : format_(::media::AudioParameters::AUDIO_PCM_LINEAR), | 224 : format_(::media::AudioParameters::AUDIO_PCM_LINEAR), |
222 channel_layout_(::media::CHANNEL_LAYOUT_MONO), | 225 channel_layout_(::media::CHANNEL_LAYOUT_MONO), |
223 sample_rate_(::media::AudioParameters::kAudioCDSampleRate), | 226 sample_rate_(::media::AudioParameters::kAudioCDSampleRate), |
224 bits_per_sample_(16), | 227 bits_per_sample_(16), |
225 frames_per_buffer_(256) {} | 228 frames_per_buffer_(256) {} |
226 ~CastAudioOutputStreamTest() override {} | 229 ~CastAudioOutputStreamTest() override {} |
227 | 230 |
228 protected: | 231 protected: |
229 void SetUp() override { | 232 void SetUp() override { |
230 metrics::InitializeMetricsHelperForTesting(); | 233 metrics::InitializeMetricsHelperForTesting(); |
231 audio_manager_.reset(new FakeAudioManager(message_loop_.task_runner())); | 234 audio_manager_ = base::MakeUnique<FakeAudioManager>(); |
232 } | 235 } |
233 | 236 |
234 void TearDown() override { | 237 void TearDown() override { audio_manager_->Shutdown(); } |
235 audio_manager_.reset(); | |
236 } | |
237 | 238 |
238 ::media::AudioParameters GetAudioParams() { | 239 ::media::AudioParameters GetAudioParams() { |
239 return ::media::AudioParameters(format_, channel_layout_, sample_rate_, | 240 return ::media::AudioParameters(format_, channel_layout_, sample_rate_, |
240 bits_per_sample_, frames_per_buffer_); | 241 bits_per_sample_, frames_per_buffer_); |
241 } | 242 } |
242 | 243 |
243 FakeMediaPipelineBackend* GetBackend() { | 244 FakeMediaPipelineBackend* GetBackend() { |
244 return audio_manager_->media_pipeline_backend(); | 245 return audio_manager_->media_pipeline_backend(); |
245 } | 246 } |
246 | 247 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 | 558 |
558 stream->Start(source_callback.get()); | 559 stream->Start(source_callback.get()); |
559 RunMessageLoopFor(2); | 560 RunMessageLoopFor(2); |
560 stream->Stop(); | 561 stream->Stop(); |
561 stream->Close(); | 562 stream->Close(); |
562 } | 563 } |
563 | 564 |
564 } // namespace | 565 } // namespace |
565 } // namespace media | 566 } // namespace media |
566 } // namespace chromecast | 567 } // namespace chromecast |
OLD | NEW |