From 059297e0850b3b711fcd6b134991ea766f327281 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 2 Oct 2017 19:52:12 +0200 Subject: audio: improve gstreamer1.0 support Add proper error message when required gstreamer plugin is missing. --- src/audio/audio.vala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/audio/audio.vala b/src/audio/audio.vala index 76e01b3..9afb840 100644 --- a/src/audio/audio.vala +++ b/src/audio/audio.vala @@ -15,7 +15,7 @@ [DBus (name = "io.mainframe.shopsystem.AudioPlayer")] public class AudioPlayerImplementation { - private dynamic Gst.Element p; + private dynamic Gst.Element? p; string path; public signal void end_of_stream(); @@ -30,18 +30,24 @@ public class AudioPlayerImplementation { return true; } - public AudioPlayerImplementation(string path) { + public AudioPlayerImplementation(string path) throws IOError { this.path = path; var alsa = Gst.ElementFactory.make("alsasink", "alsa"); - p = Gst.ElementFactory.make("playbin2", "play"); + if (alsa == null) + throw new GLib.IOError.FAILED("Cannot find alsa GStreamer plugin"); + + p = Gst.ElementFactory.make("playbin", "player"); + if (p == null) + throw new GLib.IOError.FAILED("Cannot find playbin2 GStreamer plugin"); + p.set("audio-sink", alsa); p.get_bus().add_watch(Priority.DEFAULT, bus_callback); } public void play_system(string file) { p.set_state(Gst.State.NULL); - p.uri = "file://" + path + "system/"+file; + p.uri = "file://" + path + "system/" + file; p.set_state(Gst.State.PLAYING); } -- cgit v1.2.3