summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-11-28 09:54:36 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2017-11-28 09:54:36 +0100
commit381b4ed77c3b11efa5e7619253133146a44df911 (patch)
tree6718c4c3856302a103b7398d94f04414c78ccabe
parentf0e59e782020a315c3b110a2ae2ecec07acc0e57 (diff)
Fix a crash when playing empty list
Change-Id: I4037ab08715bea231bb8e9d725ffba9718c7daca Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--binding/afm-mediaplayer-binding.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 9c41f27..2e3bef2 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -188,7 +188,8 @@ static void populate_playlist(json_object *jquery)
if (current_track == NULL) {
current_track = g_list_first(playlist);
- set_media_uri(current_track->data);
+ if (current_track && current_track->data)
+ set_media_uri(current_track->data);
}
}
@@ -226,7 +227,7 @@ static void audio_playlist(struct afb_req request)
populate_playlist(jquery);
if (playlist == NULL)
- afb_req_fail(request, "failed", "invalid playlist");
+ afb_req_fail(request, "failed", "invalid playlist");
else
afb_req_success(request, NULL, NULL);
@@ -331,7 +332,13 @@ static void controls(struct afb_req request)
g_object_get(data.playbin, "audio-sink", &obj, NULL);
if (obj == data.fake_sink) {
- set_media_uri(current_track->data);
+ if (current_track && current_track->data)
+ set_media_uri(current_track->data);
+ else {
+ pthread_mutex_unlock(&mutex);
+ afb_req_fail(request, "failed", "No playlist");
+ return;
+ }
} else {
g_object_set(data.playbin, "audio-sink", data.alsa_sink, NULL);
gst_element_set_state(data.playbin, GST_STATE_PLAYING);