summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--binding/afm-mediaplayer-binding.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index d300fed..116f0d1 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -167,6 +167,11 @@ static int set_media_uri(struct playlist_item *item)
return 0;
}
+static int in_list(gconstpointer item, gconstpointer list) {
+ return g_strcmp0(((struct playlist_item *) item)->media_path,
+ ((struct playlist_item *) list)->media_path);
+}
+
static void populate_playlist(json_object *jquery)
{
int i, idx = 0;
@@ -186,7 +191,7 @@ static void populate_playlist(json_object *jquery)
break;
ret = populate_from_json(item, jdict);
- if (!ret) {
+ if (!ret || g_list_find_custom(playlist, item, in_list)) {
g_free_playlist_item(item);
continue;
}
@@ -577,8 +582,17 @@ static void subscribe(struct afb_req request)
return;
} else if (!strcasecmp(value, "playlist")) {
+ json_object *jresp = json_object_new_object();
+
afb_req_subscribe(request, playlist_event);
afb_req_success(request, NULL, NULL);
+
+ pthread_mutex_lock(&mutex);
+ jresp = populate_json_playlist(jresp);
+ pthread_mutex_unlock(&mutex);
+
+ afb_event_push(playlist_event, jresp);
+
return;
}