[0.6.58] add rm and display handling about audio_only 32/141732/1
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 1 Aug 2017 08:45:28 +0000 (17:45 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 1 Aug 2017 08:45:28 +0000 (17:45 +0900)
Change-Id: I9bff4b210b85a3b4eb9cbde9d3212fcb5223bfac

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

index 80f2070..7102bb5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.57
+Version:    0.6.58
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index d075873..29f9cdd 100644 (file)
@@ -2321,13 +2321,20 @@ int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int
  */
 int mm_player_manage_external_storage_state(MMHandleType player, int state);
 
+/**
+ * These functions are to set/get the max variant of HAS
+ */
 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info);
-
 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height);
-
 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height);
 
 /**
+ * These functions are to set/get the audio only mode
+ */
+int mm_player_set_audio_only(MMHandleType player, bool audio_only);
+int mm_player_get_audio_only(MMHandleType player, bool *audio_only);
+
+/**
        @}
  */
 
index c168502..2971088 100644 (file)
@@ -677,7 +677,7 @@ typedef struct {
        gboolean is_nv12_tiled;
 
        /* resource manager for H/W resources */
-       MMPlayerResourceManager resource_manager;
+       MMPlayerResourceManager resource_manager[RESOURCE_TYPE_MAX];
 
        /* sound focus for being compatible with legacy session policy internally */
        MMPlayerSoundFocus sound_focus;
@@ -903,6 +903,8 @@ int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo);
 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
 int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
 int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
+int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
+int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
 
 #ifdef __cplusplus
        }
index 673b90b..9463c6b 100644 (file)
@@ -48,6 +48,7 @@ extern "C" {
 typedef enum {
        RESOURCE_TYPE_VIDEO_DECODER,
        RESOURCE_TYPE_VIDEO_OVERLAY,
+       RESOURCE_TYPE_MAX,
 } MMPlayerResourceType;
 
 typedef enum {
index cbb8778..62d3dce 100644 (file)
@@ -1372,3 +1372,33 @@ int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth
 
        return result;
 }
+
+int mm_player_set_audio_only(MMHandleType player, bool audio_only)
+{
+       int result = MM_ERROR_NONE;
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       MMPLAYER_CMD_LOCK( player );
+
+       result = _mmplayer_set_audio_only(player, audio_only);
+
+       MMPLAYER_CMD_UNLOCK( player );
+
+       return result;
+}
+
+int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
+{
+       int result = MM_ERROR_NONE;
+
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
+
+       MMPLAYER_CMD_LOCK( player );
+
+       result = _mmplayer_get_audio_only(player, audio_only);
+
+       MMPLAYER_CMD_UNLOCK( player );
+
+       return result;
+}
index 21e34d3..fd5fb16 100644 (file)
@@ -316,7 +316,7 @@ print_tag(const GstTagList * list, const gchar * tag, gpointer unused)
 /* This function should be called after the pipeline goes PAUSED or higher
 state. */
 gboolean
-_mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag) // @
+_mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag)
 {
        static gboolean has_duration = FALSE;
        static gboolean has_video_attrs = FALSE;
@@ -589,7 +589,7 @@ static gboolean __mmplayer_get_stream_service_type(mm_player_t* player)
  * it to applicaton by calling callback function
  */
 int
-__mmplayer_set_state(mm_player_t* player, int state) // @
+__mmplayer_set_state(mm_player_t* player, int state)
 {
        MMMessageParamType msg = {0, };
        int sound_result = MM_ERROR_NONE;
@@ -622,7 +622,8 @@ __mmplayer_set_state(mm_player_t* player, int state) // @
 
        /* do some FSM stuffs before posting new state to application  */
        interrupted_by_focus = player->sound_focus.by_asm_cb;
-       interrupted_by_resource = player->resource_manager.by_rm_cb;
+       interrupted_by_resource = (player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY].by_rm_cb ||
+                                                          player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER].by_rm_cb);
 
        switch (MMPLAYER_CURRENT_STATE(player)) {
        case MM_PLAYER_STATE_NULL:
@@ -1117,7 +1118,7 @@ __mmplayer_adaptive_var_info(const VariantData *self, gpointer user_data)
 }
 
 static gboolean
