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 "components/audio_modem/audio_player.h" | 5 #include "components/audio_modem/audio_player.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" |
9 #include "components/audio_modem/audio_player_impl.h" | 11 #include "components/audio_modem/audio_player_impl.h" |
10 #include "components/audio_modem/public/audio_modem_types.h" | 12 #include "components/audio_modem/public/audio_modem_types.h" |
11 #include "components/audio_modem/test/random_samples.h" | 13 #include "components/audio_modem/test/random_samples.h" |
12 #include "media/audio/audio_manager.h" | 14 #include "media/audio/audio_manager.h" |
13 #include "media/audio/audio_manager_base.h" | 15 #include "media/audio/audio_manager_base.h" |
14 #include "media/base/audio_bus.h" | 16 #include "media/base/audio_bus.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
(...skipping 26 matching lines...) Expand all Loading... |
45 private: | 47 private: |
46 void GatherPlayedSamples() { | 48 void GatherPlayedSamples() { |
47 int frames = 0, total_frames = 0; | 49 int frames = 0, total_frames = 0; |
48 do { | 50 do { |
49 // Call back into the player to get samples that it wants us to play. | 51 // Call back into the player to get samples that it wants us to play. |
50 scoped_ptr<media::AudioBus> dest = | 52 scoped_ptr<media::AudioBus> dest = |
51 media::AudioBus::Create(1, default_frame_count_); | 53 media::AudioBus::Create(1, default_frame_count_); |
52 frames = callback_->OnMoreData(dest.get(), 0); | 54 frames = callback_->OnMoreData(dest.get(), 0); |
53 total_frames += frames; | 55 total_frames += frames; |
54 // Send the samples given to us by the player to the gather callback. | 56 // Send the samples given to us by the player to the gather callback. |
55 caller_loop_->PostTask( | 57 caller_loop_->task_runner()->PostTask( |
56 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames)); | 58 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames)); |
57 } while (frames && total_frames < max_frame_count_); | 59 } while (frames && total_frames < max_frame_count_); |
58 } | 60 } |
59 | 61 |
60 int default_frame_count_; | 62 int default_frame_count_; |
61 int max_frame_count_; | 63 int max_frame_count_; |
62 GatherSamplesCallback gather_callback_; | 64 GatherSamplesCallback gather_callback_; |
63 AudioSourceCallback* callback_; | 65 AudioSourceCallback* callback_; |
64 base::MessageLoop* caller_loop_; | 66 base::MessageLoop* caller_loop_; |
65 | 67 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 204 |
203 PlayAndVerifySamples( | 205 PlayAndVerifySamples( |
204 CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123)); | 206 CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123)); |
205 | 207 |
206 PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2)); | 208 PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2)); |
207 | 209 |
208 DeletePlayer(); | 210 DeletePlayer(); |
209 } | 211 } |
210 | 212 |
211 } // namespace audio_modem | 213 } // namespace audio_modem |
OLD | NEW |