aboutsummaryrefslogtreecommitdiffstats
path: root/src/soundmanager.c
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-03-30 16:38:40 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-03-30 16:38:40 +0900
commit19751bed26db1b959584b7eeef21cc2527ac48ee (patch)
tree912c885643126d9d6db6fb1d2f873018d2fa4cfb /src/soundmanager.c
parent784e69dc7f8928f22ea1603aad8c81e4d76a24fe (diff)
Test
Change-Id: If61c650f25ca241105106bb4323e403446364d71 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/soundmanager.c')
-rw-r--r--src/soundmanager.c61
1 files changed, 8 insertions, 53 deletions
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 96d95d1..28ed7ba 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -26,60 +26,15 @@
#include "sm-def.h"
#include "sm-error.h"
#include "sm-helper.h"
+#include "sm-pending.h"
struct event{
char* name;
struct afb_event* event;
};
-struct pending{
- int sourceID;
- struct afb_req request;
- bool use_ahl;
- struct pending* next;
-};
-
static struct pending* pending_list = NULL;
-static bool add_pending(int source_id, bool use_ahl, struct afb_req request){
- struct pending* pd = malloc(sizeof(struct pending));
- if(NULL == pd){
- AFB_WARNING("memory allocation error");
- return false;
- }
- pd->sourceID = source_id;
- pd->request = request;
- pd->use_ahl = use_ahl;
- pd->next = NULL;
- if(pending_list == NULL){
- pending_list = pd;
- }
- struct pending* list = pending_list;
- while(list->next != NULL){
- list = list->next;
- }
- list->next = pd;
- return true;
-}
-
-
-static struct pending* get_pending(int source_id){
- struct pending* pd = pending_list;
- while(pd && (pd->sourceID == source_id)){
- pd = pd->next;
- }
- return pd;
-}
-
-static bool del_peding(int source_id){
- struct pending* pd = get_pending(source_id);
- if(pd != NULL){
-
- return true;
- }
- return false;
-}
-
static int SOUNDMANAGER_DOMAIN_ID;
static struct event command_event_list[COMMAND_EVENT_NUM];
static struct event routing_event_list[ROUTING_EVENT_NUM];
@@ -875,7 +830,7 @@ void setStreamState(struct afb_req request){
ctxt->source.mainConnectionID = main_connection_id;
afb_req_addref(request);
- add_peding(source_id, request);
+ pending_list = add_pending(pending_list, source_id, request);
}
#endif
@@ -1005,12 +960,12 @@ static void on_async_set_sink_volume(void *closure, int handle, int sinkID,
static void on_async_set_source_state(void *closure, int handle, int sourceID, int sourceState)
{
AFB_DEBUG( "%s called", __FUNCTION__);
- struct pending* pd = get_pending(sourceID);
- if((pd != NULL) && (pd->use_ahl)){
+ struct pending* pd = get_pending(pending_list, sourceID);
+ if(pd != NULL){
AFB_DEBUG("Call ackSetSourceState in for the application");
am_proxy_ack_set_source_state(handle, 0);
- del_peding(sourceID);
- return;
+ afb_req_success(pd->source.request, NULL, NULL);
+ pending_list = del_pending(pending_list, sourceID);
}
struct json_object* ev_obj = json_object_new_object();
const char* ss_key = get_source_state_key(sourceState);
@@ -1073,8 +1028,8 @@ int preinit()
AFB_INFO("Initialize Dbus object");
/* Initialize Dbus interface */
- ErrorCode err = initialize_proxy();
- if(err != OK){
+ ErrorCode ec = initialize_proxy();
+ if(ec != OK){
AFB_ERROR("Failed to initialize");
return -1;
}