[0.6.91] add sound focus lock to avoid duplicated unregister 55/169255/3 accepted/tizen/4.0/unified/20180206.064316 submit/tizen_4.0/20180205.083324
authorEunhae Choi <eunhae1.choi@samsung.com>
Mon, 5 Feb 2018 07:56:00 +0000 (16:56 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Mon, 5 Feb 2018 08:01:34 +0000 (08:01 +0000)
- by duplicated unregister operation, the gdbus shared connection can be closed

Change-Id: I9d1cb487bd95c7b7c80dbb922a1f4f981c7e572a

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

index 4c43d26a8437bd0669efda3f4e58d17d7e6428a5..74ebd185173518ecbf3d25b89f12a4f5d16d1748 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.90
+Version:    0.6.91
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index a9bb690b0009b60d714e67d1177381e385188140..4538dce05224f4c9c8414d3d6ca65f57bef54a5d 100644 (file)
@@ -52,6 +52,7 @@ typedef struct {
        int session_type;
        int session_flags;
        int focus_changed_msg;  // MMPlayerFocusChangedMsg
+       GMutex focus_lock;
 
 } MMPlayerSoundFocus;
 
index 281250d75acf4622023c6e9966c4db89718ac24b..9cca3ce4f253d819a8da85c6633bacb48c7dc838 100644 (file)
@@ -118,6 +118,10 @@ do {       \
 #define MMPLAYER_SUBTITLE_INFO_WAIT_UNTIL(x_player, end_time)     g_cond_wait_until(&((mm_player_t *)x_player)->subtitle_info_cond, &((mm_player_t *)x_player)->subtitle_info_mutex, end_time)
 #define MMPLAYER_SUBTITLE_INFO_SIGNAL(x_player)                   g_cond_signal(&((mm_player_t *)x_player)->subtitle_info_cond);
 
+/* sound focus lock */
+#define MMPLAYER_SOUND_FOCUS_LOCK(x_player_sound_focus)           g_mutex_lock(&((MMPlayerSoundFocus *)x_player_sound_focus)->focus_lock)
+#define MMPLAYER_SOUND_FOCUS_UNLOCK(x_player_sound_focus)         g_mutex_unlock(&((MMPlayerSoundFocus *)x_player_sound_focus)->focus_lock)
+
 #if 0
 #define MMPLAYER_FENTER();                                     LOGD("<ENTER>");
 #define MMPLAYER_FLEAVE();                                     LOGD("<LEAVE>");
index 1fe7e0a005087a7514ada492afbc3cdeb002c032..f9fdcefde0c0410d9d7825185d8feff1291bb471 100644 (file)
@@ -8691,6 +8691,9 @@ _mmplayer_create_player(MMHandleType handle)
        g_mutex_init(&player->subtitle_info_mutex);
        g_cond_init(&player->subtitle_info_cond);
 
+       /* create sound focus lock */
+       g_mutex_init(&player->sound_focus.focus_lock);
+
        player->streaming_type = STREAMING_SERVICE_NONE;
 
        /* give default value of audio effect setting */
@@ -9052,6 +9055,9 @@ _mmplayer_destroy(MMHandleType handle)
        /* release media stream callback lock */
        g_mutex_clear(&player->media_stream_cb_lock);
 
+       /* release sound focus lock */
+       g_mutex_clear(&player->sound_focus.focus_lock);
+
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;
index 0911dcfc34e68a2650a6514786659c1c2828ae73..dcb74fa167c747e2ce1d36019ac63dbe86a94e9b 100644 (file)
@@ -357,6 +357,7 @@ _mmplayer_sound_unregister(MMPlayerSoundFocus* sound_focus)
        MMPLAYER_FENTER();
 
        MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
+       MMPLAYER_SOUND_FOCUS_LOCK(sound_focus);
 
        LOGD("unregister sound focus callback\n");
 
@@ -385,6 +386,7 @@ _mmplayer_sound_unregister(MMPlayerSoundFocus* sound_focus)
                sound_focus->connected_id = 0;
        }
 
+       MMPLAYER_SOUND_FOCUS_UNLOCK(sound_focus);
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;