diff options
Diffstat (limited to 'src/soundmanager.c')
-rw-r--r-- | src/soundmanager.c | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/soundmanager.c b/src/soundmanager.c index a8a2b9e..1bc2a9d 100644 --- a/src/soundmanager.c +++ b/src/soundmanager.c @@ -21,6 +21,7 @@ #include <unistd.h> #include <json-c/json.h> #include <glib.h> +#include <pthread.h> #include "soundmanager.h" #include "audiomanager_proxy.h" #include "sm-def.h" @@ -355,7 +356,6 @@ void getListMainSinks(struct afb_req request) AFB_DEBUG("call %s", __FUNCTION__); GVariant* mainSinkList; - GError *err = NULL; ErrorCode ec = am_proxy_get_list_main_sinks(&mainSinkList); @@ -1040,6 +1040,33 @@ static void create_client_context(afb_req request, guint16 source_id, guint16 si afb_req_context_set(request, ctxt, on_client_context_terminated); } +void set_default_sink(){ + GVariant *mainSinkList; + ErrorCode ec = am_proxy_get_list_main_sinks(&mainSinkList); + if(ec != OK){ + return; + } + + gsize size = g_variant_n_children(mainSinkList); + + if(0 == size){ + return; + } + + guint16 sinkid, sinkclassid; + gchar* sinkname; + gint16 av, avr, volume, mutestate; + + GVariant* child = g_variant_get_child_value(mainSinkList, 1); + g_variant_get( + child,"(qs(nn)nnq)", + &sinkid, &sinkname, &av, &avr, &volume, &mutestate, &sinkclassid); + AFB_DEBUG( "sinkID: %d, sinkName: %s, availability: %d, availableReason: %d, volume: %d, muteState: %d, sinkClassID: %d", + sinkid, sinkname, av, avr, volume, mutestate, sinkclassid); + + set_default_sinkID(sinkid); +} + int preinit() { AFB_INFO("Initialize Dbus object"); @@ -1054,8 +1081,7 @@ int preinit() AFB_NOTICE( "Finish Initialize"); return 0; } -//test -#include <pthread.h> + static void *dbus_event_loop_run(void *args) { GMainLoop* loop = g_main_loop_new(NULL, FALSE); @@ -1164,13 +1190,16 @@ int sm_init() return -1; } AFB_DEBUG("domainID : %d", SOUNDMANAGER_DOMAIN_ID); - // tes + + set_default_sink(); + pthread_t thread_id; - int ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL); - if(ret != 0) - { - AFB_ERROR("Failed to create thread"); - } + int ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL); + if(ret != 0) + { + AFB_ERROR("Failed to create thread"); + return -1; + } return 0; } |