-__mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @
+__mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data)
 {
        mm_player_t* player = (mm_player_t*) data;
        gboolean ret = TRUE;
@@ -1804,7 +1805,7 @@ __mmplayer_gst_handle_duration(mm_player_t* player, GstMessage* msg)
 
 
 static gboolean
-__mmplayer_gst_extract_tag_from_msg(mm_player_t* player, GstMessage* msg) // @
+__mmplayer_gst_extract_tag_from_msg(mm_player_t* player, GstMessage* msg)
 {
 
 /* macro for better code readability */
@@ -2000,7 +2001,7 @@ if (gst_tag_list_get_double(tag_list, gsttag, &v_double)) {\
 }
 
 static void
-__mmplayer_gst_rtp_no_more_pads(GstElement *element,  gpointer data)  // @
+__mmplayer_gst_rtp_no_more_pads(GstElement *element,  gpointer data)
 {
        mm_player_t* player = (mm_player_t*) data;
 
@@ -2038,7 +2039,7 @@ __mmplayer_gst_rtp_no_more_pads(GstElement *element,  gpointer data)  // @
 }
 
 static gboolean
-__mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstElement* fakesink) // @
+__mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstElement* fakesink)
 {
        GstElement* parent = NULL;
 
@@ -2099,7 +2100,7 @@ ERROR:
 
 
 static void
-__mmplayer_gst_rtp_dynamic_pad(GstElement *element, GstPad *pad, gpointer data) // @
+__mmplayer_gst_rtp_dynamic_pad(GstElement *element, GstPad *pad, gpointer data)
 {
        GstPad *sinkpad = NULL;
        GstCaps* caps = NULL;
@@ -2238,7 +2239,7 @@ ERROR:
 /* FIXIT : check indent */
 #if 0
 static void
-__mmplayer_gst_wfd_dynamic_pad(GstElement *element, GstPad *pad, gpointer data) // @
+__mmplayer_gst_wfd_dynamic_pad(GstElement *element, GstPad *pad, gpointer data)
 {
        GstPad *sinkpad = NULL;
        GstCaps* caps = NULL;
@@ -2644,19 +2645,6 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data)
                /* don't make video because of not required, and not support multiple track */
                if (stype == MM_DISPLAY_SURFACE_NULL) {
                        LOGD("no video sink by null surface");
-                       MMPlayerResourceState resource_state = RESOURCE_STATE_NONE;
-                       if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state)
-                                       == MM_ERROR_NONE) {
-                               /* acquire resources for video playing */
-                               if (resource_state == RESOURCE_STATE_PREPARED) {
-                                       if (_mmplayer_resource_manager_acquire(&player->resource_manager)
-                                                       != MM_ERROR_NONE) {
-                                               LOGE("could not acquire resources for video playing\n");
-                                               _mmplayer_resource_manager_unprepare(&player->resource_manager);
-                                               goto ERROR;
-                                       }
-                               }
-                       }
 
                        gchar *caps_str = gst_caps_to_string(caps);
                        if (caps_str && (strstr(caps_str, "ST12") || strstr(caps_str, "SN12")))
@@ -3402,7 +3390,7 @@ ERROR:
 }
 
 static void
-__mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data) // @
+__mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data)
 {
        mm_player_t* player = NULL;
        MMHandleType attrs = 0;
@@ -3496,10 +3484,10 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data) //
                        }
 
                        if (surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                               if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE) {
+                               if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
                                        /* prepare resource manager for video overlay */
                                        if (resource_state >= RESOURCE_STATE_INITIALIZED) {
-                                               if (_mmplayer_resource_manager_prepare(&player->resource_manager, RESOURCE_TYPE_VIDEO_OVERLAY)
+                                               if (_mmplayer_resource_manager_prepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], RESOURCE_TYPE_VIDEO_OVERLAY)
                                                        != MM_ERROR_NONE) {
                                                        LOGE("could not prepare for video_overlay resource\n");
                                                        goto ERROR;
@@ -3508,14 +3496,12 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data) //
                                }
                        }
 
-                       if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state)
-                               == MM_ERROR_NONE) {
-                               /* acquire resources for video playing */
+                       if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
+                               /* acquire resources for video overlay */
                                if (resource_state == RESOURCE_STATE_PREPARED) {
-                                       if (_mmplayer_resource_manager_acquire(&player->resource_manager)
-                                               != MM_ERROR_NONE) {
+                                       if (_mmplayer_resource_manager_acquire(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]) != MM_ERROR_NONE) {
                                                LOGE("could not acquire resources for video playing\n");
-                                               _mmplayer_resource_manager_unprepare(&player->resource_manager);
+                                               _mmplayer_resource_manager_unprepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]);
                                                goto ERROR;
                                        }
                                }
@@ -3985,7 +3971,7 @@ __mmplayer_update_wayland_videosink_video_param(mm_player_t* player, char *param
 }
 
 int
-_mmplayer_update_video_param(mm_player_t* player, char *param_name) // @
+_mmplayer_update_video_param(mm_player_t* player, char *param_name)
 {
        MMHandleType attrs = 0;
        int surface_type = 0;
@@ -4024,8 +4010,122 @@ _mmplayer_update_video_param(mm_player_t* player, char *param_name) // @
        return MM_ERROR_NONE;
 }
 
