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

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

Issue 1973503003: (Relanding) 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: added comment 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 hardware_latency_frames_ = GetHardwareLatency(); 116 hardware_latency_frames_ = GetHardwareLatency();
117 117
118 return configured; 118 return configured;
119 } 119 }
120 120
121 void AUHALStream::Close() { 121 void AUHALStream::Close() {
122 DCHECK(thread_checker_.CalledOnValidThread()); 122 DCHECK(thread_checker_.CalledOnValidThread());
123 DVLOG(1) << "Close"; 123 DVLOG(1) << "Close";
124 CloseAudioUnit(); 124 CloseAudioUnit();
125 // Inform the audio manager that we have been closed. This will cause our 125 // Inform the audio manager that we have been closed. This will cause our
126 // destruction. 126 // destruction. Also include the device ID as a signal to the audio manager
127 manager_->ReleaseOutputStream(this); 127 // that it should try to increase the native I/O buffer size after the stream
128 // has been closed.
129 manager_->ReleaseOutputStreamUsingRealDevice(this, device_);
128 } 130 }
129 131
130 void AUHALStream::Start(AudioSourceCallback* callback) { 132 void AUHALStream::Start(AudioSourceCallback* callback) {
131 DCHECK(thread_checker_.CalledOnValidThread()); 133 DCHECK(thread_checker_.CalledOnValidThread());
132 DVLOG(1) << "Start"; 134 DVLOG(1) << "Start";
133 DCHECK(callback); 135 DCHECK(callback);
134 if (!audio_unit_) { 136 if (!audio_unit_) {
135 DLOG(ERROR) << "Open() has not been called successfully"; 137 DLOG(ERROR) << "Open() has not been called successfully";
136 return; 138 return;
137 } 139 }
(...skipping 30 matching lines...) Expand all
168 OSSTATUS_DLOG(ERROR, result) << "AudioOutputUnitStart() failed."; 170 OSSTATUS_DLOG(ERROR, result) << "AudioOutputUnitStart() failed.";
169 callback->OnError(this); 171 callback->OnError(this);
170 } 172 }
171 173
172 void AUHALStream::Stop() { 174 void AUHALStream::Stop() {
173 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
174 deferred_start_cb_.Cancel(); 176 deferred_start_cb_.Cancel();
175 if (stopped_) 177 if (stopped_)
176 return; 178 return;
177 DVLOG(1) << "Stop"; 179 DVLOG(1) << "Stop";
180 DVLOG(2) << "number_of_frames: " << number_of_frames_;
178 OSStatus result = AudioOutputUnitStop(audio_unit_); 181 OSStatus result = AudioOutputUnitStop(audio_unit_);
179 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 182 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
180 << "AudioOutputUnitStop() failed."; 183 << "AudioOutputUnitStop() failed.";
181 if (result != noErr) 184 if (result != noErr)
182 source_->OnError(this); 185 source_->OnError(this);
183 ReportAndResetStats(); 186 ReportAndResetStats();
184 base::AutoLock auto_lock(source_lock_); 187 base::AutoLock auto_lock(source_lock_);
185 source_ = NULL; 188 source_ = NULL;
186 stopped_ = true; 189 stopped_ = true;
187 } 190 }
(...skipping 23 matching lines...) Expand all
211 // If the stream parameters change for any reason, we need to insert a FIFO 214 // 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. 215 // since the OnMoreData() pipeline can't handle frame size changes.
213 if (number_of_frames != number_of_frames_) { 216 if (number_of_frames != number_of_frames_) {
214 // Create a FIFO on the fly to handle any discrepancies in callback rates. 217 // Create a FIFO on the fly to handle any discrepancies in callback rates.
215 if (!audio_fifo_) { 218 if (!audio_fifo_) {
216 // TODO(grunell): We'll only care about the first buffer size change, 219 // 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 220 // any further changes will be ignored. It would be nice to have all
218 // changes reflected in UMA stats. 221 // changes reflected in UMA stats.
219 number_of_frames_requested_ = number_of_frames; 222 number_of_frames_requested_ = number_of_frames;
220 DVLOG(1) << "Audio frame size changed from " << number_of_frames_ 223 DVLOG(1) << "Audio frame size changed from " << number_of_frames_
221 << " to " << number_of_frames 224 << " to " << number_of_frames << " adding FIFO to compensate.";
222 << "; adding FIFO to compensate.";
223 audio_fifo_.reset(new AudioPullFifo( 225 audio_fifo_.reset(new AudioPullFifo(
224 output_channels_, 226 output_channels_,
225 number_of_frames_, 227 number_of_frames_,
226 base::Bind(&AUHALStream::ProvideInput, base::Unretained(this)))); 228 base::Bind(&AUHALStream::ProvideInput, base::Unretained(this))));
227 } 229 }
228 } 230 }
229 231
230 // Make |output_bus_| wrap the output AudioBufferList. 232 // Make |output_bus_| wrap the output AudioBufferList.
231 WrapBufferList(data, output_bus_.get(), number_of_frames); 233 WrapBufferList(data, output_bus_.get(), number_of_frames);
232 234
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 OSStatus result = AudioUnitUninitialize(audio_unit_); 548 OSStatus result = AudioUnitUninitialize(audio_unit_);
547 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 549 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
548 << "AudioUnitUninitialize() failed."; 550 << "AudioUnitUninitialize() failed.";
549 result = AudioComponentInstanceDispose(audio_unit_); 551 result = AudioComponentInstanceDispose(audio_unit_);
550 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 552 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
551 << "AudioComponentInstanceDispose() failed."; 553 << "AudioComponentInstanceDispose() failed.";
552 audio_unit_ = 0; 554 audio_unit_ = 0;
553 } 555 }
554 556
555 } // namespace media 557 } // 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