Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: media/audio/pulse/pulse_input.cc

Issue 520613003: Fix memory leaks related to PulseAudioInputStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit fix. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698