+int
+_mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only)
+{
+       gboolean disable_overlay = FALSE;
+       mm_player_t* player = (mm_player_t*) hplayer;
+       MMPlayerResourceState resource_state = RESOURCE_STATE_NONE;
+       int ret = MM_ERROR_NONE;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->videobin &&
+                                                               player->pipeline->videobin[MMPLAYER_V_SINK].gst,
+                                                               MM_ERROR_PLAYER_NO_OP); /* invalid op */
+
+       if (!g_object_class_find_property(G_OBJECT_GET_CLASS(player->pipeline->videobin[MMPLAYER_V_SINK].gst), "disable-overlay")) {
+               LOGW("Display control is not supported");
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
+       g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "disable-overlay", &disable_overlay, NULL);
+
+       if (audio_only == (bool)disable_overlay) {
+               LOGE("It's the same with current setting: (%d)", audio_only);
+               return MM_ERROR_NONE;
+       }
+
+       if (audio_only) {
+               LOGE("disable overlay");
+               g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "disable-overlay", TRUE, NULL);
+
+               /* release overlay resource */
+               if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
+                       if (resource_state >= RESOURCE_STATE_ACQUIRED) {
+                               ret = _mmplayer_resource_manager_release(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]);
+                               if (ret != MM_ERROR_NONE) {
+                                       LOGE("failed to release overlay resource, ret(0x%x)\n", ret);
+                                       goto ERROR;
+                               }
+                       }
+               }
+
+               if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
+                       if (resource_state == RESOURCE_STATE_PREPARED) {
+                               ret = _mmplayer_resource_manager_unprepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]);
+                               if (ret != MM_ERROR_NONE) {
+                                       LOGE("failed to unprepare overlay resource, ret(0x%x)\n", ret);
+                                       goto ERROR;
+                               }
+                       }
+               }
+       } else {
+               if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
+                       /* prepare resource manager for video overlay */
+                       if (resource_state >= RESOURCE_STATE_INITIALIZED) {
+                               ret = _mmplayer_resource_manager_prepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], RESOURCE_TYPE_VIDEO_OVERLAY);
+                               if (ret != MM_ERROR_NONE) {
+                                       LOGE("could not prepare for video_overlay resource\n");
+                                       goto ERROR;
+                               }
+                       }
+               }
+
+               if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
+                       /* acquire resources for video overlay */
+                       if (resource_state == RESOURCE_STATE_PREPARED) {
+                               ret = _mmplayer_resource_manager_acquire(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]);
+                               if (ret != MM_ERROR_NONE) {
+                                       LOGE("could not acquire resources for video playing\n");
+                                       _mmplayer_resource_manager_unprepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]);
+                                       goto ERROR;
+                               }
+                       }
+               }
+
+               LOGD("enable overlay");
+               __mmplayer_video_param_set_display_overlay(player);
+               g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "disable-overlay", FALSE, NULL);
+       }
+
+ERROR:
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_NONE;
+}
+
+int
+_mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only)
+{
+       mm_player_t* player = (mm_player_t*) hplayer;
+       gboolean disable_overlay = FALSE;
+
+       MMPLAYER_FENTER();
+
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(paudio_only, MM_ERROR_INVALID_ARGUMENT);
+       MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->videobin &&
+                                                               player->pipeline->videobin[MMPLAYER_V_SINK].gst,
+                                                               MM_ERROR_PLAYER_NO_OP); /* invalid op */
+
+       if (!g_object_class_find_property(G_OBJECT_GET_CLASS(player->pipeline->videobin[MMPLAYER_V_SINK].gst), "disable-overlay")) {
+               LOGW("Display control is not supported");
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
+       g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "disable-overlay", &disable_overlay, NULL);
+
+       *paudio_only = (bool)(disable_overlay);
+
+       LOGD("audio_only : %d", *paudio_only);
+
+       MMPLAYER_FLEAVE();
+
+       return MM_ERROR_NONE;
+}
+
 static int
-__mmplayer_gst_element_link_bucket(GList* element_bucket) // @
+__mmplayer_gst_element_link_bucket(GList* element_bucket)
 {
        GList* bucket = element_bucket;
        MMPlayerGstElement* element = NULL;
@@ -4074,7 +4174,7 @@ __mmplayer_gst_element_link_bucket(GList* element_bucket) // @
 }
 
 static int
-__mmplayer_gst_element_add_bucket_to_bin(GstBin* bin, GList* element_bucket) // @
+__mmplayer_gst_element_add_bucket_to_bin(GstBin* bin, GList* element_bucket)
 {
        GList* bucket = element_bucket;
        MMPlayerGstElement* element = NULL;
@@ -5895,7 +5995,7 @@ static int __gst_adjust_video_position(mm_player_t* player, int offset)
 }
 
 static void
-__gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) // @
+__gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data)
 {
        GstElement *appsrc = element;
        tBuffer *buf = (tBuffer *)user_data;
@@ -5928,7 +6028,7 @@ __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data)
 }
 
 static gboolean
-__gst_appsrc_seek_data_mem(GstElement *element, guint64 size, gpointer user_data) // @
+__gst_appsrc_seek_data_mem(GstElement *element, guint64 size, gpointer user_data)
 {
        tBuffer *buf = (tBuffer *)user_data;
 
@@ -6095,7 +6195,7 @@ ERROR:
  * @see
  */
 static int
-__mmplayer_gst_create_pipeline(mm_player_t* player) // @
+__mmplayer_gst_create_pipeline(mm_player_t* player)
 {
        GstBus  *bus = NULL;
        MMPlayerGstElement *mainbin = NULL;
@@ -6801,7 +6901,7 @@ __mmplayer_reset_gapless_state(mm_player_t* player)
 }
 
 static int
-__mmplayer_gst_destroy_pipeline(mm_player_t* player) // @
+__mmplayer_gst_destroy_pipeline(mm_player_t* player)
 {
        gint timeout = 0;
        int ret = MM_ERROR_NONE;
@@ -6922,7 +7022,7 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player) // @
        return ret;
 }
 
-static int __gst_realize(mm_player_t* player) // @
+static int __gst_realize(mm_player_t* player)
 {
        gint timeout = 0;
        int ret = MM_ERROR_NONE;
@@ -6961,7 +7061,7 @@ static int __gst_realize(mm_player_t* player) // @
        return ret;
 }
 
-static int __gst_unrealize(mm_player_t* player) // @
+static int __gst_unrealize(mm_player_t* player)
 {
        int ret = MM_ERROR_NONE;
 
@@ -7030,7 +7130,7 @@ static int __gst_pending_seek(mm_player_t* player)
        return ret;
 }
 
