summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-12 19:00:19 +0000
committerenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-12 19:00:19 +0000
commitb5abfe5af5c24db11dc9108cb245ff52f3457214 (patch)
treecfdf11e60648a9df2b3ed9c38b07a53324a5c057 /content
parent2078b10421bfcf407d56366e965042dc79f18e80 (diff)
downloadchromium_src-b5abfe5af5c24db11dc9108cb245ff52f3457214.zip
chromium_src-b5abfe5af5c24db11dc9108cb245ff52f3457214.tar.gz
chromium_src-b5abfe5af5c24db11dc9108cb245ff52f3457214.tar.bz2
Safe and reliable fix for 2 race conditions.
(We may want to revisit the issue later, implementing more performant one...) BUG=107933 TEST=Everything should work, and there would be no more crashes in AudioDevice. Review URL: http://codereview.chromium.org/9112029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117464 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/renderer/media/audio_device.cc9
-rw-r--r--content/renderer/media/audio_device.h6
2 files changed, 6 insertions, 9 deletions
diff --git a/content/renderer/media/audio_device.cc b/content/renderer/media/audio_device.cc
index 75c2bad..b252d85 100644
--- a/content/renderer/media/audio_device.cc
+++ b/content/renderer/media/audio_device.cc
@@ -106,11 +106,6 @@ void AudioDevice::Start() {
void AudioDevice::Stop() {
DCHECK(MessageLoop::current() != ChildProcess::current()->io_message_loop());
- // Max waiting time for Stop() to complete. If this time limit is passed,
- // we will stop waiting and return false. It ensures that Stop() can't block
- // the calling thread forever.
- const base::TimeDelta kMaxTimeOut = base::TimeDelta::FromMilliseconds(1000);
-
base::WaitableEvent completion(false, false);
ChildProcess::current()->io_message_loop()->PostTask(
@@ -120,9 +115,7 @@ void AudioDevice::Stop() {
// We wait here for the IO task to be completed to remove race conflicts
// with OnLowLatencyCreated() and to ensure that Stop() acts as a synchronous
// function call.
- if (!completion.TimedWait(kMaxTimeOut)) {
- LOG(ERROR) << "Failed to shut down audio output on IO thread";
- }
+ completion.Wait();
ShutDownAudioThread();
}
diff --git a/content/renderer/media/audio_device.h b/content/renderer/media/audio_device.h
index 559060b..73470b5 100644
--- a/content/renderer/media/audio_device.h
+++ b/content/renderer/media/audio_device.h
@@ -89,7 +89,6 @@ class CONTENT_EXPORT AudioDevice
int channels,
double sample_rate,
RenderCallback* callback);
- virtual ~AudioDevice();
// AudioRendererSink implementation.
@@ -166,6 +165,11 @@ class CONTENT_EXPORT AudioDevice
base::SyncSocket socket_;
};
+ // Magic required by ref_counted.h to avoid any code deleting the object
+ // accidently while there are references to it.
+ friend class base::RefCountedThreadSafe<AudioDevice>;
+ virtual ~AudioDevice();
+
// Methods called on IO thread ----------------------------------------------
// The following methods are tasks posted on the IO thread that needs to
// be executed on that thread. They interact with AudioMessageFilter and