summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEunhae Choi <eunhae1.choi@samsung.com>2016-07-06 23:46:33 -0700
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2016-07-06 23:46:33 -0700
commita2baab8940dd3234d0d032e03561ebe161425921 (patch)
treecdd7c8b27ffd79f8900f7b77770a2aabd6421be8
parent008641bd919f4a4e26269e8412fbe7339643b67d (diff)
parent3c6613be64b43777f7bbbf39cf8205b40abc3f18 (diff)
downloadlibmm-player-a2baab8940dd3234d0d032e03561ebe161425921.tar.gz
libmm-player-a2baab8940dd3234d0d032e03561ebe161425921.tar.bz2
libmm-player-a2baab8940dd3234d0d032e03561ebe161425921.zip
Merge "add resource limit return during player create" into tizen
-rw-r--r--src/include/mm_player_priv.h1
-rw-r--r--src/include/mm_player_utils.h2
-rw-r--r--src/mm_player.c24
-rw-r--r--src/mm_player_capture.c6
-rw-r--r--src/mm_player_priv.c83
5 files changed, 63 insertions, 53 deletions
diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h
index 8d43d0b..cd77c8a 100644
--- a/src/include/mm_player_priv.h
+++ b/src/include/mm_player_priv.h
@@ -509,7 +509,6 @@ typedef struct {
/* message callback */
MMMessageCallback msg_cb;
void* msg_cb_param;
- GMutex msg_cb_lock;
/* progressive download */
mm_player_pd_t *pd_downloader;
diff --git a/src/include/mm_player_utils.h b/src/include/mm_player_utils.h
index d81199b..94da65c 100644
--- a/src/include/mm_player_utils.h
+++ b/src/include/mm_player_utils.h
@@ -54,8 +54,6 @@ x = NULL;
#define MMPLAYER_CMD_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->cmd_lock)
#define MMPLAYER_CMD_UNLOCK(x_player) g_mutex_unlock( &((mm_player_t*)x_player)->cmd_lock )
-#define MMPLAYER_MSG_POST_LOCK(x_player) g_mutex_lock( &((mm_player_t*)x_player)->msg_cb_lock )
-#define MMPLAYER_MSG_POST_UNLOCK(x_player) g_mutex_unlock( &((mm_player_t*)x_player)->msg_cb_lock )
#define MMPLAYER_PLAYBACK_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->playback_lock)
#define MMPLAYER_PLAYBACK_UNLOCK(x_player) g_mutex_unlock( &((mm_player_t*)x_player)->playback_lock )
#define MMPLAYER_GET_ATTRS(x_player) ((mm_player_t*)x_player)->attrs
diff --git a/src/mm_player.c b/src/mm_player.c
index d243294..e1acd4c 100644
--- a/src/mm_player.c
+++ b/src/mm_player.c
@@ -38,17 +38,17 @@
int mm_player_create(MMHandleType *player)
{
- int result = MM_ERROR_NONE;
+ int result = MM_ERROR_PLAYER_INTERNAL;
mm_player_t* new_player = NULL;
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
/* alloc player structure */
new_player = g_malloc(sizeof(mm_player_t));
- if ( ! new_player )
+ if (!new_player)
{
LOGE("Cannot allocate memory for player\n");
+ result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
goto ERROR;
}
memset(new_player, 0, sizeof(mm_player_t));
@@ -59,38 +59,32 @@ int mm_player_create(MMHandleType *player)
/* create player lock */
g_mutex_init(&new_player->playback_lock);
-
- /* create msg callback lock */
- g_mutex_init(&new_player->msg_cb_lock);
-
/* load ini files */
- result = mm_player_ini_load(&new_player->ini);
- if(result != MM_ERROR_NONE)
+ if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini))
{
LOGE("can't load ini");
goto ERROR;
}
- result = mm_player_audio_effect_ini_load(&new_player->ini);
- if(result != MM_ERROR_NONE)
+ if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini))
{
LOGE("can't load audio ini");
goto ERROR;
}
-
/* create player */
result = _mmplayer_create_player((MMHandleType)new_player);
-
if(result != MM_ERROR_NONE)
{
LOGE("failed to create player");
+ if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
+ result = MM_ERROR_PLAYER_INTERNAL;
goto ERROR;
}
*player = (MMHandleType)new_player;
- return result;
+ return MM_ERROR_NONE;
ERROR:
@@ -104,7 +98,7 @@ ERROR:
}
*player = (MMHandleType)0;
- return MM_ERROR_PLAYER_NO_FREE_SPACE; // are you sure?
+ return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
}
int mm_player_destroy(MMHandleType player)
diff --git a/src/mm_player_capture.c b/src/mm_player_capture.c
index 840095e..be80a75 100644
--- a/src/mm_player_capture.c
+++ b/src/mm_player_capture.c
@@ -55,6 +55,7 @@ static int __mm_player_convert_colorspace(mm_player_t* player, unsigned char* sr
int
_mmplayer_initialize_video_capture(mm_player_t* player)
{
+ int ret = MM_ERROR_NONE;
MMPLAYER_RETURN_VAL_IF_FAIL ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
/* create capture mutex */
g_mutex_init(&player->capture_thread_mutex);
@@ -71,10 +72,11 @@ _mmplayer_initialize_video_capture(mm_player_t* player)
if ( ! player->capture_thread )
{
+ ret = MM_ERROR_PLAYER_RESOURCE_LIMIT;
goto ERROR;
}
- return MM_ERROR_NONE;
+ return ret;
ERROR:
/* capture thread */
@@ -82,7 +84,7 @@ ERROR:
g_cond_clear (&player->capture_thread_cond );
- return MM_ERROR_PLAYER_INTERNAL;
+ return ret;
}
int
diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c
index c706ba2..eaa341b 100644
--- a/src/mm_player_priv.c
+++ b/src/mm_player_priv.c
@@ -5487,25 +5487,44 @@ __mmplayer_video_stream_get_bo(mm_player_t* player, int size)
g_mutex_lock(&player->video_bo_mutex);
- if (!player->video_bo_list) {
+ if ((!player->video_bo_list) ||
+ (g_list_length(player->video_bo_list) < player->ini.num_of_video_bo)) {
+
/* create bo list */
int idx = 0;
LOGD("Create bo list for decoded video stream(num:%d)", player->ini.num_of_video_bo);
- for (idx=0 ; idx<player->ini.num_of_video_bo ; idx++) {
+ if (player->video_bo_list) {
+ /* if bo list did not created all, try it again. */
+ idx = g_list_length(player->video_bo_list);
+ LOGD("bo list exist (len: %d)", idx);
+ }
+
+ for (; idx<player->ini.num_of_video_bo ; idx++) {
mm_player_video_bo_info_t* bo_info = g_new(mm_player_video_bo_info_t, 1);
+ if (!bo_info) {
+ LOGE("Fail to alloc bo_info.");
+ break;
+ }
bo_info->bo = tbm_bo_alloc(player->bufmgr, size, TBM_BO_DEFAULT);
if (!bo_info->bo) {
LOGE("Fail to tbm_bo_alloc.");
- return NULL;
+ g_free(bo_info);
+ break;
}
bo_info->using = FALSE;
player->video_bo_list = g_list_append(player->video_bo_list, bo_info);
}
/* update video num buffers */
- player->video_num_buffers = player->ini.num_of_video_bo;
- player->video_extra_num_buffers = (player->ini.num_of_video_bo)/2;
+ player->video_num_buffers = idx;
+ if (idx == player->ini.num_of_video_bo)
+ player->video_extra_num_buffers = player->ini.num_of_video_bo/2;
+
+ if (idx == 0) {
+ g_mutex_unlock(&player->video_bo_mutex);
+ return NULL;
+ }
LOGD("Num of video buffers(%d/%d)", player->video_num_buffers, player->video_extra_num_buffers);
}
@@ -9382,6 +9401,7 @@ EXIT_WITHOUT_UNLOCK:
int
_mmplayer_create_player(MMHandleType handle) // @
{
+ int ret = MM_ERROR_PLAYER_INTERNAL;
mm_player_t* player = MM_PLAYER_CAST(handle);
MMPLAYER_FENTER();
@@ -9403,14 +9423,15 @@ _mmplayer_create_player(MMHandleType handle) // @
if ( !player->attrs )
{
LOGE("Failed to construct attributes\n");
- goto ERROR;
+ return ret;
}
/* initialize gstreamer with configured parameter */
if ( ! __mmplayer_init_gstreamer(player) )
{
LOGE("Initializing gstreamer failed\n");
- goto ERROR;
+ _mmplayer_deconstruct_attribute(handle);
+ return ret;
}
/* initialize factories if not using decodebin */
@@ -9429,7 +9450,14 @@ _mmplayer_create_player(MMHandleType handle) // @
/* create repeat thread */
player->repeat_thread =
g_thread_try_new ("repeat_thread", __mmplayer_repeat_thread, (gpointer)player, NULL);
-
+ if (!player->repeat_thread)
+ {
+ LOGE("failed to create repeat_thread(%s)");
+ g_mutex_clear(&player->repeat_thread_mutex);
+ g_cond_clear(&player->repeat_thread_cond);
+ ret = MM_ERROR_PLAYER_RESOURCE_LIMIT;
+ goto ERROR;
+ }
/* create next play mutex */
g_mutex_init(&player->next_play_thread_mutex);
@@ -9440,13 +9468,17 @@ _mmplayer_create_player(MMHandleType handle) // @
/* create next play thread */
player->next_play_thread =
g_thread_try_new ("next_play_thread", __mmplayer_next_play_thread, (gpointer)player, NULL);
- if ( ! player->next_play_thread )
+ if (!player->next_play_thread)
{
LOGE("failed to create next play thread");
+ ret = MM_ERROR_PLAYER_RESOURCE_LIMIT;
+ g_mutex_clear(&player->next_play_thread_mutex);
+ g_cond_clear(&player->next_play_thread_cond);
goto ERROR;
}
- if ( MM_ERROR_NONE != _mmplayer_initialize_video_capture(player))
+ ret = _mmplayer_initialize_video_capture(player);
+ if (ret != MM_ERROR_NONE)
{
LOGE("failed to initialize video capture\n");
goto ERROR;
@@ -9515,42 +9547,29 @@ ERROR:
g_thread_join( player->repeat_thread );
player->repeat_thread = NULL;
- g_mutex_clear(&player->repeat_thread_mutex );
-
- g_cond_clear (&player->repeat_thread_cond );
+ g_mutex_clear(&player->repeat_thread_mutex);
+ g_cond_clear(&player->repeat_thread_cond);
}
- /* clear repeat thread mutex/cond if still alive
- * this can happen if only thread creating has failed
- */
- g_mutex_clear(&player->repeat_thread_mutex );
- g_cond_clear ( &player->repeat_thread_cond );
/* free next play thread */
- if ( player->next_play_thread )
+ if (player->next_play_thread)
{
player->next_play_thread_exit = TRUE;
- g_cond_signal( &player->next_play_thread_cond );
+ g_cond_signal(&player->next_play_thread_cond);
- g_thread_join( player->next_play_thread );
+ g_thread_join(player->next_play_thread);
player->next_play_thread = NULL;
- g_mutex_clear(&player->next_play_thread_mutex );
-
- g_cond_clear ( &player->next_play_thread_cond );
+ g_mutex_clear(&player->next_play_thread_mutex);
+ g_cond_clear(&player->next_play_thread_cond);
}
- /* clear next play thread mutex/cond if still alive
- * this can happen if only thread creating has failed
- */
- g_mutex_clear(&player->next_play_thread_mutex );
-
- g_cond_clear ( &player->next_play_thread_cond );
/* release attributes */
_mmplayer_deconstruct_attribute(handle);
MMPLAYER_FLEAVE();
- return MM_ERROR_PLAYER_INTERNAL;
+ return ret;
}
static gboolean
@@ -9804,8 +9823,6 @@ _mmplayer_destroy(MMHandleType handle) // @
/* release lock */
g_mutex_clear(&player->fsink_lock );
- g_mutex_clear(&player->msg_cb_lock );
-
/* release video bo lock and cond */
g_mutex_clear(&player->video_bo_mutex);
g_cond_clear(&player->video_bo_cond);