-static int __gst_start(mm_player_t* player) // @
+static int __gst_start(mm_player_t* player)
 {
        gboolean sound_extraction = 0;
        int ret = MM_ERROR_NONE;
@@ -7126,7 +7226,7 @@ static void __mmplayer_undo_sound_fadedown(mm_player_t* player)
        MMPLAYER_FLEAVE();
 }
 
-static int __gst_stop(mm_player_t* player) // @
+static int __gst_stop(mm_player_t* player)
 {
        GstStateChangeReturn change_ret = GST_STATE_CHANGE_SUCCESS;
        MMHandleType attrs = 0;
@@ -7213,7 +7313,7 @@ static int __gst_stop(mm_player_t* player) // @
        return ret;
 }
 
-int __gst_pause(mm_player_t* player, gboolean async) // @
+int __gst_pause(mm_player_t* player, gboolean async)
 {
        int ret = MM_ERROR_NONE;
 
@@ -7310,7 +7410,7 @@ int __gst_pause(mm_player_t* player, gboolean async) // @
        return ret;
 }
 
-int __gst_resume(mm_player_t* player, gboolean async) // @
+int __gst_resume(mm_player_t* player, gboolean async)
 {
        int ret = MM_ERROR_NONE;
        gint timeout = 0;
@@ -7355,7 +7455,7 @@ int __gst_resume(mm_player_t* player, gboolean async) // @
 }
 
 static int
-__gst_set_position(mm_player_t* player, int format, unsigned long position, gboolean internal_called) // @
+__gst_set_position(mm_player_t* player, int format, unsigned long position, gboolean internal_called)
 {
        unsigned long dur_msec = 0;
        gint64 dur_nsec = 0;
@@ -7570,7 +7670,7 @@ SEEK_ERROR:
 #define TRICKPLAY_OFFSET GST_MSECOND
 
 static int
-__gst_get_position(mm_player_t* player, int format, unsigned long* position) // @
+__gst_get_position(mm_player_t* player, int format, unsigned long* position)
 {
        MMPlayerStateType current_state = MM_PLAYER_STATE_NONE;
        gint64 pos_msec = 0;
@@ -7776,7 +7876,7 @@ static int __gst_get_buffer_position(mm_player_t* player, int format, unsigned l
 }
 
 static int
-__gst_set_message_callback(mm_player_t* player, MMMessageCallback callback, gpointer user_param) // @
+__gst_set_message_callback(mm_player_t* player, MMMessageCallback callback, gpointer user_param)
 {
        MMPLAYER_FENTER();
 
@@ -7795,7 +7895,7 @@ __gst_set_message_callback(mm_player_t* player, MMMessageCallback callback, gpoi
        return MM_ERROR_NONE;
 }
 
-static int __mmfplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile* data) // @
+static int __mmfplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile* data)
 {
        int ret = MM_ERROR_PLAYER_INVALID_URI;
        char *path = NULL;
@@ -8332,7 +8432,7 @@ EXIT_WITHOUT_UNLOCK:
 
 
 int
-_mmplayer_create_player(MMHandleType handle) // @
+_mmplayer_create_player(MMHandleType handle)
 {
        int ret = MM_ERROR_PLAYER_INTERNAL;
        mm_player_t* player = MM_PLAYER_CAST(handle);
@@ -8416,7 +8516,12 @@ _mmplayer_create_player(MMHandleType handle) // @
        }
 
        /* initialize resource manager */
-       if (MM_ERROR_NONE != _mmplayer_resource_manager_init(&player->resource_manager, player)) {
+       if (MM_ERROR_NONE != _mmplayer_resource_manager_init(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER], player)) {
+               LOGE("failed to initialize resource manager\n");
+               goto ERROR;
+       }
+
+       if (MM_ERROR_NONE != _mmplayer_resource_manager_init(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], player)) {
                LOGE("failed to initialize resource manager\n");
                goto ERROR;
        }
@@ -8510,7 +8615,7 @@ ERROR:
 }
 
 static gboolean
-__mmplayer_init_gstreamer(mm_player_t* player) // @
+__mmplayer_init_gstreamer(mm_player_t* player)
 {
        static gboolean initialized = FALSE;
        static const int max_argc = 50;
@@ -8677,7 +8782,7 @@ __mmplayer_check_async_state_transition(mm_player_t* player)
 }
 
 int
-_mmplayer_destroy(MMHandleType handle) // @
+_mmplayer_destroy(MMHandleType handle)
 {
        mm_player_t* player = MM_PLAYER_CAST(handle);
 
@@ -8741,7 +8846,10 @@ _mmplayer_destroy(MMHandleType handle) // @
                LOGE("failed to deregister asm server\n");
 
        /* de-initialize resource manager */
-       if (MM_ERROR_NONE != _mmplayer_resource_manager_deinit(&player->resource_manager))
+       if (MM_ERROR_NONE != _mmplayer_resource_manager_deinit(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER]))
+               LOGE("failed to deinitialize resource manager\n");
+
+       if (MM_ERROR_NONE != _mmplayer_resource_manager_deinit(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]))
                LOGE("failed to deinitialize resource manager\n");
 
 #ifdef USE_LAZY_PAUSE
@@ -8832,7 +8940,7 @@ __mmplayer_realize_streaming_ext(mm_player_t* player)
 }
 
 int
