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

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

Issue 61203008: Attempt to fix audio wedges by restarting all streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mock. 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 DCHECK(message_loop_->BelongsToCurrentThread()); 284 DCHECK(message_loop_->BelongsToCurrentThread());
285 285
286 // No AudioOutputProxy objects should hold a reference to us when we get 286 // No AudioOutputProxy objects should hold a reference to us when we get
287 // to this stage. 287 // to this stage.
288 DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference"; 288 DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference";
289 289
290 dispatcher_->Shutdown(); 290 dispatcher_->Shutdown();
291 DCHECK(callbacks_.empty()); 291 DCHECK(callbacks_.empty());
292 } 292 }
293 293
294 void AudioOutputResampler::CloseStreamsForWedgeFix() {
295 DCHECK(message_loop_->BelongsToCurrentThread());
296
297 // Stop and close all active streams. Once all streams across all dispatchers
298 // have been closed the AudioManager will call RestartStreamsForWedgeFix().
299 for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
300 ++it) {
301 dispatcher_->StopStream(it->first);
302 dispatcher_->CloseStream(it->first);
303 }
304
305 // Close all idle streams as well.
306 dispatcher_->CloseStreamsForWedgeFix();
307 }
308
309 void AudioOutputResampler::RestartStreamsForWedgeFix() {
310 DCHECK(message_loop_->BelongsToCurrentThread());
311 for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
312 ++it) {
313 dispatcher_->OpenStream();
314 dispatcher_->StartStream(it->second, it->first);
315 }
316 }
317
294 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params, 318 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params,
295 const AudioParameters& output_params) 319 const AudioParameters& output_params)
296 : io_ratio_(static_cast<double>(input_params.GetBytesPerSecond()) / 320 : io_ratio_(static_cast<double>(input_params.GetBytesPerSecond()) /
297 output_params.GetBytesPerSecond()), 321 output_params.GetBytesPerSecond()),
298 source_callback_(NULL), 322 source_callback_(NULL),
299 input_bytes_per_second_(input_params.GetBytesPerSecond()), 323 input_bytes_per_second_(input_params.GetBytesPerSecond()),
300 audio_converter_(input_params, output_params, false) {} 324 audio_converter_(input_params, output_params, false) {}
301 325
302 OnMoreDataConverter::~OnMoreDataConverter() { 326 OnMoreDataConverter::~OnMoreDataConverter() {
303 // Ensure Stop() has been called so we don't end up with an AudioOutputStream 327 // Ensure Stop() has been called so we don't end up with an AudioOutputStream
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 if (frames > 0 && frames < dest->frames()) 385 if (frames > 0 && frames < dest->frames())
362 dest->ZeroFramesPartial(frames, dest->frames() - frames); 386 dest->ZeroFramesPartial(frames, dest->frames() - frames);
363 return frames > 0 ? 1 : 0; 387 return frames > 0 ? 1 : 0;
364 } 388 }
365 389
366 void OnMoreDataConverter::OnError(AudioOutputStream* stream) { 390 void OnMoreDataConverter::OnError(AudioOutputStream* stream) {
367 source_callback_->OnError(stream); 391 source_callback_->OnError(stream);
368 } 392 }
369 393
370 } // namespace media 394 } // 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