Sound Manager
soundmanager.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define _GNU_SOURCE
18 #define AFB_BINDING_VERSION 2
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
22 #include <stdint.h>
23 #include <unistd.h>
24 #include <json-c/json.h>
25 #include <glib.h>
26 #include <pthread.h>
27 #include <afb/afb-binding.h>
28 #include "sm-error.h"
29 #include "sm-helper.h"
31 
32 #define AM_NAME "org.genivi.audiomanager"
33 #define AM_CMD_PATH "/org/genivi/audiomanager/commandinterface"
34 #define AM_ROUTE_PATH "/org/genivi/audiomanager/routinginterface"
35 #define AM_ROUTE_NAME "org.genivi.audiomanager.routinginterface"
36 #define SOUND_MANAGER_RETURN_INTERFACE "org.genivi.audiomanager.routing.soundmanager"
37 #define SOUND_MANAGER_BUS_NAME "org.genivi.audiomanager.routing.soundmanager"
38 #define SOUND_MANAGER_PATH "/org/genivi/audiomanager/routing/soundmanager"
39 
40 #define COMMAND_EVENT_NUM 10
41 #define ROUTING_EVENT_NUM 10
42 #define DEFAULT_SINK 1
43 #define DEFAULT_SOURCE_CLASS_ID 100
44 #define DYNAMIC_DOMAIN_ID 100
45 #define DEFAULT_DOMAIN_ID 0
46 #define DYNAMIC_SOURCE_ID 0
47 #define DEFAULT_VOLUME 100
48 #define DEFAULT_AVAILABLES 1
49 #define DEFAULT_CONNECTION_FORMAT 2
50 #define DEFAULT_INTERRUPT 0
51 #define DEFAULT_SOURCE_STATE 2
52 #define DS_CONTROLLED 1
53 
54 #define EVENT_SUBSCRIBE_ERROR_CODE 100
55 
56 const static struct afb_binding_interface *afbitf;
57 static AudiomanagerCommandinterface *am_cmd_bus;
58 static AudiomanagerRoutinginterface *am_route_bus;
59 static AudiomanagerRoutingSoundmanager *sm_adapter;
61 static GDBusConnection* system_conn = NULL;
62 
63 static GMainLoop *loop = NULL;
64 static guint16 SOUNDMANAGER_DOMAIN_ID;
65 /* To Do hash table is better */
66 struct event{
67  char* name;
68  struct afb_event* event;
69  };
70 static struct event command_event_list[COMMAND_EVENT_NUM];
71 static struct event routing_event_list[ROUTING_EVENT_NUM];
72 
73 static struct afb_event ev_new_connection;
74 static struct afb_event ev_removed_main_connection;
75 static struct afb_event ev_volume_changed;
76 static struct afb_event ev_sink_mute_state_changed;
77 static struct afb_event ev_main_connection_state_changed;
78 
79 /* Routing interface event */
80 static struct afb_event ev_set_routing_ready;
81 static struct afb_event ev_set_routing_rundown;
82 static struct afb_event ev_async_connect;
83 static struct afb_event ev_async_disconnect;
84 static struct afb_event ev_async_set_source_state;
85 
86 static const char _source_id[] = "sourceID";
87 static const char _sink_id[] = "sinkID" ;
88 static const char _sink_name[] = "sinkName" ;
89 static const char _main_connection_id[] = "mainConnectionID";
90 static const char _delay[] = "delay";
91 static const char _connection_state[] = "connectionState";
92 static const char _connection_id[] = "connectionID";
93 static const char _volume[] = "volume";
94 static const char _volume_step[] = "volumeStep";
95 static const char _interrupt[] = "interrupt";
96 static const char _mute_state[] = "muteState";
97 
98 static const char _domain_id[] = "domainID";
99 static const char _handle[] = "handle";
100 static const char _appname[] = "appname";
101 static const char _ramp[] = "ramp";
102 static const char _time[] = "time";
103 static const char _source_state[] = "sourceState";
104 static const char _source_class_id[] = "sourceClassID";
105 static const char _sink_class_id[] = "sinkClassID";
106 static const char _error[] = "error";
107 static const char _sink_data[] = "sinkData";
108 static const char _source_data[] = "sourceData";
109 static const char _interrupt_state[] = "interruptState";
110 static const char _availability[] = "availability";
111 static const char _list_volumes[] = "listVolumes";
112 static const char _payload[] = "payload";
113 static const char _connection_format[] = "connectionFormat";
114 /*
115 ********** Method of Sound Manager (API) **********
116 */
117 
147 static void connect (struct afb_req request)
148 {
149  AFB_DEBUG("call %s", __FUNCTION__);
150  guint16 source_id = 0, sink_id = 0;
151  guint16 main_connectionID = 0;
152  gint16 ret = -1;
153  REQ_ERROR req_err1 = REQ_FAIL;
154  REQ_ERROR req_err2 = REQ_FAIL;
155  GError *err = NULL;
156 
157  req_err1 = get_value_uint16(request, _source_id, &source_id);
158  /* ToDo: Hardware abstraction for application user is needed.
159  select appname(speaker) or sourceID(sinkID). If appname is desired, it changes to sourceID(sinkID) */
160 
161  const char* default_sink = afb_req_value (request, _sink_id);
162  if(default_sink != NULL){
163  if((strlen("default") == strlen(default_sink)) &&
164  (0 == strncmp("default", default_sink, strlen("default")))){
165  sink_id = DEFAULT_SINK;
166  req_err2 = REQ_OK;
167  }
168  else{
169  req_err2 = get_value_uint16(request, _sink_id, &sink_id);
170  }
171  }
172 
173  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
174  {
175  AFB_INFO("get_value_uint16 source ret = %d,sink ret = %d", source_id, sink_id);
176  AFB_NOTICE("wrong request");
177  afb_req_fail(request,"wrong-request",NULL);
178  return;
179  }
180 
182  am_cmd_bus,
183  source_id,
184  sink_id,
185  &ret,
186  &main_connectionID,
187  NULL, &err);
188 
189  if(err != NULL)
190  {
191  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
192  return;
193  }
194 
195  /* ToDo Remember appname(key) and tie to sourceID(value) */
196 
197  /*create response json object*/
198  struct json_object *res = json_object_new_object();
199  sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
200  "error", ret,
201  _main_connection_id, main_connectionID);
202  char *info = get_response_audiomanager_massage_error(ret);
203  afb_req_success(request, res, info);
204 }
205 
222 static void disconnect (struct afb_req request)
223 {
224  AFB_DEBUG("call %s", __FUNCTION__);
225 
226  guint16 id;
227  gint16 ret;
228  REQ_ERROR req_err;
229  GError *err = NULL;
230 
231  req_err = get_value_uint16(request, _main_connection_id, &id);
232  AFB_DEBUG( "requested %s = %d", _main_connection_id, id);
233 
234  if(req_err != REQ_OK)
235  {
236  afb_req_fail(request,"wrong-request",afb_req_value (request, _main_connection_id));
237  return;
238  }
240  am_cmd_bus,
241  id,
242  &ret,
243  NULL, &err);
244  AFB_DEBUG( "ret = %d", ret);
245 
246  if(err != NULL)
247  {
248  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
249  return;
250  }
251 
252  struct json_object* res_obj = json_object_new_object();
253  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
254  _error, ret);
255  char *info = get_response_audiomanager_massage_error(ret);
256 
257  afb_req_success(request, res_obj, info); /* return error num as status */
258 }
259 
275 static void setVolume (struct afb_req request)
276 {
277  AFB_DEBUG("call %s", __FUNCTION__);
278 
279  guint16 sink_id, vol;
280  gint16 ret;
281  REQ_ERROR req_err1, req_err2;
282  GError *err = NULL;
283 
284  req_err1 = get_value_uint16(request, _sink_id, &sink_id);
285  req_err2 = get_value_int16(request, _volume, &vol);
286  AFB_DEBUG( "requested %s = %d, %s = %d",_sink_id, sink_id, _volume, vol);
287  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
288  {
289  afb_req_fail(request,"wrong-request", NULL);
290  return;
291  }
292 
294  am_cmd_bus,
295  sink_id,
296  vol,
297  &ret,
298  NULL, &err);
299  AFB_DEBUG( "ret = %d", ret);
300 
301  if(err != NULL)
302  {
303  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
304  return;
305  }
306 
307  struct json_object* res_obj = json_object_new_object();
308  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
309  "error", ret);
310  char *info = get_response_audiomanager_massage_error(ret);
311 
312  afb_req_success(request, res_obj, info); /* return error num as status */
313 }
314 
331 static void volumeStep (struct afb_req request)
332 {
333  AFB_DEBUG("call %s", __FUNCTION__);
334 
335  guint16 sink_id, vol;
336  gint16 ret;
337  REQ_ERROR req_err1, req_err2;
338  GError *err = NULL;
339 
340  req_err1 = get_value_uint16(request, _sink_id, &sink_id);
341  req_err2 = get_value_int16(request, _volume_step, &vol);
342  AFB_DEBUG( "requested %s = %d, %s = %d",_sink_id, sink_id, _volume_step, vol);
343  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
344  {
345  afb_req_fail(request,"wrong-request", NULL);
346  return;
347  }
348 
350  am_cmd_bus,
351  sink_id,
352  vol,
353  &ret,
354  NULL, &err);
355  AFB_DEBUG( "ret = %d", ret);
356 
357  if(err != NULL)
358  {
359  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
360  return;
361  }
362 
363  struct json_object* res_obj = json_object_new_object();
364  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
365  "error", ret);
366  char *info = get_response_audiomanager_massage_error(ret);
367 
368  afb_req_success(request, res_obj, info); /* return error num as status */
369 }
370 
387 static void setSinkMuteState(struct afb_req request)
388 {
389  AFB_DEBUG("call %s", __FUNCTION__);
390 
391  guint16 sink_id, mute;
392  gint16 ret;
393  REQ_ERROR req_err1, req_err2;
394  GError *err = NULL;
395 
396  req_err1 = get_value_uint16(request, _sink_id, &sink_id);
397  req_err2 = get_value_int16(request, _mute_state, &mute);
398  AFB_DEBUG( "requested %s = %d, %s = %d",_sink_id, sink_id, _mute_state, mute);
399  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
400  {
401  afb_req_fail(request,"wrong-request", NULL);
402  return;
403  }
404 
406  am_cmd_bus,
407  sink_id,
408  mute,
409  &ret,
410  NULL, &err);
411  AFB_DEBUG( "ret = %d", ret);
412 
413  if(err != NULL)
414  {
415  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
416  return;
417  }
418 
419  struct json_object* res_obj = json_object_new_object();
420  sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
421  "error", ret);
422  char *info = get_response_audiomanager_massage_error(ret);
423 
424  afb_req_success(request, res_obj, info); /* return error num as status */
425 }
426 
443 static void getListMainConnections(struct afb_req request)
444 {
445  AFB_DEBUG("call getListMainConnections");
446  guint16 ret;
447  GVariant* mainConnectionList;
448  GError *err = NULL;
449 
451  am_cmd_bus,
452  &ret,
453  &mainConnectionList,
454  NULL,
455  &err
456  );
457 
458  if(err != NULL)
459  {
460  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
461  return;
462  }
463 
464  /* create response */
465  struct json_object *array_res = json_object_new_array();
466  gsize size = g_variant_n_children(mainConnectionList);
467  AFB_DEBUG("mainConnectionList size is %u",(uint16_t)size);
468  struct json_object *verb_obj = json_object_new_object();
469  sm_add_object_to_json_object_func(verb_obj, __FUNCTION__, 0);
470  json_object_array_add(array_res, verb_obj);
471  if(size <= 0)
472  {
473  AFB_NOTICE( "mainConnectionList size is 0");
474  }
475  else{
476  for(int i = 0; i < size; ++i)
477  {
478  guint16 mcid, srcid, sinkid;
479  gint16 delay, constate;
480  g_variant_get_child(
481  mainConnectionList,i,"(qqqnn)",
482  &mcid, &srcid, &sinkid, &delay, &constate
483  );
484 
485  struct json_object* res_obj = json_object_new_object();
486  sm_add_object_to_json_object(res_obj,10,
487  _main_connection_id, mcid,
488  _source_id, srcid,
489  _sink_id, sinkid,
490  _delay, delay,
491  _connection_state, constate
492  );
493  json_object_array_add(array_res,res_obj);
494  }
495  }
496  AFB_DEBUG("json object :%s:",json_object_to_json_string(array_res));
497  afb_req_success(request, array_res, "Success to get main connection list");
498 }
499 
516 static void getListMainSinks(struct afb_req request)
517 {
518  AFB_DEBUG("call %s", __FUNCTION__);
519  guint16 ret;
520  GVariant* mainSinkList;
521  GError *err = NULL;
522 
524  am_cmd_bus,
525  &ret,
526  &mainSinkList,
527  NULL,
528  &err
529  );
530 
531  if(err != NULL)
532  {
533  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
534  return;
535  }
536 
537  /* create response */
538  struct json_object *array_res = json_object_new_array();
539  gsize size = g_variant_n_children(mainSinkList);
540  AFB_DEBUG( "%s size is %u",__FUNCTION__, (uint16_t)size);
541  struct json_object *verb_obj = json_object_new_object();
542  sm_add_object_to_json_object_func(verb_obj, __FUNCTION__, 0);
543  json_object_array_add(array_res, verb_obj);
544  if(size <= 0)
545  {
546  AFB_NOTICE("%s size is 0", __FUNCTION__);
547  }
548  else{
549  /*for(int i = 0; i < size; ++i)
550  {
551  guint16 sinkid, sinkclassid;
552  gchar* sinkname;
553  GVariant* available = g_variant_new("(nn)", -1, -1);
554  gint16 volume, mutestate;
555  g_variant_get_child(
556  mainSinkList,i,"(qs(nn)nnq)",
557  &sinkid, sinkname, &volume, &mutestate, &sinkclassid);
558  struct json_object* res_obj = json_object_new_object();
559  sm_add_object_to_json_object(res_obj,2,_sink_id, sinkid);
560  json_object_object_add(res_obj, _sink_name, json_object_new_string(sinkname));
561  sm_add_object_to_json_object(res_obj,6,
562  _volume, volume,
563  _mute_state, mutestate,
564  _sink_class_id, sinkclassid);
565  json_object_array_add(array_res,res_obj);
566  }*/
567  }
568  AFB_DEBUG("json object :%s:",json_object_to_json_string(array_res));
569  //afb_req_success(request, array_res, "Success to get main sink list");
570  afb_req_success(request, array_res, "This is not implemented yet");
571 }
572 /*
573 *
574 ****** Routing Interface method(API) ***********
575 *
576 */
577 
597 static void ackConnect(struct afb_req request)
598 {
599  /* This function will be deprecated */
600  AFB_DEBUG("call %s", __FUNCTION__);
601  guint16 handle, connection_id, error;
602  guint16 ret = 0;
603  REQ_ERROR req_err1, req_err2 , req_err3;
604  GError *err = NULL;
605 
606  req_err1 = get_value_uint16(request, _handle, &handle);
607  req_err2 = get_value_uint16(request, _connection_id, &connection_id);
608  req_err3 = get_value_uint16(request, _error, &error);
609 
610  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
611  {
612  afb_req_fail(request,"wrong-request", NULL);
613  return;
614  }
615  if(connection_id == 0)
616  {
617  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
618  return;
619  }
620 
622  am_route_bus,
623  handle,
624  connection_id,
625  error,
626  NULL, &err);
627 
628  if(err != NULL)
629  {
630  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
631  return;
632  }
633  /*create response json object*/
634  struct json_object *res = json_object_new_object();
635  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
636  _error, ret);
637  char *info = get_response_audiomanager_massage_error(ret);
638  afb_req_success(request, res, info);
639 }
640 
659 static void ackDisconnect(struct afb_req request)
660 {
661  /* This function will be deprecated */
662  AFB_DEBUG("call %s", __FUNCTION__);
663  guint16 handle, connection_id, error;
664  guint16 ret = 0;
665  REQ_ERROR req_err1, req_err2 , req_err3;
666  GError *err = NULL;
667 
668  req_err1 = get_value_uint16(request, _handle, &handle);
669  req_err2 = get_value_uint16(request, _connection_id, &connection_id);
670  req_err3 = get_value_uint16(request, _error, &error);
671 
672  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
673  {
674  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
675  return;
676  }
677  if(connection_id == 0)
678  {
679  afb_req_fail(request,"wrong-request", "connectionID is more than 0");
680  return;
681  }
682 
684  am_route_bus,
685  handle,
686  connection_id,
687  error,
688  NULL, &err);
689 
690  if(err != NULL)
691  {
692  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
693  return;
694  }
695  /*create response json object*/
696  struct json_object *res = json_object_new_object();
697  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
698  _error, ret);
699  char *info = get_response_audiomanager_massage_error(ret);
700  afb_req_success(request, res, info);
701 }
702 
720 static void ackSetSourceState(struct afb_req request)
721 {
722  AFB_DEBUG("call %s", __FUNCTION__);
723  guint16 handle, error;
724  guint16 ret = 0;
725  REQ_ERROR req_err1, req_err2;
726  GError *err = NULL;
727 
728  req_err1 = get_value_uint16(request, _handle, &handle);
729  req_err2 = get_value_uint16(request, _error, &error);
730 
731  if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
732  {
733  AFB_DEBUG("wrong request");
734  afb_req_fail(request,"wrong-request", NULL);
735  return;
736  }
737 
739  am_route_bus,
740  handle,
741  error,
742  NULL, &err);
743 
744  if(err != NULL)
745  {
746  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
747  return;
748  }
749  /*create response json object*/
750  struct json_object *res = json_object_new_object();
751  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
752  _error, ret);
753  char *info = get_response_audiomanager_massage_error(ret);
754  afb_req_success(request, res, info);
755 }
756 
776 static void registerSource(struct afb_req request)
777 {
778  AFB_DEBUG("call %s", __FUNCTION__);
779  GError *err = NULL;
780 
781 
782  guint16 source_id; /* q 0 is for dynamic id*/
783  guint16 domain_id; /* q */
784  guint16 source_class_id; /* q */
785  gint32 source_state; /* i */
786  gint16 volume; /* n */
787 
788  if(REQ_OK != get_value_uint16(request, _source_id, &source_id)){
789  source_id = DYNAMIC_SOURCE_ID; /* if 0, dynamic source id will be applied */
790  }
791  REQ_ERROR req_err = get_value_uint16(request, _domain_id, &domain_id);
792  if( req_err != REQ_OK){
793  if(req_err == REQ_FAIL)
794  {
795  domain_id = SOUNDMANAGER_DOMAIN_ID; /* default in AGL */
796  }
797  else{
798  afb_req_fail(request,"wrong-request", "Please input domainID as uint16, otherwise no value is OK");
799  return;
800  }
801  }
802  if(domain_id == 0)
803  {
804  afb_req_fail(request,"wrong-request", "domainID should be more than 0");
805  return;
806  }
807  const gchar* name = afb_req_value(request, _appname); /* s */
808  if(!name)
809  {
810  char* info = "Must specify the name. Please input json arg such as {\"appname\":\"radio\"}";
811  afb_req_fail(request, NULL, info);
812  return;
813  }
814  if(REQ_OK != get_value_uint16(request, _source_class_id, &source_class_id)){
815  source_class_id = DEFAULT_SOURCE_CLASS_ID; /* BASE */
816  }
817  if(REQ_OK != get_value_int32(request, _source_state, &source_state)){
818  source_state = DEFAULT_SOURCE_STATE; /* SS_OFF */
819  }
820  if(REQ_OK != get_value_int16(request, _volume, &volume)){
821  volume = DEFAULT_VOLUME;
822  }
823  gboolean visible = TRUE; /* b */
824  struct availability_s available; /* (ii) */
825  available.availability = DEFAULT_AVAILABLES; /* A_UNKNOWN */
826  available.avalilable_reason = 0; /* AR_UNKNOWN */
827 
828  guint16 interrupt;
829  if(REQ_OK != get_value_int16(request, _interrupt, &interrupt)){
830  interrupt = DEFAULT_INTERRUPT; /* q IS_OFF */
831  }
832  struct sound_property_s sound_property_list; /* a(in) */
833  sound_property_list.type = 0;
834  sound_property_list.value = 0; /* in reality, this is array of struct */
835 
836  gint32 connection_format_list = DEFAULT_CONNECTION_FORMAT; /* ai */
837  struct main_sound_property_s main_property_list; /* a(in) */
838  main_property_list.type = 0;
839  main_property_list.value = 0;
840 
841  struct notification_config_s nconf_routing;
842  struct notification_config_s nconf_command; /* a(iin)a(iin) */
843  nconf_routing.type = 0;
844  nconf_routing.status = 0;
845  nconf_routing.parameter = 0;
846 
847  nconf_command.type = 0;
848  nconf_command.status = 0;
849  nconf_command.parameter = 0;
850 
851  /* acquire data */
852  guint16 acquire_source_id;
853  guint16 ret;
854 
855  GVariant* sourceData = create_source_data (source_id, domain_id, name, source_class_id,
856  source_state, volume, visible, available, interrupt,
857  sound_property_list, connection_format_list, main_property_list,
858  nconf_routing, nconf_command);
859 
860  GVariant* input = g_variant_ref_sink(sourceData);
862  am_route_bus,
863  input,
864  &acquire_source_id,
865  &ret,
866  NULL, &err);
867  g_variant_unref(input);
868 
869  if(err != NULL)
870  {
871  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
872  return;
873  }
874 
875  /*create response json object*/
876  struct json_object *res = json_object_new_object();
877  sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
878  _error, ret,
879  _source_id, acquire_source_id);
880  char *info = get_response_audiomanager_massage_error(ret);
881  afb_req_success(request, res, info);
882 }
883 
897 static void deregisterSource(struct afb_req request)
898 {
899  guint16 source_id;
900  guint16 ret;
901 
902  GError *err = NULL;
903 
904  if(REQ_OK != get_value_uint16(request, _source_id, &source_id)){
905  afb_req_fail(request, "wrong-request", NULL);
906  }
908  am_route_bus,
909  source_id,
910  &ret,
911  NULL, &err
912  );
913  if(err != NULL)
914  {
915  afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
916  return;
917  }
918  /*create response json object*/
919  struct json_object *res = json_object_new_object();
920  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
921  _error, ret);
922  char *info = get_response_audiomanager_massage_error(ret);
923  afb_req_success(request, res, info);
924 
925 }
926 
939 static void subscribe(struct afb_req request)
940 {
941  const char *value = afb_req_value(request, "event");
942  AFB_DEBUG( "value is %s", value);
943  int ret = 0;
944  if(value) {
945  int index = sm_search_event_name_index(value);
946  if(index < 0)
947  {
948  index = sm_search_routing_event_name_index(value);
949  if(index < 0)
950  {
951  AFB_NOTICE( "dedicated event doesn't exist");
953  }
954  else
955  {
956  afb_req_subscribe(request, *routing_event_list[index].event);
957  }
958  }
959  else
960  {
961  afb_req_subscribe(request, *command_event_list[index].event);
962  }
963  }
964  else{
965  AFB_NOTICE( "Please input event name");
967  }
968  /*create response json object*/
969  struct json_object *res = json_object_new_object();
970  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
971  _error, ret);
972  char *info = get_response_audiomanager_massage_error(ret);
973  afb_req_success(request, res, info);
974 }
975 
988 static void unsubscribe(struct afb_req request)
989 {
990  const char *value = afb_req_value(request, "event");
991  AFB_DEBUG( "value is %s", value);
992  int ret = 0;
993  if(value) {
994  int index = sm_search_event_name_index(value);
995  if(index < 0)
996  {
997  index = sm_search_routing_event_name_index(value);
998  if(index < 0)
999  {
1000  AFB_NOTICE( "dedicated event doesn't exist");
1002  }
1003  else
1004  {
1005  afb_req_unsubscribe(request, *routing_event_list[index].event);
1006  }
1007  }
1008  else
1009  {
1010  afb_req_unsubscribe(request, *command_event_list[index].event);
1011  }
1012  }
1013  else{
1014  AFB_NOTICE( "Please input event name");
1016  }
1017  /*create response json object*/
1018  struct json_object *res = json_object_new_object();
1019  sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
1020  _error, ret);
1021  char *info = get_response_audiomanager_massage_error(ret);
1022  afb_req_success(request, res, info);
1023 }
1024 
1025 /*
1026 ********** Callback Function invoked by Audio Manager **********
1027 */
1028 
1029 static void on_new_main_connection(AudiomanagerCommandinterface* interface,
1030  GVariant* mainConnection)
1031 {
1032  AFB_DEBUG("%s is called",__FUNCTION__);
1033 
1034  guint16 mcid, srcid, sinkid;
1035  gint16 delay, constate;
1036  g_variant_get(
1037  mainConnection,"(qqqnn)", &mcid, &srcid, &sinkid, &delay, &constate);
1038 
1039  struct json_object* res_obj = json_object_new_object();
1040  sm_add_object_to_json_object(res_obj,10,
1041  _main_connection_id, mcid,
1042  _source_id, srcid,
1043  _sink_id, sinkid,
1044  _delay, delay,
1045  _connection_state, constate
1046  );
1047  AFB_DEBUG("json object :%s:",json_object_to_json_string(res_obj));
1048 
1049  afb_event_push(ev_new_connection, res_obj);
1050 }
1051 
1052 static void on_removed_main_connection(
1053  AudiomanagerCommandinterface* interface, guint16 mainConnectionID)
1054 {
1055  AFB_DEBUG("%s is called",__FUNCTION__);
1056 
1057  struct json_object* res_obj = json_object_new_object();
1058  sm_add_object_to_json_object(res_obj, 2,
1059  _main_connection_id, mainConnectionID);
1060  afb_event_push(ev_removed_main_connection, res_obj);
1061 }
1062 
1063 static void on_main_connection_state_changed(
1064  AudiomanagerCommandinterface* interface, guint16 connectionID, gint16 connectionState)
1065 {
1066  AFB_DEBUG("%s is called",__FUNCTION__);
1067 
1068  struct json_object* res_obj = json_object_new_object();
1069  sm_add_object_to_json_object(res_obj, 4,
1070  _connection_id, connectionID,
1071  _connection_state, connectionState);
1072  afb_event_push(ev_main_connection_state_changed, res_obj);
1073 }
1074 
1075 static void on_volume_changed(
1076  AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 volume)
1077 {
1078  AFB_DEBUG("%s is called",__FUNCTION__);
1079  struct json_object* res_obj = json_object_new_object();
1080  sm_add_object_to_json_object(res_obj, 4,
1081  _sink_id, sinkID,
1082  _volume, volume);
1083  afb_event_push(ev_volume_changed, res_obj);
1084 }
1085 
1086 static void on_sink_mute_state_changed(
1087  AudiomanagerCommandinterface* interface, guint16 sinkID, gint16 mute)
1088 {
1089  AFB_DEBUG("%s is called",__FUNCTION__);
1090  struct json_object* res_obj = json_object_new_object();
1091  sm_add_object_to_json_object(res_obj, 4,
1092  _sink_id, sinkID,
1093  _mute_state, mute);
1094  afb_event_push(ev_sink_mute_state_changed, res_obj);
1095 }
1096 
1097 /*
1098 ********** Callback Function invoked by Audio Manager Routing Interface**********
1099 */
1100 static void on_set_routing_ready(
1101  AudiomanagerRoutinginterface* interface)
1102 {
1103  AFB_DEBUG("%s is called",__FUNCTION__);
1104  afb_event_push(ev_set_routing_ready, NULL);
1105 }
1106 
1107 static void on_set_routing_rundown(
1108  AudiomanagerRoutinginterface* interface)
1109 {
1110  AFB_DEBUG("%s is called",__FUNCTION__);
1111  afb_event_push(ev_set_routing_ready, NULL);
1112 }
1113 
1114 
1115 
1116 /*
1117 ********** Callback Function invoked by Sound Manager Adapter Interface**********
1118 *
1119 * For now, there may be no need to send events to applications from these invocation.
1120 * Sound Manager just sends ack to Audio Manager in charge of applications.
1121 *
1122 */
1123 static gboolean on_async_abort(
1125  GDBusMethodInvocation *invocation,
1126  guint16 arg_handle)
1127 {
1128  AFB_DEBUG( "%s called", __FUNCTION__);
1129  /* Nothing To Do. If it is better to implement something, I will implement */
1130  return TRUE;
1131 }
1132 
1133 static gboolean on_async_connect(
1135  GDBusMethodInvocation *invocation,
1136  guint16 arg_handle,
1137  guint16 arg_connectionID,
1138  guint16 arg_sourceID,
1139  guint16 arg_sinkID,
1140  gint arg_connectionFormat)
1141 {
1142  AFB_DEBUG( "%s called", __FUNCTION__);
1143 
1144  struct json_object* ev_obj = json_object_new_object();
1145  sm_add_object_to_json_object(ev_obj, 10,
1146  _handle, arg_handle,
1147  _connection_id, arg_connectionID,
1148  _source_id, arg_sourceID,
1149  _sink_id, arg_sinkID,
1150  _connection_format, arg_connectionFormat);
1151  afb_event_push(ev_async_connect, ev_obj);
1152 
1153  /* GError must be initialized here because it is same as grobal errno,
1154  so if afb_event_push is failed due to something, number will be changed */
1155  GError* err = NULL;
1157  am_route_bus,
1158  arg_handle,
1159  arg_connectionID,
1160  0,
1161  NULL, &err);
1162  if(err != NULL)
1163  {
1164  AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
1165  return FALSE;
1166  }
1167  return TRUE;
1168 }
1169 
1170 static gboolean on_async_disconnect(
1172  GDBusMethodInvocation *invocation,
1173  guint16 arg_handle,
1174  guint16 arg_connectionID)
1175 {
1176  AFB_DEBUG( "%s called", __FUNCTION__);
1177  struct json_object* ev_obj = json_object_new_object();
1178  sm_add_object_to_json_object(ev_obj, 4,
1179  _handle, arg_handle,
1180  _connection_id, arg_connectionID);
1181  afb_event_push(ev_async_disconnect, ev_obj);
1182  GError* err = NULL;
1184  am_route_bus,
1185  arg_handle,
1186  arg_connectionID,
1187  0,
1188  NULL, &err);
1189  if(err != NULL)
1190  {
1191  AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
1192  return FALSE;
1193  }
1194  return TRUE;
1195 }
1196 
1197 static gboolean on_async_set_sink_volume(
1199  GDBusMethodInvocation *invocation,
1200  guint16 arg_handle,
1201  guint16 arg_sinkID,
1202  gint16 arg_volume,
1203  gint16 arg_ramp,
1204  guint16 arg_time)
1205 {
1206  AFB_DEBUG( "%s called", __FUNCTION__);
1207  GError* err = NULL;
1209  am_route_bus,
1210  arg_handle,
1211  arg_volume,
1212  0, NULL, &err);
1213  if(err != NULL);{
1214  AFB_ERROR( "Can't send ack to sound manager adapter %s", __FUNCTION__);
1215  return FALSE;
1216  }
1217  return TRUE;
1218 }
1219 
1237 static gboolean on_async_set_source_state(
1239  GDBusMethodInvocation *invocation,
1240  guint16 arg_handle,
1241  guint16 arg_sourceID,
1242  gint arg_sourceState)
1243 {
1244  AFB_DEBUG( "%s called", __FUNCTION__);
1245  struct json_object* ev_obj = json_object_new_object();
1246  char* ss_key = get_source_state_key(arg_sourceState);
1247  sm_add_object_to_json_object(ev_obj, 4,
1248  _handle, arg_handle,
1249  _source_id, arg_sourceID);
1250  json_object_object_add(ev_obj, _source_state, json_object_new_string(ss_key));
1251  afb_event_push(ev_async_set_source_state, ev_obj);
1252  /* Applications must return ackSetSourceState to look sourceID, then Sound Manager doen't return ackSetSourceState */
1253  /*audiomanager_routinginterface_call_ack_set_source_state_sync(
1254  am_route_bus,
1255  arg_handle,
1256  NULL,
1257  NULL, &err);*/
1258 }
1259 
1260 
1261 /*
1262  * array of the verbs exported to afb-daemon
1263  */
1264 static const struct afb_verb_v2 binding_verbs[]= {
1265 { .verb = "connect", .callback = connect, .auth = NULL,
1266  .info = "Connect source id and sink id" , .session = AFB_SESSION_NONE},
1267 { .verb = "disconnect", .callback = disconnect, .auth = NULL,
1268  .info = "Disconnect source id and sink id" , .session = AFB_SESSION_NONE},
1269 { .verb = "setVolume", .callback = setVolume, .auth = NULL,
1270  .info = "Set volume value" , .session = AFB_SESSION_NONE}, /* it is better to show the range*/
1271 { .verb = "volumeStep", .callback = volumeStep, .auth = NULL,
1272  .info = "Set volume step range" , .session = AFB_SESSION_NONE},
1273 { .verb = "setSinkMuteState", .callback = setSinkMuteState, .auth = NULL,
1274  .info = "Set Mute state: 1 means mute, 2 means umute. Others are invalid" ,.session = AFB_SESSION_NONE},
1275 { .verb = "getListMainConnections", .callback = getListMainConnections, .auth = NULL,
1276  .info = "Get MainConnection List" , .session = AFB_SESSION_NONE},
1277 { .verb = "getListMainSinks", .callback = getListMainSinks, .auth = NULL,
1278  .info = "Get MainSink List" , .session = AFB_SESSION_NONE},
1279 { .verb = "registerSource", .callback = registerSource, .auth = NULL,
1280  .info = "Register Application" , .session = AFB_SESSION_NONE},
1281 { .verb = "deregisterSource", .callback = deregisterSource, .auth = NULL,
1282  .info = "Deregister Application" , .session = AFB_SESSION_NONE},
1283 { .verb = "ackConnect", .callback = ackConnect, .auth = NULL,
1284  .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
1285 { .verb = "ackDisconnect", .callback = ackDisconnect, .auth = NULL,
1286  .info = "Acknowledge of asyncConnect" , .session = AFB_SESSION_NONE},
1287 { .verb = "ackSetSourceState", .callback = ackSetSourceState, .auth = NULL,
1288  .info = "Acknowledge of asyncSetSourceState" , .session = AFB_SESSION_NONE},
1289 { .verb = "subscribe", .callback = subscribe, .auth = NULL,
1290  .info = "Subscribe event" , .session = AFB_SESSION_NONE},
1291 { .verb = "unsubscribe", .callback = unsubscribe, .auth = NULL,
1292  .info = "Unsubscribe event" , .session = AFB_SESSION_NONE},
1293 { .verb = NULL } /* marker for end of the array */};
1294 
1295 static void *dbus_event_loop_run(void *args)
1296 {
1297  loop = g_main_loop_new(NULL, FALSE);
1298  g_main_loop_run(loop);
1299 }
1300 
1301 /*
1302 *
1303 ********** Internal Function used by Sound Manager **********
1304 *
1305 */
1306 
1307 static int registerDomain()
1308 {
1309  /* Default Setting of Sound Manager Domain */
1310  struct domain_data ddata = {
1312  .name = "SoundManager",
1313  .busname = SOUND_MANAGER_BUS_NAME,
1314  .nodename = "soundmanager",
1315  .early = FALSE,
1316  .complete = TRUE,
1317  .state = DS_CONTROLLED
1318  };
1319  GVariant* domainData = create_domain_data(&ddata);
1320  gchar* retBusName = SOUND_MANAGER_BUS_NAME;
1321  gchar* retPath = SOUND_MANAGER_PATH;
1322  gchar* retInterface = SOUND_MANAGER_RETURN_INTERFACE;
1323  guint16 domain_id;
1324  GError *err = NULL;
1325  guint16 error;
1326 
1328  am_route_bus,
1329  domainData,
1330  retBusName,
1331  retPath,
1332  retInterface,
1333  &domain_id, &error,
1334  NULL, &err);
1335  if(err != NULL){
1336  AFB_ERROR( "Failed to call %s", __FUNCTION__);
1337  return -1;
1338  }
1339  if(error != 0)
1340  {
1341  AFB_ERROR( "Failed to register domain");
1342  return error;
1343  }
1344  SOUNDMANAGER_DOMAIN_ID = domain_id;
1345  AFB_NOTICE( "Complete registered domain id:%d",SOUNDMANAGER_DOMAIN_ID);
1346  return 0;
1347 }
1348 
1349 static int preinit()
1350 {
1351  int ret;
1352  AFB_INFO("Initialize Dbus object");
1353  /* Initialize Dbus interface */
1354  if(am_cmd_bus || am_route_bus)
1355  {
1356  AFB_ERROR( "Dbus object to Audio Manager is already created");
1357  goto out;
1358  }
1360  G_BUS_TYPE_SYSTEM,
1361  G_DBUS_PROXY_FLAGS_NONE,
1362  AM_NAME,
1363  AM_CMD_PATH,
1364  NULL,
1365  NULL
1366  );
1368  G_BUS_TYPE_SYSTEM,
1369  G_DBUS_PROXY_FLAGS_NONE,
1370  AM_NAME,
1371  AM_ROUTE_PATH,
1372  NULL,
1373  NULL
1374  );
1375 
1376  if(!am_cmd_bus || !am_route_bus)
1377  {
1378  goto out;
1379  }
1380 
1381  AFB_NOTICE( "Finish Initialize");
1382  return 0;
1383 out:
1384  AFB_ERROR("Failed to initialize");
1385  return -1;
1386 }
1387 
1388 static int create_adapter()
1389 {
1390  GError *error = NULL;
1391  gboolean ret;
1392  GVariant *value;
1393  system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
1394  if (error)
1395  {
1396  g_error_free(error);
1397  return -1;
1398  }
1400  sm_itf = AUDIOMANAGER_ROUTING_SOUNDMANAGER_GET_IFACE(sm_adapter);
1401 
1402  /* initialize sound manager adapter */
1403  sm_itf->handle_async_abort = on_async_abort;
1404  sm_itf->handle_async_connect = on_async_connect;
1405  sm_itf->handle_async_disconnect = on_async_disconnect;
1406  sm_itf->handle_async_set_sink_volume = on_async_set_sink_volume;
1407  sm_itf->handle_async_set_source_state = on_async_set_source_state;
1408 
1409  int sigret = g_signal_connect(sm_adapter, "handle-async-abort", G_CALLBACK(on_async_abort),NULL);
1410  sigret = g_signal_connect(sm_adapter, "handle-async-connect", G_CALLBACK(on_async_connect),NULL);
1411  sigret = g_signal_connect(sm_adapter, "handle-async-disconnect", G_CALLBACK(on_async_disconnect),NULL);
1412  sigret = g_signal_connect(sm_adapter, "handle-async-set-sink-volume", G_CALLBACK(on_async_set_sink_volume),NULL);
1413  sigret = g_signal_connect(sm_adapter, "handle-async-set-source-state", G_CALLBACK(on_async_set_source_state),NULL);
1414  ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(sm_adapter), system_conn, SOUND_MANAGER_PATH, &error);
1415  if (FALSE == ret)
1416  {
1417  AFB_ERROR( "failed to export");
1418  g_error_free(error);
1419  g_object_unref(system_conn);
1420 
1421  return -1;
1422  }
1423 
1424  return 0;
1425 }
1426 
1427 
1428 static void on_name_lost(GDBusServer *server, GDBusConnection *conn, gpointer data)
1429 {
1430  AFB_WARNING("%s called", __FUNCTION__);
1431 }
1432 
1433 
1434 static int sm_event_init()
1435 {
1436  AFB_NOTICE("Initialize event receive setting");
1437  printf("Initialize event receive setting");
1438  int ret;
1439  /* Initialize make event */
1440  size_t size = sizeof cmd_evlist / sizeof *cmd_evlist;
1441 
1442  /*create event*/
1443  /*ToDo Hash table is better. And event should be created in the loop
1444  I would like to change */
1445  ev_volume_changed = afb_daemon_make_event(cmd_evlist[0]);
1446  ev_new_connection = afb_daemon_make_event(cmd_evlist[1]);
1447  ev_removed_main_connection = afb_daemon_make_event(cmd_evlist[2]);
1448  ev_sink_mute_state_changed = afb_daemon_make_event(cmd_evlist[3]);
1449  ev_main_connection_state_changed = afb_daemon_make_event(cmd_evlist[4]);
1450  command_event_list[0].name = cmd_evlist[0];
1451  command_event_list[0].event = &ev_volume_changed;
1452  command_event_list[1].name = cmd_evlist[1];
1453  command_event_list[1].event = &ev_new_connection;
1454  command_event_list[2].name = cmd_evlist[2];
1455  command_event_list[2].event = &ev_removed_main_connection;
1456  command_event_list[3].name = cmd_evlist[3];
1457  command_event_list[3].event = &ev_sink_mute_state_changed;
1458  command_event_list[4].name = cmd_evlist[4];
1459  command_event_list[4].event = &ev_main_connection_state_changed;
1460 
1461  /* create routing event */
1462  ev_set_routing_ready = afb_daemon_make_event(route_evlist[0]);
1463  ev_set_routing_rundown = afb_daemon_make_event(route_evlist[1]);
1464  ev_async_connect = afb_daemon_make_event(route_evlist[2]);
1465  ev_async_set_source_state = afb_daemon_make_event(route_evlist[3]);
1466  ev_async_disconnect = afb_daemon_make_event(route_evlist[4]);
1467 
1468  routing_event_list[0].name = route_evlist[0];
1469  routing_event_list[0].event = &ev_set_routing_ready;
1470  routing_event_list[1].name = route_evlist[1];
1471  routing_event_list[1].event = &ev_set_routing_rundown;
1472  routing_event_list[2].name = route_evlist[2];
1473  routing_event_list[2].event = &ev_async_connect;
1474  routing_event_list[3].name = route_evlist[3];
1475  routing_event_list[3].event = &ev_async_set_source_state;
1476  routing_event_list[4].name = route_evlist[4];
1477  routing_event_list[4].event = &ev_async_disconnect;
1478  /*for(size_t i = 0; i < size; ++i)
1479  {
1480  struct afb_event afbev = afb_daemon_make_event(afbitf->daemon, cmd_evlist[i]));
1481  size_t afbev_size = sizeof afbev;
1482  size_t key_size = sizeof cmd_evlist[i];
1483 
1484  struct event ev = {cmd_evlist[i],afbev};
1485  command_event_list[i] = malloc(key_size + afbev_size);
1486  command_event_list[i] = ev;
1487  search_result = hsearch(entry, FIND);
1488  if(search_result)
1489  AFB_NOTICE( "event name is %s", search_result->key);
1490  }*/
1491 
1492  /* Initialize dbus event thread */
1493  if(!am_cmd_bus || !am_route_bus)
1494  {
1495  goto ev_init_out;
1496  }
1497  pthread_t thread_id;
1498  ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL);
1499  if(ret != 0)
1500  {
1501  goto ev_init_out;
1502  }
1503  /* initialize signal from audio manager command interface */
1504  g_signal_connect(am_cmd_bus,
1505  "volume_changed",
1506  G_CALLBACK(on_volume_changed),
1507  NULL);
1508  g_signal_connect(am_cmd_bus,
1509  "new_main_connection",
1510  G_CALLBACK(on_new_main_connection),
1511  NULL);
1512  g_signal_connect(am_cmd_bus,
1513  "removed_main_connection",
1514  G_CALLBACK(on_removed_main_connection),
1515  NULL);
1516  g_signal_connect(am_cmd_bus,
1517  "sink_mute_state_changed",
1518  G_CALLBACK(on_sink_mute_state_changed),
1519  NULL);
1520  g_signal_connect(am_cmd_bus,
1521  "main_connection_state_changed",
1522  G_CALLBACK(on_main_connection_state_changed),
1523  NULL);
1524  g_signal_connect(am_route_bus,
1525  "set_routing_ready",
1526  G_CALLBACK(on_set_routing_ready),
1527  NULL);
1528  g_signal_connect(am_route_bus,
1529  "set_routing_rundown",
1530  G_CALLBACK(on_set_routing_rundown),
1531  NULL);
1532 
1533  /* Get soundmanager adapter bus */
1534  ret = g_bus_own_name(G_BUS_TYPE_SYSTEM, SOUND_MANAGER_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
1535  NULL,NULL, NULL, NULL, NULL);
1536  AFB_DEBUG( "g_bus_own_name ret: %d", ret);
1537  ret = create_adapter();
1538  if(ret != 0)
1539  {
1540  goto ev_init_out;
1541  }
1542  ret = registerDomain();
1543 
1544  if(ret != 0)
1545  {
1546  AFB_ERROR("registerDomain error: %s",get_response_audiomanager_massage_error(ret));
1547  goto ev_init_out;
1548  }
1549 
1550  AFB_INFO("Finish Initialize event receive setting");
1551  return 0;
1552 
1553 ev_init_out:
1554  if(loop != NULL)
1555  {
1556  g_main_loop_unref(loop);
1557  }
1558  AFB_WARNING( "DBus connection is not created");
1559  return -1;
1560 }
1561 
1562 static void onevent(const char *event, struct json_object *object)
1563 {
1564  AFB_NOTICE("on_event %s", event);
1565 }
1566 
1567 const struct afb_binding_v2 afbBindingV2 = {
1568  .api = "soundmanager",
1569  .specification = NULL,
1570  .verbs = binding_verbs,
1571  .preinit = preinit,
1572  .init = sm_event_init,
1573  .onevent = onevent
1574 };
struct _AudiomanagerRoutingSoundmanager AudiomanagerRoutingSoundmanager
struct afb_event * event
Definition: soundmanager.c:68
#define DYNAMIC_SOURCE_ID
Definition: soundmanager.c:46
#define AM_CMD_PATH
Definition: soundmanager.c:33
#define AM_NAME
Definition: soundmanager.c:32
gint32 availability
Definition: sm-helper.h:56
gboolean audiomanager_routinginterface_call_deregister_source_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_sourceID, guint16 *out_error, GCancellable *cancellable, GError **error)
#define DEFAULT_VOLUME
Definition: soundmanager.c:47
#define AM_ROUTE_PATH
Definition: soundmanager.c:34
#define SOUND_MANAGER_RETURN_INTERFACE
Definition: soundmanager.c:36
gboolean(* handle_async_connect)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_connectionID, guint16 arg_sourceID, guint16 arg_sinkID, gint arg_connectionFormat)
#define DEFAULT_SOURCE_CLASS_ID
Definition: soundmanager.c:43
#define DYNAMIC_DOMAIN_ID
Definition: soundmanager.c:44
void sm_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: sm-helper.c:110
#define DEFAULT_AVAILABLES
Definition: soundmanager.c:48
struct _AudiomanagerCommandinterface AudiomanagerCommandinterface
struct _AudiomanagerRoutinginterface AudiomanagerRoutinginterface
#define DEFAULT_INTERRUPT
Definition: soundmanager.c:50
char * get_response_audiomanager_massage_error(int am_error_code)
Definition: sm-error.h:4
gboolean audiomanager_routinginterface_call_ack_disconnect_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, guint16 arg_connectionID, guint16 arg_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_ack_connect_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, guint16 arg_connectionID, guint16 arg_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_set_volume_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sinkID, gint16 arg_volume, gint16 *out_result, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_register_source_sync(AudiomanagerRoutinginterface *proxy, GVariant *arg_sourceData, guint16 *out_sourceID, guint16 *out_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_set_sink_mute_state_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sinkID, gint16 arg_muteState, gint16 *out_result, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_ack_set_sink_volume_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, gint16 arg_volume, guint16 arg_error, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_get_list_main_connections_sync(AudiomanagerCommandinterface *proxy, gint16 *out_result, GVariant **out_listConnections, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_get_list_main_sinks_sync(AudiomanagerCommandinterface *proxy, gint16 *out_result, GVariant **out_listMainSinks, GCancellable *cancellable, GError **error)
#define AUDIOMANAGER_ROUTING_SOUNDMANAGER_GET_IFACE(o)
gboolean(* handle_async_abort)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle)
REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id)
Definition: sm-helper.c:48
guint16 domainID
Definition: sm-helper.h:70
#define ROUTING_EVENT_NUM
Definition: soundmanager.c:41
gboolean(* handle_async_disconnect)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_connectionID)
AudiomanagerRoutinginterface * audiomanager_routinginterface_proxy_new_for_bus_sync(GBusType bus_type, GDBusProxyFlags flags, const gchar *name, const gchar *object_path, GCancellable *cancellable, GError **error)
int sm_search_event_name_index(const char *value)
Definition: sm-helper.c:127
#define SOUND_MANAGER_BUS_NAME
Definition: soundmanager.c:37
AudiomanagerRoutingSoundmanager * audiomanager_routing_soundmanager_skeleton_new(void)
REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id)
Definition: sm-helper.c:24
char * get_source_state_key(int am_source_state)
Definition: sm-error.h:38
#define SOUND_MANAGER_PATH
Definition: soundmanager.c:38
gboolean audiomanager_commandinterface_call_connect_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sourceID, guint16 arg_sinkID, gint16 *out_result, guint16 *out_mainConnectionID, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_volume_step_sync(AudiomanagerCommandinterface *proxy, guint16 arg_sinkID, gint16 arg_volumeStep, gint16 *out_result, GCancellable *cancellable, GError **error)
#define DS_CONTROLLED
Definition: soundmanager.c:52
guint16 type
Definition: sm-helper.h:52
const struct afb_binding_v2 afbBindingV2
REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id)
Definition: sm-helper.c:72
void sm_add_object_to_json_object(struct json_object *j_obj, int count,...)
Definition: sm-helper.c:96
GVariant * create_domain_data(struct domain_data *data)
Definition: sm-helper.c:218
gboolean audiomanager_routinginterface_call_ack_set_source_state_sync(AudiomanagerRoutinginterface *proxy, guint16 arg_handle, guint16 arg_error, GCancellable *cancellable, GError **error)
#define DEFAULT_SINK
Definition: soundmanager.c:42
#define DEFAULT_CONNECTION_FORMAT
Definition: soundmanager.c:49
gboolean(* handle_async_set_source_state)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_sourceID, gint arg_sourceState)
GVariant * create_source_data(guint16 sourceID, guint16 domainID, const char *appname, guint16 sourceClassID, gint32 sourceState, gint16 volume, gboolean visible, struct availability_s availables, guint16 interrupt, struct sound_property_s soundPropertyList, gint32 connectionFormatList, struct main_sound_property_s mainPropertyList, struct notification_config_s NConfRouting, struct notification_config_s NConfCommand)
Definition: sm-helper.c:159
#define EVENT_SUBSCRIBE_ERROR_CODE
Definition: soundmanager.c:54
REQ_ERROR
Definition: sm-helper.h:26
AudiomanagerCommandinterface * audiomanager_commandinterface_proxy_new_for_bus_sync(GBusType bus_type, GDBusProxyFlags flags, const gchar *name, const gchar *object_path, GCancellable *cancellable, GError **error)
gboolean audiomanager_commandinterface_call_disconnect_sync(AudiomanagerCommandinterface *proxy, guint16 arg_mainConnectionID, gint16 *out_result, GCancellable *cancellable, GError **error)
gboolean audiomanager_routinginterface_call_register_domain_sync(AudiomanagerRoutinginterface *proxy, GVariant *arg_domaindata, const gchar *arg_returnBusname, const gchar *arg_returnPath, const gchar *arg_returnInterface, guint16 *out_domainid, guint16 *out_error, GCancellable *cancellable, GError **error)
gboolean(* handle_async_set_sink_volume)(AudiomanagerRoutingSoundmanager *object, GDBusMethodInvocation *invocation, guint16 arg_handle, guint16 arg_sinkID, gint16 arg_volume, gint16 arg_ramp, guint16 arg_time)
#define DEFAULT_SOURCE_STATE
Definition: soundmanager.c:51
#define COMMAND_EVENT_NUM
Definition: soundmanager.c:40
char * name
Definition: soundmanager.c:67
int sm_search_routing_event_name_index(const char *value)
Definition: sm-helper.c:143