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 // 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 break; | 117 break; |
118 case AlsaPcmOutputStream::kIsPlaying: | 118 case AlsaPcmOutputStream::kIsPlaying: |
119 os << "kIsPlaying"; | 119 os << "kIsPlaying"; |
120 break; | 120 break; |
121 case AlsaPcmOutputStream::kIsStopped: | 121 case AlsaPcmOutputStream::kIsStopped: |
122 os << "kIsStopped"; | 122 os << "kIsStopped"; |
123 break; | 123 break; |
124 case AlsaPcmOutputStream::kIsClosed: | 124 case AlsaPcmOutputStream::kIsClosed: |
125 os << "kIsClosed"; | 125 os << "kIsClosed"; |
126 break; | 126 break; |
127 }; | 127 } |
128 return os; | 128 return os; |
129 } | 129 } |
130 | 130 |
131 const char AlsaPcmOutputStream::kDefaultDevice[] = "default"; | 131 const char AlsaPcmOutputStream::kDefaultDevice[] = "default"; |
132 const char AlsaPcmOutputStream::kAutoSelectDevice[] = ""; | 132 const char AlsaPcmOutputStream::kAutoSelectDevice[] = ""; |
133 const char AlsaPcmOutputStream::kPlugPrefix[] = "plug:"; | 133 const char AlsaPcmOutputStream::kPlugPrefix[] = "plug:"; |
134 | 134 |
135 // We use 40ms as our minimum required latency. If it is needed, we may be able | 135 // We use 40ms as our minimum required latency. If it is needed, we may be able |
136 // to get it down to 20ms. | 136 // to get it down to 20ms. |
137 const uint32_t AlsaPcmOutputStream::kMinLatencyMicros = 40 * 1000; | 137 const uint32_t AlsaPcmOutputStream::kMinLatencyMicros = 40 * 1000; |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 } | 776 } |
777 | 777 |
778 bool AlsaPcmOutputStream::IsOnAudioThread() const { | 778 bool AlsaPcmOutputStream::IsOnAudioThread() const { |
779 return message_loop_ && message_loop_ == base::MessageLoop::current(); | 779 return message_loop_ && message_loop_ == base::MessageLoop::current(); |
780 } | 780 } |
781 | 781 |
782 int AlsaPcmOutputStream::RunDataCallback(AudioBus* audio_bus, | 782 int AlsaPcmOutputStream::RunDataCallback(AudioBus* audio_bus, |
783 uint32_t total_bytes_delay) { | 783 uint32_t total_bytes_delay) { |
784 TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback"); | 784 TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback"); |
785 | 785 |
786 if (source_callback_) | 786 if (source_callback_) { |
787 return source_callback_->OnMoreData(audio_bus, total_bytes_delay, 0); | 787 return source_callback_->OnMoreData(audio_bus, total_bytes_delay, |
| 788 base::TimeDelta(), 0); |
| 789 } |
788 | 790 |
789 return 0; | 791 return 0; |
790 } | 792 } |
791 | 793 |
792 void AlsaPcmOutputStream::RunErrorCallback(int code) { | 794 void AlsaPcmOutputStream::RunErrorCallback(int code) { |
793 if (source_callback_) | 795 if (source_callback_) |
794 source_callback_->OnError(this); | 796 source_callback_->OnError(this); |
795 } | 797 } |
796 | 798 |
797 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 799 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
798 // release ownership of the currently registered callback. | 800 // release ownership of the currently registered callback. |
799 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { | 801 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { |
800 DCHECK(IsOnAudioThread()); | 802 DCHECK(IsOnAudioThread()); |
801 source_callback_ = callback; | 803 source_callback_ = callback; |
802 } | 804 } |
803 | 805 |
804 } // namespace media | 806 } // namespace media |
OLD | NEW |