Added error checks in soundmanger
authorAmith Kumar Mahale <amith.m@samsung.com>
Wed, 8 May 2013 12:06:10 +0000 (17:36 +0530)
committerAmith Kumar Mahale <amith.m@samsung.com>
Wed, 8 May 2013 12:06:10 +0000 (17:36 +0530)
Change-Id: I31c046e4ed311f296d93dcf22a131128033e6644
Signed-off-by: Amith Kumar Mahale <amith.m@samsung.com>
src/CallSoundManager.cpp

index e3ca156..44f9603 100644 (file)
@@ -242,24 +242,32 @@ SoundManager::OnTimerExpired(Timer& timer)
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pReminderPlayer Construct failed with %d",res);
+                                       delete __pReminderPlayer;
+                                       __pReminderPlayer = null;
                                        return;
                                }
                                res = __pReminderPlayer->OpenFile(reminderTonePath,false);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pReminderPlayer OpenFile failed with %d",res);
+                                       delete __pReminderPlayer;
+                                       __pReminderPlayer = null;
                                        return;
                                }
                                res = __pReminderPlayer->SetLooping(false);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pReminderPlayer SetLooping failed with %d",res);
+                                       delete __pReminderPlayer;
+                                       __pReminderPlayer = null;
                                        return;
                                }
                                res = __pReminderPlayer->SetVolume(80);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pReminderPlayer SetVolume failed with %d",res);
+                                       delete __pReminderPlayer;
+                                       __pReminderPlayer = null;
                                        return;
                                }
                        }
@@ -311,24 +319,32 @@ SoundManager::SetDisconnectTone(void)
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pDisconnectPlayer Construct failed with %d",res);
+                                       delete __pDisconnectPlayer;
+                                       __pDisconnectPlayer = null;
                                        return;
                                }
                                res = __pDisconnectPlayer->OpenFile(disconnectTonePath,false);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pDisconnectPlayer OpenFile failed with %d",res);
+                                       delete __pDisconnectPlayer;
+                                       __pDisconnectPlayer = null;
                                        return;
                                }
                                res = __pDisconnectPlayer->SetLooping(false);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pDisconnectPlayer SetLooping failed with %d",res);
+                                       delete __pDisconnectPlayer;
+                                       __pDisconnectPlayer = null;
                                        return;
                                }
                                res = __pDisconnectPlayer->SetVolume(80);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pDisconnectPlayer SetLooping SetVolume with %d",res);
+                                       delete __pDisconnectPlayer;
+                                       __pDisconnectPlayer = null;
                                        return;
                                }
 
@@ -392,24 +408,32 @@ SoundManager::SetConnectTone(void)
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pConnectPlayer Construct failed with %d",res);
+                                       delete __pConnectPlayer;
+                                       __pConnectPlayer = null;
                                        return;
                                }
                                res = __pConnectPlayer->OpenFile(connectTonePath,false);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pConnectPlayer OpenFile failed with %d",res);
+                                       delete __pConnectPlayer;
+                                       __pConnectPlayer = null;
                                        return;
                                }
                                res = __pConnectPlayer->SetLooping(false);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pConnectPlayer SetLooping failed with %d",res);
+                                       delete __pConnectPlayer;
+                                       __pConnectPlayer = null;
                                        return;
                                }
                                res = __pConnectPlayer->SetVolume(80);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pConnectPlayer SetVolume failed with %d",res);
+                                       delete __pConnectPlayer;
+                                       __pConnectPlayer = null;
                                        return;
                                }
                        }
@@ -458,24 +482,35 @@ SoundManager::SetWaitTone(void)
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pWaitingTonePlayer Construct failed with %d",res);
+                                       delete __pWaitingTonePlayer;
+                                       __pWaitingTonePlayer = null;
                                        return;
                                }
                                res = __pWaitingTonePlayer->OpenFile(waitingTonePath,false);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pWaitingTonePlayer OpenFile failed with %d",res);
+                                       delete __pWaitingTonePlayer;
+                                       __pWaitingTonePlayer = null;
+
                                        return;
                                }
                                res = __pWaitingTonePlayer->SetLooping(true);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pWaitingTonePlayer SetLooping failed with %d",res);
+                                       delete __pWaitingTonePlayer;
+                                       __pWaitingTonePlayer = null;
+
                                        return;
                                }
                                res = __pWaitingTonePlayer->SetVolume(80);
                                if(res != E_SUCCESS)
                                {
                                        AppLogDebug("__pWaitingTonePlayer SetVolume failed with %d",res);
+                                       delete __pWaitingTonePlayer;
+                                       __pWaitingTonePlayer = null;
+
                                        return;
                                }
                        }
@@ -526,6 +561,8 @@ SoundManager::StartAlert(String& contactRingTone)
                if(res != E_SUCCESS)
                {
                        AppLogDebug("__pPlayer Construct failed with %d",res);
+                       delete __pPlayer;
+                       __pPlayer = null;
                        return;
                }
        }
@@ -603,25 +640,28 @@ SoundManager::StopAlert(void)
        if (__isSoundStatusOn == true)
        {
                //todo: stop player
-               AppLogDebug("Stopping ring tone");
-               if(__pPlayer->GetState() == PLAYER_STATE_PLAYING)
-               {
-                       res = __pPlayer->Stop();
-               }
-               if(res != E_SUCCESS)
+               if(__pPlayer != null)
                {
-                       AppLogDebug("__pPlayer Stop failed with %d",res);
-                       return;
-               }
-               res = __pPlayer->Close();
-               if(res != E_SUCCESS)
-               {
-                       AppLogDebug("__pPlayer Close failed with %d",res);
-                       return;
+                       AppLogDebug("Stopping ring tone");
+                       if(__pPlayer->GetState() == PLAYER_STATE_PLAYING)
+                       {
+                               res = __pPlayer->Stop();
+                       }
+                       if(res != E_SUCCESS)
+                       {
+                               AppLogDebug("__pPlayer Stop failed with %d",res);
+                               return;
+                       }
+                       res = __pPlayer->Close();
+                       if(res != E_SUCCESS)
+                       {
+                               AppLogDebug("__pPlayer Close failed with %d",res);
+                               return;
+                       }
+                       SetSoundMode(SOUND_MODE_VOICE);
+                       __isSoundStatusOn = false;
+                       StopSession();
                }
-               SetSoundMode(SOUND_MODE_VOICE);
-               __isSoundStatusOn = false;
-               StopSession();
        }
        if (__isVibrateStatusOn == true)
        {