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

Unified Diff: media/audio/audio_output_controller.cc

Issue 10399049: Replace delay loop by sleep() call. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_controller.cc
===================================================================
--- media/audio/audio_output_controller.cc (revision 137419)
+++ media/audio/audio_output_controller.cc (working copy)
@@ -209,6 +209,7 @@
void AudioOutputController::StartStream() {
DCHECK(message_loop_->BelongsToCurrentThread());
+
#if defined(OS_MACOSX)
// HACK: workaround for crbug.com/128128.
// Mac OS crashes if we start playback too soon after previous ended.
@@ -216,9 +217,13 @@
// some time after logical one is closed, so sequence of play / pause / play /
// pause / ... would reuse the same stream, but we need fix for M20.
// TODO(enal): Remove after turning on mixer by default.
- while ((Time::Now() - previous_stop_time_).InMilliseconds() <
- kMacWorkaroundInMilliseconds) {
- base::PlatformThread::YieldCurrentThread();
+ int milliseconds_since_stop =
+ (Time::Now() - previous_stop_time_).InMilliseconds();
+ if ((milliseconds_since_stop >= 0) &&
+ (milliseconds_since_stop < kMacWorkaroundInMilliseconds)) {
+ base::PlatformThread::Sleep(
+ TimeDelta::FromMilliseconds(kMacWorkaroundInMilliseconds -
+ milliseconds_since_stop));
}
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698