| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (stream_) | 98 if (stream_) |
| 99 stream_->Close(); | 99 stream_->Close(); |
| 100 stream_ = NULL; | 100 stream_ = NULL; |
| 101 stop_closure_.Cancel(); | 101 stop_closure_.Cancel(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 // AudioOutputStream::AudioSourceCallback overrides: | 105 // AudioOutputStream::AudioSourceCallback overrides: |
| 106 // Following methods could be called from *ANY* thread. | 106 // Following methods could be called from *ANY* thread. |
| 107 virtual int OnMoreData(AudioBus* dest, | 107 virtual int OnMoreData(AudioBus* dest, |
| 108 int /* total_bytes_delay */) OVERRIDE { | 108 AudioBuffersState /* state */) OVERRIDE { |
| 109 base::AutoLock al(state_lock_); | 109 base::AutoLock al(state_lock_); |
| 110 size_t bytes_written = 0; | 110 size_t bytes_written = 0; |
| 111 | 111 |
| 112 if (wav_audio_.AtEnd(cursor_) || | 112 if (wav_audio_.AtEnd(cursor_) || |
| 113 !wav_audio_.CopyTo(dest, cursor_, &bytes_written)) { | 113 !wav_audio_.CopyTo(dest, cursor_, &bytes_written)) { |
| 114 if (delayed_stop_posted_) | 114 if (delayed_stop_posted_) |
| 115 return 0; | 115 return 0; |
| 116 delayed_stop_posted_ = true; | 116 delayed_stop_posted_ = true; |
| 117 AudioManager::Get()->GetTaskRunner()->PostDelayedTask( | 117 AudioManager::Get()->GetTaskRunner()->PostDelayedTask( |
| 118 FROM_HERE, | 118 FROM_HERE, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 g_observer_for_testing = observer; | 210 g_observer_for_testing = observer; |
| 211 } | 211 } |
| 212 | 212 |
| 213 // static | 213 // static |
| 214 void AudioStreamHandler::SetAudioSourceForTesting( | 214 void AudioStreamHandler::SetAudioSourceForTesting( |
| 215 AudioOutputStream::AudioSourceCallback* source) { | 215 AudioOutputStream::AudioSourceCallback* source) { |
| 216 g_audio_source_for_testing = source; | 216 g_audio_source_for_testing = source; |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace media | 219 } // namespace media |
| OLD | NEW |