| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 StopStream(); | 99 StopStream(); |
| 100 if (stream_) | 100 if (stream_) |
| 101 stream_->Close(); | 101 stream_->Close(); |
| 102 stream_ = NULL; | 102 stream_ = NULL; |
| 103 stop_closure_.Cancel(); | 103 stop_closure_.Cancel(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 // AudioOutputStream::AudioSourceCallback overrides: | 107 // AudioOutputStream::AudioSourceCallback overrides: |
| 108 // Following methods could be called from *ANY* thread. | 108 // Following methods could be called from *ANY* thread. |
| 109 int OnMoreData(AudioBus* dest, | 109 int OnMoreData(AudioBus* dest, uint32 /* total_bytes_delay */) override { |
| 110 uint32_t /* total_bytes_delay */, | |
| 111 uint32_t /* frames_skipped */) override { | |
| 112 base::AutoLock al(state_lock_); | 110 base::AutoLock al(state_lock_); |
| 113 size_t bytes_written = 0; | 111 size_t bytes_written = 0; |
| 114 | 112 |
| 115 if (wav_audio_->AtEnd(cursor_) || | 113 if (wav_audio_->AtEnd(cursor_) || |
| 116 !wav_audio_->CopyTo(dest, cursor_, &bytes_written)) { | 114 !wav_audio_->CopyTo(dest, cursor_, &bytes_written)) { |
| 117 if (delayed_stop_posted_) | 115 if (delayed_stop_posted_) |
| 118 return 0; | 116 return 0; |
| 119 delayed_stop_posted_ = true; | 117 delayed_stop_posted_ = true; |
| 120 AudioManager::Get()->GetTaskRunner()->PostDelayedTask( | 118 AudioManager::Get()->GetTaskRunner()->PostDelayedTask( |
| 121 FROM_HERE, | 119 FROM_HERE, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 g_observer_for_testing = observer; | 236 g_observer_for_testing = observer; |
| 239 } | 237 } |
| 240 | 238 |
| 241 // static | 239 // static |
| 242 void AudioStreamHandler::SetAudioSourceForTesting( | 240 void AudioStreamHandler::SetAudioSourceForTesting( |
| 243 AudioOutputStream::AudioSourceCallback* source) { | 241 AudioOutputStream::AudioSourceCallback* source) { |
| 244 g_audio_source_for_testing = source; | 242 g_audio_source_for_testing = source; |
| 245 } | 243 } |
| 246 | 244 |
| 247 } // namespace media | 245 } // namespace media |
| OLD | NEW |