[0.6.104] remove dead code about repeat 69/175669/2
authorEunhae Choi <eunhae1.choi@samsung.com>
Wed, 11 Apr 2018 11:23:07 +0000 (20:23 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Wed, 11 Apr 2018 11:40:24 +0000 (20:40 +0900)
Change-Id: I83bf9e6c8a9bed16f184ddddf14814287f47afd6

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

index bccb4d4..8fdd010 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.103
+Version:    0.6.104
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 9e0e76a..d257ae6 100644 (file)
@@ -915,48 +915,6 @@ LOGD("buffer position: [%d] ~ [%d] \%\n", start_pos, stop_pos );
 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos);
 
 /**
- * This function is to activate the section repeat. If it's set, selected section will be played \n
- * continually before deactivating it by mm_player_deactivate_section_repeat(). \n
- * The unit for setting is millisecond.
- *
- * @param      player          [in]    Handle of player.
- * @param      start_pos               [in]    start position.
- * @param      end_pos                 [in]    end position.
- *
- * @return     This function returns zero on success, or negative value with error code.
- * @see                mm_player_deactivate_section_repeat
- * @remark  None
- * @par Example
- * @code
-int position;
-int endtime = 4000; //msec
-
-mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
-
-mm_player_activate_section_repeat(g_player, position, position+endtime);
- * @endcode
- */
-int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos);
-
-/**
- * This function is to deactivate the section repeat.
- *
- * @param      player          [in]    Handle of player.
- *
- * @return     This function returns zero on success, or negative value with error code.
- * @see                mm_player_activate_section_repeat
- * @remark  None
- * @par Example
- * @code
-if ( mm_player_deactivate_section_repeat(g_player) != MM_ERROR_NONE)
-{
-       LOGW("failed to deactivate section repeat\n");
-}
- * @endcode
- */
-int mm_player_deactivate_section_repeat(MMHandleType player);
-
-/**
  * This function sets callback function for receiving messages from player.
  * So, player can notify warning, error and normal cases to application.
  *
index d167a57..692ff4c 100644 (file)
@@ -538,11 +538,6 @@ typedef struct {
        int target_state;                               // player state which user want to go to
        guint state_change_timeout;
 
-       gboolean section_repeat;
-       gint section_repeat_start;
-       gint section_repeat_end;
-       guint play_count;
-
        gchar *album_art;
 
        int cmd;
@@ -551,12 +546,6 @@ typedef struct {
        GMutex cmd_lock;
        GMutex playback_lock;
 
-       /* repeat thread lock */
-       GCond repeat_thread_cond;
-       GMutex repeat_thread_mutex;
-       GThread* repeat_thread;
-       gboolean repeat_thread_exit;
-
        /* next play thread */
        GThread* next_play_thread;
        gboolean next_play_thread_exit;
@@ -896,8 +885,6 @@ int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
 int _mmplayer_adjust_video_postion(MMHandleType hplayer, int offset);
-int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
-int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
index da33c5c..0a6fe9f 100644 (file)
@@ -78,12 +78,6 @@ do { \
 #define MMPLAYER_NEXT_PLAY_THREAD_WAIT(x_player)             g_cond_wait(&((mm_player_t *)x_player)->next_play_thread_cond, &((mm_player_t *)x_player)->next_play_thread_mutex)
 #define MMPLAYER_NEXT_PLAY_THREAD_SIGNAL(x_player)           g_cond_signal(&((mm_player_t *)x_player)->next_play_thread_cond);
 
-/* repeat thread */
-#define MMPLAYER_REPEAT_THREAD_LOCK(x_player)                g_mutex_lock(&((mm_player_t *)x_player)->repeat_thread_mutex)
-#define MMPLAYER_REPEAT_THREAD_UNLOCK(x_player)              g_mutex_unlock(&((mm_player_t *)x_player)->repeat_thread_mutex)
-#define MMPLAYER_REPEAT_THREAD_WAIT(x_player)                g_cond_wait(&((mm_player_t *)x_player)->repeat_thread_cond, &((mm_player_t *)x_player)->repeat_thread_mutex)
-#define MMPLAYER_REPEAT_THREAD_SIGNAL(x_player)              g_cond_signal(&((mm_player_t *)x_player)->repeat_thread_cond);
-
 /* gst bus msg thread */
 #define MMPLAYER_BUS_MSG_THREAD_LOCK(x_player)                   g_mutex_lock(&((mm_player_t *)x_player)->bus_msg_thread_mutex)
 #define MMPLAYER_BUS_MSG_THREAD_UNLOCK(x_player)                 g_mutex_unlock(&((mm_player_t *)x_player)->bus_msg_thread_mutex)
index 311e4a3..4de2262 100644 (file)
@@ -393,36 +393,6 @@ int mm_player_resume(MMHandleType player)
        return result;
 }
 
