OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/copresence/mediums/audio/audio_player.h" | 5 #include "components/copresence/mediums/audio/audio_player.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "components/copresence/public/copresence_constants.h" | 9 #include "components/copresence/public/copresence_constants.h" |
10 #include "components/copresence/test/audio_test_support.h" | 10 #include "components/copresence/test/audio_test_support.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 TestAudioOutputStream(int default_frame_count, | 22 TestAudioOutputStream(int default_frame_count, |
23 int max_frame_count, | 23 int max_frame_count, |
24 GatherSamplesCallback gather_callback) | 24 GatherSamplesCallback gather_callback) |
25 : default_frame_count_(default_frame_count), | 25 : default_frame_count_(default_frame_count), |
26 max_frame_count_(max_frame_count), | 26 max_frame_count_(max_frame_count), |
27 gather_callback_(gather_callback), | 27 gather_callback_(gather_callback), |
28 callback_(NULL) { | 28 callback_(NULL) { |
29 caller_loop_ = base::MessageLoop::current(); | 29 caller_loop_ = base::MessageLoop::current(); |
30 } | 30 } |
31 | 31 |
32 virtual ~TestAudioOutputStream() {} | 32 ~TestAudioOutputStream() override {} |
33 | 33 |
34 virtual bool Open() override { return true; } | 34 bool Open() override { return true; } |
35 virtual void Start(AudioSourceCallback* callback) override { | 35 void Start(AudioSourceCallback* callback) override { |
36 callback_ = callback; | 36 callback_ = callback; |
37 GatherPlayedSamples(); | 37 GatherPlayedSamples(); |
38 } | 38 } |
39 virtual void Stop() override {} | 39 void Stop() override {} |
40 virtual void SetVolume(double volume) override {} | 40 void SetVolume(double volume) override {} |
41 virtual void GetVolume(double* volume) override {} | 41 void GetVolume(double* volume) override {} |
42 virtual void Close() override {} | 42 void Close() override {} |
43 | 43 |
44 private: | 44 private: |
45 void GatherPlayedSamples() { | 45 void GatherPlayedSamples() { |
46 int frames = 0, total_frames = 0; | 46 int frames = 0, total_frames = 0; |
47 do { | 47 do { |
48 // Call back into the player to get samples that it wants us to play. | 48 // Call back into the player to get samples that it wants us to play. |
49 scoped_ptr<media::AudioBus> dest = | 49 scoped_ptr<media::AudioBus> dest = |
50 media::AudioBus::Create(1, default_frame_count_); | 50 media::AudioBus::Create(1, default_frame_count_); |
51 frames = callback_->OnMoreData(dest.get(), 0); | 51 frames = callback_->OnMoreData(dest.get(), 0); |
52 total_frames += frames; | 52 total_frames += frames; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 TEST_F(AudioPlayerTest, PlayingEndToEnd) { | 180 TEST_F(AudioPlayerTest, PlayingEndToEnd) { |
181 const int kNumSamples = kDefaultFrameCount * 10; | 181 const int kNumSamples = kDefaultFrameCount * 10; |
182 CreatePlayer(); | 182 CreatePlayer(); |
183 | 183 |
184 PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples)); | 184 PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples)); |
185 | 185 |
186 DeletePlayer(); | 186 DeletePlayer(); |
187 } | 187 } |
188 | 188 |
189 } // namespace copresence | 189 } // namespace copresence |
OLD | NEW |