Fix mismatching function prototype 59/228759/3 submit/tizen/20200326.082511
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 25 Mar 2020 08:13:34 +0000 (17:13 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Thu, 26 Mar 2020 04:34:36 +0000 (13:34 +0900)
avoid unexpected complete callback for tone playback
fixup missing data type for volume_type in internal keysound function

[Version] 0.12.67
[Issue Type] Bug

Change-Id: I3bf44c8abcbd239ae867ba427d193268729762ee

mm_sound_keysound.c
packaging/libmm-sound.spec
server/mm_sound_mgr_codec.c
server/plugin/tone/mm_sound_plugin_codec_tone.c

index 38f4a0b..397ce17 100644 (file)
 #include <memory.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <vconf.h>
-
-#include <gio/gio.h>
 
 #include <mm_error.h>
 #include <mm_debug.h>
 #include <mm_sound.h>
+#include <glib.h>
 
 #include "include/mm_sound_common.h"
 
 #define PULSEAUDIO_READY "/tmp/.pulseaudio_ready"
 #endif
 
-#define PA_BUS_NAME                                 "org.pulseaudio.Server"
-#define PA_SOUND_PLAYER_OBJECT_PATH                 "/org/pulseaudio/SoundPlayer"
-#define PA_SOUND_PLAYER_INTERFACE                   "org.pulseaudio.SoundPlayer"
 #define PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_PLAY     "SimplePlay"
 #define PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP     "SimpleStop"
 #define PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP_ALL "SimpleStopAll"
-#define PA_SOUND_RESPONSE_TIMEOUT                   2000
+
+#define AUDIO_VOLUME_CONFIG_TYPE(vol) (vol & 0x00FF)
+#define AUDIO_VOLUME_CONFIG_GAIN(vol) (vol & 0xFF00)
+
+#define USE_PIPE /* default is pipe now */
+
+#ifdef USE_PIPE
 
 #define KEYTONE_PATH "/tmp/keytone"
 #define FILENAME_LEN 1024
@@ -52,9 +53,6 @@
 #define VOLUME_GAIN_TYPE_LEN 32
 #define METHOD_LEN 32
 
-#define AUDIO_VOLUME_CONFIG_TYPE(vol) (vol & 0x00FF)
-#define AUDIO_VOLUME_CONFIG_GAIN(vol) (vol & 0xFF00)
-
 #define MAX_WRITE_RETRY 50
 #define WRITE_RETRY_INTERVAL_MS 20
 
@@ -66,9 +64,18 @@ typedef struct ipc_data {
 } ipc_t;
 
 static int __mm_sound_simple_pipe(const char *filename, int volume_config, const char *method);
+#else /* USE_PIPE */
+#include <gio/gio.h>
+
+#define PA_BUS_NAME                                 "org.pulseaudio.Server"
+#define PA_SOUND_PLAYER_OBJECT_PATH                 "/org/pulseaudio/SoundPlayer"
+#define PA_SOUND_PLAYER_INTERFACE                   "org.pulseaudio.SoundPlayer"
+#define PA_SOUND_RESPONSE_TIMEOUT                   2000
+
 static int __mm_sound_simple_dbus(const char *filename, int volume_config, const char *method);
+#endif /* USE_PIPE */
 
-static const char* __convert_volume_type_to_role(volume_type)
+static const char* __convert_volume_type_to_role(int volume_type)
 {
        debug_log("volume_type(%d)", volume_type);
        switch (volume_type) {
@@ -124,14 +131,23 @@ static const char* __convert_volume_gain_type_to_string(int volume_gain_type)
 EXPORT_API
 int mm_sound_play_keysound(const char *filename, int volume_config)
 {
+#ifdef USE_PIPE
        return __mm_sound_simple_pipe(filename, volume_config, PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_PLAY);
+#else
+       return __mm_sound_simple_dbus(filename, volume_config, PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_PLAY);
+#endif
 }
 
 EXPORT_API
 int mm_sound_stop_keysound(const char *filename)
 {
+#ifdef USE_PIPE
        return __mm_sound_simple_pipe(filename, 0,
                        (filename) ? PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP : PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP_ALL);
+#else
+       return __mm_sound_simple_dbus(filename, 0,
+                       (filename) ? PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP : PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP_ALL);
+#endif
 }
 
 #ifdef USE_LWIPC
@@ -171,6 +187,7 @@ static int __verify_input_file(const char *filename)
        return MM_ERROR_NONE;
 }
 
+#ifdef USE_PIPE
 static int __mm_sound_simple_pipe(const char *filename, int volume_config, const char *method)
 {
        int ret = MM_ERROR_NONE;
@@ -250,8 +267,9 @@ static int __mm_sound_simple_pipe(const char *filename, int volume_config, const
        close(fd);
 
        return ret;
-       }
+}
 
+#else /* USE_PIPE */
 static int __mm_sound_simple_dbus(const char *filename, int volume_config, const char *method)
 {
        int ret = MM_ERROR_NONE;
@@ -354,4 +372,5 @@ END:
                g_object_unref(conn);
 
        return ret;
-}
\ No newline at end of file
+}
+#endif /* USE_PIPE */
index f1cdb55..e27a814 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.12.66
+Version:    0.12.67
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index c2c968b..9b85863 100644 (file)
@@ -82,7 +82,7 @@ static guint g_timer_id = 0;
 #endif
 
 static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin);
