Commit d88a7a08 authored by enal@chromium.org's avatar enal@chromium.org

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
parent 02b615cc
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment