summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_output_controller.h
diff options
context:
space:
mode:
authormiu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 12:19:55 +0000
committermiu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 12:19:55 +0000
commitc72d327cc55656ba65c6411137821fadd1ea3f2b (patch)
treef70148c9e5c5b9a50b7a306e57c971177e593d12 /media/audio/audio_output_controller.h
parent96979827697cf7f6cab097b83787cbe1667e2e04 (diff)
downloadchromium_src-c72d327cc55656ba65c6411137821fadd1ea3f2b.zip
chromium_src-c72d327cc55656ba65c6411137821fadd1ea3f2b.tar.gz
chromium_src-c72d327cc55656ba65c6411137821fadd1ea3f2b.tar.bz2
Crash/stability fix for device change logic in AudioOutputController. The outstanding weak pointers need to be invalidated when streams are closed/re-created in order to auto-cancel the "polling starts."
Note: This is part one of a two-part patch. This encompasses changes which can only be applied to M24 and later. See http://codereview.chromium.org/11741010 for a more detailed description of the root cause and solution. BUG=167920 TEST=Ran media_unittests. TBR=dalecurtis@chromium.org Review URL: https://chromiumcodereview.appspot.com/11753008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_output_controller.h')
-rw-r--r--media/audio/audio_output_controller.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h
index 762a948..61718a3 100644
--- a/media/audio/audio_output_controller.h
+++ b/media/audio/audio_output_controller.h
@@ -196,10 +196,13 @@ class MEDIA_EXPORT AudioOutputController
// Signals event when done if it is not NULL.
void DoStopCloseAndClearStream(base::WaitableEvent *done);
- AudioManager* audio_manager_;
+ AudioManager* const audio_manager_;
// |handler_| may be called only if |state_| is not kClosed.
EventHandler* handler_;
+
+ // Note: It's important to invalidate the weak pointers whenever stream_ is
+ // changed. See comment for weak_this_.
AudioOutputStream* stream_;
// The current volume of the audio stream.
@@ -226,10 +229,8 @@ class MEDIA_EXPORT AudioOutputController
AudioParameters params_;
- // Used to post delayed tasks to ourselves that we can cancel.
- // We don't want the tasks to hold onto a reference as it will slow down
- // shutdown and force it to wait for the most delayed task.
- // Also, if we're shutting down, we do not want to poll for more data.
+ // Used to auto-cancel the delayed tasks that are created to poll for data
+ // (when starting-up a stream).
base::WeakPtrFactory<AudioOutputController> weak_this_;
DISALLOW_COPY_AND_ASSIGN(AudioOutputController);