diff options
author | Jens Georg <mail@jensge.org> | 2014-05-01 14:17:23 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2014-05-01 15:00:37 +0200 |
commit | 33caa39d4d8bf643e68bbc49cd7466d88df5db65 (patch) | |
tree | 2ef983bbafe0a7b005ecb63fed5f7ad4e069679b | |
parent | 1f400830dbfc4ffb2475d06567b9ad3901fa09df (diff) | |
download | rygel-33caa39d4d8bf643e68bbc49cd7466d88df5db65.tar.gz |
renderer-gst,playbin: Don't exit when playbin is missing
Signed-off-by: Jens Georg <mail@jensge.org>
https://bugzilla.gnome.org/show_bug.cgi?id=710443
-rw-r--r-- | src/librygel-renderer-gst/rygel-playbin-player.vala | 24 | ||||
-rw-r--r-- | src/librygel-renderer-gst/rygel-playbin-renderer.vala | 21 | ||||
-rw-r--r-- | src/plugins/playbin/rygel-playbin-module.vala | 9 | ||||
-rw-r--r-- | src/plugins/playbin/rygel-playbin-plugin.vala | 16 |
4 files changed, 53 insertions, 17 deletions
diff --git a/src/librygel-renderer-gst/rygel-playbin-player.vala b/src/librygel-renderer-gst/rygel-playbin-player.vala index 0bfb9129..b71c5cc4 100644 --- a/src/librygel-renderer-gst/rygel-playbin-player.vala +++ b/src/librygel-renderer-gst/rygel-playbin-player.vala @@ -30,6 +30,10 @@ using Gst; using GUPnP; +public errordomain Rygel.Playbin.PlayerError { + NO_ELEMENT +} + /** * Implementation of RygelMediaPlayer for GStreamer. * @@ -339,8 +343,12 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer { } } - private Player () { + private Player () throws Error { this.playbin = ElementFactory.make ("playbin", null); + if (this.playbin == null) { + throw new PlayerError.NO_ELEMENT ( + _("Your GStreamer installation seems to be missing the \"playbin\" element. The Rygel GStreamer renderer implementation cannot work without it")); + } this.setup_playbin (); } @@ -351,8 +359,21 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer { this.setup_playbin (); } + [Deprecated (since="0.23.1")] public static Player get_default () { if (player == null) { + try { + player = new Player (); + } catch (Error error) { + assert_not_reached (); + } + } + + return player; + } + + public static Player instance () throws Error { + if (player == null) { player = new Player (); } @@ -607,7 +628,6 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer { // Needed to get "Stop" events from the playbin. // We can do this because we have a bus watch this.playbin.auto_flush_bus = false; - assert (this.playbin != null); this.playbin.source_setup.connect (this.on_source_setup); this.playbin.notify["uri"].connect (this.on_uri_notify); diff --git a/src/librygel-renderer-gst/rygel-playbin-renderer.vala b/src/librygel-renderer-gst/rygel-playbin-renderer.vala index 0bc335df..14b6fd3b 100644 --- a/src/librygel-renderer-gst/rygel-playbin-renderer.vala +++ b/src/librygel-renderer-gst/rygel-playbin-renderer.vala @@ -50,8 +50,14 @@ public class Rygel.Playbin.Renderer : Rygel.MediaRenderer { * @param title Friendly name of the new UPnP renderer on the network. */ public Renderer (string title) { - Object (title: title, - player: Player.get_default ()); + try { + Object (title: title, + player: Player.instance ()); + } catch (Error error) { + warning (error.message); + + return_val_if_fail (false, null); + } } /** @@ -73,9 +79,14 @@ public class Rygel.Playbin.Renderer : Rygel.MediaRenderer { * Get the GstPlayBin used by this Renderer. */ public Gst.Element? get_playbin () { - var player = Rygel.Playbin.Player.get_default (); - return_val_if_fail (player != null, null); + try { + var player = Rygel.Playbin.Player.instance (); + + return player.playbin; + } catch (Error error) { + warning (error.message); - return player.playbin; + return null; + } } } diff --git a/src/plugins/playbin/rygel-playbin-module.vala b/src/plugins/playbin/rygel-playbin-module.vala index 29d86681..9b032711 100644 --- a/src/plugins/playbin/rygel-playbin-module.vala +++ b/src/plugins/playbin/rygel-playbin-module.vala @@ -34,8 +34,11 @@ public void module_init (PluginLoader loader) { unowned string[] args = null; Gst.init (ref args); + try { + var plugin = new Playbin.Plugin (); - var plugin = new Playbin.Plugin (); - - loader.add_plugin (plugin); + loader.add_plugin (plugin); + } catch (Error error) { + warning (error.message); + } } diff --git a/src/plugins/playbin/rygel-playbin-plugin.vala b/src/plugins/playbin/rygel-playbin-plugin.vala index 8f0e3edb..7507e19b 100644 --- a/src/plugins/playbin/rygel-playbin-plugin.vala +++ b/src/plugins/playbin/rygel-playbin-plugin.vala @@ -31,16 +31,18 @@ using Gee; internal class Rygel.Playbin.Plugin : Rygel.MediaRendererPlugin { public const string NAME = "Playbin"; - public Plugin () { + public Plugin () throws Error { base (Plugin.NAME, _("GStreamer Player")); - } - - public override void constructed () { - base.constructed (); - this.supported_profiles = Player.get_default ().supported_profiles; + this.supported_profiles = Player.instance ().supported_profiles; } public override MediaPlayer? get_player () { - return Playbin.Player.get_default (); + try { + return Playbin.Player.instance (); + } catch (Error error) { + warning (_("Could not create GStreamer player")); + + return null; + } } } |