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 30 matching lines...) Expand all Loading... |
41 virtual void GetVolume(double* volume) OVERRIDE {} | 41 virtual void GetVolume(double* volume) OVERRIDE {} |
42 virtual void Close() OVERRIDE {} | 42 virtual 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(), media::AudioBuffersState()); | 51 frames = callback_->OnMoreData(dest.get(), 0); |
52 total_frames += frames; | 52 total_frames += frames; |
53 // Send the samples given to us by the player to the gather callback. | 53 // Send the samples given to us by the player to the gather callback. |
54 caller_loop_->PostTask( | 54 caller_loop_->PostTask( |
55 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames)); | 55 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames)); |
56 } while (frames && total_frames < max_frame_count_); | 56 } while (frames && total_frames < max_frame_count_); |
57 } | 57 } |
58 | 58 |
59 int default_frame_count_; | 59 int default_frame_count_; |
60 int max_frame_count_; | 60 int max_frame_count_; |
61 GatherSamplesCallback gather_callback_; | 61 GatherSamplesCallback gather_callback_; |
(...skipping 118 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 |