Bug 997208 - Remove unnecessary nullptr checks before deleting in content/media. r=cajbir
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 17 Apr 2014 09:23:16 -0400
changeset 179455 76e1244494ef4b1456c16decd668521af9583c6b
parent 179454 5aa4eed6cd167ce121adf9796ac8a44240328076
child 179456 21043f348d6520c995d1d8a8d05468ac41cb13f1
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerscajbir
bugs997208
milestone31.0a1
Bug 997208 - Remove unnecessary nullptr checks before deleting in content/media. r=cajbir
content/media/gstreamer/GStreamerFormatHelper.cpp
content/media/omx/AudioOutput.cpp
content/media/plugins/MediaPluginHost.cpp
content/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/content/media/gstreamer/GStreamerFormatHelper.cpp
+++ b/content/media/gstreamer/GStreamerFormatHelper.cpp
@@ -25,20 +25,18 @@ GStreamerFormatHelper* GStreamerFormatHe
 
     gInstance = new GStreamerFormatHelper();
   }
 
   return gInstance;
 }
 
 void GStreamerFormatHelper::Shutdown() {
-  if (gInstance) {
-    delete gInstance;
-    gInstance = nullptr;
-  }
+  delete gInstance;
+  gInstance = nullptr;
 }
 
 static char const *const sContainers[6][2] = {
   {"video/mp4", "video/quicktime"},
   {"video/quicktime", "video/quicktime"},
   {"audio/mp4", "audio/x-m4a"},
   {"audio/x-m4a", "audio/x-m4a"},
   {"audio/mpeg", "audio/mpeg, mpegversion=(int)1"},
--- a/content/media/omx/AudioOutput.cpp
+++ b/content/media/omx/AudioOutput.cpp
@@ -175,20 +175,18 @@ void AudioOutput::Pause()
   }
 }
 
 void AudioOutput::Close()
 {
   AUDIO_OFFLOAD_LOG(PR_LOG_DEBUG, ("%s", __PRETTY_FUNCTION__));
   mTrack.clear();
 
-  if (mCallbackData) {
-    delete mCallbackData;
-    mCallbackData = NULL;
-  }
+  delete mCallbackData;
+  mCallbackData = nullptr;
 }
 
 // static
 void AudioOutput::CallbackWrapper(int aEvent, void* aCookie, void* aInfo)
 {
   CallbackData* data = (CallbackData*) aCookie;
   data->Lock();
   AudioOutput* me = data->GetOutput();
--- a/content/media/plugins/MediaPluginHost.cpp
+++ b/content/media/plugins/MediaPluginHost.cpp
@@ -318,15 +318,13 @@ MediaPluginHost *GetMediaPluginHost()
   if (!sMediaPluginHost) {
     sMediaPluginHost = new MediaPluginHost();
   }
   return sMediaPluginHost;
 }
 
 void MediaPluginHost::Shutdown()
 {
-  if (sMediaPluginHost) {
-    delete sMediaPluginHost;
-    sMediaPluginHost = nullptr;
-  }
+  delete sMediaPluginHost;
+  sMediaPluginHost = nullptr;
 }
 
 } // namespace mozilla
--- a/content/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -463,20 +463,17 @@ void
 MediaEngineWebRTCAudioSource::Shutdown()
 {
   if (!mInitDone) {
     // duplicate these here in case we failed during Init()
     if (mChannel != -1) {
       mVoENetwork->DeRegisterExternalTransport(mChannel);
     }
 
-    if (mNullTransport) {
-      delete mNullTransport;
-    }
-
+    delete mNullTransport;
     return;
   }
 
   if (mState == kStarted) {
     while (!mSources.IsEmpty()) {
       Stop(mSources[0], kAudioTrack); // XXX change to support multiple tracks
     }
     MOZ_ASSERT(mState == kStopped);
@@ -486,19 +483,17 @@ MediaEngineWebRTCAudioSource::Shutdown()
     Deallocate();
   }
 
   mVoEBase->Terminate();
   if (mChannel != -1) {
     mVoENetwork->DeRegisterExternalTransport(mChannel);
   }
 
-  if (mNullTransport) {
-    delete mNullTransport;
-  }
+  delete mNullTransport;
 
   mVoEProcessing = nullptr;
   mVoENetwork = nullptr;
   mVoERender = nullptr;
   mVoEBase = nullptr;
 
   mState = kReleased;
   mInitDone = false;