diff options
author | Sebastian Reichel <sre@ring0.de> | 2017-10-02 19:52:12 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2017-10-02 20:24:19 +0200 |
commit | 059297e0850b3b711fcd6b134991ea766f327281 (patch) | |
tree | f0d75fda1f82f352ef398667e4eb5520e04a5adb /src | |
parent | c41b6053cf403051bb06278acb686072ec58cda4 (diff) | |
download | serial-barcode-scanner-059297e0850b3b711fcd6b134991ea766f327281.tar.bz2 |
audio: improve gstreamer1.0 support
Add proper error message when required gstreamer plugin is missing.
Diffstat (limited to 'src')
-rw-r--r-- | src/audio/audio.vala | 14 |
1 files 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); } |