Add exception handling for the failure of CUsbConnectionListener creation. 19/37719/1
authorKim Tae Soo <taesoo46.kim@samsung.com>
Fri, 3 Apr 2015 04:51:10 +0000 (13:51 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Fri, 3 Apr 2015 04:51:10 +0000 (13:51 +0900)
- Consideration in case of system without any USB port.
- Even if CUsbConnectionListener creation fails, app should start properly.

Change-Id: I2cf42ece38646a9440710e71c73ea49138e6c863
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
src/playback/music-controller.cpp

index 194f835..aff012e 100644 (file)
@@ -217,7 +217,6 @@ SMusicController *CMusicController::t_Create(void)
                        _CHECK(mhandle->pPlayback->Create() == true)
                        _CHECK(mhandle->pPlayback->SetCallback(sm_CbPlaybackCompletion, this) == true)
                        _CHECK(mhandle->pPlaylist = new CPlaylist)
-                       _CHECK(CUsbConnectionListener::Create() == true)
 
                        _WHEN_SUCCESS{
                                mhandle->statePlay = PLAY_STATUS_INITIAL;
@@ -227,9 +226,13 @@ SMusicController *CMusicController::t_Create(void)
                                CInfo::SetSortType(E_SORT_TITLE_A_Z);
                                CInfo::SetSourceType(SOURCE_TYPE_ALL);
                                mhandle->cbinfo = mhandle->pMediadata->AddCallback(E_CONTENT_UPDATE, sm_CbContentUpdated, this);
+
+                               // Even if CUsbConnectionListener creation failed,
+                               // application should run properly.
+                               if (!CUsbConnectionListener::Create())
+                                       _DBG("CUsbConnectionListener::Create failed");
                        }
 
-                       _CHECK_FAIL{ CUsbConnectionListener::Destroy(); }
                        _CHECK_FAIL{ delete mhandle->pPlaylist; }
                        _CHECK_FAIL{}
                        _CHECK_FAIL{ mhandle->pPlayback->Destroy(); }
@@ -249,7 +252,8 @@ SMusicController *CMusicController::t_Create(void)
 
 void CMusicController::t_Destroy(void)
 {
-       CUsbConnectionListener::Destroy();
+       if (CUsbConnectionListener::FlagCreate())
+               CUsbConnectionListener::Destroy();
 
        if (!m->pPlayback->UnsetCallback())
                _ERR(" playback remove completion callback failed");