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

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

Issue 11348166: Always wait for DataReady() on Windows WaveOut. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only wait on WaveOut. Created 8 years, 1 month 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
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_controller.h" 5 #include "media/audio/audio_output_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 312 }
313 } 313 }
314 314
315 int frames = sync_reader_->Read(source, dest); 315 int frames = sync_reader_->Read(source, dest);
316 sync_reader_->UpdatePendingBytes( 316 sync_reader_->UpdatePendingBytes(
317 buffers_state.total_bytes() + frames * params_.GetBytesPerFrame()); 317 buffers_state.total_bytes() + frames * params_.GetBytesPerFrame());
318 return frames; 318 return frames;
319 } 319 }
320 320
321 void AudioOutputController::WaitTillDataReady() { 321 void AudioOutputController::WaitTillDataReady() {
322 if (!sync_reader_->DataReady()) { 322 while (!sync_reader_->DataReady())
scherkus (not reviewing) 2012/11/21 21:37:57 how about backing up your comments w/ something li
DaleCurtis 2012/11/21 22:42:10 We'll need OS_MAC in there too for now since the h
323 // In the different place we use different mechanism to poll, get max 323 base::PlatformThread::YieldCurrentThread();
Chris Rogers 2012/11/21 19:33:37 We should probably check that this while is not sp
scherkus (not reviewing) 2012/11/21 21:37:57 perhaps a CHECK()-timeout and monitor for any repo
DaleCurtis 2012/11/21 22:42:10 CHECK() worries me, I've added a 1.5 second timeou
324 // polling delay from constants used there.
325 const base::TimeDelta kMaxPollingDelay = TimeDelta::FromMilliseconds(
326 kPollNumAttempts * kPollPauseInMilliseconds);
327 Time start_time = Time::Now();
328 do {
329 base::PlatformThread::Sleep(TimeDelta::FromMilliseconds(1));
330 } while (!sync_reader_->DataReady() &&
331 Time::Now() - start_time < kMaxPollingDelay);
332 }
333 } 324 }
334 325
335 void AudioOutputController::OnError(AudioOutputStream* stream, int code) { 326 void AudioOutputController::OnError(AudioOutputStream* stream, int code) {
336 // Handle error on the audio controller thread. 327 // Handle error on the audio controller thread.
337 message_loop_->PostTask(FROM_HERE, base::Bind( 328 message_loop_->PostTask(FROM_HERE, base::Bind(
338 &AudioOutputController::DoReportError, this, code)); 329 &AudioOutputController::DoReportError, this, code));
339 } 330 }
340 331
341 void AudioOutputController::DoStopCloseAndClearStream(WaitableEvent* done) { 332 void AudioOutputController::DoStopCloseAndClearStream(WaitableEvent* done) {
342 DCHECK(message_loop_->BelongsToCurrentThread()); 333 DCHECK(message_loop_->BelongsToCurrentThread());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 case kPausedWhenStarting: 377 case kPausedWhenStarting:
387 case kPaused: 378 case kPaused:
388 // From the outside these three states are equivalent. 379 // From the outside these three states are equivalent.
389 return; 380 return;
390 default: 381 default:
391 NOTREACHED() << "Invalid original state."; 382 NOTREACHED() << "Invalid original state.";
392 } 383 }
393 } 384 }
394 385
395 } // namespace media 386 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698