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

Side by Side Diff: media/audio/mac/audio_auhal_mac.cc

Issue 1903753002: Restores larger output buffer size when output stream requiring smaller size is closed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 7 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 | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/audio/mac/audio_auhal_mac.h" 5 #include "media/audio/mac/audio_auhal_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 OSSTATUS_DLOG(ERROR, result) << "AudioOutputUnitStart() failed."; 168 OSSTATUS_DLOG(ERROR, result) << "AudioOutputUnitStart() failed.";
169 callback->OnError(this); 169 callback->OnError(this);
170 } 170 }
171 171
172 void AUHALStream::Stop() { 172 void AUHALStream::Stop() {
173 DCHECK(thread_checker_.CalledOnValidThread()); 173 DCHECK(thread_checker_.CalledOnValidThread());
174 deferred_start_cb_.Cancel(); 174 deferred_start_cb_.Cancel();
175 if (stopped_) 175 if (stopped_)
176 return; 176 return;
177 DVLOG(1) << "Stop"; 177 DVLOG(1) << "Stop";
178 DVLOG(2) << "number_of_frames: " << number_of_frames_;
178 OSStatus result = AudioOutputUnitStop(audio_unit_); 179 OSStatus result = AudioOutputUnitStop(audio_unit_);
179 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 180 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
180 << "AudioOutputUnitStop() failed."; 181 << "AudioOutputUnitStop() failed.";
181 if (result != noErr) 182 if (result != noErr)
182 source_->OnError(this); 183 source_->OnError(this);
183 ReportAndResetStats(); 184 ReportAndResetStats();
184 base::AutoLock auto_lock(source_lock_); 185 base::AutoLock auto_lock(source_lock_);
185 source_ = NULL; 186 source_ = NULL;
186 stopped_ = true; 187 stopped_ = true;
187 } 188 }
(...skipping 23 matching lines...) Expand all
211 // If the stream parameters change for any reason, we need to insert a FIFO 212 // If the stream parameters change for any reason, we need to insert a FIFO
212 // since the OnMoreData() pipeline can't handle frame size changes. 213 // since the OnMoreData() pipeline can't handle frame size changes.
213 if (number_of_frames != number_of_frames_) { 214 if (number_of_frames != number_of_frames_) {
214 // Create a FIFO on the fly to handle any discrepancies in callback rates. 215 // Create a FIFO on the fly to handle any discrepancies in callback rates.
215 if (!audio_fifo_) { 216 if (!audio_fifo_) {
216 // TODO(grunell): We'll only care about the first buffer size change, 217 // TODO(grunell): We'll only care about the first buffer size change,
217 // any further changes will be ignored. It would be nice to have all 218 // any further changes will be ignored. It would be nice to have all
218 // changes reflected in UMA stats. 219 // changes reflected in UMA stats.
219 number_of_frames_requested_ = number_of_frames; 220 number_of_frames_requested_ = number_of_frames;
220 DVLOG(1) << "Audio frame size changed from " << number_of_frames_ 221 DVLOG(1) << "Audio frame size changed from " << number_of_frames_
221 << " to " << number_of_frames 222 << " to " << number_of_frames << " adding FIFO to compensate.";
222 << "; adding FIFO to compensate.";
223 audio_fifo_.reset(new AudioPullFifo( 223 audio_fifo_.reset(new AudioPullFifo(
224 output_channels_, 224 output_channels_,
225 number_of_frames_, 225 number_of_frames_,
226 base::Bind(&AUHALStream::ProvideInput, base::Unretained(this)))); 226 base::Bind(&AUHALStream::ProvideInput, base::Unretained(this))));
227 } 227 }
228 } 228 }
229 229
230 // Make |output_bus_| wrap the output AudioBufferList. 230 // Make |output_bus_| wrap the output AudioBufferList.
231 WrapBufferList(data, output_bus_.get(), number_of_frames); 231 WrapBufferList(data, output_bus_.get(), number_of_frames);
232 232
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 OSStatus result = AudioUnitUninitialize(audio_unit_); 546 OSStatus result = AudioUnitUninitialize(audio_unit_);
547 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 547 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
548 << "AudioUnitUninitialize() failed."; 548 << "AudioUnitUninitialize() failed.";
549 result = AudioComponentInstanceDispose(audio_unit_); 549 result = AudioComponentInstanceDispose(audio_unit_);
550 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 550 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
551 << "AudioComponentInstanceDispose() failed."; 551 << "AudioComponentInstanceDispose() failed.";
552 audio_unit_ = 0; 552 audio_unit_ = 0;
553 } 553 }
554 554
555 } // namespace media 555 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698