aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dbus/audio_manager_interface.c194
-rw-r--r--src/dbus/audio_manager_interface.h30
-rw-r--r--src/dbus/command_interface.xml6
-rw-r--r--src/soundmanager.c80
4 files changed, 309 insertions, 1 deletions
diff --git a/src/dbus/audio_manager_interface.c b/src/dbus/audio_manager_interface.c
index c276d70..15ad786 100644
--- a/src/dbus/audio_manager_interface.c
+++ b/src/dbus/audio_manager_interface.c
@@ -542,6 +542,48 @@ static const _ExtendedGDBusMethodInfo _audiomanager_commandinterface_method_info
FALSE
};
+static const _ExtendedGDBusArgInfo _audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_result =
+{
+ {
+ -1,
+ (gchar *) "result",
+ (gchar *) "n",
+ NULL
+ },
+ FALSE
+};
+
+static const _ExtendedGDBusArgInfo _audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_listMainSources =
+{
+ {
+ -1,
+ (gchar *) "listMainSources",
+ (gchar *) "a(qs(nn)q)",
+ NULL
+ },
+ FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_pointers[] =
+{
+ &_audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_result,
+ &_audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_listMainSources,
+ NULL
+};
+
+static const _ExtendedGDBusMethodInfo _audiomanager_commandinterface_method_info_get_list_main_sources =
+{
+ {
+ -1,
+ (gchar *) "GetListMainSources",
+ NULL,
+ (GDBusArgInfo **) &_audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_pointers,
+ NULL
+ },
+ "handle-get-list-main-sources",
+ FALSE
+};
+
static const _ExtendedGDBusMethodInfo * const _audiomanager_commandinterface_method_info_pointers[] =
{
&_audiomanager_commandinterface_method_info_connect,
@@ -551,6 +593,7 @@ static const _ExtendedGDBusMethodInfo * const _audiomanager_commandinterface_met
&_audiomanager_commandinterface_method_info_set_sink_mute_state,
&_audiomanager_commandinterface_method_info_get_list_main_connections,
&_audiomanager_commandinterface_method_info_get_list_main_sinks,
+ &_audiomanager_commandinterface_method_info_get_list_main_sources,
NULL
};
@@ -827,6 +870,7 @@ audiomanager_commandinterface_override_properties (GObjectClass *klass, guint pr
* @handle_disconnect: Handler for the #AudiomanagerCommandinterface::handle-disconnect signal.
* @handle_get_list_main_connections: Handler for the #AudiomanagerCommandinterface::handle-get-list-main-connections signal.
* @handle_get_list_main_sinks: Handler for the #AudiomanagerCommandinterface::handle-get-list-main-sinks signal.
+ * @handle_get_list_main_sources: Handler for the #AudiomanagerCommandinterface::handle-get-list-main-sources signal.
* @handle_set_sink_mute_state: Handler for the #AudiomanagerCommandinterface::handle-set-sink-mute-state signal.
* @handle_set_volume: Handler for the #AudiomanagerCommandinterface::handle-set-volume signal.
* @handle_volume_step: Handler for the #AudiomanagerCommandinterface::handle-volume-step signal.
@@ -1010,6 +1054,28 @@ audiomanager_commandinterface_default_init (AudiomanagerCommandinterfaceIface *i
1,
G_TYPE_DBUS_METHOD_INVOCATION);
+ /**
+ * AudiomanagerCommandinterface::handle-get-list-main-sources:
+ * @object: A #AudiomanagerCommandinterface.
+ * @invocation: A #GDBusMethodInvocation.
+ *
+ * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-genivi-audiomanager-commandinterface.GetListMainSources">GetListMainSources()</link> D-Bus method.
+ *
+ * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call audiomanager_commandinterface_complete_get_list_main_sources() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+ *
+ * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+ */
+ g_signal_new ("handle-get-list-main-sources",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (AudiomanagerCommandinterfaceIface, handle_get_list_main_sources),
+ g_signal_accumulator_true_handled,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_BOOLEAN,
+ 1,
+ G_TYPE_DBUS_METHOD_INVOCATION);
+
/* GObject signals for received D-Bus signals: */
/**
* AudiomanagerCommandinterface::new-main-connection:
@@ -1985,6 +2051,110 @@ _out:
}
/**
+ * audiomanager_commandinterface_call_get_list_main_sources:
+ * @proxy: A #AudiomanagerCommandinterfaceProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-genivi-audiomanager-commandinterface.GetListMainSources">GetListMainSources()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call audiomanager_commandinterface_call_get_list_main_sources_finish() to get the result of the operation.
+ *
+ * See audiomanager_commandinterface_call_get_list_main_sources_sync() for the synchronous, blocking version of this method.
+ */
+void
+audiomanager_commandinterface_call_get_list_main_sources (
+ AudiomanagerCommandinterface *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+ "GetListMainSources",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * audiomanager_commandinterface_call_get_list_main_sources_finish:
+ * @proxy: A #AudiomanagerCommandinterfaceProxy.
+ * @out_result: (out): Return location for return parameter or %NULL to ignore.
+ * @out_listMainSources: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to audiomanager_commandinterface_call_get_list_main_sources().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with audiomanager_commandinterface_call_get_list_main_sources().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+audiomanager_commandinterface_call_get_list_main_sources_finish (
+ AudiomanagerCommandinterface *proxy,
+ gint16 *out_result,
+ GVariant **out_listMainSources,
+ GAsyncResult *res,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "(n@a(qs(nn)q))",
+ out_result,
+ out_listMainSources);
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * audiomanager_commandinterface_call_get_list_main_sources_sync:
+ * @proxy: A #AudiomanagerCommandinterfaceProxy.
+ * @out_result: (out): Return location for return parameter or %NULL to ignore.
+ * @out_listMainSources: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-genivi-audiomanager-commandinterface.GetListMainSources">GetListMainSources()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See audiomanager_commandinterface_call_get_list_main_sources() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+audiomanager_commandinterface_call_get_list_main_sources_sync (
+ AudiomanagerCommandinterface *proxy,
+ gint16 *out_result,
+ GVariant **out_listMainSources,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+ "GetListMainSources",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "(n@a(qs(nn)q))",
+ out_result,
+ out_listMainSources);
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
* audiomanager_commandinterface_complete_connect:
* @object: A #AudiomanagerCommandinterface.
* @invocation: (transfer full): A #GDBusMethodInvocation.
@@ -2140,6 +2310,30 @@ audiomanager_commandinterface_complete_get_list_main_sinks (
listMainSinks));
}
+/**
+ * audiomanager_commandinterface_complete_get_list_main_sources:
+ * @object: A #AudiomanagerCommandinterface.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @result: Parameter to return.
+ * @listMainSources: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-genivi-audiomanager-commandinterface.GetListMainSources">GetListMainSources()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+audiomanager_commandinterface_complete_get_list_main_sources (
+ AudiomanagerCommandinterface *object,
+ GDBusMethodInvocation *invocation,
+ gint16 result,
+ GVariant *listMainSources)
+{
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(n@a(qs(nn)q))",
+ result,
+ listMainSources));
+}
+
/* ------------------------------------------------------------------------ */
/**
diff --git a/src/dbus/audio_manager_interface.h b/src/dbus/audio_manager_interface.h
index c2568f1..f43bceb 100644
--- a/src/dbus/audio_manager_interface.h
+++ b/src/dbus/audio_manager_interface.h
@@ -48,6 +48,10 @@ struct _AudiomanagerCommandinterfaceIface
AudiomanagerCommandinterface *object,
GDBusMethodInvocation *invocation);
+ gboolean (*handle_get_list_main_sources) (
+ AudiomanagerCommandinterface *object,
+ GDBusMethodInvocation *invocation);
+
gboolean (*handle_set_sink_mute_state) (
AudiomanagerCommandinterface *object,
GDBusMethodInvocation *invocation,
@@ -140,6 +144,12 @@ void audiomanager_commandinterface_complete_get_list_main_sinks (
gint16 result,
GVariant *listMainSinks);
+void audiomanager_commandinterface_complete_get_list_main_sources (
+ AudiomanagerCommandinterface *object,
+ GDBusMethodInvocation *invocation,
+ gint16 result,
+ GVariant *listMainSources);
+
/* D-Bus signal emissions functions: */
@@ -323,6 +333,26 @@ gboolean audiomanager_commandinterface_call_get_list_main_sinks_sync (
GCancellable *cancellable,
GError **error);
+void audiomanager_commandinterface_call_get_list_main_sources (
+ AudiomanagerCommandinterface *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean audiomanager_commandinterface_call_get_list_main_sources_finish (
+ AudiomanagerCommandinterface *proxy,
+ gint16 *out_result,
+ GVariant **out_listMainSources,
+ GAsyncResult *res,
+ GError **error);
+
+gboolean audiomanager_commandinterface_call_get_list_main_sources_sync (
+ AudiomanagerCommandinterface *proxy,
+ gint16 *out_result,
+ GVariant **out_listMainSources,
+ GCancellable *cancellable,
+ GError **error);
+
/* ---- */
diff --git a/src/dbus/command_interface.xml b/src/dbus/command_interface.xml
index e33d7fb..2be9ba2 100644
--- a/src/dbus/command_interface.xml
+++ b/src/dbus/command_interface.xml
@@ -32,9 +32,13 @@
</method>
<method name="GetListMainSinks">
<arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
- <arg type="a(qs(nn)nnq)" name="listMainSinks" direction="out"/>
+ <arg type="a(qs(nn)nnq)" name="listMainSinks" direction="out"/>
<!-- uint16 sinkID; std::string name; am_Availability_s availability; am_mainVolume_t volume; am_MuteState_e muteState; am_sinkClass_t sinkClassID; -->
</method>
+ <method name="GetListMainSources">
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(qs(nn)q)" name="listMainSources" direction="out"/> <!-- am_sourceID_t sourceID; std::string name; am_Availability_s availability; am_sourceClass_t sourceClassID; -->
+ </method>
<signal name="NewMainConnection">
<arg type="(qqqnn)" name="mainConnection" direction="out"/>
</signal>
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 3677830..0ac116f 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -500,6 +500,84 @@ static void getListMainConnections(struct afb_req request)
}
/**
+ * Call "getListMainSources" function of Audio Manager.
+ * Get main source list
+ *
+ * #### Parameters
+ * Request key
+ * None
+ *
+ *
+ * #### Return
+ * - error : Error status number. If error is 0, it means the request is accepted, otherwise error message is attached with error code in reply message.
+ * Even if there is no connection list, Sound Manager return success.
+ *
+ * #### Note
+ *
+ */
+static void getListMainSources(struct afb_req request)
+{
+ AFB_DEBUG("call %s", __FUNCTION__);
+ guint16 ret;
+ GVariant* mainSourceList;
+ GError *err = NULL;
+
+ audiomanager_commandinterface_call_get_list_main_sources_sync(
+ am_cmd_bus,
+ &ret,
+ &mainSourceList,
+ NULL,
+ &err
+ );
+
+ if(err != NULL)
+ {
+ afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__);
+ return;
+ }
+
+ /* create response */
+ struct json_object *response = json_object_new_object();
+ gsize size = g_variant_n_children(mainSourceList);
+ AFB_DEBUG( "%s size is %u",__FUNCTION__, (uint16_t)size);
+ sm_add_object_to_json_object_func(response, __FUNCTION__, 0);
+ if(size <= 0)
+ {
+ AFB_NOTICE("%s size is 0", __FUNCTION__);
+ }
+ else{
+ struct json_object *array_res = json_object_new_array();
+ for(int i = 0; i < size; ++i)
+ {
+ guint16 sourceid, sourceclassid;
+ gchar* sourcename;
+
+ gint16 av;
+ gint16 avr;
+ GVariant* child = g_variant_get_child_value(mainSourceList, i);
+ g_variant_get(
+ child,"(qs(nn)q)",
+ &sourceid, &sourcename, &av, &avr, &sourceclassid);
+ AFB_DEBUG( "sourceID: %d, sourceName: %s, availability: %d, availableReason: %d, sourceClassID: %d",
+ sourceid, sourcename, av, avr, sourceclassid);
+
+ struct json_object* res_obj = json_object_new_object();
+ sm_add_object_to_json_object(res_obj, 2, KEY_SOURCE_ID, sourceid);
+ json_object_object_add(res_obj, KEY_SINK_NAME, json_object_new_string(sourcename));
+ sm_add_object_to_json_object(res_obj,6,
+ KEY_AVAILABILITY, av,
+ KEY_AVAILABILITY_REASON, avr,
+ KEY_SOURCE_CLASS_ID, sourceclassid);
+ json_object_array_add(array_res,res_obj);
+ g_variant_unref(child);
+ }
+ json_object_object_add(response, "sinks", array_res);
+ }
+ afb_req_success(request, response, "Success to get main source list");
+ g_variant_unref(mainSourceList);
+}
+
+/**
* Call "getListMainSinks" function of Audio Manager.
* Get main sink list
*
@@ -1357,6 +1435,8 @@ static const struct afb_verb_v2 binding_verbs[]= {
.info = "Get MainConnection List" , .session = AFB_SESSION_NONE},
{ .verb = "getListMainSinks", .callback = getListMainSinks, .auth = NULL,
.info = "Get MainSink List" , .session = AFB_SESSION_NONE},
+{ .verb = "getListMainSources", .callback = getListMainSources, .auth = NULL,
+ .info = "Get MainSource List" , .session = AFB_SESSION_NONE},
{ .verb = "registerSource", .callback = registerSource, .auth = NULL,
.info = "Register audio role" , .session = AFB_SESSION_NONE},
{ .verb = "deregisterSource", .callback = deregisterSource, .auth = NULL,