| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // THREAD SAFETY | 5 // THREAD SAFETY |
| 6 // | 6 // |
| 7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used | 7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used |
| 8 // from the audio thread. We DCHECK on this assumption whenever we can. | 8 // from the audio thread. We DCHECK on this assumption whenever we can. |
| 9 // | 9 // |
| 10 // SEMANTICS OF Close() | 10 // SEMANTICS OF Close() |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 } | 737 } |
| 738 | 738 |
| 739 bool AlsaPcmOutputStream::IsOnAudioThread() const { | 739 bool AlsaPcmOutputStream::IsOnAudioThread() const { |
| 740 return message_loop_ && message_loop_ == base::MessageLoop::current(); | 740 return message_loop_ && message_loop_ == base::MessageLoop::current(); |
| 741 } | 741 } |
| 742 | 742 |
| 743 int AlsaPcmOutputStream::RunDataCallback(AudioBus* audio_bus, | 743 int AlsaPcmOutputStream::RunDataCallback(AudioBus* audio_bus, |
| 744 AudioBuffersState buffers_state) { | 744 AudioBuffersState buffers_state) { |
| 745 TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback"); | 745 TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback"); |
| 746 | 746 |
| 747 if (source_callback_) { | 747 if (source_callback_) |
| 748 source_callback_->WaitTillDataReady(); | |
| 749 return source_callback_->OnMoreData(audio_bus, buffers_state); | 748 return source_callback_->OnMoreData(audio_bus, buffers_state); |
| 750 } | |
| 751 | 749 |
| 752 return 0; | 750 return 0; |
| 753 } | 751 } |
| 754 | 752 |
| 755 void AlsaPcmOutputStream::RunErrorCallback(int code) { | 753 void AlsaPcmOutputStream::RunErrorCallback(int code) { |
| 756 if (source_callback_) | 754 if (source_callback_) |
| 757 source_callback_->OnError(this); | 755 source_callback_->OnError(this); |
| 758 } | 756 } |
| 759 | 757 |
| 760 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 758 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
| 761 // release ownership of the currently registered callback. | 759 // release ownership of the currently registered callback. |
| 762 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { | 760 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { |
| 763 DCHECK(IsOnAudioThread()); | 761 DCHECK(IsOnAudioThread()); |
| 764 source_callback_ = callback; | 762 source_callback_ = callback; |
| 765 } | 763 } |
| 766 | 764 |
| 767 } // namespace media | 765 } // namespace media |
| OLD | NEW |