Fix double unlock of slot mutex in user stops scneario
[platform/core/multimedia/libmm-sound.git] / server / mm_sound_mgr_codec.c
index 6e4192f..c2c968b 100644 (file)
@@ -56,8 +56,6 @@ typedef struct {
 
        int pluginid;
        int status;
-       bool stop_by_user;
-
 } __mmsound_mgr_codec_handle_t;
 
 static MMSoundPluginType *g_codec_plugins = NULL;
@@ -84,7 +82,7 @@ static guint g_timer_id = 0;
 #endif
 
 static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin);
-static int _MMSoundMgrCodecStopCallback(int param);
+static int _MMSoundMgrCodecStopCallback(int param, bool stop_by_user);
 static gboolean _mm_sound_mgr_codec_slot_is_empty();
 
 static gboolean _idle_cb(gpointer user_data)
@@ -433,8 +431,6 @@ int MMSoundMgrCodecStop(const int slotid)
        debug_msg("Found slot, Slotid [%d] State [%d]", slotid, g_slots[slotid].status);
 #endif
 
-       g_slots[slotid].stop_by_user = true;
-
        err = g_plugins[g_slots[slotid].pluginid].Stop(g_slots[slotid].plughandle);
        if (err != MM_ERROR_NONE)
                debug_error("Fail to STOP Code : 0x%08X", err);
@@ -446,7 +442,7 @@ cleanup:
        return err;
 }
 
-static int _MMSoundMgrCodecStopCallback(int param)
+static int _MMSoundMgrCodecStopCallback(int param, bool stop_by_user)
 {
        int err = MM_ERROR_NONE;
 
@@ -455,9 +451,9 @@ static int _MMSoundMgrCodecStopCallback(int param)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       debug_enter("Slot(%d) : stop-by-user(%d)", param, g_slots[param].stop_by_user);
+       debug_enter("Slot(%d) : stop-by-user(%d)", param, stop_by_user);
 
-       if (!g_slots[param].stop_by_user) {
+       if (!stop_by_user) {
                SLOT_LOCK();
                __mm_sound_mgr_ipc_notify_play_file_end(param);
                debug_msg("Client callback msg_type (instance) : [%d]", (int)g_slots[param].param);
@@ -472,7 +468,7 @@ static int _MMSoundMgrCodecStopCallback(int param)
        if (_mm_sound_mgr_codec_slot_is_empty())
                _mm_sound_mgr_codec_shutdown_timer_start();
 
-       if (!g_slots[param].stop_by_user)
+       if (!stop_by_user)
                SLOT_UNLOCK();
 
        debug_fleave();