summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-06-16 22:32:49 +0100
committerTim-Philipp Müller <tim@centricular.com>2015-06-16 22:32:49 +0100
commit247a6aab9abec56d94a894cc2b9e882a1af1d327 (patch)
treedf6b81e6bf4339173c91b428c602b01fce44f77a
parent65b7b9954aceaadd450c97bd9fe0677235a5a0d4 (diff)
tools: gst-play: error out instead of crashing if there's no playbin element
-rw-r--r--tools/gst-play.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/gst-play.c b/tools/gst-play.c
index c9b6e73f5..a6ea68b7e 100644
--- a/tools/gst-play.c
+++ b/tools/gst-play.c
@@ -138,16 +138,20 @@ static GstPlay *
play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink,
gboolean gapless, gdouble initial_volume)
{
- GstElement *sink;
+ GstElement *sink, *playbin;
GstPlay *play;
+ playbin = gst_element_factory_make ("playbin", "playbin");
+ if (playbin == NULL)
+ return NULL;
+
play = g_new0 (GstPlay, 1);
play->uris = uris;
play->num_uris = g_strv_length (uris);
play->cur_idx = -1;
- play->playbin = gst_element_factory_make ("playbin", "playbin");
+ play->playbin = playbin;
if (audio_sink != NULL) {
if (strchr (audio_sink, ' ') != NULL)
@@ -1213,6 +1217,12 @@ main (int argc, char **argv)
/* prepare */
play = play_new (uris, audio_sink, video_sink, gapless, volume);
+ if (play == NULL) {
+ g_printerr
+ ("Failed to create 'playbin' element. Check your GStreamer installation.\n");
+ return EXIT_FAILURE;
+ }
+
if (interactive) {
if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
g_print (_("Press 'k' to see a list of keyboard shortcuts.\n"));