summaryrefslogtreecommitdiffstats
path: root/media/audio/fake_audio_input_stream.cc
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 14:07:39 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 14:07:39 +0000
commitd6a5d747415a472f8755af23de94cd42fb20799a (patch)
treec069dd45c4bac1858abb5fc716cab13a808058e2 /media/audio/fake_audio_input_stream.cc
parent49ee2828a9fb5c9502768c2ba932aef9ed00a604 (diff)
downloadchromium_src-d6a5d747415a472f8755af23de94cd42fb20799a.zip
chromium_src-d6a5d747415a472f8755af23de94cd42fb20799a.tar.gz
chromium_src-d6a5d747415a472f8755af23de94cd42fb20799a.tar.bz2
Stopping the audio thread before destroying the AudioManager<Platform>.
The destruction of the AudioManager family happens in order of: AudioManager<Platform>, AudioManagerBase, AudioManager. So before getting into the destruction of AudioManagerBase, we have make sure the audio thread has been stopped before AudioManager<Platform> is gone, otherwise it will end up into unexpected behavior, for example, crash because of pure virtual function. BUG=117470 TEST=media_unittests, Address Sanitizer Review URL: http://codereview.chromium.org/9692038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/fake_audio_input_stream.cc')
-rw-r--r--media/audio/fake_audio_input_stream.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/media/audio/fake_audio_input_stream.cc b/media/audio/fake_audio_input_stream.cc
index b9b271b..f1284f1 100644
--- a/media/audio/fake_audio_input_stream.cc
+++ b/media/audio/fake_audio_input_stream.cc
@@ -5,26 +5,26 @@
#include "media/audio/fake_audio_input_stream.h"
#include "base/bind.h"
+#include "media/audio/audio_manager_base.h"
using base::Time;
using base::TimeDelta;
AudioInputStream* FakeAudioInputStream::MakeFakeStream(
+ AudioManagerBase* manager,
const AudioParameters& params) {
- return new FakeAudioInputStream(params);
+ return new FakeAudioInputStream(manager, params);
}
-FakeAudioInputStream::FakeAudioInputStream(const AudioParameters& params)
- : callback_(NULL),
+FakeAudioInputStream::FakeAudioInputStream(AudioManagerBase* manager,
+ const AudioParameters& params)
+ : audio_manager_(manager),
+ callback_(NULL),
buffer_size_((params.channels * params.bits_per_sample *
params.samples_per_packet) / 8),
thread_("FakeAudioRecordingThread"),
callback_interval_(base::TimeDelta::FromMilliseconds(
(params.samples_per_packet * 1000) / params.sample_rate)) {
- // This object is ref counted (so that it can be used with Thread, PostTask)
- // but the caller expects a plain pointer. So we take a reference here and
- // will Release() ourselves in Close().
- AddRef();
}
FakeAudioInputStream::~FakeAudioInputStream() {}
@@ -42,7 +42,7 @@ void FakeAudioInputStream::Start(AudioInputCallback* callback) {
thread_.Start();
thread_.message_loop()->PostDelayedTask(
FROM_HERE,
- base::Bind(&FakeAudioInputStream::DoCallback, this),
+ base::Bind(&FakeAudioInputStream::DoCallback, base::Unretained(this)),
callback_interval_);
}
@@ -62,7 +62,7 @@ void FakeAudioInputStream::DoCallback() {
last_callback_time_ = now;
thread_.message_loop()->PostDelayedTask(
FROM_HERE,
- base::Bind(&FakeAudioInputStream::DoCallback, this),
+ base::Bind(&FakeAudioInputStream::DoCallback, base::Unretained(this)),
next_callback_time);
}
@@ -75,7 +75,7 @@ void FakeAudioInputStream::Close() {
callback_->OnClose(this);
callback_ = NULL;
}
- Release(); // Destoys this object.
+ audio_manager_->ReleaseInputStream(this);
}
double FakeAudioInputStream::GetMaxVolume() {