/**
* @internal
- * @brief Adds the option to the stream information for the stream routing.
- * @since_tizen 3.0
- * @param[in] stream_info The handle of stream information
- * @param[in] option The option for the stream routing
- *
- * @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_INTERNAL Internal error inside the sound system
- * @pre Call sound_manager_create_stream_information() or sound_manager_create_stream_information_internal() before calling this function.
- * @post You can apply this setting by calling sound_manager_apply_stream_routing_options().
- * @see sound_manager_create_stream_information()
- * @see sound_manager_create_stream_information_internal()
- * @see sound_manager_destroy_stream_information()
- * @see sound_manager_remove_option_for_stream_routing()
- * @see sound_manager_apply_stream_routing_options()
- */
-int sound_manager_add_option_for_stream_routing (sound_stream_info_h stream_info, const char *option);
-
-/**
- * @internal
- * @brief Removes the option to the stream information for the stream routing.
- * @since_tizen 3.0
- * @param[in] stream_info The handle of stream information
- * @param[in] option The option for the stream routing
- *
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre Call sound_manager_create_stream_information()/sound_manager_add_option_for_stream_routing() before calling this function.
- * @post You can apply this setting by calling sound_manager_apply_stream_routing_options().
- * @see sound_manager_create_stream_information()
- * @see sound_manager_create_stream_information_internal()
- * @see sound_manager_destroy_stream_information()
- * @see sound_manager_remove_option_for_stream_routing()
- * @see sound_manager_apply_stream_routing_options()
- */
-int sound_manager_remove_option_for_stream_routing (sound_stream_info_h stream_info, const char *option);
-
-/**
- * @internal
- * @brief Applies the stream routing options.
+ * @brief Sets the stream routing option.
* @since_tizen 3.0
* @param[in] stream_info The handle of stream information
+ * @param[in] name The name of option
+ * @param[in] value The value of option
*
* @remarks @a If the stream has not been made yet, this setting will be applied when the stream starts to play.\n
*
* otherwise a negative error value
* @retval #SOUND_MANAGER_ERROR_NONE Success
* @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @pre Call sound_manager_create_stream_information()/sound_manager_add_option_for_stream_routing() before calling this function.
+ * @pre Call sound_manager_create_stream_information() before calling this function.
* @see sound_manager_create_stream_information()
* @see sound_manager_create_stream_information_internal()
* @see sound_manager_destroy_stream_information()
- * @see sound_manager_add_option_for_stream_routing()
- * @see sound_manager_remove_option_for_stream_routing()
*/
-int sound_manager_apply_stream_routing_options (sound_stream_info_h stream_info);
+int sound_manager_set_stream_routing_option (sound_stream_info_h stream_info, const char *name, int value);
/**
* @internal
} stream_route_type;
#define AVAIL_DEVICES_MAX 16
#define AVAIL_FRAMEWORKS_MAX 16
-#define ROUTE_OPTIONS_MAX 16
typedef struct _stream_conf_info_s {
int priority;
sound_stream_focus_state_changed_cb user_cb;
void *user_data;
manual_route_info_s manual_route_info;
- char *route_options[ROUTE_OPTIONS_MAX];
} sound_stream_info_s;
sound_stream_info_s *sound_stream_info_arr[SOUND_STREAM_INFO_ARR_MAX];
int __set_manual_route_info (unsigned int index, manual_route_info_s *info);
-int __set_route_options (unsigned int index, char **route_options);
+int __set_route_option (unsigned int index, const char *key, int value);
int __convert_sound_type (sound_type_e sound_type, const char **volume_type);
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.3.12
+Version: 0.3.13
Release: 0
Group: Multimedia/API
License: Apache-2.0
return __convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_add_option_for_stream_routing (sound_stream_info_h stream_info, const char *option)
-{
- int ret = MM_ERROR_NONE;
- int i = 0;
- bool added_successfully = false;
- sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
-
- LOGI(">> enter");
-
- SM_INSTANCE_CHECK(stream_h);
- SM_NULL_ARG_CHECK(option);
-
- for (i = 0; i < ROUTE_OPTIONS_MAX; i++) {
- if (stream_h->route_options[i]) {
- if (!strncmp (stream_h->route_options[i], option, strlen(option))) {
- return __convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
- }
- continue;
- } else {
- stream_h->route_options[i] = strdup(option);
- added_successfully = true;
- break;
- }
- }
-
- if (!added_successfully) {
- ret = MM_ERROR_SOUND_INTERNAL;
- }
-
- LOGI("<< leave : ret(%p)", ret);
-
- return __convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_remove_option_for_stream_routing (sound_stream_info_h stream_info, const char *option)
-{
- int ret = MM_ERROR_NONE;
- int i = 0;
- bool removed_successfully = false;
- sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
-
- LOGI(">> enter");
-
- SM_INSTANCE_CHECK(stream_h);
- SM_NULL_ARG_CHECK(option);
-
- for (i = 0; i < ROUTE_OPTIONS_MAX; i++) {
- if (stream_h->route_options[i] && !strncmp (stream_h->route_options[i], option, strlen(option))) {
- free(stream_h->route_options[i]);
- stream_h->route_options[i] = NULL;
- removed_successfully = true;
- break;
- }
- }
-
- if (!removed_successfully) {
- ret = MM_ERROR_INVALID_ARGUMENT;
- }
-
- LOGI("<< leave : ret(%p)", ret);
-
- return __convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_apply_stream_routing_options (sound_stream_info_h stream_info)
+int sound_manager_set_stream_routing_option (sound_stream_info_h stream_info, const char *name, int value)
{
int ret = MM_ERROR_NONE;
int i = 0;
LOGI(">> enter");
SM_INSTANCE_CHECK(stream_h);
+ SM_NULL_ARG_CHECK(name);
- for (i = 0; i < ROUTE_OPTIONS_MAX; i++) {
- if (stream_h->route_options[i]) {
- need_to_apply = true;
- break;
- }
- }
- if (need_to_apply) {
- ret = __set_route_options(stream_h->index, stream_h->route_options);
- } else {
- __convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INTERNAL);
- }
+ ret = __set_route_option(stream_h->index, name, value);
LOGI("<< leave : ret(%p)", ret);
#define PA_STREAM_MANAGER_INTERFACE "org.pulseaudio.StreamManager"
#define PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_INFO "GetStreamInfo"
#define PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_DEVICES "SetStreamRouteDevices"
-#define PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_OPTIONS "SetStreamRouteOptions"
+#define PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_OPTION "SetStreamRouteOption"
#define PA_STREAM_MANAGER_METHOD_NAME_GET_VOLUME_MAX_LEVEL "GetVolumeMaxLevel"
#define PA_STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE "GetCurrentVolumeType"
return ret;
}
-int __set_route_options (unsigned int index, char **route_options)
+int __set_route_option (unsigned int index, const char *name, int value)
{
int ret = MM_ERROR_NONE;
int i = 0;
- GVariantBuilder *builder;
GVariant *result = NULL;
GDBusConnection *conn = NULL;
GError *err = NULL;
- assert(route_options);
+ assert(name);
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
return MM_ERROR_SOUND_INTERNAL;
}
- builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
- for (i = 0; i < ROUTE_OPTIONS_MAX; i++) {
- if (route_options[i]) {
- g_variant_builder_add(builder, "s", route_options[i]);
- LOGI("[OPTIONS] %s", route_options[i]);
- } else {
- break;
- }
- }
+ LOGI("[OPTION] %s(%d)", name, value);
+
result = g_dbus_connection_call_sync (conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
- PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_OPTIONS,
- g_variant_new ("(uas)", index, builder),
+ PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_OPTION,
+ g_variant_new ("(usi)", index, name, value),
G_VARIANT_TYPE("(s)"),
G_DBUS_CALL_FLAGS_NONE,
2000,
const gchar *dbus_ret = NULL;
g_variant_get(result, "(&s)", &dbus_ret);
LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
- if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+ if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret))) {
+ ret = MM_ERROR_SOUND_INVALID_STATE;
+ } else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
ret = MM_ERROR_SOUND_INTERNAL;
}
g_variant_unref(result);
}
- g_variant_builder_unref(builder);
g_object_unref(conn);
return ret;
}
free(stream_h->stream_conf_info.avail_frameworks[i]);
}
}
- for (i = 0; i < ROUTE_OPTIONS_MAX; i++) {
- if (stream_h->route_options[i]) {
- free(stream_h->route_options[i]);
- }
- }
+
for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
if (sound_stream_info_arr[i] && sound_stream_info_arr[i]->index == stream_h->index) {
sound_stream_info_arr[i] = NULL;
CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING,
CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING,
CURRENT_STATUS_APPLY_STREAM_ROUTING,
- CURRENT_STATUS_ADD_OPTION_FOR_STREAM_ROUTING,
- CURRENT_STATUS_REMOVE_OPTION_FOR_STREAM_ROUTING,
- CURRENT_STATUS_APPLY_STREAM_ROUTING_OPTIONS,
+ CURRENT_STATUS_SET_STREAM_ROUTING_OPTION,
CURRENT_STATUS_ACQUIRE_FOCUS,
CURRENT_STATUS_RELEASE_FOCUS,
CURRENT_STATUS_GET_ACQUIRED_FOCUS,
{
g_menu_state = CURRENT_STATUS_APPLY_STREAM_ROUTING;
}
- else if (strncmp(cmd, "aos", 3) == 0 )
+ else if (strncmp(cmd, "sso", 3) == 0 )
{
- g_menu_state = CURRENT_STATUS_ADD_OPTION_FOR_STREAM_ROUTING;
- }
- else if (strncmp(cmd, "ros", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_REMOVE_OPTION_FOR_STREAM_ROUTING;
- }
- else if (strncmp(cmd, "aso", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_APPLY_STREAM_ROUTING_OPTIONS;
+ g_menu_state = CURRENT_STATUS_SET_STREAM_ROUTING_OPTION;
}
else if (strncmp(cmd, "afc", 3) == 0 )
{
g_print("gfs. Get Focus State\n");
g_print("sfw. Set Focus State Watch CB\t");
g_print("ufw. Unset Focus State Watch CB\n");
- g_print("aos. *Add option for stream routing\t");
- g_print("ros. *Remove option for stream routing\t");
- g_print("aso. *Apply options for stream routing\n");
+ g_print("sso. *Set option for stream routing\n");
g_print("vcr. *Create VStream\t");
g_print("vsr. *Start VStream\t");
g_print("vst. *Stop VStream\t");
{
g_print("*** press enter to apply devices for stream routing\n");
}
- else if (g_menu_state == CURRENT_STATUS_ADD_OPTION_FOR_STREAM_ROUTING)
- {
- g_print("*** input option to add\n");
- }
- else if (g_menu_state == CURRENT_STATUS_REMOVE_OPTION_FOR_STREAM_ROUTING)
- {
- g_print("*** input option to remove\n");
- }
- else if (g_menu_state == CURRENT_STATUS_APPLY_STREAM_ROUTING_OPTIONS)
+ else if (g_menu_state == CURRENT_STATUS_SET_STREAM_ROUTING_OPTION)
{
- g_print("*** press enter to apply options for stream routing \n");
+ g_print("*** input option(name/value) for routing (0:option_1/0, 1:option_1/1, 2:option_2/0, 3:option_2:1)\n");
}
else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS)
{
reset_menu_state();
}
break;
- case CURRENT_STATUS_ADD_OPTION_FOR_STREAM_ROUTING:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- ret = sound_manager_add_option_for_stream_routing (g_stream_info_h, cmd);
- if (ret) {
- g_print("failed to sound_manager_add_option_for_stream_routing(), ret(0x%x)\n", ret);
- }
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_REMOVE_OPTION_FOR_STREAM_ROUTING:
+ case CURRENT_STATUS_SET_STREAM_ROUTING_OPTION:
{
int ret = SOUND_MANAGER_ERROR_NONE;
- ret = sound_manager_remove_option_for_stream_routing (g_stream_info_h, cmd);
- if (ret) {
- g_print("failed to sound_manager_remove_option_for_stream_routing(), ret(0x%x)\n", ret);
+ int selection = 0;
+ char *name = NULL;
+ int value = -1;
+ selection = atoi(cmd);
+ switch(selection) {
+ case 0:
+ name = "option_1";
+ value = 0;
+ break;
+ case 1:
+ name = "option_1";
+ value = 1;
+ break;
+ case 2:
+ name = "option_2";
+ value = 0;
+ break;
+ case 3:
+ name = "option_2";
+ value = 1;
+ break;
+ default:
+ g_print("invalid argument, try again..\n");
+ reset_menu_state();
+ break;
}
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_APPLY_STREAM_ROUTING_OPTIONS:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- ret = sound_manager_apply_stream_routing_options (g_stream_info_h);
+ ret = sound_manager_set_stream_routing_option (g_stream_info_h, name, value);
if (ret) {
- g_print("failed to sound_manager_apply_stream_routing_options(), ret(0x%x)\n", ret);
+ g_print("failed to sound_manager_set_stream_routing_option(), ret(0x%x)\n", ret);
}
reset_menu_state();
}