-_mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid) // @
+_mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        MMHandleType attrs = 0;
@@ -8877,7 +8985,7 @@ _mmplayer_get_client_pid(MMHandleType hplayer, int* pid)
 }
 
 int
-_mmplayer_realize(MMHandleType hplayer) // @
+_mmplayer_realize(MMHandleType hplayer)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        char *uri = NULL;
@@ -9014,20 +9122,40 @@ _mmplayer_unrealize(MMHandleType hplayer)
                if (ret != MM_ERROR_NONE)
                        LOGE("failed to release sound focus, ret(0x%x)\n", ret);
 
-               if (!player->resource_manager.by_rm_cb && /* is being released */
-                       _mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE) {
+               if (!player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER].by_rm_cb && /* is being released */
+                       !player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY].by_rm_cb &&
+                       _mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER], &resource_state) == MM_ERROR_NONE) {
                        if (resource_state >= RESOURCE_STATE_ACQUIRED) {
-                               ret = _mmplayer_resource_manager_release(&player->resource_manager);
+                               ret = _mmplayer_resource_manager_release(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER]);
+                               if (ret != MM_ERROR_NONE)
+                                       LOGE("failed to release decoder resource, ret(0x%x)\n", ret);
+                       }
+               }
+
+               if (!player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER].by_rm_cb && /* is being released */
+                       !player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY].by_rm_cb &&
+                       _mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
+                       if (resource_state >= RESOURCE_STATE_ACQUIRED) {
+                               ret = _mmplayer_resource_manager_release(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]);
+                               if (ret != MM_ERROR_NONE)
+                                       LOGE("failed to release overlay resource, ret(0x%x)\n", ret);
+                       }
+               }
+
+               if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER], &resource_state) == MM_ERROR_NONE) {
+                       if (resource_state == RESOURCE_STATE_PREPARED) {
+                               ret = _mmplayer_resource_manager_unprepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER]);
                                if (ret != MM_ERROR_NONE)
-                                       LOGE("failed to release resource, ret(0x%x)\n", ret);
+                                       LOGE("failed to unprepare decoder resource, ret(0x%x)\n", ret);
                        }
                }
 
-               if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE) {
+
+               if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY], &resource_state) == MM_ERROR_NONE) {
                        if (resource_state == RESOURCE_STATE_PREPARED) {
-                               ret = _mmplayer_resource_manager_unprepare(&player->resource_manager);
+                               ret = _mmplayer_resource_manager_unprepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_OVERLAY]);
                                if (ret != MM_ERROR_NONE)
-                                       LOGE("failed to unprepare resource, ret(0x%x)\n", ret);
+                                       LOGE("failed to unprepare overlay resource, ret(0x%x)\n", ret);
                        }
                }
        } else
@@ -9039,7 +9167,7 @@ _mmplayer_unrealize(MMHandleType hplayer)
 }
 
 int
-_mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, gpointer user_param) // @
+_mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, gpointer user_param)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
 
@@ -9049,7 +9177,7 @@ _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback,
 }
 
 int
-_mmplayer_get_state(MMHandleType hplayer, int* state) // @
+_mmplayer_get_state(MMHandleType hplayer, int* state)
 {
        mm_player_t *player = (mm_player_t*)hplayer;
 
@@ -9062,7 +9190,7 @@ _mmplayer_get_state(MMHandleType hplayer, int* state) // @
 
 
 int
-_mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume) // @
+_mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume)
 {
        mm_player_t* player = (mm_player_t*) hplayer;
        GstElement* vol_element = NULL;
@@ -9139,7 +9267,7 @@ _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType* volume)
 
 
 int
-_mmplayer_set_mute(MMHandleType hplayer, int mute) // @
+_mmplayer_set_mute(MMHandleType hplayer, int mute)
 {
        mm_player_t* player = (mm_player_t*) hplayer;
        GstElement* vol_element = NULL;
@@ -9179,7 +9307,7 @@ _mmplayer_set_mute(MMHandleType hplayer, int mute) // @
 }
 
 int
-_mmplayer_get_mute(MMHandleType hplayer, int* pmute) // @
+_mmplayer_get_mute(MMHandleType hplayer, int* pmute)
 {
        mm_player_t* player = (mm_player_t*) hplayer;
 
@@ -9239,7 +9367,7 @@ _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_chan
 }
 
 int
-_mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param) // @
+_mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
 {
        mm_player_t* player = (mm_player_t*) hplayer;
 
@@ -9258,7 +9386,7 @@ _mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio
 }
 
 int
-_mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param) // @
+_mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param)
 {
        mm_player_t* player = (mm_player_t*) hplayer;
 
@@ -9281,7 +9409,7 @@ _mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callba
 }
 
 int
-_mmplayer_set_audiostream_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param) // @
+_mmplayer_set_audiostream_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param)
 {
        mm_player_t* player = (mm_player_t*) hplayer;
 
@@ -9396,7 +9524,7 @@ __mmplayer_start_streaming_ext(mm_player_t *player)
 }
 
 int
-_mmplayer_start(MMHandleType hplayer) // @
+_mmplayer_start(MMHandleType hplayer)
 {
        mm_player_t* player = (mm_player_t*) hplayer;
        gint ret = MM_ERROR_NONE;
@@ -9548,7 +9676,7 @@ static void __mmplayer_check_pipeline(mm_player_t* player)
 
 /* NOTE : it should be able to call 'stop' anytime*/
 int
-_mmplayer_stop(MMHandleType hplayer) // @
+_mmplayer_stop(MMHandleType hplayer)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
@@ -9584,7 +9712,7 @@ _mmplayer_stop(MMHandleType hplayer) // @
 }
 
 int