-int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
-int mm_player_deactivate_section_repeat(MMHandleType player)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_deactivate_section_repeat(player);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
 {
        int result = MM_ERROR_NONE;
index cb25e29..cc67ea5 100644 (file)
@@ -258,10 +258,10 @@ _mmplayer_construct_attribute(MMHandleType handle)
                        "profile_play_count",
                        MM_ATTRS_TYPE_INT,
                        MM_ATTRS_FLAG_RW,
-                       (void *) 1,                     // -1 : repeat continually
+                       (void *) 1,                     /* -1 : repeat continually */
                        MM_ATTRS_VALID_TYPE_INT_RANGE,
                        -1,
-                       MMPLAYER_MAX_INT
+                       1
                },
                {
                        "profile_prepare_async",
index a4eb8b0..c73fd17 100755 (executable)
@@ -179,7 +179,6 @@ static void         __mmplayer_add_sink(mm_player_t* player, GstElement* sink);
 static void            __mmplayer_del_sink(mm_player_t* player, GstElement* sink);
 static void            __mmplayer_release_signal_connection(mm_player_t* player, MMPlayerSignalType type);
 static gpointer __mmplayer_next_play_thread(gpointer data);
-static gpointer __mmplayer_repeat_thread(gpointer data);
 static gboolean _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag);
 
 static gboolean __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element);
@@ -733,80 +732,6 @@ static gpointer __mmplayer_next_play_thread(gpointer data)
        return NULL;
 }
 
