X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=binding%2Fmediaplayer-api.c;fp=binding%2Fmediaplayer-api.c;h=44944df9b8466c8baca35eb5ea29fd599e6ee164;hb=e799aff439bd86cf4048242069c5a277f48ec396;hp=b03b2463f1a7c611dd50bb46f217cb059a78b356;hpb=3855968eb0f1ac8214787efe8281902145d79e17;p=apps%2Fmediaplayer.git diff --git a/binding/mediaplayer-api.c b/binding/mediaplayer-api.c index b03b246..44944df 100644 --- a/binding/mediaplayer-api.c +++ b/binding/mediaplayer-api.c @@ -86,6 +86,9 @@ static json_object *new_json_object_from_device(GList *list) json_object_array_add(jarray, jstring); } + if (jstring == NULL) + return NULL; + json_object_object_add(jresp, "Media", jarray); // TODO: Add media path @@ -109,6 +112,7 @@ static void media_results_get (struct afb_req request) } jresp = new_json_object_from_device(list); + g_list_free(list); ListUnlock(); if (jresp == NULL) { @@ -123,12 +127,11 @@ static void media_broadcast_device_added (GList *list) { json_object *jresp = new_json_object_from_device(list); - afb_event_push(media_added_event, jresp); + if (jresp != NULL) { + afb_event_push(media_added_event, jresp); + } } -/* - * TODO: support multiple devices - */ static void media_broadcast_device_removed (const char *obj_path) { json_object *jresp = json_object_new_object();