-_mmplayer_pause(MMHandleType hplayer) // @
+_mmplayer_pause(MMHandleType hplayer)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        gint64 pos_msec = 0;
@@ -9930,7 +10058,7 @@ _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
 }
 
 int
-_mmplayer_set_position(MMHandleType hplayer, int format, int position) // @
+_mmplayer_set_position(MMHandleType hplayer, int format, int position)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
@@ -9950,7 +10078,7 @@ _mmplayer_set_position(MMHandleType hplayer, int format, int position) // @
 }
 
 int
-_mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *position) // @
+_mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *position)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
@@ -9963,7 +10091,7 @@ _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *position
 }
 
 int
-_mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos) // @
+_mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
@@ -9976,7 +10104,7 @@ _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* s
 }
 
 int
-_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int position) // @
+_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int position)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
@@ -9992,7 +10120,7 @@ _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int position
        return ret;
 }
 int
-_mmplayer_adjust_video_postion(MMHandleType hplayer, int offset) // @
+_mmplayer_adjust_video_postion(MMHandleType hplayer, int offset)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int ret = MM_ERROR_NONE;
@@ -10082,7 +10210,7 @@ __mmplayer_update_content_type_info(mm_player_t* player)
 }
 
 static void
-__mmplayer_typefind_have_type(GstElement *tf, guint probability, // @
+__mmplayer_typefind_have_type(GstElement *tf, guint probability,
 GstCaps *caps, gpointer data)
 {
        mm_player_t* player = (mm_player_t*)data;
@@ -10414,7 +10542,7 @@ ERROR:
 
 /* it will return first created element */
 static gboolean
-__mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // @
+__mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps)
 {
        MMPlayerGstElement* mainbin = NULL;
        const char* mime = NULL;
@@ -11759,10 +11887,10 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
                        /* prepare resource manager for video decoder */
                        MMPlayerResourceState resource_state = RESOURCE_STATE_NONE;
 
-                       if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE) {
+                       if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER], &resource_state) == MM_ERROR_NONE) {
                                /* prepare resource manager for video decoder */
                                if ((resource_state >= RESOURCE_STATE_INITIALIZED) && (resource_state < RESOURCE_STATE_ACQUIRED)) {
-                                       if (_mmplayer_resource_manager_prepare(&player->resource_manager, RESOURCE_TYPE_VIDEO_DECODER)
+                                       if (_mmplayer_resource_manager_prepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER], RESOURCE_TYPE_VIDEO_DECODER)
                                                != MM_ERROR_NONE) {
                                                LOGW("could not prepare for video_decoder resource, skip it.");
                                                result = GST_AUTOPLUG_SELECT_SKIP;
@@ -11770,6 +11898,19 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
                                        }
                                }
                        }
+
+                       if (_mmplayer_resource_manager_get_state(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER], &resource_state)
+                                       == MM_ERROR_NONE) {
+                               /* acquire resources for video playing */
+                               if (resource_state == RESOURCE_STATE_PREPARED) {
+                                       if (_mmplayer_resource_manager_acquire(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER])
+                                                       != MM_ERROR_NONE) {
+                                               LOGE("could not acquire resources for video decoding\n");
+                                               _mmplayer_resource_manager_unprepare(&player->resource_manager[RESOURCE_TYPE_VIDEO_DECODER]);
+                                               goto DONE;
+                                       }
+                               }
+                       }
                }
        }
 
@@ -11847,7 +11988,7 @@ GstCaps * caps,  gpointer data)
 
 static void
 __mmplayer_gst_decode_pad_removed(GstElement *elem,  GstPad* new_pad,
-gpointer data) // @
+gpointer data)
 {
        //mm_player_t* player = (mm_player_t*)data;
        GstCaps* caps = NULL;
@@ -12092,7 +12233,7 @@ static gboolean __mmplayer_configure_audio_callback(mm_player_t* player)
 }
 
 static void
-__mmplayer_init_factories(mm_player_t* player) // @
+__mmplayer_init_factories(mm_player_t* player)
 {
        MMPLAYER_RETURN_IF_FAIL(player);
 
@@ -12102,7 +12243,7 @@ __mmplayer_init_factories(mm_player_t* player) // @
 }
 
 static void
-__mmplayer_release_factories(mm_player_t* player) // @
+__mmplayer_release_factories(mm_player_t* player)
 {
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player);
@@ -12785,7 +12926,7 @@ ERROR:
        return FALSE;
 }
 
