[0.2.41] make _get_play_position return pos in idle state 04/114604/1 accepted/tizen/3.0/common/20170215.121304 accepted/tizen/3.0/ivi/20170215.034234 accepted/tizen/3.0/mobile/20170215.033722 accepted/tizen/3.0/tv/20170215.033949 accepted/tizen/3.0/wearable/20170215.034109 submit/tizen_3.0/20170214.112531
authorEunhae Choi <eunhae1.choi@samsung.com>
Wed, 8 Feb 2017 10:27:03 +0000 (19:27 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 14 Feb 2017 07:20:50 +0000 (16:20 +0900)
If position msg was received, it will return as a pos value in idle state.
- the position msg will be sent in case of resource conflict

Change-Id: Id03b1157c1863bc3654f5c7d7e82ba07b573854b

legacy/include/legacy_player_private.h
legacy/src/legacy_player.c
packaging/mmsvc-player.spec

index cefba6307f28a2f5fa57496783da47205c1a77a0..4f2e40c3b252c4059243ab4fa4acd9b5b9108d68 100644 (file)
@@ -114,6 +114,7 @@ typedef struct _player_s {
 #endif
        player_error_e error_code;
        media_format_h pkt_fmt;
+       int last_play_position;
 } player_s;
 
 int __player_convert_error_code(int code, char* func_name);
index 4130252f5a4b642d3c3ac81d7e7a40d30972d7b8..98cc5f8df8b5dfd79c80704fa9bb59708b5797da 100644 (file)
@@ -763,6 +763,10 @@ static int __msg_callback(int message, void *param, void *user_data)
 #endif
                }
                break;
+       case MM_MESSAGE_PLAY_POSITION:
+               LOGI("MM_MESSAGE_PLAY_POSITION (%d ms)", msg->time.elapsed);
+               handle->last_play_position = (int)msg->time.elapsed;
+               break;
        case MM_MESSAGE_UNKNOWN:        /* 0x00 */
        case MM_MESSAGE_WARNING:        /* 0x02 */
        case MM_MESSAGE_CONNECTING:     /* 0x100 */
@@ -1250,16 +1254,17 @@ static void *__prepare_async_thread_func(void *data)
 
 int legacy_player_prepare_async(player_h player, player_prepared_cb callback, void *user_data)
 {
+       int ret = MM_ERROR_NONE;
+       int visible = 0;
+       int value = 0;
+
        LOGI("[%s] Start", __FUNCTION__);
        PLAYER_INSTANCE_CHECK(player);
        player_s *handle = (player_s *)player;
        PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
        PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
-       int ret;
-       int visible;
-       int value;
-
+       handle->last_play_position = 0;
        if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
                LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing... we can't do any more ", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION);
                return PLAYER_ERROR_INVALID_OPERATION;
@@ -1313,15 +1318,17 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo
 
 int legacy_player_prepare(player_h player)
 {
+       int ret = MM_ERROR_NONE;
+       int visible = 0;
+       int value = 0;
+
        LOGI("[%s] Start", __FUNCTION__);
        PLAYER_TRACE_BEGIN("MM:PLAYER:PREPARE");
        PLAYER_INSTANCE_CHECK(player);
        player_s *handle = (player_s *)player;
        PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
-       int ret;
-       int visible;
-       int value;
+       handle->last_play_position = 0;
        ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
        if (ret != MM_ERROR_NONE)
                LOGW("[%s] Failed to set message callback function (0x%x)", __FUNCTION__, ret);
@@ -1735,14 +1742,27 @@ int legacy_player_set_play_position(player_h player, int millisecond, bool accur
 
 int legacy_player_get_play_position(player_h player, int *millisecond)
 {
+       unsigned long pos = 0;
+
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(millisecond);
        player_s *handle = (player_s *)player;
-       if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
+       if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
                LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
                return PLAYER_ERROR_INVALID_STATE;
        }
-       unsigned long pos;
+
+       /* During playbak if a interrupt is occurred, the player can be destroyed internally.
+          libmm-player will post position msg with last playback position before destory pipeline */
+       if (handle->state == PLAYER_STATE_IDLE) {
+               if (handle->last_play_position > 0)
+                       *millisecond = handle->last_play_position;
+               else
+                       *millisecond = 0;
+               LOGD("position %d", *millisecond);
+               return PLAYER_ERROR_NONE;
+       }
+
        int ret = mm_player_get_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, &pos);
        if (ret != MM_ERROR_NONE) {
                return __player_convert_error_code(ret, (char *)__FUNCTION__);
index 6504fdeb4d78fbc27bca1491617160b324e9e4fb..2a407f87bae4c25340e7826a261970e402dc4ad2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.40
+Version:    0.2.41
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0