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

Side by Side Diff: media/audio/virtual_audio_input_stream.cc

Issue 1074963003: Clean up potentially leaky use of base::DeletePointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed another probleb Created 5 years, 8 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
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/virtual_audio_input_stream.h" 5 #include "media/audio/virtual_audio_input_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 AudioConverter audio_converter_; 45 AudioConverter audio_converter_;
46 46
47 DISALLOW_COPY_AND_ASSIGN(LoopbackAudioConverter); 47 DISALLOW_COPY_AND_ASSIGN(LoopbackAudioConverter);
48 }; 48 };
49 49
50 VirtualAudioInputStream::VirtualAudioInputStream( 50 VirtualAudioInputStream::VirtualAudioInputStream(
51 const AudioParameters& params, 51 const AudioParameters& params,
52 const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner, 52 const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
53 const AfterCloseCallback& after_close_cb) 53 bool delete_on_close)
54 : worker_task_runner_(worker_task_runner), 54 : worker_task_runner_(worker_task_runner),
55 after_close_cb_(after_close_cb), 55 delete_on_close_(delete_on_close),
56 callback_(NULL), 56 callback_(NULL),
57 buffer_(new uint8[params.GetBytesPerBuffer()]), 57 buffer_(new uint8[params.GetBytesPerBuffer()]),
58 params_(params), 58 params_(params),
59 mixer_(params_, params_, false), 59 mixer_(params_, params_, false),
60 num_attached_output_streams_(0), 60 num_attached_output_streams_(0),
61 fake_worker_(worker_task_runner_, params_), 61 fake_worker_(worker_task_runner_, params_),
62 audio_bus_(AudioBus::Create(params)) { 62 audio_bus_(AudioBus::Create(params)) {
63 DCHECK(params_.IsValid()); 63 DCHECK(params_.IsValid());
64 DCHECK(worker_task_runner_.get()); 64 DCHECK(worker_task_runner_.get());
65 65
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Because the audio is being looped-back, the delay since since it was 145 // Because the audio is being looped-back, the delay since since it was
146 // recorded is zero. 146 // recorded is zero.
147 callback_->OnData(this, audio_bus_.get(), 0, 1.0); 147 callback_->OnData(this, audio_bus_.get(), 0, 1.0);
148 } 148 }
149 149
150 void VirtualAudioInputStream::Close() { 150 void VirtualAudioInputStream::Close() {
151 DCHECK(thread_checker_.CalledOnValidThread()); 151 DCHECK(thread_checker_.CalledOnValidThread());
152 152
153 Stop(); // Make sure callback_ is no longer being used. 153 Stop(); // Make sure callback_ is no longer being used.
154 154
155 // If a non-null AfterCloseCallback was provided to the constructor, invoke it 155 if (delete_on_close_) {
156 // here. The callback is moved to a stack-local first since |this| could be 156 delete this;
157 // destroyed during Run().
158 if (!after_close_cb_.is_null()) {
159 const AfterCloseCallback cb = after_close_cb_;
160 after_close_cb_.Reset();
161 cb.Run(this);
162 } 157 }
163 } 158 }
164 159
165 double VirtualAudioInputStream::GetMaxVolume() { 160 double VirtualAudioInputStream::GetMaxVolume() {
166 return 1.0; 161 return 1.0;
167 } 162 }
168 163
169 void VirtualAudioInputStream::SetVolume(double volume) {} 164 void VirtualAudioInputStream::SetVolume(double volume) {}
170 165
171 double VirtualAudioInputStream::GetVolume() { 166 double VirtualAudioInputStream::GetVolume() {
172 return 1.0; 167 return 1.0;
173 } 168 }
174 169
175 bool VirtualAudioInputStream::SetAutomaticGainControl(bool enabled) { 170 bool VirtualAudioInputStream::SetAutomaticGainControl(bool enabled) {
176 return false; 171 return false;
177 } 172 }
178 173
179 bool VirtualAudioInputStream::GetAutomaticGainControl() { 174 bool VirtualAudioInputStream::GetAutomaticGainControl() {
180 return false; 175 return false;
181 } 176 }
182 177
183 bool VirtualAudioInputStream::IsMuted() { 178 bool VirtualAudioInputStream::IsMuted() {
184 return false; 179 return false;
185 } 180 }
186 181
187 } // namespace media 182 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/virtual_audio_input_stream.h ('k') | media/audio/virtual_audio_input_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698