-static gboolean __mmplayer_feature_filter(GstPluginFeature *feature, gpointer data) // @
+static gboolean __mmplayer_feature_filter(GstPluginFeature *feature, gpointer data)
 {
        const gchar *klass;
 
index 5024f78..81758e5 100644 (file)
@@ -86,9 +86,9 @@ static char *state_to_str(mrp_res_resource_state_t st)
 static void mrp_state_callback(mrp_res_context_t *context, mrp_res_error_t err, void *user_data)
 {
        int i = 0;
-       const mrp_res_resource_set_t *rset;
-       mrp_res_resource_t *resource;
-       mm_player_t* player = NULL;
+       const mrp_res_resource_set_t *rset = NULL;
+       mrp_res_resource_t *resource = NULL;
+       MMPlayerResourceManager *resource_manager = NULL;
 
        MMPLAYER_FENTER();
 
@@ -96,9 +96,9 @@ static void mrp_state_callback(mrp_res_context_t *context, mrp_res_error_t err,
                LOGE(" - user data is null\n");
                return;
        }
-       player = (mm_player_t*)user_data;
+       resource_manager = (MMPlayerResourceManager *)user_data;
        if (err != MRP_RES_ERROR_NONE) {
-               LOGE(" - error message received from Murphy, for the player(%p), err(0x%x)\n", player, err);
+               LOGE(" - error message received from Murphy, for the rm(%p), err(0x%x)\n", resource_manager, err);
                return;
        }
 
@@ -119,17 +119,17 @@ static void mrp_state_callback(mrp_res_context_t *context, mrp_res_error_t err,
                        }
                        mrp_res_free_string_array(resource_names);
                }
-               player->resource_manager.is_connected = TRUE;
+               resource_manager->is_connected = TRUE;
                break;
        case MRP_RES_DISCONNECTED:
                LOGD(" - disconnected from Murphy\n");
-               if (player->resource_manager.rset) {
-                       mrp_res_delete_resource_set(player->resource_manager.rset);
-                       player->resource_manager.rset = NULL;
+               if (resource_manager->rset) {
+                       mrp_res_delete_resource_set(resource_manager->rset);
+                       resource_manager->rset = NULL;
                }
-               mrp_res_destroy(player->resource_manager.context);
-               player->resource_manager.context = NULL;
-               player->resource_manager.is_connected = FALSE;
+               mrp_res_destroy(resource_manager->context);
+               resource_manager->context = NULL;
+               resource_manager->is_connected = FALSE;
                break;
        }
 
@@ -141,20 +141,20 @@ static void mrp_state_callback(mrp_res_context_t *context, mrp_res_error_t err,
 static void mrp_rset_state_callback(mrp_res_context_t *cx, const mrp_res_resource_set_t *rs, void *user_data)
 {
        int i = 0;
-       mm_player_t *player = (mm_player_t *)user_data;
        mrp_res_resource_t *res;
+       MMPlayerResourceManager *resource_manager = (MMPlayerResourceManager *)user_data;
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RESOURCE_SET_LOCK(&player->resource_manager);
+       MMPLAYER_RESOURCE_SET_LOCK(resource_manager);
 
-       if (!mrp_res_equal_resource_set(rs, player->resource_manager.rset)) {
-               LOGW("- resource set(%p) is not same as this player handle's(%p)", rs, player->resource_manager.rset);
-               MMPLAYER_RESOURCE_SET_UNLOCK(&player->resource_manager);
+       if (!mrp_res_equal_resource_set(rs, resource_manager->rset)) {
+               LOGW("- resource set(%p) is not same as this player handle's rset(%p)", rs, resource_manager->rset);
+               MMPLAYER_RESOURCE_SET_UNLOCK(resource_manager);
                return;
        }
 
-       LOGD(" - resource set state of player(%p) is changed to [%s]\n", player, state_to_str(rs->state));
+       LOGD(" - resource set state of rm(%p) is changed to [%s]\n", resource_manager, state_to_str(rs->state));
        for (i = 0; i < MRP_RESOURCE_MAX; i++) {
                res = mrp_res_get_resource_by_name(rs, resource_str[i]);
                if (res == NULL)
@@ -163,32 +163,32 @@ static void mrp_rset_state_callback(mrp_res_context_t *cx, const mrp_res_resourc
                        LOGD(" -- resource name [%s] -> [%s]'\n", res->name, state_to_str(res->state));
        }
 
-       mrp_res_delete_resource_set(player->resource_manager.rset);
-       player->resource_manager.rset = mrp_res_copy_resource_set(rs);
+       mrp_res_delete_resource_set(resource_manager->rset);
+       resource_manager->rset = mrp_res_copy_resource_set(rs);
 
        if (rs->state == MRP_RES_RESOURCE_ACQUIRED) {
                LOGD(" - resource set is acquired");
-               player->resource_manager.state = RESOURCE_STATE_ACQUIRED;
-               MMPLAYER_RESOURCE_SET_SIGNAL(&player->resource_manager);
-       } else if ((player->resource_manager.state >= RESOURCE_STATE_ACQUIRED) &&
+               resource_manager->state = RESOURCE_STATE_ACQUIRED;
+               MMPLAYER_RESOURCE_SET_SIGNAL(resource_manager);
+       } else if ((resource_manager->state >= RESOURCE_STATE_ACQUIRED) &&
                           (rs->state == MRP_RES_RESOURCE_AVAILABLE)) {
                LOGD(" - resource set is released");
-               player->resource_manager.state = RESOURCE_STATE_PREPARED;
-               MMPLAYER_RESOURCE_SET_SIGNAL(&player->resource_manager);
+               resource_manager->state = RESOURCE_STATE_PREPARED;
+               MMPLAYER_RESOURCE_SET_SIGNAL(resource_manager);
 
                /* mm player was unrealized by resource conflict. */
-               if (player->resource_manager.by_rm_cb == TRUE) {
+               if (resource_manager->by_rm_cb == TRUE) {
                        LOGD(" - delete resource set ");
-                       if (player->resource_manager.rset) {
-                               mrp_res_delete_resource_set(player->resource_manager.rset);
-                               player->resource_manager.rset = NULL;
+                       if (resource_manager->rset) {
+                               mrp_res_delete_resource_set(resource_manager->rset);
+                               resource_manager->rset = NULL;
                        }
-                       player->resource_manager.state = RESOURCE_STATE_INITIALIZED;
-                       player->resource_manager.by_rm_cb = FALSE;
+                       resource_manager->state = RESOURCE_STATE_INITIALIZED;
+                       resource_manager->by_rm_cb = FALSE;
                }
        }
 
-       MMPLAYER_RESOURCE_SET_UNLOCK(&player->resource_manager);
+       MMPLAYER_RESOURCE_SET_UNLOCK(resource_manager);
 
        MMPLAYER_FLEAVE();
 }
@@ -198,8 +198,9 @@ static void mrp_resource_release_cb(mrp_res_context_t *cx, const mrp_res_resourc
 {
        int i = 0;
        int result = MM_ERROR_NONE;
-       mm_player_t* player = NULL;
-       mrp_res_resource_t *res;
+       mm_player_t *player = NULL;
+       MMPlayerResourceManager *resource_manager = NULL;
+       mrp_res_resource_t *res = NULL;
        gboolean resource_released = FALSE;
 
        MMPLAYER_FENTER();
@@ -208,14 +209,15 @@ static void mrp_resource_release_cb(mrp_res_context_t *cx, const mrp_res_resourc
                LOGE("- user_data is null\n");
                return;
        }
-       player = (mm_player_t*)user_data;
+       resource_manager = (MMPlayerResourceManager *)user_data;
+       player = (mm_player_t *)resource_manager->user_data;
 
-       if (!mrp_res_equal_resource_set(rs, player->resource_manager.rset)) {
-               LOGW("- resource set(%p) is not same as this player handle's(%p)", rs, player->resource_manager.rset);
+       if (!mrp_res_equal_resource_set(rs, resource_manager->rset)) {
+               LOGW("- resource set(%p) is not same as this player handle's(%p)", rs, resource_manager->rset);
                return;
        }
 
-       LOGD(" - resource set state of player(%p) is changed to [%s]\n", player, state_to_str(rs->state));
+       LOGD(" - resource set state of rm(%p) is changed to [%s]\n", resource_manager, state_to_str(rs->state));
        for (i = 0; i < MRP_RESOURCE_MAX; i++) {
                res = mrp_res_get_resource_by_name(rs, resource_str[i]);
                if (res == NULL) {
@@ -236,7 +238,7 @@ static void mrp_resource_release_cb(mrp_res_context_t *cx, const mrp_res_resourc
                        MMMessageParamType msg = {0, };
                        unsigned long pos = 0;
 
-                       player->resource_manager.by_rm_cb = TRUE; /* will be reset in state cb */
+                       resource_manager->by_rm_cb = TRUE; /* will be reset in state cb */
 
                        /* get last play position */
                        if (_mmplayer_get_position((MMHandleType)player, MM_PLAYER_POS_FORMAT_TIME, &pos) != MM_ERROR_NONE) {
@@ -273,7 +275,7 @@ static int create_rset(MMPlayerResourceManager *resource_manager)
        resource_manager->rset = mrp_res_create_resource_set(resource_manager->context,
                                MRP_APP_CLASS_FOR_PLAYER,
                                mrp_rset_state_callback,
-                               (void*)resource_manager->user_data);
+                               (void*)resource_manager);
        if (resource_manager->rset == NULL) {
                LOGE(" - could not create resource set\n");
                return MM_ERROR_RESOURCE_INTERNAL;
@@ -308,7 +310,7 @@ static int set_resource_release_cb(MMPlayerResourceManager *resource_manager)
        bool mrp_ret = FALSE;
 
        if (resource_manager->rset) {
-               mrp_ret = mrp_res_set_release_callback(resource_manager->rset, mrp_resource_release_cb, resource_manager->user_data);
+               mrp_ret = mrp_res_set_release_callback(resource_manager->rset, mrp_resource_release_cb, resource_manager);
                if (!mrp_ret) {
                        LOGE(" - could not set release callback\n");
                        ret = MM_ERROR_RESOURCE_INTERNAL;
@@ -342,7 +344,7 @@ int _mmplayer_resource_manager_init(MMPlayerResourceManager *resource_manager, v
        resource_manager->mloop = mrp_mainloop_glib_get(mrp_loop);
        g_main_loop_unref(mrp_loop);
        if (resource_manager->mloop) {
-               resource_manager->context = mrp_res_create(resource_manager->mloop, mrp_state_callback, user_data);
+               resource_manager->context = mrp_res_create(resource_manager->mloop, mrp_state_callback, resource_manager);
                if (resource_manager->context == NULL) {
                        LOGE(" - could not get context for resource manager\n");
                        mrp_mainloop_destroy(resource_manager->mloop);
@@ -383,6 +385,9 @@ int _mmplayer_resource_manager_prepare(MMPlayerResourceManager *resource_manager
                case RESOURCE_TYPE_VIDEO_DECODER:
                        ret = include_resource(resource_manager, resource_str[MRP_RESOURCE_FOR_VIDEO_DECODER]);
                        break;
+               default:
+                       LOGE("unknown resource type %d", resource_type);
+                       return MM_ERROR_INVALID_ARGUMENT;
                }
        }