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 #include "media/audio/pulse/pulse_input.h" | 5 #include "media/audio/pulse/pulse_input.h" |
6 | 6 |
7 #include <pulse/pulseaudio.h> | 7 #include <pulse/pulseaudio.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/audio/pulse/audio_manager_pulse.h" | 10 #include "media/audio/pulse/audio_manager_pulse.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 callback_ = NULL; | 112 callback_ = NULL; |
113 } | 113 } |
114 | 114 |
115 void PulseAudioInputStream::Close() { | 115 void PulseAudioInputStream::Close() { |
116 DCHECK(thread_checker_.CalledOnValidThread()); | 116 DCHECK(thread_checker_.CalledOnValidThread()); |
117 { | 117 { |
118 AutoPulseLock auto_lock(pa_mainloop_); | 118 AutoPulseLock auto_lock(pa_mainloop_); |
119 if (handle_) { | 119 if (handle_) { |
120 // Disable all the callbacks before disconnecting. | 120 // Disable all the callbacks before disconnecting. |
121 pa_stream_set_state_callback(handle_, NULL, NULL); | 121 pa_stream_set_state_callback(handle_, NULL, NULL); |
122 pa_stream_flush(handle_, NULL, NULL); | 122 pa_operation* operation = pa_stream_flush( |
| 123 handle_, &pulse::StreamSuccessCallback, pa_mainloop_); |
| 124 WaitForOperationCompletion(pa_mainloop_, operation); |
123 | 125 |
124 if (pa_stream_get_state(handle_) != PA_STREAM_UNCONNECTED) | 126 if (pa_stream_get_state(handle_) != PA_STREAM_UNCONNECTED) |
125 pa_stream_disconnect(handle_); | 127 pa_stream_disconnect(handle_); |
126 | 128 |
127 // Release PulseAudio structures. | 129 // Release PulseAudio structures. |
128 pa_stream_unref(handle_); | 130 pa_stream_unref(handle_); |
129 handle_ = NULL; | 131 handle_ = NULL; |
130 } | 132 } |
131 } | 133 } |
132 | 134 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // Sleep 5ms to wait until render consumes the data in order to avoid | 286 // Sleep 5ms to wait until render consumes the data in order to avoid |
285 // back to back OnData() method. | 287 // back to back OnData() method. |
286 if (fifo_.available_blocks()) | 288 if (fifo_.available_blocks()) |
287 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5)); | 289 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5)); |
288 } | 290 } |
289 | 291 |
290 pa_threaded_mainloop_signal(pa_mainloop_, 0); | 292 pa_threaded_mainloop_signal(pa_mainloop_, 0); |
291 } | 293 } |
292 | 294 |
293 } // namespace media | 295 } // namespace media |
OLD | NEW |