aboutsummaryrefslogtreecommitdiffstats
path: root/src/soundmanager.c
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-16 18:14:52 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-16 18:38:27 +0900
commit0c458cecd936c4263f46fe582afb91df7f5ed61c (patch)
tree2c43e8f9d0fab40fc5d53fe3217bb9095542d0e8 /src/soundmanager.c
parentcbf280b545bbb3a879c55913564796f944b217c4 (diff)
Get first sinkID and set it as default on initialize
Get first sinkID and set it as default on initialize Change-Id: I7e5d6ef9db270f182dd1775985a2b6cf9b3fdc74 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
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;
}