| 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/location.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 void GetVolume(double* volume) override {} | 44 void GetVolume(double* volume) override {} |
| 45 void Close() override {} | 45 void Close() override {} |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 void GatherPlayedSamples() { | 48 void GatherPlayedSamples() { |
| 49 int frames = 0, total_frames = 0; | 49 int frames = 0, total_frames = 0; |
| 50 do { | 50 do { |
| 51 // 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. |
| 52 scoped_ptr<media::AudioBus> dest = | 52 scoped_ptr<media::AudioBus> dest = |
| 53 media::AudioBus::Create(1, default_frame_count_); | 53 media::AudioBus::Create(1, default_frame_count_); |
| 54 frames = callback_->OnMoreData(dest.get(), 0); | 54 frames = callback_->OnMoreData(dest.get(), 0, 0); |
| 55 total_frames += frames; | 55 total_frames += frames; |
| 56 // 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. |
| 57 caller_loop_->task_runner()->PostTask( | 57 caller_loop_->task_runner()->PostTask( |
| 58 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames)); | 58 FROM_HERE, base::Bind(gather_callback_, base::Passed(&dest), frames)); |
| 59 } while (frames && total_frames < max_frame_count_); | 59 } while (frames && total_frames < max_frame_count_); |
| 60 } | 60 } |
| 61 | 61 |
| 62 int default_frame_count_; | 62 int default_frame_count_; |
| 63 int max_frame_count_; | 63 int max_frame_count_; |
| 64 GatherSamplesCallback gather_callback_; | 64 GatherSamplesCallback gather_callback_; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 PlayAndVerifySamples( | 205 PlayAndVerifySamples( |
| 206 CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123)); | 206 CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123)); |
| 207 | 207 |
| 208 PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2)); | 208 PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2)); |
| 209 | 209 |
| 210 DeletePlayer(); | 210 DeletePlayer(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace audio_modem | 213 } // namespace audio_modem |
| OLD | NEW |