summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_output_resampler.cc
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-07 19:09:24 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-07 19:09:24 +0000
commit49cdfd863b19e9a6c6fc524b76c5a11422d2ae9f (patch)
treec6c01bbeaf203df2aa3fb1d596e882d62d81d88a /media/audio/audio_output_resampler.cc
parent9fe89eaf1fbb8b1383c7f94817de2604032b2843 (diff)
downloadchromium_src-49cdfd863b19e9a6c6fc524b76c5a11422d2ae9f.zip
chromium_src-49cdfd863b19e9a6c6fc524b76c5a11422d2ae9f.tar.gz
chromium_src-49cdfd863b19e9a6c6fc524b76c5a11422d2ae9f.tar.bz2
Fix double StopStream() calls during wedge fix.
Whoops. The wedge fix ignored start / stop status when stopping streams which leads to heap corruption when the underlying dispatcher tries to stop a stream it can't find in the audio stream map. BUG=326656 TEST=new unittest NOTRY=true Review URL: https://codereview.chromium.org/109113002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239342 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_output_resampler.cc')
-rw-r--r--media/audio/audio_output_resampler.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc
index 3179ddb..c53f3e0 100644
--- a/media/audio/audio_output_resampler.cc
+++ b/media/audio/audio_output_resampler.cc
@@ -43,6 +43,8 @@ class OnMoreDataConverter
// Clears |source_callback_| and flushes the resampler.
void Stop();
+ bool started() { return source_callback_ != NULL; }
+
private:
// AudioConverter::InputCallback implementation.
virtual double ProvideInput(AudioBus* audio_bus,
@@ -298,7 +300,8 @@ void AudioOutputResampler::CloseStreamsForWedgeFix() {
// have been closed the AudioManager will call RestartStreamsForWedgeFix().
for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
++it) {
- dispatcher_->StopStream(it->first);
+ if (it->second->started())
+ dispatcher_->StopStream(it->first);
dispatcher_->CloseStream(it->first);
}
@@ -308,10 +311,16 @@ void AudioOutputResampler::CloseStreamsForWedgeFix() {
void AudioOutputResampler::RestartStreamsForWedgeFix() {
DCHECK(message_loop_->BelongsToCurrentThread());
+ // By opening all streams first and then starting them one by one we ensure
+ // the dispatcher only opens streams for those which will actually be used.
for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
++it) {
dispatcher_->OpenStream();
- dispatcher_->StartStream(it->second, it->first);
+ }
+ for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
+ ++it) {
+ if (it->second->started())
+ dispatcher_->StartStream(it->second, it->first);
}
}