MediaPortal Audio renderer - better video playback quality (3 Viewers)

tourettes

Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    New version available for testing: https://forum.team-mediaportal.com/637138-post3.html

    Initial version of the audio HW based reference clock. No other changes. Following setting can be used to toggle between the reference clock "source"

    HWBasedRefClock

    Toggles between the audio HW based reference clock and system time based reference clock. Audio HW based reference clock is the default value (1).

    EVR presenter stats have new "Aud. sys. drift:" debug stat that shows the drifting between audio HW clock and system clock. On my dev PC that is approx 1.00006x
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: MediaPortal Audio renderer - better video playback quality

    tourettes
    could you explain a little bit in which cases it makes sense to change the value to 0 (system clock)?
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Re: AW: MediaPortal Audio renderer - better video playback quality

    @tourettes
    could you explain a little bit in which cases it makes sense to change the value to 0 (system clock)?

    In theory newer, since the A/V sync shouldn't be drifting anymore if the system clock and audio clocks are running different speeds. But if there are some more severe issues spotted then it is worth to test the system clock as reference. Also it is not yet 100% sure that the audio clock related code is able to cure the slowly drifting A/V sync.
     

    red5goahead

    MP Donator
  • Premium Supporter
  • November 24, 2007
    695
    144
    Italy, North West
    Home Country
    Italy Italy
    Re: AW: MediaPortal Audio renderer - better video playback quality

    @tourettes
    could you explain a little bit in which cases it makes sense to change the value to 0 (system clock)?

    In theory newer, since the A/V sync shouldn't be drifting anymore if the system clock and audio clocks are running different speeds. But if there are some more severe issues spotted then it is worth to test the system clock as reference. Also it is not yet 100% sure that the audio clock related code is able to cure the slowly drifting A/V sync.

    Some A/V synch problem with audio HW based reference clock. Watching Covert Affairs after some pauses and some stops play lost A/V synch. video delay for maybe 500-750 ms.
     

    davidf

    Retired Team Member
  • Premium Supporter
  • April 3, 2006
    796
    348
    Scotland
    Home Country
    Scotland Scotland
    tourettes you need the code within the TODO because of audio clock starting half way through a period which would give a high adjustment rate incorrectly (although this depends on the code within the audio renderer so I can't be sure).

    Added adjustment for completeness - the correction code is in integer maths which used to be quicker but probably isn't anymore, you have the bias to worry about which is a double anyway.
    Code:
    SetTimestamps(LONGLONG systemTime,LONGLONG rendererTime, bool rendererInUse)
    {
    
    if (m_lastRendererInUse && rendererInUse) 
      {
        // only set samples from here to remove pause/unpause inconsistency
        SetSampleError(systemTime-rendererTime,rendererTime-m_lastrendererTime); //the first 2 might be the wrong way round
        m_referenceClock+=rendererTime-m_lastrendererTime; //only use audio renderer time if in use throughout
      }
    else m_referenceClock+=systemTime-m_lastsystemTime;
    m_lastRendererInUse=rendererInUse;
    m_lastrendererTime=rendererTime;
    m_lastsystemTime=systemTime;
    } 
    
    LONGLONG GetCurrentTime()
    {
    return m_referenceClock+CorrectDelta(GetCurrentSystemTime()-m_lastsystemTime); 
    }
    
    LONGLONG m_llTotalSampleDuration=1; //stop div by zero
    LONGLONG m_llTotalSampleError=0;
    //stop adding after 10 mins as it's pretty accurate by that point
    #define MAX_SAMPLE_DURATION 60000000000 
    
    void SetSampleError(LONGLONG sampleError, LONGLONG sampleDuration)
    {
      if (m_llTotalSampleDuration<MAX_SAMPLE_DURATION)
      {
        m_llTotalSampleDuration+=sampleDuration;
        m_llTotalSampleError+=sampleError;
      }
    }
    
    LONGLONG CorrectDelta(LONGLONG delta)
    {
      return (delta*(m_llTotalSampleError+m_llTotalSampleDuration))/m_llTotalSampleDuration;
    }
    
    double Adjustment()
    {
      return (double) (m_llTotalSampleError+m_llTotalSampleDuration)/m_llTotalSampleDuration;
    }
     

    davidf

    Retired Team Member
  • Premium Supporter
  • April 3, 2006
    796
    348
    Scotland
    Home Country
    Scotland Scotland
    I can't see what's wrong yet (how is m_dAdjustment calculated?) but the figures are not what I expected. The stats on my machine show a constant 1.0003 which would add up to a clock drift of just over 1 second per hour or 24 seconds per day. It could be in the Audio Clock I suppose but I'm certainly not seeing my clock go off by 3.5 minutes per week.

    From your previous samples I calculated the multiplier over the 100 seconds and got
    Code:
    1.025641026
    1.033352838
    0.988735232
    1.001775899
    0.995644405
    1.001562247
    1.000780999
    1.001797268
    1.000702905
    1.001494482
    1.000596414
    0.998207012
    0.999618143
    1.000012975
    1.000043739
    0.974490926
    0.999941171
    1.000030931
    1.000012306
    1.000063017
    1.000029069
    1.000061145
    0.999831872
    0.999821214
    0.999520431
    0.999628714
    1.00001548
    1.000051558
    1.000002572
    0.999973146
    1.000040886
    1.000033127
    0.999562469
    1.000042323
    1.000054706
    1.000017365
    0.999964128
    1.000018537
    0.999796572
    1.000038036
    1.000047515
    1.000048656
    1.00004625
    1.000046214
    1.000003538
    1.000042427
    1.000025842
    1.000045783
    0.999837386
    1.00004325
    1.000025625
    0.999894569
    0.999987454
    1.000037607
    1.000030734
    0.999826985
    1.000033887
    1.000033856
    0.999831319
    0.999735537
    0.999789313
    1.000015096
    as the system clock multiplier which is less than you got. Also there is a fair amount of variation over this time which I didn't see in the stats when I tried it last night, the figure was a constant 1.0003.

    I'll have a look tonight after I give up on trying to fix my RAID disk which failed while I was on holiday - wish I hadn't used RAID 0 now :-(
     

    Truri

    MP Donator
  • Premium Supporter
  • November 9, 2008
    192
    9
    Home Country
    Germany Germany
    AW: Re: MediaPortal Audio renderer - better video playback quality

    on my htpc Aud. sys. drift show 0,9996.....

    Same here.
    New version seems to work without problems so far.
    I will report if I find something ;)
     

    Users who are viewing this thread

    Top Bottom