home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
Improvement Suggestions
Usb tuner instance id problems, and some another thoughts.....
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="te3hpurp" data-source="post: 538723" data-attributes="member: 82806"><p>Dev's might not like this dirty hack, but it works</p><p>for me very nicely. </p><p></p><p>First and major problem with USB tuners are that</p><p>by the desing of Windows instance id of USB tuner can change</p><p>by every restart/resume of windows. Sometimes it even changes</p><p>while windows is running. I could not figure out exact conditions </p><p>when this happens, but anyway it affecvts at least two parts of Tve3.</p><p></p><p>First of all, when Tve3 restarts and it starts to detect tuner installed </p><p>into machine, and if device path differs with existing usb tuner path, new </p><p>tuner is added into database. Device path is something like this:</p><p></p><p>@device<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />np:\\?\usb#vid_eb1a&pid_2870#5&732838b&0&2#{71985f48-1ca1-11d3-9cc8-00c04f7971e0}\{7c8095ab-c110-40e5-9f4d-310858bbbf64}</p><p></p><p>And i don't think it is very good to add new tuner into database every time the instance</p><p>part of above changes: example:#5&732838b&0&2#. What we need to to is to check</p><p>(maybe controlled by optional setting) that if "@device<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />np:\\?\usb#vid_eb1a" </p><p>part matches, we are actually dealing with same card that was allready detected and in Db.</p><p>And only update necessary part in Db. In current solution Tve3 add new card and it has no</p><p>channels mapped to this new card and by so, it won't work.</p><p></p><p></p><p>here is modified start of Businesslayer.cs AddCard func.</p><p>[CODE]</p><p> public Card AddCard(string name, string devicePath, Server server)</p><p> {</p><p> Card card = GetCardByDevicePath(devicePath);</p><p> if (card != null)</p><p> {</p><p> card.Name = name;</p><p> card.IdServer = server.IdServer;</p><p> return card;</p><p> }</p><p> // this is adfdded detection.</p><p></p><p> IList<Card> _cards = Cards;</p><p> foreach (Card c in _cards)</p><p> {</p><p> if (devicePath.ToLower().Contains("usb") && (c.DevicePath.Contains(devicePath.Substring(0, 28))))</p><p> {</p><p> c.DevicePath = devicePath;</p><p> c.Name = name;</p><p> c.Persist();</p><p> return c; </p><p> }</p><p> }</p><p>[/CODE]</p><p></p><p>That should do it, but that is not enough. Because if instance id changes </p><p>after Tve3 has started, we still have a problem(belive me it has happened <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /> ).</p><p></p><p>Well there is nothing we can do, as, in TvCardDVB(x).cs the BuildGraph()</p><p>fails. </p><p></p><p>I tried one thing and it worked for my usb dvb-t tuner. Original fuction</p><p>is like this:</p><p></p><p> [CODE]public override void BuildGraph()</p><p> {</p><p> try</p><p> {</p><p> if (_graphState != GraphState.Idle)</p><p> {</p><p> Log.Log.Error("dvbt:Graph already built");</p><p> throw new TvException("Graph already build");</p><p> }</p><p> Log.Log.WriteFile("dvbt:BuildGraph");</p><p> _graphBuilder = (IFilterGraph2)new FilterGraph();</p><p> _capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();</p><p> _capBuilder.SetFiltergraph(_graphBuilder);</p><p> _rotEntry = new DsROTEntry(_graphBuilder);</p><p> AddNetworkProviderFilter(typeof(DVBTNetworkProvider).GUID);</p><p> CreateTuningSpace();</p><p> AddMpeg2DemuxerToGraph();</p><p> AddAndConnectBDABoardFilters(_device);</p><p> AddBdaTransportFiltersToGraph();</p><p> string graphName = _device.Name + " - DVBT Graph.grf";</p><p> FilterGraphTools.SaveGraphFile(_graphBuilder, graphName);</p><p> GetTunerSignalStatistics();</p><p> _graphState = GraphState.Created;</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> Log.Log.Write(ex);</p><p> Dispose();</p><p> _graphState = GraphState.Idle;</p><p> throw new TvExceptionGraphBuildingFailed("Graph building failed", ex);</p><p> }</p><p> }[/CODE]</p><p></p><p>As you can see Tve3 saves graph into .grf file after it has been build ok. So i thought, well</p><p>My usb tuner name is the same, only instance id has changed, so i try the saved grf file. It worked</p><p>okay. So instead of trying to build graph, if first check if grf file exist, and if so</p><p>i'll try to use it. If using it fails, then try normal graph build.</p><p></p><p>[CODE] _graphBuilder = (IFilterGraph2)new FilterGraph();</p><p> string graphName = _device.Name + " - DVBT Graph.grf";</p><p> if (System.IO.File.Exists(graphName))</p><p> {</p><p> FilterGraphTools.LoadGraphFile(_graphBuilder, graphName);</p><p> }[/CODE]</p><p></p><p>It's also a bit faster then building graph from scratch.</p><p></p><p>With these patches, and this: </p><p><a href="https://forum.team-mediaportal.com/submit-patches-mediaportal-tv-server-etc-325/generic-network-provider-not-allways-best-solution-72733/" target="_blank">https://forum.team-mediaportal.com/submit-patches-mediaportal-tv-server-etc-325/generic-network-provider-not-allways-best-solution-72733/</a></p><p>i have the most stable MP i've ever had. </p><p>With abality to use MS codecs in windows 7 x86, was the main stability increaser i've seen in Mp history(~1,5 years).</p><p></p><p>I've set all codecs to Ms codecs, that i can. Mp has runned stable ever since Ms-Coded patch was introduced in TsReader.</p><p>I can play DVD's OnLineVideos,Live-Tv(SD & HD), MKV's etc in very smooth manner. No need to restart MP, It just works.</p><p>And with these own patches i can use usb dvb-t and pci dvb-s2 tuners with some combined channels.</p><p></p><p>I have one more patch that I use, but i dunno if it's necessary anymore, but zapping between SD & HD failed</p><p>many times on some builds, so i tweaked TvHome.cs in ViewChannelAndCheck function. I just put</p><p></p><p>[CODE]g_Player.Stop();[/CODE] </p><p></p><p>in the beginning of the function. After that i've had 0 fails while zapping between SD & HD. I might loose</p><p>some timeshifting buffers, but i lose it anyway if zapping fails.</p><p></p><p>Lastly Thank You again and again for marvelous product.</p><p></p><p>Regards,</p></blockquote><p></p>
[QUOTE="te3hpurp, post: 538723, member: 82806"] Dev's might not like this dirty hack, but it works for me very nicely. First and major problem with USB tuners are that by the desing of Windows instance id of USB tuner can change by every restart/resume of windows. Sometimes it even changes while windows is running. I could not figure out exact conditions when this happens, but anyway it affecvts at least two parts of Tve3. First of all, when Tve3 restarts and it starts to detect tuner installed into machine, and if device path differs with existing usb tuner path, new tuner is added into database. Device path is something like this: @device:pnp:\\?\usb#vid_eb1a&pid_2870#5&732838b&0&2#{71985f48-1ca1-11d3-9cc8-00c04f7971e0}\{7c8095ab-c110-40e5-9f4d-310858bbbf64} And i don't think it is very good to add new tuner into database every time the instance part of above changes: example:#5&732838b&0&2#. What we need to to is to check (maybe controlled by optional setting) that if "@device:pnp:\\?\usb#vid_eb1a" part matches, we are actually dealing with same card that was allready detected and in Db. And only update necessary part in Db. In current solution Tve3 add new card and it has no channels mapped to this new card and by so, it won't work. here is modified start of Businesslayer.cs AddCard func. [CODE] public Card AddCard(string name, string devicePath, Server server) { Card card = GetCardByDevicePath(devicePath); if (card != null) { card.Name = name; card.IdServer = server.IdServer; return card; } // this is adfdded detection. IList<Card> _cards = Cards; foreach (Card c in _cards) { if (devicePath.ToLower().Contains("usb") && (c.DevicePath.Contains(devicePath.Substring(0, 28)))) { c.DevicePath = devicePath; c.Name = name; c.Persist(); return c; } } [/CODE] That should do it, but that is not enough. Because if instance id changes after Tve3 has started, we still have a problem(belive me it has happened :-) ). Well there is nothing we can do, as, in TvCardDVB(x).cs the BuildGraph() fails. I tried one thing and it worked for my usb dvb-t tuner. Original fuction is like this: [CODE]public override void BuildGraph() { try { if (_graphState != GraphState.Idle) { Log.Log.Error("dvbt:Graph already built"); throw new TvException("Graph already build"); } Log.Log.WriteFile("dvbt:BuildGraph"); _graphBuilder = (IFilterGraph2)new FilterGraph(); _capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); _capBuilder.SetFiltergraph(_graphBuilder); _rotEntry = new DsROTEntry(_graphBuilder); AddNetworkProviderFilter(typeof(DVBTNetworkProvider).GUID); CreateTuningSpace(); AddMpeg2DemuxerToGraph(); AddAndConnectBDABoardFilters(_device); AddBdaTransportFiltersToGraph(); string graphName = _device.Name + " - DVBT Graph.grf"; FilterGraphTools.SaveGraphFile(_graphBuilder, graphName); GetTunerSignalStatistics(); _graphState = GraphState.Created; } catch (Exception ex) { Log.Log.Write(ex); Dispose(); _graphState = GraphState.Idle; throw new TvExceptionGraphBuildingFailed("Graph building failed", ex); } }[/CODE] As you can see Tve3 saves graph into .grf file after it has been build ok. So i thought, well My usb tuner name is the same, only instance id has changed, so i try the saved grf file. It worked okay. So instead of trying to build graph, if first check if grf file exist, and if so i'll try to use it. If using it fails, then try normal graph build. [CODE] _graphBuilder = (IFilterGraph2)new FilterGraph(); string graphName = _device.Name + " - DVBT Graph.grf"; if (System.IO.File.Exists(graphName)) { FilterGraphTools.LoadGraphFile(_graphBuilder, graphName); }[/CODE] It's also a bit faster then building graph from scratch. With these patches, and this: [url]https://forum.team-mediaportal.com/submit-patches-mediaportal-tv-server-etc-325/generic-network-provider-not-allways-best-solution-72733/[/url] i have the most stable MP i've ever had. With abality to use MS codecs in windows 7 x86, was the main stability increaser i've seen in Mp history(~1,5 years). I've set all codecs to Ms codecs, that i can. Mp has runned stable ever since Ms-Coded patch was introduced in TsReader. I can play DVD's OnLineVideos,Live-Tv(SD & HD), MKV's etc in very smooth manner. No need to restart MP, It just works. And with these own patches i can use usb dvb-t and pci dvb-s2 tuners with some combined channels. I have one more patch that I use, but i dunno if it's necessary anymore, but zapping between SD & HD failed many times on some builds, so i tweaked TvHome.cs in ViewChannelAndCheck function. I just put [CODE]g_Player.Stop();[/CODE] in the beginning of the function. After that i've had 0 fails while zapping between SD & HD. I might loose some timeshifting buffers, but i lose it anyway if zapping fails. Lastly Thank You again and again for marvelous product. Regards, [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Improvement Suggestions
Usb tuner instance id problems, and some another thoughts.....
Contact us
RSS
Top
Bottom