[TV] Usb tuner instance id problems, and some another thoughts..... (1 Viewer)

te3hpurp

Retired Team Member
  • Premium Supporter
  • September 23, 2008
    910
    231
    Rovaniemi
    Home Country
    Finland Finland
    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;              
              }
          }

    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);
          }
        }

    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);
            }

    It's also a bit faster then building graph from scratch.

    With these patches, and this:
    https://forum.team-mediaportal.com/...ork-provider-not-allways-best-solution-72733/
    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();

    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,
     

    romuz

    Retired Team Member
  • Premium Supporter
  • July 26, 2008
    1,045
    250
    Moskau
    Home Country
    Russian Federation Russian Federation
    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();

    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,

    Could you tell please how that change affects on zapping speed?
    Because i got fails while zapping between SD & HD with MS codec too.
     

    Users who are viewing this thread

    Top Bottom