RESOURCE_TYPE_VIDEO_OVERLAY,
} MMPlayerResourceType;
+typedef enum {
+ RESOURCE_STATE_NONE,
+ RESOURCE_STATE_INITIALIZED,
+ RESOURCE_STATE_PREPARED,
+ RESOURCE_STATE_ACQUIRED,
+ RESOURCE_STATE_MAX,
+} MMPlayerResourceState;
+
+
typedef struct {
mrp_mainloop_t *mloop;
mrp_res_context_t *context;
mrp_res_resource_set_t *rset;
+ MMPlayerResourceState state;
bool is_connected;
void *user_data;
bool by_rm_cb;
int _mmplayer_resource_manager_release(MMPlayerResourceManager *resource_manager);
int _mmplayer_resource_manager_unprepare(MMPlayerResourceManager *resource_manager);
int _mmplayer_resource_manager_deinit(MMPlayerResourceManager *resource_manager);
+int _mmplayer_resource_manager_get_state(MMPlayerResourceManager *resource_manager, MMPlayerResourceState *state);
+
#ifdef __cplusplus
}
GstElement* sinkbin = NULL;
gboolean reusing = FALSE;
GstElement *text_selector = NULL;
+ MMPlayerResourceState resource_state = RESOURCE_STATE_NONE;
/* check handles */
player = (mm_player_t*) data;
LOGD("not make videobin because it dose not want\n");
goto ERROR;
}
+
if (surface_client_type == MM_DISPLAY_SURFACE_X)
{
- /* prepare resource manager for video overlay */
- if((_mmplayer_resource_manager_prepare(&player->resource_manager, RESOURCE_TYPE_VIDEO_OVERLAY)))
+ if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE)
{
- LOGE("could not prepare for video_overlay resource\n");
- goto ERROR;
+ /* prepare resource manager for video overlay */
+ if (resource_state >= RESOURCE_STATE_INITIALIZED)
+ {
+ if (_mmplayer_resource_manager_prepare(&player->resource_manager, RESOURCE_TYPE_VIDEO_OVERLAY)
+ != MM_ERROR_NONE)
+ {
+ LOGE("could not prepare for video_overlay resource\n");
+ goto ERROR;
+ }
+ }
}
}
- /* acquire resources for video playing */
- if((player->resource_manager.rset && _mmplayer_resource_manager_acquire(&player->resource_manager)))
+ if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state)
+ == MM_ERROR_NONE)
{
- LOGE("could not acquire resources for video playing\n");
- _mmplayer_resource_manager_unprepare(&player->resource_manager);
- goto ERROR;
+ /* 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;
+ }
+ }
}
if (MM_ERROR_NONE != __mmplayer_gst_create_video_pipeline(player, caps, surface_type) )
_mmplayer_unrealize(MMHandleType hplayer)
{
mm_player_t* player = (mm_player_t*)hplayer;
+ MMPlayerResourceState resource_state = RESOURCE_STATE_NONE;
int ret = MM_ERROR_NONE;
MMPLAYER_FENTER();
LOGE("failed to release sound focus, ret(0x%x)\n", ret);
}
- ret = _mmplayer_resource_manager_release(&player->resource_manager);
- if (ret == MM_ERROR_RESOURCE_INVALID_STATE)
+ if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE)
{
- LOGW("it could be in the middle of resource callback or there's no acquired resource\n");
- ret = MM_ERROR_NONE;
- }
- else if (ret != MM_ERROR_NONE)
- {
- LOGE("failed to release resource, ret(0x%x)\n", ret);
+ if (resource_state >= RESOURCE_STATE_ACQUIRED)
+ {
+ ret = _mmplayer_resource_manager_release(&player->resource_manager);
+ if (ret != MM_ERROR_NONE)
+ {
+ LOGE("failed to release resource, ret(0x%x)\n", ret);
+ }
+ }
}
- ret = _mmplayer_resource_manager_unprepare(&player->resource_manager);
- if (ret != MM_ERROR_NONE)
+
+ if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE)
{
- LOGE("failed to unprepare resource, ret(0x%x)\n", ret);
+ if (resource_state == RESOURCE_STATE_PREPARED)
+ {
+ ret = _mmplayer_resource_manager_unprepare(&player->resource_manager);
+ if (ret != MM_ERROR_NONE)
+ {
+ LOGE("failed to unprepare resource, ret(0x%x)\n", ret);
+ }
+ }
}
}
else
}
/* prepare resource manager for video decoder */
- if((_mmplayer_resource_manager_prepare(&player->resource_manager, RESOURCE_TYPE_VIDEO_DECODER)))
+ MMPlayerResourceState resource_state = RESOURCE_STATE_NONE;
+
+ if (_mmplayer_resource_manager_get_state(&player->resource_manager, &resource_state) == MM_ERROR_NONE)
{
- LOGW ("could not prepare for video_decoder resource, skip it.");
- result = GST_AUTOPLUG_SELECT_SKIP;
- goto DONE;
+ /* prepare resource manager for video overlay */
+ if (resource_state >= RESOURCE_STATE_INITIALIZED)
+ {
+ if (_mmplayer_resource_manager_prepare(&player->resource_manager, RESOURCE_TYPE_VIDEO_DECODER)
+ != MM_ERROR_NONE)
+ {
+ LOGW ("could not prepare for video_decoder resource, skip it.");
+ result = GST_AUTOPLUG_SELECT_SKIP;
+ goto DONE;
+ }
+ }
}
}
}
return;
}
+ if (rs->state == MRP_RES_RESOURCE_ACQUIRED)
+ player->resource_manager.state = RESOURCE_STATE_ACQUIRED;
+
LOGD(" - resource set state of player(%p) is changed to [%s]\n", player, state_to_str(rs->state));
for (i = 0; i < MRP_RESOURCE_MAX; i++)
{
return MM_ERROR_RESOURCE_INTERNAL;
}
+ resource_manager->state = RESOURCE_STATE_INITIALIZED;
+
MMPLAYER_FLEAVE();
return MM_ERROR_NONE;
}
}
+ resource_manager->state = RESOURCE_STATE_PREPARED;
+
MMPLAYER_FLEAVE();
return ret;
}
}
+ resource_manager->state = RESOURCE_STATE_PREPARED;
+
MMPLAYER_FLEAVE();
return ret;
resource_manager->rset = NULL;
}
+ resource_manager->state = RESOURCE_STATE_INITIALIZED;
+
MMPLAYER_FLEAVE();
return ret;
resource_manager->mloop = NULL;
}
+ resource_manager->state = RESOURCE_STATE_NONE;
+
MMPLAYER_FLEAVE();
return MM_ERROR_NONE;
}
+
+int _mmplayer_resource_manager_get_state(MMPlayerResourceManager *resource_manager, MMPlayerResourceState *state)
+{
+
+ MMPLAYER_FENTER();
+ MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
+ MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_INVALID_ARGUMENT);
+
+ LOGD("resource_state is %d", resource_manager->state);
+
+ *state = resource_manager->state;
+
+ MMPLAYER_FLEAVE();
+
+ return MM_ERROR_NONE;
+}
+