Bug 830648 - AudioChannelAgent::StartPlaying() should check if already registered to AudioChannelService., r=mchen
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 15 Jan 2013 15:31:19 +0100
changeset 118885 dda39cd3fd5ae6bcb6b26a7947de5342a045b372
parent 118884 3a99974fac17b0bdba6b0ff6fc6e95bd1fddd001
child 118886 28a2d814fda4699a158324db3fa901e4e62abe0a
push id21336
push useramarchesini@mozilla.com
push dateTue, 15 Jan 2013 14:31:53 +0000
treeherdermozilla-inbound@dda39cd3fd5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchen
bugs830648
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 830648 - AudioChannelAgent::StartPlaying() should check if already registered to AudioChannelService., r=mchen
dom/audiochannel/AudioChannelAgent.cpp
--- a/dom/audiochannel/AudioChannelAgent.cpp
+++ b/dom/audiochannel/AudioChannelAgent.cpp
@@ -15,16 +15,19 @@ AudioChannelAgent::AudioChannelAgent()
   , mAudioChannelType(AUDIO_AGENT_CHANNEL_ERROR)
   , mIsRegToService(false)
   , mVisible(true)
 {
 }
 
 AudioChannelAgent::~AudioChannelAgent()
 {
+  if (mIsRegToService) {
+    StopPlaying();
+  }
 }
 
 /* readonly attribute long audioChannelType; */
 NS_IMETHODIMP AudioChannelAgent::GetAudioChannelType(int32_t *aAudioChannelType)
 {
   *aAudioChannelType = mAudioChannelType;
   return NS_OK;
 }
@@ -61,32 +64,32 @@ NS_IMETHODIMP AudioChannelAgent::Init(in
   return NS_OK;
 }
 
 /* boolean startPlaying (); */
 NS_IMETHODIMP AudioChannelAgent::StartPlaying(bool *_retval)
 {
   AudioChannelService *service = AudioChannelService::GetAudioChannelService();
   if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR ||
-      service == nullptr) {
+      service == nullptr || mIsRegToService) {
     return NS_ERROR_FAILURE;
   }
 
   service->RegisterAudioChannelAgent(this,
     static_cast<AudioChannelType>(mAudioChannelType));
   *_retval = !service->GetMuted(this, !mVisible);
   mIsRegToService = true;
   return NS_OK;
 }
 
 /* void stopPlaying (); */
 NS_IMETHODIMP AudioChannelAgent::StopPlaying(void)
 {
   if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR ||
-      mIsRegToService == false) {
+      !mIsRegToService) {
     return NS_ERROR_FAILURE;
   }
 
   AudioChannelService *service = AudioChannelService::GetAudioChannelService();
   service->UnregisterAudioChannelAgent(this);
   mIsRegToService = false;
   return NS_OK;
 }