Index: TvLibrary.Interfaces/Interfaces/ITVCard.cs =================================================================== --- TvLibrary.Interfaces/Interfaces/ITVCard.cs (revision 26036) +++ TvLibrary.Interfaces/Interfaces/ITVCard.cs (working copy) @@ -86,6 +86,12 @@ void StopGraph(); /// + /// Pauses the current graph + /// + /// + void PauseGraph(); + + /// /// returns the min. channel number for analog cards /// int MinChannel { get; } Index: TVLibrary/Implementations/Analog/Graphs/Analog/TvCardAnalog.cs =================================================================== --- TVLibrary/Implementations/Analog/Graphs/Analog/TvCardAnalog.cs (revision 26036) +++ TVLibrary/Implementations/Analog/Graphs/Analog/TvCardAnalog.cs (working copy) @@ -116,7 +116,53 @@ return true; } + /// + /// Pause the current graph + /// + /// + public override void PauseGraph() + { + if (!CheckThreadId()) + return; + FreeAllSubChannels(); + FilterState state; + if (_graphBuilder == null) + return; + IMediaControl mediaCtl = (_graphBuilder as IMediaControl); + if (mediaCtl == null) + { + throw new TvException("Can not convert graphBuilder to IMediaControl"); + } + mediaCtl.GetState(10, out state); + + Log.Log.WriteFile("analog: PauseGraph state:{0}", state); + _isScanning = false; + if (_tsFileSink != null) + { + IMPRecord record = _tsFileSink as IMPRecord; + if (record != null) + { + record.StopTimeShifting(_subChannelId); + record.StopRecord(_subChannelId); + } + } + if (state != FilterState.Running) + { + _graphState = GraphState.Created; + return; + } + int hr = mediaCtl.Pause(); + if (hr < 0 || hr > 1) + { + Log.Log.WriteFile("analog: PauseGraph returns:0x{0:X}", hr); + throw new TvException("Unable to pause graph"); + } + Log.Log.WriteFile("analog: Graph paused"); + } + + + /// /// Stops the current graph /// /// @@ -633,7 +679,7 @@ /// /// Methods which starts the graph /// - private void RunGraph(int subChannel) + public override void RunGraph(int subChannel) { bool graphRunning = GraphRunning(); Index: TVLibrary/Implementations/Analog/Graphs/HDPVR/TVCardHDPVR.cs =================================================================== --- TVLibrary/Implementations/Analog/Graphs/HDPVR/TVCardHDPVR.cs (revision 26036) +++ TVLibrary/Implementations/Analog/Graphs/HDPVR/TVCardHDPVR.cs (working copy) @@ -127,6 +127,38 @@ /// Stops the current graph /// /// + public override void PauseGraph() + { + FreeAllSubChannels(); + FilterState state; + if (_graphBuilder == null) + return; + IMediaControl mediaCtl = (_graphBuilder as IMediaControl); + if (mediaCtl == null) + { + throw new TvException("Can not convert graphBuilder to IMediaControl"); + } + mediaCtl.GetState(10, out state); + Log.Log.WriteFile("HDPVR: PauseGraph state:{0}", state); + _isScanning = false; + if (state != FilterState.Running) + { + _graphState = GraphState.Created; + return; + } + int hr = mediaCtl.Pause(); + if (hr < 0 || hr > 1) + { + Log.Log.WriteFile("HDPVR: PauseGraph returns:0x{0:X}", hr); + throw new TvException("Unable to pause graph"); + } + Log.Log.WriteFile("HDPVR: Graph paused"); + } + + /// + /// Stops the current graph + /// + /// public override void StopGraph() { FreeAllSubChannels(); @@ -767,7 +799,7 @@ /// /// Method which starts the graph /// - private void RunGraph(int subChannel) + public override void RunGraph(int subChannel) { bool graphRunning = GraphRunning(); Index: TVLibrary/Implementations/DVB/ConditionalAccess/ConditionalAccess.cs =================================================================== --- TVLibrary/Implementations/DVB/ConditionalAccess/ConditionalAccess.cs (revision 26036) +++ TVLibrary/Implementations/DVB/ConditionalAccess/ConditionalAccess.cs (working copy) @@ -373,6 +373,7 @@ if (_twinhan.IsCamPresent()) return false; } + return true; } } Index: TVLibrary/Implementations/DVB/Graphs/TvCardDvbBase.cs =================================================================== --- TVLibrary/Implementations/DVB/Graphs/TvCardDvbBase.cs (revision 26036) +++ TVLibrary/Implementations/DVB/Graphs/TvCardDvbBase.cs (working copy) @@ -628,7 +628,7 @@ /// /// Methods which starts the graph /// - protected void RunGraph(int subChannel) + public override void RunGraph(int subChannel) { bool graphRunning = GraphRunning(); @@ -675,6 +675,41 @@ } /// + /// Methods which pauses the graph + /// + public override void PauseGraph() + { + Log.Log.WriteFile("dvb:PauseGraph called"); + if (!CheckThreadId()) + return; + _epgGrabbing = false; + _isScanning = false; + FreeAllSubChannels(); + if (_mdplugs != null) + { + _mdplugs.FreeAllChannels(); + } + if (_graphBuilder == null) + return; + + FilterState state; + ((IMediaControl)_graphBuilder).GetState(10, out state); + if (state != FilterState.Running) + { + Log.Log.WriteFile("dvb:StopGraph filterstate already paused, returning."); + return; + } + Log.Log.WriteFile("dvb:PauseGraph"); + int hr = ((IMediaControl)_graphBuilder).Pause(); + if (hr < 0 || hr > 1) + { + Log.Log.Error("dvb:PauseGraph returns:0x{0:X}", hr); + throw new TvException("Unable to pause graph"); + } + _graphState = GraphState.Created; + } + + /// /// Methods which stops the graph /// public override void StopGraph() @@ -717,7 +752,13 @@ } else { + int hr = ((IMediaControl)_graphBuilder).Stop(); Log.Log.WriteFile("dvb:StopGraph - conditionalAccess.AllowedToStopGraph = false"); + if (hr < 0 || hr > 1) + { + Log.Log.Error("dvb:StopGraph returns:0x{0:X}", hr); + throw new TvException("Unable to stop graph"); + } _graphState = GraphState.Created; } } Index: TVLibrary/Implementations/Hybrid/HybridCard.cs =================================================================== --- TVLibrary/Implementations/Hybrid/HybridCard.cs (revision 26036) +++ TVLibrary/Implementations/Hybrid/HybridCard.cs (working copy) @@ -176,7 +176,15 @@ _group.StopGraph(); } + /// + /// Pauses the current graph + /// + public void PauseGraph() + { + _group.PauseGraph(); + } + /// /// returns true if card is currently grabbing the epg /// Index: TVLibrary/Implementations/Hybrid/HybridCardGroup.cs =================================================================== --- TVLibrary/Implementations/Hybrid/HybridCardGroup.cs (revision 26036) +++ TVLibrary/Implementations/Hybrid/HybridCardGroup.cs (working copy) @@ -97,6 +97,14 @@ } /// + /// Pauses the current graph + /// + public void PauseGraph() + { + _cards[_currentCardIndex].PauseGraph(); + } + + /// /// returns true if card is currently grabbing the epg /// /// Index: TVLibrary/Implementations/RadioWebStream/RadioWebStreamCard.cs =================================================================== --- TVLibrary/Implementations/RadioWebStream/RadioWebStreamCard.cs (revision 26036) +++ TVLibrary/Implementations/RadioWebStream/RadioWebStreamCard.cs (working copy) @@ -322,6 +322,15 @@ } /// + /// Pauese the current graph + /// + /// + public void PauseGraph() + { + if (!CheckThreadId()) return; + } + + /// /// Returns if the tuner belongs to a hybrid card /// public bool IsHybrid Index: TVLibrary/Implementations/TvCardBase.cs =================================================================== --- TVLibrary/Implementations/TvCardBase.cs (revision 26036) +++ TVLibrary/Implementations/TvCardBase.cs (working copy) @@ -590,6 +590,17 @@ public abstract void StopGraph(); /// + /// Pauses the current graph + /// + /// + public abstract void PauseGraph(); + + /// + /// Starts the graph + /// + public abstract void RunGraph(int subChannel); + + /// /// A derrived class should activate / deactivate the epg grabber /// /// Mode @@ -681,8 +692,9 @@ _subChannelId = 0; if (!continueGraph) { - Log.Log.Info("tvcard:FreeSubChannel : no subchannels present, stopping graph"); - StopGraph(); + Log.Log.Info("tvcard:FreeSubChannel : no subchannels present, pausing graph"); + //StopGraph(); + PauseGraph(); } else { Index: TvService/CardManagement/CardHandler/UserManagement.cs =================================================================== --- TvService/CardManagement/CardHandler/UserManagement.cs (revision 26036) +++ TvService/CardManagement/CardHandler/UserManagement.cs (working copy) @@ -152,7 +152,8 @@ } if (_cardHandler.IsIdle) { - _cardHandler.Card.StopGraph(); + //_cardHandler.Card.StopGraph(); + _cardHandler.Card.PauseGraph(); } } Index: TvService/TVController.cs =================================================================== --- TvService/TVController.cs (revision 26036) +++ TvService/TVController.cs (working copy) @@ -29,6 +29,7 @@ using System.Reflection; using TvLibrary; using TvLibrary.Implementations; +using TvLibrary.Implementations.DVB; using TvLibrary.Interfaces; using TvLibrary.Implementations.Analog; using TvLibrary.Implementations.Hybrid; @@ -604,11 +605,12 @@ if (card.PreloadCard) { Log.Info("Controller: preloading card :{0}", card.Name); - card.BuildGraph(); + card.BuildGraph(); if (unknownCard is TvCardAnalog) { ((TvCardAnalog)unknownCard).ReloadCardConfiguration(); } + card.RunGraph(0); } else {