-static gpointer __mmplayer_repeat_thread(gpointer data)
-{
-       mm_player_t* player = (mm_player_t*) data;
-       gboolean ret_value = FALSE;
-       MMHandleType attrs = 0;
-       gint count = 0;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
-
-       MMPLAYER_REPEAT_THREAD_LOCK(player);
-       while (!player->repeat_thread_exit) {
-               LOGD("repeat thread started. waiting for signal.\n");
-               MMPLAYER_REPEAT_THREAD_WAIT(player);
-
-               if (player->repeat_thread_exit) {
-                       LOGD("exiting repeat thread\n");
-                       break;
-               }
-
-
-               /* lock */
-               MMPLAYER_CMD_LOCK(player);
-
-               attrs = MMPLAYER_GET_ATTRS(player);
-
-               if (mm_attrs_get_int_by_name(attrs, "profile_play_count", &count) != MM_ERROR_NONE) {
-                       LOGE("can not get play count\n");
-                       MMPLAYER_CMD_UNLOCK(player);
-                       break;
-               }
-
-               if (player->section_repeat) {
-                       ret_value = _mmplayer_activate_section_repeat((MMHandleType)player, player->section_repeat_start, player->section_repeat_end);
-               } else {
-                       if (player->playback_rate < 0.0) {
-                               player->resumed_by_rewind = TRUE;
-                               _mmplayer_set_mute((MMHandleType)player, 0);
-                               MMPLAYER_POST_MSG(player, MM_MESSAGE_RESUMED_BY_REW, NULL);
-                       }
-
-                       ret_value = __gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, player->playback_rate,
-                               GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
-                               0, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
-
-                       /* initialize */
-                       player->sent_bos = FALSE;
-               }
-
-               if (!ret_value) {
-                       LOGE("failed to set position to zero for rewind\n");
-                       MMPLAYER_CMD_UNLOCK(player);
-                       continue;
-               }
-
-               /* decrease play count */
-               if (count > 1) {
-                       /* we successeded to rewind. update play count and then wait for next EOS */
-                       count--;
-
-                       mm_attrs_set_int_by_name(attrs, "profile_play_count", count);
-
-                       /* commit attribute */
-                       if (mmf_attrs_commit(attrs))
-                               LOGE("failed to commit attribute\n");
-               }
-
-               /* unlock */
-               MMPLAYER_CMD_UNLOCK(player);
-       }
-
-       MMPLAYER_REPEAT_THREAD_UNLOCK(player);
-       return NULL;
-}
-
 static void
 __mmplayer_update_buffer_setting(mm_player_t *player, GstMessage *buffering_msg)
 {
@@ -1148,30 +1073,20 @@ __mmplayer_gst_callback(GstMessage *msg, gpointer data)
 
                        if (attrs) {
                                mm_attrs_get_int_by_name(attrs, "profile_play_count", &count);
-                               player->play_count = count;
-
-                               LOGD("remaining play count: %d, playback rate: %f\n", count, player->playback_rate);
 
-                               if (count > 1 || count == -1 || player->playback_rate < 0.0) /* default value is 1 */ {
-                                       gint ret_value = 0;
+                               LOGD("play count: %d, playback rate: %f\n", count, player->playback_rate);
 
-                                       if (player->section_repeat) {
-                                               ret_value = _mmplayer_activate_section_repeat((MMHandleType)player, player->section_repeat_start, player->section_repeat_end);
-                                       } else {
-                                               if (player->playback_rate < 0.0) {
-                                                       player->resumed_by_rewind = TRUE;
-                                                       _mmplayer_set_mute((MMHandleType)player, 0);
-                                                       MMPLAYER_POST_MSG(player, MM_MESSAGE_RESUMED_BY_REW, NULL);
-                                               }
-
-                                               __mmplayer_handle_eos_delay(player, player->ini.delay_before_repeat);
-
-                                               /* initialize */
-                                               player->sent_bos = FALSE;
+                               if (count == -1 || player->playback_rate < 0.0) /* default value is 1 */ {
+                                       if (player->playback_rate < 0.0) {
+                                               player->resumed_by_rewind = TRUE;
+                                               _mmplayer_set_mute((MMHandleType)player, 0);
+                                               MMPLAYER_POST_MSG(player, MM_MESSAGE_RESUMED_BY_REW, NULL);
                                        }
 
-                                       if (MM_ERROR_NONE != ret_value)
-                                               LOGE("failed to set position to zero for rewind\n");
+                                       __mmplayer_handle_eos_delay(player, player->ini.delay_before_repeat);
+
+                                       /* initialize */
+                                       player->sent_bos = FALSE;
 
                                        /* not posting eos when repeating */
                                        break;
@@ -8262,23 +8177,6 @@ _mmplayer_create_player(MMHandleType handle)
        /* create update tag lock */
        g_mutex_init(&player->update_tag_lock);
 
-       /* create repeat mutex */
-       g_mutex_init(&player->repeat_thread_mutex);
-
-       /* create repeat cond */
-       g_cond_init(&player->repeat_thread_cond);
-
-       /* 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);
 
@@ -8334,7 +8232,6 @@ _mmplayer_create_player(MMHandleType handle)
        player->playback_rate = DEFAULT_PLAYBACK_RATE;
 
        player->play_subtitle = FALSE;
-       player->play_count = 0;
        player->use_deinterleave = FALSE;
        player->max_audio_channels = 0;
        player->video_share_api_delta = 0;
@@ -8377,20 +8274,6 @@ ERROR:
        /* free update tag lock */
        g_mutex_clear(&player->update_tag_lock);
 
-       /* free thread */
-       if (player->repeat_thread) {
-               MMPLAYER_REPEAT_THREAD_LOCK(player);
-               player->repeat_thread_exit = TRUE;
-               MMPLAYER_REPEAT_THREAD_SIGNAL(player);
-               MMPLAYER_REPEAT_THREAD_UNLOCK(player);
-
-               g_thread_join(player->repeat_thread);
-               player->repeat_thread = NULL;
-
-               g_mutex_clear(&player->repeat_thread_mutex);
-               g_cond_clear(&player->repeat_thread_cond);
-       }
-
        /* free next play thread */
        if (player->next_play_thread) {
                MMPLAYER_NEXT_PLAY_THREAD_LOCK(player);
@@ -8593,20 +8476,6 @@ _mmplayer_destroy(MMHandleType handle)
 
        __mmplayer_destroy_streaming_ext(player);
 
-       /* release repeat thread */
-       if (player->repeat_thread) {
-               MMPLAYER_REPEAT_THREAD_LOCK(player);
-               player->repeat_thread_exit = TRUE;
-               MMPLAYER_REPEAT_THREAD_SIGNAL(player);
-               MMPLAYER_REPEAT_THREAD_UNLOCK(player);
-
-               LOGD("waitting for repeat thread exit\n");
-               g_thread_join(player->repeat_thread);
-               g_mutex_clear(&player->repeat_thread_mutex);
-               g_cond_clear(&player->repeat_thread_cond);
-               LOGD("repeat thread released\n");
-       }
-
        /* release next play thread */
        if (player->next_play_thread) {
                MMPLAYER_NEXT_PLAY_THREAD_LOCK(player);
@@ -9431,71 +9300,6 @@ _mmplayer_resume(MMHandleType hplayer)
        return ret;
 }
 
-int
-__mmplayer_set_play_count(mm_player_t* player, gint count)
-{
-       MMHandleType attrs = 0;
-
-       MMPLAYER_FENTER();
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       attrs =  MMPLAYER_GET_ATTRS(player);
-       if (!attrs) {
-               LOGE("fail to get attributes.\n");
-               return MM_ERROR_PLAYER_INTERNAL;
-       }
-
-       mm_attrs_set_int_by_name(attrs, "profile_play_count", count);
-       if (mmf_attrs_commit(attrs)) /* return -1 if error */
-               LOGE("failed to commit\n");
-
-       MMPLAYER_FLEAVE();
-
-       return  MM_ERROR_NONE;
-}
-
-int
-_mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end)
-{
-       mm_player_t* player = (mm_player_t*)hplayer;
-       gint64 start_pos = 0;
-       gint64 end_pos = 0;
-       gint infinity = -1;
-
-       MMPLAYER_FENTER();
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(end <= GST_TIME_AS_MSECONDS(player->duration), MM_ERROR_INVALID_ARGUMENT);
-
-       player->section_repeat = TRUE;
-       player->section_repeat_start = start;
-       player->section_repeat_end = end;
-
-       start_pos = player->section_repeat_start * G_GINT64_CONSTANT(1000000);
-       end_pos = player->section_repeat_end * G_GINT64_CONSTANT(1000000);
-
-       __mmplayer_set_play_count(player, infinity);
-
-       if ((!__gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
-                                       player->playback_rate,
-                                       GST_FORMAT_TIME,
-                                       (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
-                                       GST_SEEK_TYPE_SET, start_pos,
-                                       GST_SEEK_TYPE_SET, end_pos))) {
-               LOGE("failed to activate section repeat\n");
-
-               return MM_ERROR_PLAYER_SEEK;
-       }
-
-       LOGD("succeeded to set section repeat from %d to %d\n",
-               player->section_repeat_start, player->section_repeat_end);
-
-       MMPLAYER_FLEAVE();
-
-       return  MM_ERROR_NONE;
-}
-
 static int
 __mmplayer_set_pcm_extraction(mm_player_t* player)
 {
@@ -9563,39 +9367,6 @@ __mmplayer_set_pcm_extraction(mm_player_t* player)
 }
 
 int
-_mmplayer_deactivate_section_repeat(MMHandleType hplayer)
-{
-       mm_player_t* player = (mm_player_t*)hplayer;
-       gint64 cur_pos = 0;
-       gint onetime = 1;
-
-       MMPLAYER_FENTER();
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       player->section_repeat = FALSE;
-
-       __mmplayer_set_play_count(player, onetime);
-
-       gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &cur_pos);
-
-       if ((!__gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
-                                       1.0,
-                                       GST_FORMAT_TIME,
-                                       (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
-                                       GST_SEEK_TYPE_SET, cur_pos,
-                                       GST_SEEK_TYPE_SET, player->duration))) {
-               LOGE("failed to deactivate section repeat\n");
-
-               return MM_ERROR_PLAYER_SEEK;
-       }
-
-       MMPLAYER_FENTER();
-
-       return MM_ERROR_NONE;
-}
-
-int
 _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
@@ -11991,24 +11762,20 @@ static gboolean
 __mmplayer_eos_timer_cb(gpointer u_data)
 {
        mm_player_t* player = NULL;
+       MMHandleType attrs = 0;
+       int count = 0;
+
+       MMPLAYER_RETURN_VAL_IF_FAIL(u_data, FALSE);
+
        player = (mm_player_t*) u_data;
+       attrs = MMPLAYER_GET_ATTRS(player);
 
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
+       mm_attrs_get_int_by_name(attrs, "profile_play_count", &count);
 
-       if (player->play_count > 1) {
+       if (count == -1) {
                gint ret_value = 0;
                ret_value = __gst_set_position(player, MM_PLAYER_POS_FORMAT_TIME, 0, TRUE);
-               if (ret_value == MM_ERROR_NONE) {
-                       MMHandleType attrs = 0;
-                       attrs = MMPLAYER_GET_ATTRS(player);
-
-                       /* we successeded to rewind. update play count and then wait for next EOS */
-                       player->play_count--;
-
-                       mm_attrs_set_int_by_name(attrs, "profile_play_count", player->play_count);
-                       if (mmf_attrs_commit(attrs))
-                               LOGE("failed to update attributes\n");
-               } else {
+               if (ret_value != MM_ERROR_NONE) {
                        LOGE("seeking to 0 failed in repeat play");
                }
        } else {
@@ -12856,7 +12623,6 @@ int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filep
                else
                        result = util_exist_file_path(filepath);
 
-
                if (result != MM_ERROR_NONE) {
                        LOGE("invalid subtitle path 0x%X", result);
                        return result; /* file not found or permission denied */