aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-03-30 19:31:19 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-03-30 19:31:19 +0900
commitcd51e80f13fb09aba2313f492cb761b3e60d1741 (patch)
treef0dc9d45a1a5c09145ec4838de2eb3f22336aaba
parent19751bed26db1b959584b7eeef21cc2527ac48ee (diff)
Bug Fix
Change-Id: Ie2e6d0b355b4b97a8cb10eb568a838d9115d7611 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/audiomanager_proxy.c48
-rw-r--r--src/audiomanager_proxy.h6
-rw-r--r--src/sm-helper.c8
-rw-r--r--src/sm-pending.c1
-rw-r--r--src/soundmanager.c15
5 files changed, 53 insertions, 25 deletions
diff --git a/src/audiomanager_proxy.c b/src/audiomanager_proxy.c
index d4cb7bc..83774d4 100644
--- a/src/audiomanager_proxy.c
+++ b/src/audiomanager_proxy.c
@@ -215,6 +215,8 @@ ErrorCode am_proxy_connect(int source, int sink, int *main_connection_id){
if(is_range_over_guint16(source) == OUT_RANGE || is_range_over_guint16(sink) == OUT_RANGE){
return OUT_RANGE;
}
+ AFB_DEBUG("Call %s: source:%d sink:%d", __FUNCTION__, source, sink);
+
guint16 connection_id = 0, ret = 0;
ErrorCode ec;
GError *err = NULL;
@@ -232,6 +234,7 @@ ErrorCode am_proxy_connect(int source, int sink, int *main_connection_id){
}
ErrorCode am_proxy_disconnect(int main_connection_id){
+ AFB_DEBUG("Call %s: mainConnectionID:%d", __FUNCTION__, main_connection_id);
if(is_range_over_guint16(main_connection_id) == OUT_RANGE){
return OUT_RANGE;
}
@@ -250,6 +253,7 @@ ErrorCode am_proxy_disconnect(int main_connection_id){
}
ErrorCode am_proxy_set_volume(int sink, int volume){
+ AFB_DEBUG("Call %s: sink:%d volume:%d", __FUNCTION__, sink, volume);
if(is_range_over_guint16(sink) == OUT_RANGE && is_range_over_gint16(volume) == OUT_RANGE){
return OUT_RANGE;
}
@@ -268,6 +272,7 @@ ErrorCode am_proxy_set_volume(int sink, int volume){
}
ErrorCode am_proxy_volume_step(int sink, int volume){
+ AFB_DEBUG("Call %s: sink:%d volume:%d", __FUNCTION__, sink, volume);
if(is_range_over_guint16(sink) == OUT_RANGE && is_range_over_gint16(volume) == OUT_RANGE){
return OUT_RANGE;
}
@@ -286,6 +291,7 @@ ErrorCode am_proxy_volume_step(int sink, int volume){
}
ErrorCode am_proxy_set_sink_mute_state(int sink, int mute_state){
+ AFB_DEBUG("Call %s: sink:%d mute_state:%d", __FUNCTION__, sink, mute_state);
if(is_range_over_guint16(sink) == OUT_RANGE || is_range_over_gint16(mute_state) == OUT_RANGE){
return OUT_RANGE;
}
@@ -302,16 +308,17 @@ ErrorCode am_proxy_set_sink_mute_state(int sink, int mute_state){
return ec;
}
-ErrorCode am_proxy_get_list_main_connections(GVariant* connection_list){
+ErrorCode am_proxy_get_list_main_connections(GVariant** connection_list){
guint16 ret = 0;
ErrorCode ec;
GError *err = NULL;
+ AFB_DEBUG("Call %s", __FUNCTION__);
assert(am_cmd_bus != NULL);
audiomanager_commandinterface_call_get_list_main_connections_sync(
am_cmd_bus,
&ret,
- &connection_list,
+ connection_list,
NULL,
&err
);
@@ -319,16 +326,17 @@ ErrorCode am_proxy_get_list_main_connections(GVariant* connection_list){
return ec;
}
-ErrorCode am_proxy_get_list_main_sources(GVariant* source_list){
+ErrorCode am_proxy_get_list_main_sources(GVariant** source_list){
guint16 ret = 0;
ErrorCode ec;
GError *err = NULL;
+ AFB_DEBUG("Call %s", __FUNCTION__);
assert(am_cmd_bus != NULL);
audiomanager_commandinterface_call_get_list_main_sources_sync(
am_cmd_bus,
&ret,
- &source_list,
+ source_list,
NULL,
&err
);
@@ -336,16 +344,17 @@ ErrorCode am_proxy_get_list_main_sources(GVariant* source_list){
return ec;
}
-ErrorCode am_proxy_get_list_main_sinks(GVariant* sink_list){
+ErrorCode am_proxy_get_list_main_sinks(GVariant** sink_list){
guint16 ret = 0;
ErrorCode ec;
GError *err = NULL;
+ AFB_DEBUG("Call %s", __FUNCTION__);
assert(am_cmd_bus != NULL);
- audiomanager_commandinterface_call_get_list_main_sources_sync(
+ audiomanager_commandinterface_call_get_list_main_sinks_sync(
am_cmd_bus,
&ret,
- &sink_list,
+ sink_list,
NULL,
&err
);
@@ -354,6 +363,7 @@ ErrorCode am_proxy_get_list_main_sinks(GVariant* sink_list){
}
ErrorCode am_proxy_ack_connect(int handle, int connection_id, int usr_err){
+ AFB_DEBUG("Call %s handle:%d connectionID:%d error:%d", __FUNCTION__, handle, connection_id, usr_err);
if(is_range_over_guint16(handle) == OUT_RANGE ||
is_range_over_guint16(connection_id) == OUT_RANGE ||
is_range_over_guint16(usr_err) == OUT_RANGE){
@@ -372,6 +382,7 @@ ErrorCode am_proxy_ack_connect(int handle, int connection_id, int usr_err){
}
ErrorCode am_proxy_ack_disconnect(int handle, int connection_id, int usr_err){
+ AFB_DEBUG("Call %s handle:%d connectionID:%d error:%d", __FUNCTION__, handle, connection_id, usr_err);
if(is_range_over_guint16(handle) == OUT_RANGE ||
is_range_over_guint16(connection_id) == OUT_RANGE ||
is_range_over_guint16(usr_err) == OUT_RANGE){
@@ -388,6 +399,7 @@ ErrorCode am_proxy_ack_disconnect(int handle, int connection_id, int usr_err){
}
ErrorCode am_proxy_ack_set_source_state(int handle, int usr_err){
+ AFB_DEBUG("Call %s handle:%d error:%d", __FUNCTION__, handle, usr_err);
if(is_range_over_guint16(handle) == OUT_RANGE ||
is_range_over_guint16(usr_err) == OUT_RANGE){
return OUT_RANGE;
@@ -404,6 +416,7 @@ ErrorCode am_proxy_ack_set_source_state(int handle, int usr_err){
}
ErrorCode am_proxy_register_source(GVariant *source_data, int *source){
+ AFB_DEBUG("Call %s", __FUNCTION__);
assert(am_route_bus != NULL);
guint16 ret = 0, g_source = 0;
ErrorCode ec;
@@ -415,13 +428,14 @@ ErrorCode am_proxy_register_source(GVariant *source_data, int *source){
&g_source,
&ret,
NULL, &err);
- g_variant_unref(source_data);
+
*source = (int)g_source;
ec = check_send_error(err, ret);
return ec;
}
ErrorCode am_proxy_deregister_source(int source){
+ AFB_DEBUG("Call %s source:%d", __FUNCTION__, source);
if(is_range_over_guint16(source) == OUT_RANGE){
return OUT_RANGE;
}
@@ -445,7 +459,10 @@ ErrorCode am_proxy_register_domain(GVariant* domain_data, int *domain){
ErrorCode ec;
GError *err = NULL;
+ AFB_DEBUG("Call %s", __FUNCTION__);
assert(am_route_bus != NULL);
+ assert(domain_data);
+ AFB_DEBUG("Call %s", __FUNCTION__);
audiomanager_routinginterface_call_register_domain_sync(
am_route_bus,
domain_data,
@@ -455,7 +472,6 @@ ErrorCode am_proxy_register_domain(GVariant* domain_data, int *domain){
&g_domain, &ret,
NULL, &err);
- g_variant_unref(domain_data);
*domain = (int)g_domain;
ec = check_send_error(err, ret);
return ec;
@@ -467,6 +483,7 @@ GVariant* create_domain_data(struct domain_data* domain){
* This function is only used by soundmanager.
*/
GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("(qsssbbn)"));
g_variant_builder_add (&builder, "q", (guint16)domain->domainID);
g_variant_builder_add (&builder, "s", domain->name);
g_variant_builder_add (&builder, "s", domain->busname);
@@ -474,6 +491,7 @@ GVariant* create_domain_data(struct domain_data* domain){
g_variant_builder_add (&builder, "b", (gboolean)domain->early);
g_variant_builder_add (&builder, "b", (gboolean)domain->complete);
g_variant_builder_add (&builder, "n", (gint16)domain->state);
+ AFB_DEBUG("create domainData");
return g_variant_builder_end (&builder);
}
@@ -541,14 +559,14 @@ GVariant* create_source_data(int sourceID, int domainID, const char* appname, in
g_variant_builder_close(&builder);
g_variant_builder_close (&builder);
- AFB_DEBUG("created sourceData %d", __LINE__);
+ AFB_DEBUG("create sourceData");
return g_variant_builder_end (&builder);
}
ErrorCode initialize_proxy(){
if(am_cmd_bus || am_route_bus)
{
- return UNABLE_SEND;
+ return NOT_INITIALIZED;
}
am_cmd_bus = audiomanager_commandinterface_proxy_new_for_bus_sync(
G_BUS_TYPE_SYSTEM,
@@ -558,6 +576,9 @@ ErrorCode initialize_proxy(){
NULL,
NULL
);
+ if(!am_cmd_bus){
+ AFB_ERROR("Failed to create command interface");
+ }
am_route_bus = audiomanager_routinginterface_proxy_new_for_bus_sync(
G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
@@ -566,7 +587,10 @@ ErrorCode initialize_proxy(){
NULL,
NULL
);
- return (!am_cmd_bus || !am_route_bus) ? OK : UNABLE_SEND;
+ if(!am_route_bus){
+ AFB_ERROR("Failed to create routing interface");
+ }
+ return (am_cmd_bus && am_route_bus) ? OK : UNABLE_SEND;
}
void close_proxy(){
diff --git a/src/audiomanager_proxy.h b/src/audiomanager_proxy.h
index e0c6b3d..49a6558 100644
--- a/src/audiomanager_proxy.h
+++ b/src/audiomanager_proxy.h
@@ -71,9 +71,9 @@ ErrorCode am_proxy_disconnect(int main_connection_id);
ErrorCode am_proxy_set_volume(int sink, int volume);
ErrorCode am_proxy_volume_step(int sink, int volume);
ErrorCode am_proxy_set_sink_mute_state(int sink, int mute_state);
-ErrorCode am_proxy_get_list_main_connections(GVariant* connection_list);
-ErrorCode am_proxy_get_list_main_sources(GVariant* source_list);
-ErrorCode am_proxy_get_list_main_sinks(GVariant* sink_list);
+ErrorCode am_proxy_get_list_main_connections(GVariant** connection_list);
+ErrorCode am_proxy_get_list_main_sources(GVariant** source_list);
+ErrorCode am_proxy_get_list_main_sinks(GVariant** sink_list);
ErrorCode am_proxy_ack_connect(int handle, int connection_id, int usr_err);
ErrorCode am_proxy_ack_disconnect(int handle, int connection_id, int usr_err);
ErrorCode am_proxy_ack_set_source_state(int handle, int usr_err);
diff --git a/src/sm-helper.c b/src/sm-helper.c
index c55eefb..e0dec49 100644
--- a/src/sm-helper.c
+++ b/src/sm-helper.c
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "sm-helper.h"
+
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <json-c/json.h>
#include <stdarg.h>
+#include "sm-helper.h"
+#include "sm-error.h"
REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id)
{
@@ -190,8 +192,8 @@ bool send_result(ErrorCode ec, struct afb_req req, const char* function){
if(ec == UNABLE_SEND)
{
AFB_ERROR("Unable to call : %s", function);
- afb_req_fail_f(req, "failed", "%s : %s",
- get_response_audiomanager_massage_error(ec), function);
+ afb_req_fail_f(req, "failed", "%s : %s", function,
+ get_response_audiomanager_massage_error(ec));
return false;
}
return true;
diff --git a/src/sm-pending.c b/src/sm-pending.c
index 43b18cf..99ce031 100644
--- a/src/sm-pending.c
+++ b/src/sm-pending.c
@@ -23,6 +23,7 @@ struct pending* add_pending(struct pending *list, int source_id, struct afb_req
if(list == NULL){
pd = malloc(sizeof(struct pending));
if(NULL == pd){
+ AFB_WARNING("memory allocation error");
return NULL;
}
pd->source.sourceID = source_id;
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 28ed7ba..d1ff16c 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -116,7 +116,7 @@ void connect (struct afb_req request)
return;
}
- ErrorCode ec = am_proxy_connect(source_id, source_id, &main_connectionID);
+ ErrorCode ec = am_proxy_connect(source_id, sink_id, &main_connectionID);
if(!SEND_RESULT(ec, request)) return;
@@ -258,7 +258,7 @@ void getListMainConnections(struct afb_req request)
GVariant* mainConnectionList;
GError *err = NULL;
- ErrorCode ec = am_proxy_get_list_main_connections(mainConnectionList);
+ ErrorCode ec = am_proxy_get_list_main_connections(&mainConnectionList);
if(!SEND_RESULT(ec, request)) return;
@@ -305,7 +305,7 @@ void getListMainSources(struct afb_req request)
GVariant* mainSourceList;
GError *err = NULL;
- ErrorCode ec = am_proxy_get_list_main_sources(mainSourceList);
+ ErrorCode ec = am_proxy_get_list_main_sources(&mainSourceList);
if(!SEND_RESULT(ec, request)) return;
@@ -357,7 +357,7 @@ void getListMainSinks(struct afb_req request)
GVariant* mainSinkList;
GError *err = NULL;
- ErrorCode ec = am_proxy_get_list_main_sinks(mainSinkList);
+ ErrorCode ec = am_proxy_get_list_main_sinks(&mainSinkList);
if(!SEND_RESULT(ec, request)) return;
@@ -397,7 +397,6 @@ void getListMainSinks(struct afb_req request)
KEY_MUTE_STATE, mutestate,
KEY_SINK_CLASS_ID, sinkclassid);
json_object_array_add(array_res,res_obj);
- g_variant_unref(child);
}
json_object_object_add(response, "sinks", array_res);
}
@@ -779,6 +778,7 @@ void streamClose(struct afb_req request){
return;
}
if(ctxt->source.mainConnectionID > 0){
+ AFB_DEBUG("context has mainConnectionID:%d", ctxt->source.mainConnectionID);
ec = am_proxy_disconnect(ctxt->source.mainConnectionID);
SEND_RESULT_NO_RESP(ec);
ctxt->source.mainConnectionID = -1;
@@ -1016,6 +1016,7 @@ static void create_client_context(afb_req request, guint16 source_id, guint16 si
strncpy(ctxt->appname, appid, MAX_LENGTH_STR);
}
ctxt->source.sourceID = source_id;
+ ctxt->source.mainConnectionID = -1;
ctxt->sink.endpointID = sink_id;
ctxt->sink.sinkID = sink_id;
ctxt->sink.endpointType = endpoint_type;
@@ -1029,7 +1030,7 @@ int preinit()
/* Initialize Dbus interface */
ErrorCode ec = initialize_proxy();
- if(ec != OK){
+ if(ec == NOT_INITIALIZED){
AFB_ERROR("Failed to initialize");
return -1;
}
@@ -1129,7 +1130,7 @@ int sm_init()
.complete = TRUE,
.state = DS_CONTROLLED
};
- ec = am_proxy_register_domain( create_domain_data(&ddata), &SOUNDMANAGER_DOMAIN_ID);
+ ec = am_proxy_register_domain(create_domain_data(&ddata) , &SOUNDMANAGER_DOMAIN_ID);
if(!SEND_RESULT_NO_RESP(ec)){
return -1;
}