aboutsummaryrefslogtreecommitdiffstats
path: root/mediaplayer-api.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-07-14 17:35:50 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-07-20 17:29:45 -0700
commit6a0857aa2b06826de0b7f4dcf583d582fd63bfea (patch)
tree7ce89cadb7d99d16883b9577221d2f2056c5ccdf /mediaplayer-api.c
parentcccbe1188021ac4f7cbba7ee26d297448f29bbf3 (diff)
media: binding: improve media removal support
Use glib's inotify support instead of UDisks to get the actual path of an unmounted drive. This in turn allows removal of items on the playlist respective to only that device. Bug-AGL: SPEC-610 SPEC-757 Change-Id: Iaabb004934367bf1e60dab3f9f3365c2eb0b517d Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'mediaplayer-api.c')
-rw-r--r--mediaplayer-api.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mediaplayer-api.c b/mediaplayer-api.c
index b03b246..44944df 100644
--- a/mediaplayer-api.c
+++ b/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();