tools: gst-play: error out instead of crashing if there's no playbin element
This commit is contained in:
parent
65b7b9954a
commit
247a6aab9a
@ -138,16 +138,20 @@ static GstPlay *
|
|||||||
play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink,
|
play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink,
|
||||||
gboolean gapless, gdouble initial_volume)
|
gboolean gapless, gdouble initial_volume)
|
||||||
{
|
{
|
||||||
GstElement *sink;
|
GstElement *sink, *playbin;
|
||||||
GstPlay *play;
|
GstPlay *play;
|
||||||
|
|
||||||
|
playbin = gst_element_factory_make ("playbin", "playbin");
|
||||||
|
if (playbin == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
play = g_new0 (GstPlay, 1);
|
play = g_new0 (GstPlay, 1);
|
||||||
|
|
||||||
play->uris = uris;
|
play->uris = uris;
|
||||||
play->num_uris = g_strv_length (uris);
|
play->num_uris = g_strv_length (uris);
|
||||||
play->cur_idx = -1;
|
play->cur_idx = -1;
|
||||||
|
|
||||||
play->playbin = gst_element_factory_make ("playbin", "playbin");
|
play->playbin = playbin;
|
||||||
|
|
||||||
if (audio_sink != NULL) {
|
if (audio_sink != NULL) {
|
||||||
if (strchr (audio_sink, ' ') != NULL)
|
if (strchr (audio_sink, ' ') != NULL)
|
||||||
@ -1213,6 +1217,12 @@ main (int argc, char **argv)
|
|||||||
/* prepare */
|
/* prepare */
|
||||||
play = play_new (uris, audio_sink, video_sink, gapless, volume);
|
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 (interactive) {
|
||||||
if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
|
if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
|
||||||
g_print (_("Press 'k' to see a list of keyboard shortcuts.\n"));
|
g_print (_("Press 'k' to see a list of keyboard shortcuts.\n"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user