-static int _MMSoundMgrCodecStopCallback(int param, bool stop_by_user);
+static int _MMSoundMgrCodecStopCallback(int slotid, bool stop_by_user);
 static gboolean _mm_sound_mgr_codec_slot_is_empty();
 
 static gboolean _idle_cb(gpointer user_data)
@@ -442,29 +442,33 @@ cleanup:
        return err;
 }
 
-static int _MMSoundMgrCodecStopCallback(int param, bool stop_by_user)
+static int _MMSoundMgrCodecStopCallback(int slotid, bool stop_by_user)
 {
        int err = MM_ERROR_NONE;
 
-       if (param < 0 || param >= MANAGER_HANDLE_MAX) {
-               debug_error("Slot(%d) is invalid", param);
+       if (slotid < 0 || slotid >= MANAGER_HANDLE_MAX) {
+               debug_error("Slot(%d) is invalid", slotid);
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       debug_enter("Slot(%d) : stop-by-user(%d)", param, stop_by_user);
+       debug_enter("Slot(%d) : stop-by-user(%d)", slotid, stop_by_user);
 
        if (!stop_by_user) {
+               /* NOTE : slot is already locked by MMSoundMgrCodecStop() in user stop case */
                SLOT_LOCK();
-               __mm_sound_mgr_ipc_notify_play_file_end(param);
-               debug_msg("Client callback msg_type (instance) : [%d]", (int)g_slots[param].param);
+
+               if (g_slots[slotid].pluginid == MM_SOUND_SUPPORTED_CODEC_WAVE)
+                       __mm_sound_mgr_ipc_notify_play_file_end(slotid);
+
+               debug_msg("Client callback msg_type (instance) : [%d]", (int)g_slots[slotid].param);
        }
 
-       debug_msg("Handle allocated handle : [%p]", g_slots[param].plughandle);
-       err = g_plugins[g_slots[param].pluginid].Destroy(g_slots[param].plughandle);
+       debug_msg("Handle allocated handle : [%p]", g_slots[slotid].plughandle);
+       err = g_plugins[g_slots[slotid].pluginid].Destroy(g_slots[slotid].plughandle);
        if (err < 0)
-               debug_critical("Slot(%d) : Fail to destroy slot, err [0x%x]", param, err);
+               debug_critical("Slot(%d) : Fail to destroy slot, err [0x%x]", slotid, err);
 
-       _mm_sound_mgr_codec_slot_clear(param, true);
+       _mm_sound_mgr_codec_slot_clear(slotid, true);
        if (_mm_sound_mgr_codec_slot_is_empty())
                _mm_sound_mgr_codec_shutdown_timer_start();
 
index aa403fd..a8f0d50 100644 (file)
@@ -95,7 +95,7 @@ typedef struct {
 
        /* control Informations */
        int repeat_count;
-       int (*stop_cb)(int);
+       int (*stop_cb)(int, bool);
        int cb_param;
        int state;
        int number;
@@ -1155,7 +1155,7 @@ exit:
        pthread_mutex_unlock(&toneInfo->mutex);
 
        if (toneInfo->stop_cb)
-               toneInfo->stop_cb(toneInfo->cb_param);
+               toneInfo->stop_cb(toneInfo->cb_param, false);
 
        debug_leave();
 }