[0.6.41] use state type for interrupt msg 37/123437/1
authorEunhae Choi <eunhae1.choi@samsung.com>
Wed, 5 Apr 2017 12:04:32 +0000 (21:04 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Wed, 5 Apr 2017 12:04:35 +0000 (21:04 +0900)
- use state type for interrupt msg
- fix bug about set_state / msg_posting macro
- do not return the mm_sound ret value directly

Change-Id: Ia801cac13888b92a2790ed2974fa885929460dc1

packaging/libmm-player.spec
src/include/mm_player_utils.h
src/mm_player_priv.c

index 79aa5ed..b63e438 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.40
+Version:    0.6.41
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 9176954..ad33ffc 100644 (file)
@@ -151,13 +151,17 @@ do { \
 
 /* message posting */
 #define MMPLAYER_POST_MSG(x_player, x_msgtype, x_msg_param) \
-LOGD("posting %s to application\n", #x_msgtype); \
-__mmplayer_post_message(x_player, x_msgtype, x_msg_param);
+do { \
+       LOGD("posting %s to application\n", #x_msgtype); \
+       __mmplayer_post_message(x_player, x_msgtype, x_msg_param); \
+} while (0)
 
 /* setting player state */
 #define MMPLAYER_SET_STATE(x_player, x_state) \
-LOGD("update state machine to %d\n", x_state); \
-__mmplayer_set_state(x_player, x_state);
+do { \
+       LOGD("update state machine to %d\n", x_state); \
+       __mmplayer_set_state(x_player, x_state); \
+} while (0)
 
 #define MMPLAYER_CHECK_STATE(x_player, x_command) \
 LOGD("checking player state before doing %s\n", #x_command); \
index 4d716fa..15c5705 100644 (file)
@@ -593,14 +593,13 @@ __mmplayer_set_state(mm_player_t* player, int state) // @
        gboolean post_bos = FALSE;
        gboolean interrupted_by_focus = FALSE;
        gboolean interrupted_by_resource = FALSE;
-       int ret = MM_ERROR_NONE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
        if (MMPLAYER_CURRENT_STATE(player) == state) {
                LOGW("already same state(%s)\n", MMPLAYER_STATE_GET_NAME(state));
                MMPLAYER_PENDING_STATE(player) = MM_PLAYER_STATE_NONE;
-               return ret;
+               return MM_ERROR_NONE;
        }
 
        /* update player states */
@@ -697,14 +696,13 @@ __mmplayer_set_state(mm_player_t* player, int state) // @
                                                LOGE("failed to go ahead because of video conflict\n");
 
                                                msg.union_type = MM_MSG_UNION_CODE;
-                                               msg.code = MM_ERROR_POLICY_INTERRUPTED;
+                                               msg.code = MM_PLAYER_FOCUS_CHANGED_BY_RESOURCE_CONFLICT;
                                                MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, &msg);
 
                                                _mmplayer_unrealize((MMHandleType)player);
                                        } else {
                                                LOGE("failed to play by sound focus error : 0x%X\n", sound_result);
                                                _mmplayer_pause((MMHandleType)player);
-                                               return sound_result;
                                        }
 
                                        return MM_ERROR_POLICY_INTERNAL;
@@ -759,6 +757,7 @@ __mmplayer_set_state(mm_player_t* player, int state) // @
        /* post message to application */
        if (MMPLAYER_TARGET_STATE(player) == state) {
                /* fill the message with state of player */
+               msg.union_type = MM_MSG_UNION_STATE;
                msg.state.previous = MMPLAYER_PREV_STATE(player);
                msg.state.current = MMPLAYER_CURRENT_STATE(player);
 
@@ -766,18 +765,18 @@ __mmplayer_set_state(mm_player_t* player, int state) // @
 
                /* state changed by focus or resource callback */
                if (interrupted_by_focus || interrupted_by_resource) {
-                       msg.union_type = MM_MSG_UNION_CODE;
                        if (interrupted_by_focus)
-                               msg.code = player->sound_focus.focus_changed_msg;
+                               msg.state.code = player->sound_focus.focus_changed_msg;
                        else if (interrupted_by_resource)
-                               msg.code = MM_PLAYER_FOCUS_CHANGED_BY_RESOURCE_CONFLICT;
+                               msg.state.code = MM_PLAYER_FOCUS_CHANGED_BY_RESOURCE_CONFLICT;
                        MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, &msg);
-               } else /* state changed by usecase */
+               } else /* state changed by usecase */
                        MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_CHANGED, &msg);
+               }
        } else {
                LOGD("intermediate state, do nothing.\n");
                MMPLAYER_PRINT_STATE(player);
-               return ret;
+               return MM_ERROR_NONE;
        }
 
        if (post_bos) {
@@ -785,7 +784,7 @@ __mmplayer_set_state(mm_player_t* player, int state) // @
                player->sent_bos = TRUE;
        }
 
-       return ret;
+       return MM_ERROR_NONE;
 }
 
 static gpointer __mmplayer_next_play_thread(gpointer data)
@@ -7040,8 +7039,9 @@ static int __gst_realize(mm_player_t* player) // @
                /* return error if failed to set state */
                LOGE("failed to set READY state");
                return ret;
-       } else
-               MMPLAYER_SET_STATE(player, MM_PLAYER_STATE_READY);
+       }
+
+       MMPLAYER_SET_STATE(player, MM_PLAYER_STATE_READY);
 
        /* create dot before error-return. for debugging */
        MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-status-realize");
@@ -13344,11 +13344,13 @@ __mmplayer_eos_timer_cb(gpointer u_data)
 
                        mm_attrs_set_int_by_name(attrs, "profile_play_count", player->play_count);
                        mmf_attrs_commit(attrs);
-               } else
+               } else {
                        LOGE("seeking to 0 failed in repeat play");
-       } else
+               }
+       } else {
                /* posting eos */
                MMPLAYER_POST_MSG(player, MM_MESSAGE_END_OF_STREAM, NULL);
+       }
 
        /* we are returning FALSE as we need only one posting */
        return FALSE;