From: Sangchul Lee Date: Fri, 5 Apr 2019 01:42:31 +0000 (+0900) Subject: Add internal API to get the pid of the latest stream X-Git-Tag: accepted/tizen/unified/20191224.131822~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5a027c76cac715cd5200bb796f0fdb11b31440d;p=platform%2Fcore%2Fapi%2Fsound-manager.git Add internal API to get the pid of the latest stream - int sound_manager_get_latest_stream_pid(int stream_type, unsigned int *pid) [Version] 0.6.0 [Issue Type] New feature Change-Id: I39013f1bb6297a5b47c3d75e52f12460800c07bb Signed-off-by: Sangchul Lee --- diff --git a/include/sound_manager_internal.h b/include/sound_manager_internal.h index e684544..87425c2 100644 --- a/include/sound_manager_internal.h +++ b/include/sound_manager_internal.h @@ -826,6 +826,7 @@ int sound_manager_get_device_vendor_id(sound_device_h device, int *vendor_id); int sound_manager_get_device_product_id(sound_device_h device, int *product_id); /** + * @internal * @brief Checks if the stream information is using the device. * @since_tizen 5.5 * @@ -864,6 +865,40 @@ int sound_manager_is_stream_on_device_by_id(sound_stream_info_h stream_info, int int sound_manager_set_acm_master_mode(bool enable); /** + * @internal + * @brief Enumeration for stream type. + * @since_tizen 6.0 + * @remarks These values can be combined with bitwise 'or'. + * @see sound_manager_get_latest_stream_pid() + */ +typedef enum { + STREAM_TYPE_MEDIA = 0x0001, + STREAM_TYPE_SYSTEM = 0x0002, + STREAM_TYPE_ALARM = 0x0004, + STREAM_TYPE_NOTIFICATION = 0x0008, + STREAM_TYPE_EMERGENCY = 0x0010, + STREAM_TYPE_VOICE_INFORMATION = 0x0020 +} stream_type_e; + +/** + * @internal + * @brief Gets the PID of the latest stream among the streams of specific types. + * @since_tizen 6.0 + * + * @remarks If there is no satisfied stream in the system, it'll return #SOUND_MANAGER_ERROR_NO_DATA.\n + * + * @param[in] stream_type The requested stream type that should be searched, values of #stream_type_e combined with bitwise 'or' + * @param[out] pid The PID of the latest stream of the requested stream types among all the streams which are alive. + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #SOUND_MANAGER_ERROR_NO_DATA No data + */ +int sound_manager_get_latest_stream_pid(int stream_type, unsigned int *pid); + +/** * @} */ diff --git a/include/sound_manager_internal_tv.h b/include/sound_manager_internal_tv.h index c3fb40a..8d266b7 100644 --- a/include/sound_manager_internal_tv.h +++ b/include/sound_manager_internal_tv.h @@ -763,6 +763,7 @@ int sound_manager_get_device_vendor_id(sound_device_h device, int *vendor_id); int sound_manager_get_device_product_id(sound_device_h device, int *product_id); /** + * @internal * @brief Checks if the stream information is using the device. * @since_tizen 5.5 * @@ -786,6 +787,40 @@ int sound_manager_get_device_product_id(sound_device_h device, int *product_id); int sound_manager_is_stream_on_device_by_id(sound_stream_info_h stream_info, int device_id, bool *is_on); /** + * @internal + * @brief Enumeration for stream type. + * @since_tizen 6.0 + * @remarks These values can be combined with bitwise 'or'. + * @see sound_manager_get_latest_stream_pid() + */ +typedef enum { + STREAM_TYPE_MEDIA = 0x0001, + STREAM_TYPE_SYSTEM = 0x0002, + STREAM_TYPE_ALARM = 0x0004, + STREAM_TYPE_NOTIFICATION = 0x0008, + STREAM_TYPE_EMERGENCY = 0x0010, + STREAM_TYPE_VOICE_INFORMATION = 0x0020 +} stream_type_e; + +/** + * @internal + * @brief Gets the PID of the latest stream among the streams of specific types. + * @since_tizen 6.0 + * + * @remarks If there is no satisfied stream in the system, it'll return #SOUND_MANAGER_ERROR_NO_DATA.\n + * + * @param[in] stream_type The requested stream type that should be searched, values of #stream_type_e combined with bitwise 'or' + * @param[out] pid The PID of the latest stream of the requested stream types among all the streams which are alive. + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #SOUND_MANAGER_ERROR_NO_DATA No data + */ +int sound_manager_get_latest_stream_pid(int stream_type, unsigned int *pid); + +/** * @} */ diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index 3019971..04871b5 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -379,6 +379,8 @@ int _set_preferred_device_id(sound_stream_info_s *stream_info, sound_device_io_d int _get_preferred_device(sound_stream_info_s *stream_info, int *in_device_id, int *out_device_id); +int _get_latest_stream_pid(int stream_type, unsigned int *pid); + #ifdef __cplusplus } #endif diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index a447d69..514d5a2 100644 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.5.46 +Version: 0.6.0 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index eee36b4..c9aba4c 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -713,7 +713,23 @@ int sound_manager_set_acm_master_mode(bool enable) { int ret = MM_ERROR_NONE; + LOGI(">> enter"); + ret = _set_acm_master_mode(enable); return _convert_sound_manager_error_code(__func__, ret); } + +int sound_manager_get_latest_stream_pid(int stream_type, unsigned int *pid) +{ + int ret = MM_ERROR_NONE; + + LOGI(">> enter, stream_type(0x%x)", stream_type); + + SM_NULL_ARG_CHECK(pid); + SM_NULL_ARG_CHECK(stream_type); + + ret = _get_latest_stream_pid(stream_type, pid); + + return _convert_sound_manager_error_code(__func__, ret); +} \ No newline at end of file diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 3930c5b..7c70e2f 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -19,6 +19,28 @@ #include #include +#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" @@ -38,6 +60,7 @@ #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" @@ -163,34 +186,34 @@ int _convert_stream_type(sound_stream_type_e stream_type_enum, char **stream_typ 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 @@ -214,38 +237,38 @@ int _convert_stream_type_for_internal(sound_stream_type_internal_e stream_type_e 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: @@ -264,9 +287,9 @@ void _set_focus_availability(sound_stream_info_s *stream_info) 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); } @@ -280,44 +303,44 @@ int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_ 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 { @@ -1881,7 +1904,7 @@ int _set_media_stream_only(int device_id, bool enable) return ret; if (enable) - stream_type = "media"; + stream_type = STREAM_MEDIA; else stream_type = "none"; @@ -1940,7 +1963,7 @@ int _get_media_stream_only(int device_id, bool *enabled) } 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; @@ -3116,4 +3139,78 @@ LEAVE: 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 diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index 034e43f..b01e71b 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -97,6 +97,7 @@ enum { 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, @@ -337,6 +338,8 @@ void _interpret_main_menu(char *cmd) 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; @@ -455,6 +458,7 @@ void display_sub_basic() 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 @@ -606,6 +610,8 @@ static void displaymenu() 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"); @@ -2312,6 +2318,32 @@ static void interpret(char *cmd) 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;