summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-18 18:57:14 +0000
committerenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-18 18:57:14 +0000
commitd88a7a0805c7cfcbcd05f4876e4314cdb8f9ef97 (patch)
tree15b26eb9b462fb90fb7c717a988640d11cd75b04 /media
parent02b615ccf745d3900cca97106e7f038fa06c8197 (diff)
downloadchromium_src-d88a7a0805c7cfcbcd05f4876e4314cdb8f9ef97.zip
chromium_src-d88a7a0805c7cfcbcd05f4876e4314cdb8f9ef97.tar.gz
chromium_src-d88a7a0805c7cfcbcd05f4876e4314cdb8f9ef97.tar.bz2
Replace delay loop by sleep() call.
As a workaround for crbug.com/128128 we added delay. It is better to explicitly call sleep() than to loop. BUG=128128 TEST=No observable change in behavior, code somewhat cleaner and uses less resources. Review URL: https://chromiumcodereview.appspot.com/10399049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/audio_output_controller.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc
index 13966d1..70f7a1c 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -209,6 +209,7 @@ void AudioOutputController::PollAndStartIfDataReady() {
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 @@ void AudioOutputController::StartStream() {
// 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