summaryrefslogtreecommitdiffstats
path: root/binding/afm-mediaplayer-binding.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-06-11 21:08:45 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-06-13 02:42:53 +0000
commit4848cc2ed0365c3ba1bffc7f3c1f59652e245a7e (patch)
treebf52d2546fbc3b5555cae8614ef31fc6266ff1e2 /binding/afm-mediaplayer-binding.c
parent5c5ca783ee759af83a80f91e265da69205cbcfbf (diff)
binding: mediaplayer: fix race condition with initial album art
gst_init and audio sinks weren't always getting setup in time for a subscriber to get the initial album art. Solution is to move the setup out of the pthread callback and confirm they are ran before .init() returns Bug-AGL: SPEC-1496 Change-Id: I70779bcb1ca539146c98718f5b0edd781f9899b4 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/afm-mediaplayer-binding.c')
-rw-r--r--binding/afm-mediaplayer-binding.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 116f0d1..86ed5bf 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -710,7 +710,7 @@ static gboolean position_event(CustomData *data)
return TRUE;
}
-static void *gstreamer_loop_thread(void *ptr)
+static void gstreamer_init()
{
GstBus *bus;
json_object *response;
@@ -776,10 +776,6 @@ static void *gstreamer_loop_thread(void *ptr)
populate_playlist(val);
}
json_object_put(response);
-
- g_main_loop_run(g_main_loop_new(NULL, FALSE));
-
- return NULL;
}
static void onevent(const char *event, struct json_object *object)
@@ -842,6 +838,11 @@ static void onevent(const char *event, struct json_object *object)
afb_event_push(playlist_event, jresp);
}
+void *gstreamer_loop_thread(void *ptr)
+{
+ g_main_loop_run(g_main_loop_new(NULL, FALSE));
+}
+
static int init() {
pthread_t thread_id;
json_object *response, *query;
@@ -878,6 +879,8 @@ static int init() {
metadata_event = afb_daemon_make_event("metadata");
playlist_event = afb_daemon_make_event("playlist");
+ gstreamer_init();
+
return pthread_create(&thread_id, NULL, gstreamer_loop_thread, NULL);
}