OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/audio/sounds/audio_stream_handler.h" | 5 #include "media/audio/sounds/audio_stream_handler.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 StopStream(); | 105 StopStream(); |
106 if (stream_) | 106 if (stream_) |
107 stream_->Close(); | 107 stream_->Close(); |
108 stream_ = NULL; | 108 stream_ = NULL; |
109 stop_closure_.Cancel(); | 109 stop_closure_.Cancel(); |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 // AudioOutputStream::AudioSourceCallback overrides: | 113 // AudioOutputStream::AudioSourceCallback overrides: |
114 // Following methods could be called from *ANY* thread. | 114 // Following methods could be called from *ANY* thread. |
115 int OnMoreData(AudioBus* dest, | 115 int OnMoreData(base::TimeDelta /* delay */, |
116 uint32_t /* total_bytes_delay */, | 116 base::TimeTicks /* delay_timestamp */, |
117 uint32_t /* frames_skipped */) override { | 117 int /* prior_frames_skipped */, |
| 118 AudioBus* dest) override { |
118 base::AutoLock al(state_lock_); | 119 base::AutoLock al(state_lock_); |
119 size_t bytes_written = 0; | 120 size_t bytes_written = 0; |
120 | 121 |
121 if (wav_audio_->AtEnd(cursor_) || | 122 if (wav_audio_->AtEnd(cursor_) || |
122 !wav_audio_->CopyTo(dest, cursor_, &bytes_written)) { | 123 !wav_audio_->CopyTo(dest, cursor_, &bytes_written)) { |
123 if (delayed_stop_posted_) | 124 if (delayed_stop_posted_) |
124 return 0; | 125 return 0; |
125 delayed_stop_posted_ = true; | 126 delayed_stop_posted_ = true; |
126 audio_manager_->GetTaskRunner()->PostDelayedTask( | 127 audio_manager_->GetTaskRunner()->PostDelayedTask( |
127 FROM_HERE, stop_closure_.callback(), | 128 FROM_HERE, stop_closure_.callback(), |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 g_observer_for_testing = observer; | 246 g_observer_for_testing = observer; |
246 } | 247 } |
247 | 248 |
248 // static | 249 // static |
249 void AudioStreamHandler::SetAudioSourceForTesting( | 250 void AudioStreamHandler::SetAudioSourceForTesting( |
250 AudioOutputStream::AudioSourceCallback* source) { | 251 AudioOutputStream::AudioSourceCallback* source) { |
251 g_audio_source_for_testing = source; | 252 g_audio_source_for_testing = source; |
252 } | 253 } |
253 | 254 |
254 } // namespace media | 255 } // namespace media |
OLD | NEW |