#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
#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
} 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) {
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
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;
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;
g_object_unref(conn);
return ret;
-}
\ No newline at end of file
+}
+#endif /* USE_PIPE */
#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)
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();