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

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

Issue 99173007: Merge 238501 "Attempt to fix audio wedges by restarting all stre..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1700/src/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_output_resampler.h ('k') | media/audio/mock_audio_manager.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 (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/audio_output_resampler.h" 5 #include "media/audio/audio_output_resampler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 DCHECK(message_loop_->BelongsToCurrentThread()); 288 DCHECK(message_loop_->BelongsToCurrentThread());
289 289
290 // No AudioOutputProxy objects should hold a reference to us when we get 290 // No AudioOutputProxy objects should hold a reference to us when we get
291 // to this stage. 291 // to this stage.
292 DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference"; 292 DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference";
293 293
294 dispatcher_->Shutdown(); 294 dispatcher_->Shutdown();
295 DCHECK(callbacks_.empty()); 295 DCHECK(callbacks_.empty());
296 } 296 }
297 297
298 void AudioOutputResampler::CloseStreamsForWedgeFix() {
299 DCHECK(message_loop_->BelongsToCurrentThread());
300
301 // Stop and close all active streams. Once all streams across all dispatchers
302 // have been closed the AudioManager will call RestartStreamsForWedgeFix().
303 for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
304 ++it) {
305 dispatcher_->StopStream(it->first);
306 dispatcher_->CloseStream(it->first);
307 }
308
309 // Close all idle streams as well.
310 dispatcher_->CloseStreamsForWedgeFix();
311 }
312
313 void AudioOutputResampler::RestartStreamsForWedgeFix() {
314 DCHECK(message_loop_->BelongsToCurrentThread());
315 for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
316 ++it) {
317 dispatcher_->OpenStream();
318 dispatcher_->StartStream(it->second, it->first);
319 }
320 }
321
298 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params, 322 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params,
299 const AudioParameters& output_params) 323 const AudioParameters& output_params)
300 : source_callback_(NULL), 324 : source_callback_(NULL),
301 source_bus_(NULL), 325 source_bus_(NULL),
302 input_bytes_per_second_(input_params.GetBytesPerSecond()), 326 input_bytes_per_second_(input_params.GetBytesPerSecond()),
303 audio_converter_(input_params, output_params, false) { 327 audio_converter_(input_params, output_params, false) {
304 io_ratio_ = 328 io_ratio_ =
305 static_cast<double>(input_params.GetBytesPerSecond()) / 329 static_cast<double>(input_params.GetBytesPerSecond()) /
306 output_params.GetBytesPerSecond(); 330 output_params.GetBytesPerSecond();
307 } 331 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 return frames > 0 ? 1 : 0; 409 return frames > 0 ? 1 : 0;
386 } 410 }
387 411
388 void OnMoreDataConverter::OnError(AudioOutputStream* stream) { 412 void OnMoreDataConverter::OnError(AudioOutputStream* stream) {
389 base::AutoLock auto_lock(source_lock_); 413 base::AutoLock auto_lock(source_lock_);
390 if (source_callback_) 414 if (source_callback_)
391 source_callback_->OnError(stream); 415 source_callback_->OnError(stream);
392 } 416 }
393 417
394 } // namespace media 418 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_resampler.h ('k') | media/audio/mock_audio_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698