| 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 <memory> |
| 8 #include <utility> |
| 9 |
| 7 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 8 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 9 #include "chromecast/base/metrics/cast_metrics_test_helper.h" | 12 #include "chromecast/base/metrics/cast_metrics_test_helper.h" |
| 10 #include "chromecast/media/audio/cast_audio_manager.h" | 13 #include "chromecast/media/audio/cast_audio_manager.h" |
| 11 #include "chromecast/public/media/cast_decoder_buffer.h" | 14 #include "chromecast/public/media/cast_decoder_buffer.h" |
| 12 #include "chromecast/public/media/media_pipeline_backend.h" | 15 #include "chromecast/public/media/media_pipeline_backend.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 17 |
| 15 namespace chromecast { | 18 namespace chromecast { |
| 16 namespace media { | 19 namespace media { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 }; | 148 }; |
| 146 | 149 |
| 147 class FakeAudioSourceCallback | 150 class FakeAudioSourceCallback |
| 148 : public ::media::AudioOutputStream::AudioSourceCallback { | 151 : public ::media::AudioOutputStream::AudioSourceCallback { |
| 149 public: | 152 public: |
| 150 FakeAudioSourceCallback() : error_(false) {} | 153 FakeAudioSourceCallback() : error_(false) {} |
| 151 | 154 |
| 152 bool error() const { return error_; } | 155 bool error() const { return error_; } |
| 153 | 156 |
| 154 // ::media::AudioOutputStream::AudioSourceCallback overrides. | 157 // ::media::AudioOutputStream::AudioSourceCallback overrides. |
| 155 int OnMoreData(::media::AudioBus* audio_bus, | 158 int OnMoreData(base::TimeDelta /* delay */, |
| 156 uint32_t total_bytes_delay, | 159 base::TimeTicks /* delay_timestamp */, |
| 157 uint32_t frames_skipped) override { | 160 int /* prior_frames_skipped */, |
| 158 audio_bus->Zero(); | 161 ::media::AudioBus* dest) override { |
| 159 return audio_bus->frames(); | 162 dest->Zero(); |
| 163 return dest->frames(); |
| 160 } | 164 } |
| 161 void OnError(::media::AudioOutputStream* stream) override { error_ = true; } | 165 void OnError(::media::AudioOutputStream* stream) override { error_ = true; } |
| 162 | 166 |
| 163 private: | 167 private: |
| 164 bool error_; | 168 bool error_; |
| 165 }; | 169 }; |
| 166 | 170 |
| 167 class FakeAudioManager : public CastAudioManager { | 171 class FakeAudioManager : public CastAudioManager { |
| 168 public: | 172 public: |
| 169 FakeAudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 173 explicit FakeAudioManager( |
| 174 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 170 : CastAudioManager(task_runner, task_runner, nullptr, nullptr, nullptr), | 175 : CastAudioManager(task_runner, task_runner, nullptr, nullptr, nullptr), |
| 171 media_pipeline_backend_(nullptr) {} | 176 media_pipeline_backend_(nullptr) {} |
| 172 ~FakeAudioManager() override {} | 177 ~FakeAudioManager() override {} |
| 173 | 178 |
| 174 // CastAudioManager overrides. | 179 // CastAudioManager overrides. |
| 175 std::unique_ptr<MediaPipelineBackend> CreateMediaPipelineBackend( | 180 std::unique_ptr<MediaPipelineBackend> CreateMediaPipelineBackend( |
| 176 const MediaPipelineDeviceParams& params) override { | 181 const MediaPipelineDeviceParams& params) override { |
| 177 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 182 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 178 DCHECK(!media_pipeline_backend_); | 183 DCHECK(!media_pipeline_backend_); |
| 179 | 184 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 TEST_F(CastAudioOutputStreamTest, CloseWithoutStart) { | 519 TEST_F(CastAudioOutputStreamTest, CloseWithoutStart) { |
| 515 ::media::AudioOutputStream* stream = CreateStream(); | 520 ::media::AudioOutputStream* stream = CreateStream(); |
| 516 ASSERT_TRUE(stream); | 521 ASSERT_TRUE(stream); |
| 517 ASSERT_TRUE(stream->Open()); | 522 ASSERT_TRUE(stream->Open()); |
| 518 stream->Close(); | 523 stream->Close(); |
| 519 } | 524 } |
| 520 | 525 |
| 521 } // namespace | 526 } // namespace |
| 522 } // namespace media | 527 } // namespace media |
| 523 } // namespace chromecast | 528 } // namespace chromecast |
| OLD | NEW |