diff --git a/src/ChannelFactory.vala b/src/ChannelFactory.vala index 997afcc..cd09521 100644 --- a/src/ChannelFactory.vala +++ b/src/ChannelFactory.vala @@ -44,6 +44,7 @@ namespace DVB { public Gst.Element tee; public bool forced; public ForcedStopNotify notify_func; + public Gst.Pad srcpad; } /** @@ -336,8 +337,6 @@ namespace DVB { dvbbasebin.set ("program-numbers", new_programs.str); - if (!this.set_playing_or_destroy ()) - return false; this.active_channels.remove (channel); } @@ -345,6 +344,12 @@ namespace DVB { if (stop_channel) { /* No one watches the channel anymore */ + Pad sinkpad = celements.tee.get_static_pad ("sink"); + log.debug ("Unlinking pad %s and pad %s", + celements.srcpad.get_name (), sinkpad.get_name ()); + if (!celements.srcpad.unlink (sinkpad)) + log.warning ("Failed unlinking"); + log.debug ("Removing tee %s from pipeline", celements.tee.get_name ()); celements.tee.set_state (State.NULL); @@ -353,6 +358,8 @@ namespace DVB { this.elements_map.unset (channel_sid); } } + if (!this.set_playing_or_destroy ()) + return false; } else { /* More than one channel in use */ if (stop_channel) { @@ -491,6 +498,7 @@ namespace DVB { } else { log.debug ("Src pad %s linked with sink pad %s", pad.get_name (), sinkpad.get_name ()); + this.elements_map.get (sid).srcpad = pad; } } }