summaryrefslogtreecommitdiffstats
path: root/src/soundmanager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/soundmanager.c')
-rw-r--r--src/soundmanager.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 6acf2a0..1d10a1e 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -966,6 +966,37 @@ 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){
+ AFB_NOTICE("Sink is not registered in Audio Manaager then can't set default sinkID, then set as %d", DEFAULT_SINK);
+ return;
+ }
+
+ guint16 sinkid, sinkclassid;
+ gchar* sinkname;
+ gint16 av, avr, volume, mutestate;
+
+ // Take the first one as default sinkID
+ GVariant* child = g_variant_get_child_value(mainSinkList, 0);
+ 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);
+ g_variant_unref(child);
+ g_variant_unref(mainSinkList);
+
+ set_default_sinkID(sinkid);
+}
+
int preinit()
{
AFB_INFO("Initialize Dbus object");
@@ -1071,6 +1102,7 @@ int sm_init()
}
AFB_DEBUG("domainID : %d", SOUNDMANAGER_DOMAIN_ID);
+ set_default_sink();
return 0;
}