#include <mm_sound.h>
#include <vconf.h>
+#define STREAM_MEDIA "media"
+#define STREAM_SYSTEM "system"
+#define STREAM_ALARM "alarm"
+#define STREAM_NOTIFICATION "notification"
+#define STREAM_VOICE_INFORMATION "voice-information"
+#define STREAM_VOICE_RECOGNITION "voice-recognition"
+#define STREAM_VOICE_RECOGNITION_SERVICE "voice-recognition-service"
+#define STREAM_VOIP "voip"
+#define STREAM_CALL_VOICE "call-voice"
+#define STREAM_CALL_VIDEO "call-video"
+#define STREAM_RINGTONE_VOIP "ringtone-voip"
+#define STREAM_RINGTONE_CALL "ringtone-call"
+#define STREAM_RINGBACKTONE_CALL "ringbacktone-call"
+#define STREAM_EMERGENCY "emergency"
+#define STREAM_SOLO "solo"
+#define STREAM_RADIO "radio"
+#define STREAM_LOOPBACK "loopback"
+#define STREAM_LOOPBACK_MIRRORING "loopback-mirroring"
+#define STREAM_COMPRESSED_MEDIA "compressed-media"
+#define STREAM_NETWORK_SOURCE_MEDIA "network-source-media"
+#define STREAM_EXT_MEDIA "ext-media"
+
#define PA_BUS_NAME "org.pulseaudio.Server"
#define PA_STREAM_MANAGER_OBJECT_PATH "/org/pulseaudio/StreamManager"
#define PA_STREAM_MANAGER_METHOD_NAME_CHECK_STREAM_EXIST_BY_PID "CheckStreamExistByPid"
#define PA_STREAM_MANAGER_METHOD_NAME_ACTIVATE_DUCKING "ActivateDucking"
#define PA_STREAM_MANAGER_METHOD_NAME_GET_DUCKING_STATE "GetDuckingState"
+#define PA_STREAM_MANAGER_METHOD_NAME_GET_LASTEST_STREAM_PID "GetPidOfLatestStream"
#define PA_DEVICE_MANAGER_OBJECT_PATH "/org/pulseaudio/DeviceManager"
#define PA_DEVICE_MANAGER_INTERFACE "org.pulseaudio.DeviceManager"
switch (stream_type_enum) {
case SOUND_STREAM_TYPE_MEDIA:
- *stream_type = "media";
+ *stream_type = STREAM_MEDIA;
break;
case SOUND_STREAM_TYPE_SYSTEM:
- *stream_type = "system";
+ *stream_type = STREAM_SYSTEM;
break;
case SOUND_STREAM_TYPE_ALARM:
- *stream_type = "alarm";
+ *stream_type = STREAM_ALARM;
break;
case SOUND_STREAM_TYPE_NOTIFICATION:
- *stream_type = "notification";
+ *stream_type = STREAM_NOTIFICATION;
break;
case SOUND_STREAM_TYPE_EMERGENCY:
- *stream_type = "emergency";
+ *stream_type = STREAM_EMERGENCY;
break;
case SOUND_STREAM_TYPE_VOICE_INFORMATION:
- *stream_type = "voice-information";
+ *stream_type = STREAM_VOICE_INFORMATION;
break;
case SOUND_STREAM_TYPE_VOICE_RECOGNITION:
- *stream_type = "voice-recognition";
+ *stream_type = STREAM_VOICE_RECOGNITION;
break;
case SOUND_STREAM_TYPE_RINGTONE_VOIP:
- *stream_type = "ringtone-voip";
+ *stream_type = STREAM_RINGTONE_VOIP;
break;
case SOUND_STREAM_TYPE_VOIP:
- *stream_type = "voip";
+ *stream_type = STREAM_VOIP;
break;
case SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY:
- *stream_type = "ext-media";
+ *stream_type = STREAM_EXT_MEDIA;
break;
default:
//LCOV_EXCL_START
switch (stream_type_enum) {
case SOUND_STREAM_TYPE_RINGTONE_CALL:
- *stream_type = "ringtone-call";
+ *stream_type = STREAM_RINGTONE_CALL;
break;
case SOUND_STREAM_TYPE_RINGBACKTONE_CALL:
- *stream_type = "ringbacktone-call";
+ *stream_type = STREAM_RINGBACKTONE_CALL;
break;
case SOUND_STREAM_TYPE_VOICE_CALL:
- *stream_type = "call-voice";
+ *stream_type = STREAM_CALL_VOICE;
break;
case SOUND_STREAM_TYPE_VIDEO_CALL:
- *stream_type = "call-video";
+ *stream_type = STREAM_CALL_VIDEO;
break;
case SOUND_STREAM_TYPE_RADIO:
- *stream_type = "radio";
+ *stream_type = STREAM_RADIO;
break;
case SOUND_STREAM_TYPE_LOOPBACK:
- *stream_type = "loopback";
+ *stream_type = STREAM_LOOPBACK;
break;
case SOUND_STREAM_TYPE_LOOPBACK_MIRRORING:
- *stream_type = "loopback-mirroring";
+ *stream_type = STREAM_LOOPBACK_MIRRORING;
break;
case SOUND_STREAM_TYPE_SOLO:
- *stream_type = "solo";
+ *stream_type = STREAM_SOLO;
break;
case SOUND_STREAM_TYPE_VOICE_RECOGNITION_SERVICE:
- *stream_type = "voice-recognition-service";
+ *stream_type = STREAM_VOICE_RECOGNITION_SERVICE;
break;
case SOUND_STREAM_TYPE_MEDIA_COMPRESSED:
- *stream_type = "compressed-media";
+ *stream_type = STREAM_COMPRESSED_MEDIA;
break;
#ifndef TIZEN_FEATURE_TV_PROD
case SOUND_STREAM_TYPE_MEDIA_NETWORK_SOURCE:
- *stream_type = "network-source-media";
+ *stream_type = STREAM_NETWORK_SOURCE_MEDIA;
break;
#endif
default:
LOGE("invalid argument");
return;
}
- if (!strncmp(stream_info->stream_type, "solo", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_info->stream_type, "radio", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_info->stream_type, "loopback-mirroring", SOUND_STREAM_TYPE_LEN)) {
+ if (!strncmp(stream_info->stream_type, STREAM_SOLO, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_info->stream_type, STREAM_RADIO, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_info->stream_type, STREAM_LOOPBACK_MIRRORING, SOUND_STREAM_TYPE_LEN)) {
stream_info->is_focus_unavailable = true;
LOGI("this stream_type[%s] does not support focus", stream_info->stream_type);
}
SM_NULL_ARG_CHECK_FOR_PRIV(stream_type);
SM_NULL_ARG_CHECK_FOR_PRIV(change_reason);
- if (!strncmp(stream_type, "media", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "compressed-media", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "radio", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "loopback", SOUND_STREAM_TYPE_LEN)) {
+ if (!strncmp(stream_type, STREAM_MEDIA, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_type, STREAM_COMPRESSED_MEDIA, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_type, STREAM_RADIO, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_type, STREAM_LOOPBACK, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
- } else if (!strncmp(stream_type, "system", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_SYSTEM, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_SYSTEM;//LCOV_EXCL_LINE
- } else if (!strncmp(stream_type, "alarm", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_ALARM, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_ALARM;
- } else if (!strncmp(stream_type, "notification", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_NOTIFICATION, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION;
- } else if (!strncmp(stream_type, "emergency", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_EMERGENCY, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_EMERGENCY;//LCOV_EXCL_LINE
- } else if (!strncmp(stream_type, "voice-information", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_VOICE_INFORMATION, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION;//LCOV_EXCL_LINE
- } else if (!strncmp(stream_type, "voice-recognition", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "voice-recognition-service", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_VOICE_RECOGNITION, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_type, STREAM_VOICE_RECOGNITION_SERVICE, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_RECOGNITION;
- } else if (!strncmp(stream_type, "ringtone-voip", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "ringtone-call", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "ringbacktone-call", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_RINGTONE_VOIP, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_type, STREAM_RINGTONE_CALL, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_type, STREAM_RINGBACKTONE_CALL, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE;
- } else if (!strncmp(stream_type, "voip", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_VOIP, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_VOIP;
- } else if (!strncmp(stream_type, "call-voice", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "call-video", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_CALL_VOICE, SOUND_STREAM_TYPE_LEN) ||
+ !strncmp(stream_type, STREAM_CALL_VIDEO, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_CALL;//LCOV_EXCL_LINE
- } else if (!strncmp(stream_type, "ext-media", SOUND_STREAM_TYPE_LEN)) {
+ } else if (!strncmp(stream_type, STREAM_EXT_MEDIA, SOUND_STREAM_TYPE_LEN)) {
*change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA_EXTERNAL_ONLY;
} else {
return ret;
if (enable)
- stream_type = "media";
+ stream_type = STREAM_MEDIA;
else
stream_type = "none";
}
g_variant_get(result, "(&s)", &stream_type);
- if (!strncmp(stream_type, "media", SOUND_STREAM_TYPE_LEN))
+ if (!strncmp(stream_type, STREAM_MEDIA, SOUND_STREAM_TYPE_LEN))
*enabled = true;
else
*enabled = false;
return ret;
}
-//LCOV_EXCL_STOP
\ No newline at end of file
+
+int _get_latest_stream_pid(int stream_type, unsigned int *pid)
+{
+ int ret = MM_ERROR_NONE;
+ GDBusConnection *conn = NULL;
+ GError *err = NULL;
+ GVariant *result = NULL;
+ GVariantBuilder *builder_for_stream_types;
+ const gchar *dbus_ret = NULL;
+ unsigned int _pid;
+
+ SM_NULL_ARG_CHECK_FOR_PRIV(pid)
+
+ if ((ret = __get_dbus_connection(&conn)))
+ return ret;
+
+ builder_for_stream_types = g_variant_builder_new(G_VARIANT_TYPE("as"));
+ if (!builder_for_stream_types) {
+ LOGE("failed to g_variant_builder_new()");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto LEAVE;
+ }
+
+ if (stream_type & STREAM_TYPE_MEDIA)
+ g_variant_builder_add(builder_for_stream_types, "s", STREAM_MEDIA);
+ if (stream_type & STREAM_TYPE_SYSTEM)
+ g_variant_builder_add(builder_for_stream_types, "s", STREAM_SYSTEM);
+ if (stream_type & STREAM_TYPE_ALARM)
+ g_variant_builder_add(builder_for_stream_types, "s", STREAM_ALARM);
+ if (stream_type & STREAM_TYPE_NOTIFICATION)
+ g_variant_builder_add(builder_for_stream_types, "s", STREAM_NOTIFICATION);
+ if (stream_type & STREAM_TYPE_EMERGENCY)
+ g_variant_builder_add(builder_for_stream_types, "s", STREAM_EMERGENCY);
+ if (stream_type & STREAM_TYPE_VOICE_INFORMATION)
+ g_variant_builder_add(builder_for_stream_types, "s", STREAM_VOICE_INFORMATION);
+
+ result = g_dbus_connection_call_sync(conn,
+ PA_BUS_NAME,
+ PA_STREAM_MANAGER_OBJECT_PATH,
+ PA_STREAM_MANAGER_INTERFACE,
+ PA_STREAM_MANAGER_METHOD_NAME_GET_LASTEST_STREAM_PID,
+ g_variant_new("(sas)", "out", builder_for_stream_types),
+ G_VARIANT_TYPE("(us)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ 1000,
+ NULL,
+ &err);
+ if (!result || err) {
+ LOGE("g_dbus_connection_call_sync() for GET_LASTEST_STREAM_PID error");
+ ret = _convert_dbus_error(err ? err->message : NULL);
+ if (err)
+ g_error_free(err);
+ goto LEAVE;
+ }
+
+ g_variant_get(result, "(u&s)", &_pid, &dbus_ret);
+
+ LOGI("dbus return value is (%s)", dbus_ret);
+
+ if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+ *pid = _pid;
+ else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
+ ret = MM_ERROR_SOUND_NO_DATA;
+ else
+ ret = MM_ERROR_SOUND_INTERNAL;
+
+LEAVE:
+ if (builder_for_stream_types)
+ g_variant_builder_unref(builder_for_stream_types);
+ g_variant_unref(result);
+ g_object_unref(conn);
+
+ return ret;
+}
+//LCOV_EXCL_STOP
CURRENT_STATUS_SET_FILTER_PRESET,
CURRENT_STATUS_UNSET_FILTER,
CURRENT_STATUS_IS_STREAM_ON_DEVICE_BY_ID,
+ CURRENT_STATUS_GET_LATEST_STREAM_PID,
#ifndef TIZEN_FEATURE_TV_PROD
CURRENT_STATUS_GET_MAX_MASTER_VOLUME,
CURRENT_STATUS_SET_MASTER_VOLUME,
g_menu_state = CURRENT_STATUS_UNSET_FILTER;
else if (strncmp(cmd, "isd", MAX_CMD_LEN) == 0)
g_menu_state = CURRENT_STATUS_IS_STREAM_ON_DEVICE_BY_ID;
+ else if (strncmp(cmd, "gsp", MAX_CMD_LEN) == 0)
+ g_menu_state = CURRENT_STATUS_GET_LATEST_STREAM_PID;
#ifndef TIZEN_FEATURE_TV_PROD
else if (strncmp(cmd, "mgx", MAX_CMD_LEN) == 0)
g_menu_state = CURRENT_STATUS_GET_MAX_MASTER_VOLUME;
g_print("sfp. *Set Filter Preset\t");
g_print("uft. *Unset Filter\n");
g_print("isd. *Is Stream on Device by ID\n");
+ g_print("gsp. *Get PID of the Latest Stream\n");
#ifndef TIZEN_FEATURE_TV_PROD
g_print("acm. *Set ACM Master mode\n");
#endif
g_print("*** press enter to unset filter of media stream\n");
else if (g_menu_state == CURRENT_STATUS_IS_STREAM_ON_DEVICE_BY_ID)
g_print("*** input device id\n");
+ else if (g_menu_state == CURRENT_STATUS_GET_LATEST_STREAM_PID)
+ g_print("*** input stream types of candidates (0:media, 1:voice-information, 2:notification, 3:media + voice-information, 4:media + voice-information + notification)\n");
#ifndef TIZEN_FEATURE_TV_PROD
else if (g_menu_state == CURRENT_STATUS_GET_MAX_MASTER_VOLUME)
g_print("*** press enter to get max master volume level\n");
reset_menu_state();
break;
}
+ case CURRENT_STATUS_GET_LATEST_STREAM_PID: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int selection = 0;
+ int stream_type = 0;
+ unsigned int pid;
+ selection = atoi(cmd);
+
+ if (selection == 0)
+ stream_type |= STREAM_TYPE_MEDIA;
+ else if (selection == 1)
+ stream_type |= STREAM_TYPE_VOICE_INFORMATION;
+ else if (selection == 2)
+ stream_type |= STREAM_TYPE_NOTIFICATION;
+ else if (selection == 3)
+ stream_type |= (STREAM_TYPE_MEDIA | STREAM_TYPE_VOICE_INFORMATION);
+ else if (selection == 4)
+ stream_type |= (STREAM_TYPE_MEDIA | STREAM_TYPE_VOICE_INFORMATION | STREAM_TYPE_NOTIFICATION);
+
+ ret = sound_manager_get_latest_stream_pid(stream_type, &pid);
+ if (ret)
+ g_print("fail to sound_manager_get_latest_stream_pid(), stream_type(0x%x), ret(0x%x)\n", stream_type, ret);
+ else
+ g_print("PID of the latest stream is (%u)\n", pid);
+ reset_menu_state();
+ break;
+ }
#ifndef TIZEN_FEATURE_TV_PROD
case CURRENT_STATUS_GET_MAX_MASTER_VOLUME: {
int max_level;