23 #include <json-c/json.h> 26 #include <afb/afb-binding.h> 27 #include "sm-helper.h" 29 #include "dbus/audio_manager_interface.h" 31 #define AM_NAME "org.genivi.audiomanager" 32 #define AM_CMD_PATH "/org/genivi/audiomanager/commandinterface" 33 #define AM_ROUTE_PATH "/org/genivi/audiomanager/routinginterface" 34 #define SOUND_MANAGER_NAME "org.soundmanager.genivi.routingsend" 35 #define SOUND_MANAGER_PATH "org/soundmanager/genivi/routingsend" 37 #define COMMAND_EVENT_NUM 10 38 #define ROUTING_EVENT_NUM 10 39 #define MAX_LEN_STR 100 41 const static struct afb_binding_interface *afbitf;
42 static AudiomanagerCommandinterface *am_cmd_bus;
43 static AudiomanagerRoutinginterface *am_route_bus;
44 static OrgSoundmanagerGeniviRoutingsend *sm_adapter;
45 static OrgSoundmanagerGeniviRoutingsendIface* sm_itf;
47 static GMainLoop *loop = NULL;
56 static struct afb_event ev_new_connection;
57 static struct afb_event ev_removed_main_connection;
58 static struct afb_event ev_volume_changed;
59 static struct afb_event ev_sink_mute_state_changed;
60 static struct afb_event ev_main_connection_state_changed;
63 static struct afb_event ev_set_routing_ready;
64 static struct afb_event ev_set_routing_rundown;
65 static struct afb_event ev_async_connect;
66 static struct afb_event ev_async_set_source_state;
68 static const char _sourceid[] =
"sourceID";
69 static const char _sinkid[] =
"sinkID" ;
70 static const char _main_connection_id[] =
"mainConnectionID";
71 static const char _delay[] =
"delay";
72 static const char _connectionState[] =
"connectionState";
73 static const char _connectionID[] =
"connectionID";
74 static const char _volume[] =
"volume";
75 static const char _volumeStep[] =
"volumeStep";
76 static const char _muteState[] =
"muteState";
78 static const char _handle[] =
"handle";
79 static const char _appname[] =
"appname";
80 static const char _ramp[] =
"ramp";
81 static const char _time[] =
"time";
82 static const char _sourceState[] =
"sourceState";
83 static const char _sourceClassID[] =
"sourceClassID";
84 static const char _error[] =
"error";
85 static const char _sinkData[] =
"sinkData";
86 static const char _sourceData[] =
"sourceData";
87 static const char _interruptState[] =
"interruptState";
88 static const char _availability[] =
"availability";
89 static const char _domainID[] =
"domainID";
90 static const char _listvolumes[] =
"listvolumes";
91 static const char _payload[] =
"payload";
92 static const char _connectionFormat[] =
"connectionFormat";
98 static void connect (
struct afb_req request)
100 DEBUG(afbitf,
"call connect");
101 guint16 source_id, sink_id;
102 guint16 main_connectionID = 0;
104 REQ_ERROR req_err1, req_err2;
108 req_err1 = getid_uint16(request, _sourceid, &source_id);
109 req_err2 = getid_uint16(request, _sinkid, &sink_id);
111 if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
113 DEBUG(afbitf,
"getid_uint16 source ret = %d,sink ret = %d", source_id, sink_id);
114 NOTICE(afbitf,
"wrong request");
115 afb_req_fail(request,
"wrong-request",NULL);
119 audiomanager_commandinterface_call_connect_sync(
129 afb_req_fail(request,
"failed",
"Unable to call connect");
136 struct json_object *res = json_object_new_object();
137 sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
139 _main_connection_id, main_connectionID);
141 get_response_audiomanager_massage_error(ret,&info);
142 afb_req_success(request, res, info);
146 static void disconnect (
struct afb_req request)
148 DEBUG(afbitf,
"call disconnect");
155 req_err = getid_uint16(request, _main_connection_id, &
id);
156 DEBUG(afbitf,
"requested %s = %d", _main_connection_id,
id);
158 if(req_err != REQ_OK)
160 afb_req_fail(request,
"wrong-request",afb_req_value (request, _main_connection_id));
163 audiomanager_commandinterface_call_disconnect_sync(
168 DEBUG(afbitf,
"ret = %d", ret);
172 afb_req_fail(request,
"failed",
"Unable to call getListMainConnections");
176 struct json_object* res_obj = json_object_new_object();
177 sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
180 get_response_audiomanager_massage_error(ret,&info);
182 afb_req_success(request, res_obj, info);
185 static void setVolume (
struct afb_req request)
187 DEBUG(afbitf,
"call setVolume");
189 guint16 sink_id, vol;
191 REQ_ERROR req_err1, req_err2;
194 req_err1 = getid_uint16(request, _sinkid, &sink_id);
195 req_err2 = getid_int16(request, _volume, &vol);
196 DEBUG(afbitf,
"requested %s = %d, %s = %d",_sinkid, sink_id, _volume, vol);
197 if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
199 afb_req_fail(request,
"wrong-request", NULL);
203 audiomanager_commandinterface_call_set_volume_sync(
209 DEBUG(afbitf,
"ret = %d", ret);
213 afb_req_fail(request,
"failed",
"Unable to call setVolume");
217 struct json_object* res_obj = json_object_new_object();
218 sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
221 get_response_audiomanager_massage_error(ret,&info);
223 afb_req_success(request, res_obj, info);
226 static void volumeStep (
struct afb_req request)
228 DEBUG(afbitf,
"call volumeStep");
230 guint16 sink_id, vol;
232 REQ_ERROR req_err1, req_err2;
235 req_err1 = getid_uint16(request, _sinkid, &sink_id);
236 req_err2 = getid_int16(request, _volumeStep, &vol);
237 DEBUG(afbitf,
"requested %s = %d, %s = %d",_sinkid, sink_id, _volumeStep, vol);
238 if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
240 afb_req_fail(request,
"wrong-request", NULL);
244 audiomanager_commandinterface_call_volume_step_sync(
250 DEBUG(afbitf,
"ret = %d", ret);
254 afb_req_fail(request,
"failed",
"Unable to call volumeStep");
258 struct json_object* res_obj = json_object_new_object();
259 sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
262 get_response_audiomanager_massage_error(ret,&info);
264 afb_req_success(request, res_obj, info);
268 static void setSinkMuteState(
struct afb_req request)
270 DEBUG(afbitf,
"call setSinkMuteStete");
272 guint16 sink_id, mute;
274 REQ_ERROR req_err1, req_err2;
277 req_err1 = getid_uint16(request, _sinkid, &sink_id);
278 req_err2 = getid_int16(request, _muteState, &mute);
279 DEBUG(afbitf,
"requested %s = %d, %s = %d",_sinkid, sink_id, _muteState, mute);
280 if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
282 afb_req_fail(request,
"wrong-request", NULL);
286 audiomanager_commandinterface_call_set_sink_mute_state_sync(
292 DEBUG(afbitf,
"ret = %d", ret);
296 afb_req_fail(request,
"failed",
"Unable to call setSinkMuteStete");
300 struct json_object* res_obj = json_object_new_object();
301 sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
304 get_response_audiomanager_massage_error(ret,&info);
306 afb_req_success(request, res_obj, info);
310 static void getListMainConnections(
struct afb_req request)
312 DEBUG(afbitf,
"call getListMainConnections");
314 GVariant* mainConnectionList;
317 audiomanager_commandinterface_call_get_list_main_connections_sync(
324 DEBUG(afbitf,
"ret = %d, mainConnectionList pointer = %p", ret, &mainConnectionList);
328 afb_req_fail(request,
"failed",
"Unable to call getListMainConnections");
333 struct json_object *array_res = json_object_new_array();
334 gsize size = g_variant_n_children(mainConnectionList);
335 DEBUG(afbitf,
"mainConnectionList size is %u",(uint16_t)size);
336 struct json_object *verb_obj = json_object_new_object();
337 sm_add_object_to_json_object_func(verb_obj, __FUNCTION__, 0);
338 json_object_array_add(array_res, verb_obj);
341 NOTICE(afbitf,
"mainConnectionList size is 0");
344 for(
int i = 0; i < size; ++i)
346 guint16 mcid, srcid, sinkid;
347 gint16 delay, constate;
349 mainConnectionList,i,
"(qqqnn)",
350 &mcid, &srcid, &sinkid, &delay, &constate
353 struct json_object* res_obj = json_object_new_object();
354 sm_add_object_to_json_object_func(res_obj,__FUNCTION__,10,
355 _main_connection_id, mcid,
359 _connectionState, constate
361 json_object_array_add(array_res,res_obj);
364 DEBUG(afbitf,
"json object :%s:",json_object_to_json_string(array_res));
365 afb_req_success(request, array_res,
"Success to get main connection list");
373 static void ackConnect(
struct afb_req request)
376 DEBUG(afbitf,
"call %s", __FUNCTION__);
377 guint16 handle, connection_id, error;
378 REQ_ERROR req_err1, req_err2 , req_err3;
381 req_err1 = getid_uint16(request, _handle, &handle);
382 req_err2 = getid_uint16(request, _connectionID, &connection_id);
383 req_err3 = getid_uint16(request, _error, &error);
385 if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
387 afb_req_fail(request,
"wrong-request", NULL);
390 if(connection_id == 0)
392 afb_req_fail(request,
"wrong-request",
"connectionID is more than 0");
397 audiomanager_routinginterface_call_ack_connect_sync(
406 afb_req_fail(request,
"failed",
"Unable to call ackConnect");
409 afb_req_success(request, NULL, NULL);
411 static void ackDisconnect(
struct afb_req request)
414 DEBUG(afbitf,
"call %s", __FUNCTION__);
415 guint16 handle, connection_id, error;
416 REQ_ERROR req_err1, req_err2 , req_err3;
419 req_err1 = getid_uint16(request, _handle, &handle);
420 req_err2 = getid_uint16(request, _connectionID, &connection_id);
421 req_err3 = getid_uint16(request, _error, &error);
423 if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
425 afb_req_fail(request,
"wrong-request",
"connectionID is more than 0");
428 if(connection_id == 0)
430 afb_req_fail(request,
"wrong-request",
"connectionID is more than 0");
434 audiomanager_routinginterface_call_ack_disconnect_sync(
443 afb_req_fail(request,
"failed",
"Unable to call ackDisconnect");
446 afb_req_success(request, NULL, NULL);
448 static void ackSetSourceState(
struct afb_req request)
452 DEBUG(afbitf,
"call %s", __FUNCTION__);
453 guint16 handle, error;
454 REQ_ERROR req_err1, req_err2;
457 req_err1 = getid_uint16(request, _handle, &handle);
458 req_err2 = getid_uint16(request, _error, &error);
460 if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
462 NOTICE(afbitf,
"wrong request");
463 afb_req_fail(request,
"wrong-request", NULL);
467 audiomanager_routinginterface_call_ack_set_source_state_sync(
475 afb_req_fail(request,
"failed",
"Unable to call ackDisconnect");
478 afb_req_success(request, NULL, NULL);
480 static void registerSink(
struct afb_req request)
484 static void deregisterSink(
struct afb_req request)
490 static void registerSource(
struct afb_req request)
492 DEBUG(afbitf,
"call %s", __FUNCTION__);
497 guint16 source_class_id;
498 gint32 source_state = 1;
501 if(REQ_OK != getid_uint16(request, _sourceid, &source_id)){
504 if( REQ_OK != getid_uint16(request, _domainID, &domain_id)){
505 afb_req_fail(request,
"wrong-request",
"domainID should be more than 0");
510 afb_req_fail(request,
"wrong-request",
"domainID should be more than 0");
513 const gchar*
name = afb_req_value(request, _appname);
516 char* info =
"Must specify the name. Please input json arg such as {\"appname\":\"radio\"}";
517 afb_req_fail(request, NULL, info);
520 if(REQ_OK != getid_uint16(request, _sourceClassID, &source_class_id)){
523 if(REQ_OK != getid_uint16(request, _sourceState, &source_state)){
526 if(REQ_OK != getid_int16(request, _volume, &volume)){
529 gboolean visible = TRUE;
530 struct availability_s available;
531 available.availability = 1;
532 available.avalilable_reason = 0;
533 guint16 interrupt = 1;
535 struct sound_property_s sound_property_list;
536 sound_property_list.type = 0;
537 sound_property_list.value = 0;
539 gint32 connection_format_list = 0;
540 struct main_sound_property_s main_property_list;
541 main_property_list.type = 0;
542 main_property_list.value = 0;
544 struct notification_config_s nconf_routing;
545 struct notification_config_s nconf_command;
546 nconf_routing.type = 0;
547 nconf_routing.status = 0;
548 nconf_routing.parameter = 0;
550 nconf_command.type = 0;
551 nconf_command.status = 0;
552 nconf_command.parameter = 0;
555 guint16 acquire_source_id;
558 GVariant* sourceData = create_source_data (source_id, domain_id, name, source_class_id,
559 source_state, volume, visible, available, interrupt,
560 sound_property_list, connection_format_list, main_property_list,
561 nconf_routing, nconf_command, afbitf);
563 GVariant* input = g_variant_ref_sink(sourceData);
564 audiomanager_routinginterface_call_register_source_sync(
570 g_variant_unref(input);
574 afb_req_fail(request,
"failed",
"Unable to call registerSource");
579 struct json_object *res = json_object_new_object();
580 sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
582 _sourceid, acquire_source_id);
584 get_response_audiomanager_massage_error(error,&info);
585 afb_req_success(request, res, info);
588 static void deregisterSource(
struct afb_req request)
595 if(REQ_OK != getid_uint16(request, _sourceid, &source_id)){
596 afb_req_fail(request,
"wrong-request", NULL);
598 audiomanager_routinginterface_call_deregister_source_sync(
606 afb_req_fail(request,
"failed",
"Unable to call deregisterSource");
610 struct json_object *res = json_object_new_object();
611 sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
614 get_response_audiomanager_massage_error(error,&info);
615 afb_req_success(request, res, info);
619 static void confirmRoutingReady(
struct afb_req request)
623 static void confirmRoutingRundown(
struct afb_req request)
627 static void ackSetVolumes(
struct afb_req request)
631 static void ackSinkNotificationConfiguration(
struct afb_req request)
635 static void ackSourceNotificationConfiguration(
struct afb_req request)
641 static void subscribe(
struct afb_req request)
643 const char *value = afb_req_value(request,
"event");
645 DEBUG(afbitf,
"value is %s", value);
647 int index = sm_search_event_name_index(value);
650 index = sm_search_routing_event_name_index(value);
653 ERROR(afbitf,
"dedicated event doesn't exist");
657 afb_req_subscribe(request, *routing_event_list[index].
event);
662 afb_req_subscribe(request, *command_event_list[index].
event);
666 ERROR(afbitf,
"Please input event name");
668 afb_req_success(request, NULL, NULL);
671 static void unsubscribe(
struct afb_req request)
673 const char *value = afb_req_value(request,
"event");
675 DEBUG(afbitf,
"value is %s", value);
677 int index = sm_search_event_name_index(value);
680 index = sm_search_routing_event_name_index(value);
683 ERROR(afbitf,
"dedicated event doesn't exist");
687 afb_req_unsubscribe(request, *routing_event_list[index].
event);
692 afb_req_unsubscribe(request, *command_event_list[index].
event);
696 ERROR(afbitf,
"Please input event name");
698 afb_req_success(request, NULL, NULL);
705 static void on_new_main_connection(AudiomanagerCommandinterface* interface,
706 GVariant* mainConnection)
708 DEBUG(afbitf,
"%s is called",__FUNCTION__);
710 guint16 mcid, srcid, sinkid;
711 gint16 delay, constate;
713 mainConnection,
"(qqqnn)", &mcid, &srcid, &sinkid, &delay, &constate);
715 struct json_object* res_obj = json_object_new_object();
716 sm_add_object_to_json_object(res_obj,10,
717 _main_connection_id, mcid,
721 _connectionState, constate
723 DEBUG(afbitf,
"json object :%s:",json_object_to_json_string(res_obj));
725 afb_event_push(ev_new_connection, res_obj);
728 static void on_removed_main_connection(
729 AudiomanagerCommandinterface* interface, guint16 mainConnectionID)
731 DEBUG(afbitf,
"%s is called",__FUNCTION__);
733 struct json_object* res_obj = json_object_new_object();
734 sm_add_object_to_json_object(res_obj, 2,
735 _main_connection_id, mainConnectionID);
736 afb_event_push(ev_removed_main_connection, res_obj);
739 static void on_main_connection_state_changed(
740 AudiomanagerCommandinterface* interface, guint16 connectionID, gint16 connectionState)
742 DEBUG(afbitf,
"%s is called",__FUNCTION__);
744 struct json_object* res_obj = json_object_new_object();
745 sm_add_object_to_json_object(res_obj, 4,
746 _connectionID, connectionID,
747 _connectionState, connectionState);
748 afb_event_push(ev_main_connection_state_changed, res_obj);
751 static void on_volume_changed(
752 AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 volume)
754 DEBUG(afbitf,
"%s is called",__FUNCTION__);
755 struct json_object* res_obj = json_object_new_object();
756 sm_add_object_to_json_object(res_obj, 4,
759 afb_event_push(ev_volume_changed, res_obj);
762 static void on_sink_mute_state_changed(
763 AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 mute)
765 DEBUG(afbitf,
"%s is called",__FUNCTION__);
766 struct json_object* res_obj = json_object_new_object();
767 sm_add_object_to_json_object(res_obj, 4,
770 afb_event_push(ev_sink_mute_state_changed, res_obj);
776 static void on_set_routing_ready(
777 AudiomanagerRoutinginterface* interface)
779 DEBUG(afbitf,
"%s is called",__FUNCTION__);
780 afb_event_push(ev_set_routing_ready, NULL);
783 static void on_set_routing_rundown(
784 AudiomanagerRoutinginterface* interface)
786 DEBUG(afbitf,
"%s is called",__FUNCTION__);
787 afb_event_push(ev_set_routing_ready, NULL);
804 static gboolean on_async_abort(
805 OrgSoundmanagerGeniviRoutingsend *
object,
806 GDBusMethodInvocation *invocation,
809 DEBUG(afbitf,
"%s called", __FUNCTION__);
814 static gboolean on_async_connect(
815 OrgSoundmanagerGeniviRoutingsend *
object,
816 GDBusMethodInvocation *invocation,
818 guint16 arg_connectionID,
819 guint16 arg_sourceID,
821 gint arg_connectionFormat)
823 DEBUG(afbitf,
"%s called", __FUNCTION__);
825 struct json_object* res_obj = json_object_new_object();
826 sm_add_object_to_json_object(res_obj, 10,
828 _connectionID, arg_connectionID,
829 _sourceid, arg_sourceID,
831 _connectionFormat, arg_connectionFormat);
832 afb_event_push(ev_async_connect, res_obj);
833 audiomanager_routinginterface_call_ack_connect_sync(
841 ERROR(afbitf,
"Can't create sound manager adapter");
847 static gboolean on_async_disconnect(
848 OrgSoundmanagerGeniviRoutingsend *
object,
849 GDBusMethodInvocation *invocation,
851 guint16 arg_connectionID)
853 DEBUG(afbitf,
"%s called", __FUNCTION__);
855 audiomanager_routinginterface_call_ack_disconnect_sync(
863 ERROR(afbitf,
"Can't create sound manager adapter");
869 static gboolean on_async_set_sink_volume(
870 OrgSoundmanagerGeniviRoutingsend *
object,
871 GDBusMethodInvocation *invocation,
878 DEBUG(afbitf,
"%s called", __FUNCTION__);
883 static gboolean on_async_set_source_state(
884 OrgSoundmanagerGeniviRoutingsend *
object,
885 GDBusMethodInvocation *invocation,
887 guint16 arg_sourceID,
888 gint arg_sourceState)
890 DEBUG(afbitf,
"%s called", __FUNCTION__);
892 struct json_object* res_obj = json_object_new_object();
893 sm_add_object_to_json_object(res_obj, 6,
895 _sourceid, arg_sourceID,
896 _sourceState, arg_sourceState);
897 afb_event_push(ev_async_set_source_state, res_obj);
906 ERROR(afbitf,
"Can't create sound manager adapter");
912 static gboolean init_sound_manager_adapter(GDBusServer *server, GDBusConnection *conn, gpointer data)
914 DEBUG(afbitf,
"%s called", __FUNCTION__);
915 sm_adapter = org_soundmanager_genivi_routingsend_skeleton_new();
916 sm_itf = ORG_SOUNDMANAGER_GENIVI_ROUTINGSEND_GET_IFACE(sm_adapter);
918 sm_itf->handle_async_abort = on_async_abort;
919 sm_itf->handle_async_connect = on_async_connect;
920 sm_itf->handle_async_disconnect = on_async_disconnect;
921 sm_itf->handle_async_set_sink_volume = on_async_set_sink_volume;
922 sm_itf->handle_async_set_source_state = on_async_set_source_state;
923 gboolean ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(sm_adapter), conn,
SOUND_MANAGER_PATH, NULL);
926 ERROR(afbitf,
"Can't create sound manager adapter");
935 static const struct afb_verb_desc_v1 binding_verbs[]= {
937 { .name =
"connect", .session = AFB_SESSION_NONE, .callback = connect, .info =
"Connect source id and sink id" },
938 { .name =
"disconnect", .session = AFB_SESSION_NONE, .callback = disconnect, .info =
"Disconnect source id and sink id" },
939 { .name =
"setVolume", .session = AFB_SESSION_NONE, .callback = setVolume, .info =
"Set volume value" },
940 { .name =
"volumeStep", .session = AFB_SESSION_NONE, .callback = volumeStep, .info =
"Set volume step range" },
941 { .name =
"setSinkMuteState", .session = AFB_SESSION_NONE, .callback = setSinkMuteState, .info =
"Set Mute state: 1 means mute, 2 means umute. Others are invalid" },
942 { .name =
"getListMainConnections", .session = AFB_SESSION_NONE, .callback = getListMainConnections, .info =
"Get MainConnection List" },
944 { .name =
"registerSource", .session = AFB_SESSION_NONE, .callback = registerSource, .info =
"Register Application" },
945 { .name =
"deregisterSource", .session = AFB_SESSION_NONE, .callback = deregisterSource, .info =
"Deregister Application" },
946 { .name =
"ackConnect", .session = AFB_SESSION_NONE, .callback = ackConnect, .info =
"Acknowledge of asyncConnect" },
947 { .name =
"ackDisconnect", .session = AFB_SESSION_NONE, .callback = ackDisconnect, .info =
"Acknowledge of asyncConnect" },
948 { .name =
"ackSetSourceState", .session = AFB_SESSION_NONE, .callback = ackSetSourceState, .info =
"Acknowledge of asyncSetSourceState" },
949 { .name =
"subscribe", .session = AFB_SESSION_NONE, .callback = subscribe, .info =
"Subscribe event" },
950 { .name =
"unsubscribe", .session = AFB_SESSION_NONE, .callback = unsubscribe, .info =
"Unsubscribe event" },
954 static const struct afb_binding binding_description =
956 .type = AFB_BINDING_VERSION_1,
958 .info =
"Sound Manager" ,
959 .prefix =
"soundmanager" ,
960 .verbs = binding_verbs
964 static void *dbus_event_loop_run(
void *args)
966 loop = g_main_loop_new(NULL, FALSE);
967 g_main_loop_run(loop);
970 static void free_dbus()
972 ERROR(afbitf,
"free dbus");
986 INFO(afbitf,
"Initialize Dbus object");
988 if(am_cmd_bus || am_route_bus)
990 ERROR(afbitf,
"Dbus object to Audio Manager is already created");
993 am_cmd_bus = audiomanager_commandinterface_proxy_new_for_bus_sync(
995 G_DBUS_PROXY_FLAGS_NONE,
1001 am_route_bus = audiomanager_routinginterface_proxy_new_for_bus_sync(
1003 G_DBUS_PROXY_FLAGS_NONE,
1010 if(!am_cmd_bus || !am_route_bus)
1015 INFO(afbitf,
"Finish Initialize");
1018 ERROR(afbitf,
"Failed to initialize");
1023 static int sm_event_init()
1025 INFO(afbitf,
"Initialize event receive setting");
1028 size_t size =
sizeof cmd_evlist /
sizeof *cmd_evlist;
1033 ev_volume_changed = afb_daemon_make_event(afbitf->daemon, cmd_evlist[0]);
1034 ev_new_connection = afb_daemon_make_event(afbitf->daemon, cmd_evlist[1]);
1035 ev_removed_main_connection = afb_daemon_make_event(afbitf->daemon, cmd_evlist[2]);
1036 ev_sink_mute_state_changed = afb_daemon_make_event(afbitf->daemon, cmd_evlist[3]);
1037 ev_main_connection_state_changed = afb_daemon_make_event(afbitf->daemon, cmd_evlist[4]);
1038 command_event_list[0].
name = cmd_evlist[0];
1039 command_event_list[0].
event = &ev_volume_changed;
1040 command_event_list[1].
name = cmd_evlist[1];
1041 command_event_list[1].
event = &ev_new_connection;
1042 command_event_list[2].
name = cmd_evlist[2];
1043 command_event_list[2].
event = &ev_removed_main_connection;
1044 command_event_list[3].
name = cmd_evlist[3];
1045 command_event_list[3].
event = &ev_sink_mute_state_changed;
1046 command_event_list[4].
name = cmd_evlist[4];
1047 command_event_list[4].
event = &ev_main_connection_state_changed;
1050 ev_set_routing_ready = afb_daemon_make_event(afbitf->daemon, route_evlist[0]);
1051 ev_set_routing_rundown = afb_daemon_make_event(afbitf->daemon, route_evlist[1]);
1052 ev_async_connect = afb_daemon_make_event(afbitf->daemon, route_evlist[2]);
1053 ev_async_set_source_state = afb_daemon_make_event(afbitf->daemon, route_evlist[3]);
1054 routing_event_list[0].
name = route_evlist[0];
1055 routing_event_list[0].
event = &ev_set_routing_ready;
1056 routing_event_list[1].
name = route_evlist[1];
1057 routing_event_list[1].
event = &ev_set_routing_rundown;
1058 routing_event_list[2].
name = route_evlist[1];
1059 routing_event_list[2].
event = &ev_async_connect;
1060 routing_event_list[3].
name = route_evlist[1];
1061 routing_event_list[3].
event = &ev_async_set_source_state;
1077 if(!am_cmd_bus || !am_route_bus)
1081 pthread_t thread_id;
1082 ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL);
1088 g_signal_connect(am_cmd_bus,
1090 G_CALLBACK(on_volume_changed),
1092 g_signal_connect(am_cmd_bus,
1093 "new_main_connection",
1094 G_CALLBACK(on_new_main_connection),
1096 g_signal_connect(am_cmd_bus,
1097 "removed_main_connection",
1098 G_CALLBACK(on_removed_main_connection),
1100 g_signal_connect(am_cmd_bus,
1101 "sink_mute_state_changed",
1102 G_CALLBACK(on_sink_mute_state_changed),
1104 g_signal_connect(am_cmd_bus,
1105 "main_connection_state_changed",
1106 G_CALLBACK(on_main_connection_state_changed),
1108 g_signal_connect(am_route_bus,
1109 "set_routing_ready",
1110 G_CALLBACK(on_set_routing_ready),
1112 g_signal_connect(am_route_bus,
1113 "set_routing_rundown",
1114 G_CALLBACK(on_set_routing_rundown),
1119 NULL, init_sound_manager_adapter, NULL, NULL, NULL);
1121 INFO(afbitf,
"Finish Initialize event receive setting");
1127 g_main_loop_unref(loop);
1130 ERROR(afbitf,
"DBus connection is not created");
1142 return (ret == 0) ? &binding_description : NULL;
1147 DEBUG(afbitf,
"Initializing Audio Manager Notification \n");
1148 int ret = sm_event_init();
const struct afb_binding * afbBindingV1Register(const struct afb_binding_interface *itf)
int afbBindingV1ServiceInit(struct afb_service service)
#define ROUTING_EVENT_NUM
#define SOUND_MANAGER_PATH
#define SOUND_MANAGER_NAME
#define COMMAND_EVENT_NUM