#define AUDIO_VOLUME_CONFIG_TYPE(vol) (vol & 0x00FF)
#define AUDIO_VOLUME_CONFIG_GAIN(vol) (vol & 0xFF00)
+#define FILENAME_LEN 1024
+#define MIN_KEYTONE_INTERVAL_US 30000
+#define NO_PRIORITY (-1)
+
#define USE_PIPE /* default is pipe now */
#ifdef USE_PIPE
#define KEYTONE_PATH "/tmp/keytone"
-#define FILENAME_LEN 1024
#define ROLE_LEN 64
#define VOLUME_GAIN_TYPE_LEN 32
#define METHOD_LEN 32
#define MAX_WRITE_RETRY 50
#define WRITE_RETRY_INTERVAL_MS 20
-#define MIN_KEYTONE_INTERVAL_US 30000
+#define MM_SOUND_SIMPLE __mm_sound_simple_pipe
typedef struct ipc_data {
char filename[FILENAME_LEN];
char role[ROLE_LEN];
char volume_gain_type[VOLUME_GAIN_TYPE_LEN];
char method[METHOD_LEN];
+ int priority; /* lower as a higher priority, -1 for no priority (= don't care) */
} ipc_t;
-static int __mm_sound_simple_pipe(const char *filename, int volume_config, const char *method);
+static int __mm_sound_simple_pipe(const char *filename, int volume_config, int priority, const char *method);
+
#else /* USE_PIPE */
+
#include <gio/gio.h>
#define PA_BUS_NAME "org.pulseaudio.Server"
#define PA_SOUND_PLAYER_INTERFACE "org.pulseaudio.SoundPlayer"
#define PA_SOUND_RESPONSE_TIMEOUT 5000
-static int __mm_sound_simple_dbus(const char *filename, int volume_config, const char *method);
+#define MM_SOUND_SIMPLE __mm_sound_simple_dbus
+
+static int __mm_sound_simple_dbus(const char *filename, int volume_config, int priority, const char *method);
#endif /* USE_PIPE */
static const char* __convert_volume_type_to_role(int volume_type)
}
EXPORT_API
-int mm_sound_play_keysound(const char *filename, int volume_config)
+int mm_sound_play_keysound_priority(const char *filename, int volume_config, int priority)
{
#ifndef TIZEN_TV
if (__is_interval_too_short(filename)) {
}
#endif
-#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
+ return MM_SOUND_SIMPLE(filename, volume_config, priority, PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_PLAY);
+}
+
+EXPORT_API
+int mm_sound_play_keysound(const char *filename, int volume_config)
+{
+ return mm_sound_play_keysound_priority(filename, volume_config, NO_PRIORITY);
}
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
+ return MM_SOUND_SIMPLE(filename, 0, NO_PRIORITY,
+ filename ? PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP : PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP_ALL);
}
#ifdef USE_LWIPC
}
#ifdef USE_PIPE
-static int __mm_sound_simple_pipe(const char *filename, int volume_config, const char *method)
+static int __mm_sound_simple_pipe(const char *filename, int volume_config, int priority, const char *method)
{
int ret = MM_ERROR_NONE;
int retry_remaining = MAX_WRITE_RETRY;
g_strlcpy(data.volume_gain_type,
__convert_volume_gain_type_to_string(AUDIO_VOLUME_CONFIG_GAIN(volume_config)),
VOLUME_GAIN_TYPE_LEN);
+ data.priority = priority;
}
- debug_msg("filepath=[%s], role=[%s], volume_gain_type=[%s], method=[%s]",
- data.filename, data.role, data.volume_gain_type, data.method);
+ debug_msg("filepath=[%s], role=[%s], volume_gain_type=[%s], priority=[%d], method=[%s]",
+ data.filename, data.role, data.volume_gain_type, data.priority, data.method);
/* Open PIPE */
fd = open(KEYTONE_PATH, O_WRONLY | O_NONBLOCK);
}
#else /* USE_PIPE */
-static int __mm_sound_simple_dbus(const char *filename, int volume_config, const char *method)
+static int __mm_sound_simple_dbus(const char *filename, int volume_config, int priority, const char *method)
{
int ret = MM_ERROR_NONE;
const char *role = NULL;
PA_SOUND_PLAYER_OBJECT_PATH,
PA_SOUND_PLAYER_INTERFACE,
PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_PLAY,
- g_variant_new("(sss)", filename, role, vol_gain_type),
+ g_variant_new("(sssi)", filename, role, vol_gain_type, priority),
NULL, G_DBUS_CALL_FLAGS_NONE, PA_SOUND_RESPONSE_TIMEOUT, NULL, &err);
if (!result || err) {
debug_error("g_dbus_connection_call_sync() for %s error (%s)", method, err ? err->message : NULL);
g_variant_get(result, "(i)", &idx);
if (idx == -1) {
- debug_error("[%s] failure, filename(%s)/role(%s)/gain(%s)/stream idx(%d)",
- method, filename, role, vol_gain_type, idx);
+ debug_error("[%s] failure, filename(%s)/role(%s)/gain(%s)/priority(%d)/stream idx(%d)",
+ method, filename, role, vol_gain_type, priority, idx);
ret = MM_ERROR_SOUND_INTERNAL;
goto END;
}
- debug_msg("[%s] success, filename(%s)/role(%s)/gain(%s)/stream idx(%d)",
- method, filename, role, vol_gain_type, idx);
+ debug_msg("[%s] success, filename(%s)/role(%s)/gain(%s)/priority(%d),stream idx(%d)",
+ method, filename, role, vol_gain_type, priority, idx);
} else if (g_strcmp0(method, PA_SOUND_PLAYER_METHOD_NAME_SIMPLE_STOP) == 0) {
ret = __verify_input_file(filename);