Add the code for checking state in SetAudioStreamType()
authorEonseokLee <eonseok.lee@samsung.com>
Thu, 21 Mar 2013 05:59:43 +0000 (14:59 +0900)
committerEonseokLee <eonseok.lee@samsung.com>
Thu, 21 Mar 2013 06:14:14 +0000 (15:14 +0900)
Change-Id: Id258f01341fa243560b73f620ee912937e8c42c7
Signed-off-by: EonseokLee <eonseok.lee@samsung.com>
inc/FMediaPlayer.h
src/FMedia_PlayerImpl.cpp

index fa5bdfa..3de6b23 100755 (executable)
@@ -722,6 +722,8 @@ public:
        * @param[in]    type                                            An audio stream type
        * @exception    E_SUCCESS                                       The method is successful.
        * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_INVALID_STATE                                 This instance is in an invalid state for this method.
+       * @remarks      This method works only for the @c PLAYER_STATE_INITIALIZED state of the %Player instance.
        */
        result SetAudioStreamType(AudioStreamType type);
 
index 63c3356..b64c590 100644 (file)
@@ -446,7 +446,6 @@ _PlayerImpl::OpenFile(const Tizen::Base::String& mediaLocalPath, bool isAsync)
        int err = ::PLAYER_ERROR_NONE;
        Tizen::Base::String strFileName;
        std::unique_ptr<char[]> pInputFilePath;
-
        SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
 
        err = player_get_state(__hPlayer, &__corePlayerCurState);
@@ -462,7 +461,6 @@ _PlayerImpl::OpenFile(const Tizen::Base::String& mediaLocalPath, bool isAsync)
                                "[E_FILE_NOT_FOUND] mediaLocalPath's length is (%d).", mediaLocalPath.GetLength());
 
        pInputFilePath.reset(_StringConverter::CopyToCharArrayN(mediaLocalPath));
-
        SysTryCatch(NID_MEDIA, pInputFilePath.get() , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. pInputFilePath is null");
        SysLog(NID_MEDIA, "Input file path after conversion is [%s]", pInputFilePath.get());
 
@@ -569,7 +567,6 @@ _PlayerImpl::OpenInputData(std::unique_ptr<char[]> pStrInputFilePath)
 {
        result r = E_SUCCESS;
        int err = ::PLAYER_ERROR_NONE;
-
        SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
 
        if (__isOpenBuffer)
@@ -647,7 +644,6 @@ _PlayerImpl::OpenInputData(std::unique_ptr<char[]> pStrInputFilePath)
                r = MapExceptionToResult(err);
                SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] error has been occured. Failed to perform player_prepare_async operation with 0x%x", GetErrorMessage(r), err);
        }
-
        if (__isStreamingContent)
        {
                err = player_set_buffering_cb(__hPlayer, PlayerBufferingCallBack, (void*)this);
@@ -2182,6 +2178,11 @@ _PlayerImpl::SetAudioStreamType(AudioStreamType type)
 
        SysAssertf(__hPlayer !=  null, "Not yet constructed! Construct() should be called before use");
 
+       ret = player_get_state(__hPlayer, &__corePlayerCurState);
+       r = MapExceptionToResult(ret);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_get_state operation with 0x%x ", GetErrorMessage(r), ret);
+       SysTryCatch(NID_MEDIA, __corePlayerCurState == ::PLAYER_STATE_IDLE, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Player state is in an invalid state. Current core state is %d", __corePlayerCurState);
+
        ret = player_set_sound_type(__hPlayer, _AudioManagerConvert::ConvertAudioStreamType2SoundType(type));
        r = MapExceptionToResult(ret);
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform player_set_sound_type operation with 0x%x", GetErrorMessage(r), ret);