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

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: Addressed review comment. 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(handle_,
DaleCurtis 2014/08/29 18:12:04 Wrapping is incorrect, move handle_ to the next li
123 &pulse::StreamSuccessCallback,
124 pa_mainloop_);
125 WaitForOperationCompletion(pa_mainloop_, operation);
123 126
124 if (pa_stream_get_state(handle_) != PA_STREAM_UNCONNECTED) 127 if (pa_stream_get_state(handle_) != PA_STREAM_UNCONNECTED)
125 pa_stream_disconnect(handle_); 128 pa_stream_disconnect(handle_);
126 129
127 // Release PulseAudio structures. 130 // Release PulseAudio structures.
128 pa_stream_unref(handle_); 131 pa_stream_unref(handle_);
129 handle_ = NULL; 132 handle_ = NULL;
130 } 133 }
131 } 134 }
132 135
(...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 287 // Sleep 5ms to wait until render consumes the data in order to avoid
285 // back to back OnData() method. 288 // back to back OnData() method.
286 if (fifo_.available_blocks()) 289 if (fifo_.available_blocks())
287 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5)); 290 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5));
288 } 291 }
289 292
290 pa_threaded_mainloop_signal(pa_mainloop_, 0); 293 pa_threaded_mainloop_signal(pa_mainloop_, 0);
291 } 294 }
292 295
293 } // namespace media 296 } // 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