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
General Development (no feature request here!)
MediaPortal Audio renderer - better video playback quality
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="davidf" data-source="post: 661286" data-attributes="member: 19484"><p>[USER=10858]tourettes[/USER] 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).</p><p></p><p>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.</p><p>[code]</p><p>SetTimestamps(LONGLONG systemTime,LONGLONG rendererTime, bool rendererInUse)</p><p>{</p><p></p><p>if (m_lastRendererInUse && rendererInUse) </p><p> {</p><p> // only set samples from here to remove pause/unpause inconsistency</p><p> SetSampleError(systemTime-rendererTime,rendererTime-m_lastrendererTime); //the first 2 might be the wrong way round</p><p> m_referenceClock+=rendererTime-m_lastrendererTime; //only use audio renderer time if in use throughout</p><p> }</p><p>else m_referenceClock+=systemTime-m_lastsystemTime;</p><p>m_lastRendererInUse=rendererInUse;</p><p>m_lastrendererTime=rendererTime;</p><p>m_lastsystemTime=systemTime;</p><p>} </p><p></p><p>LONGLONG GetCurrentTime()</p><p>{</p><p>return m_referenceClock+CorrectDelta(GetCurrentSystemTime()-m_lastsystemTime); </p><p>}</p><p></p><p>LONGLONG m_llTotalSampleDuration=1; //stop div by zero</p><p>LONGLONG m_llTotalSampleError=0;</p><p>//stop adding after 10 mins as it's pretty accurate by that point</p><p>#define MAX_SAMPLE_DURATION 60000000000 </p><p></p><p>void SetSampleError(LONGLONG sampleError, LONGLONG sampleDuration)</p><p>{</p><p> if (m_llTotalSampleDuration<MAX_SAMPLE_DURATION)</p><p> {</p><p> m_llTotalSampleDuration+=sampleDuration;</p><p> m_llTotalSampleError+=sampleError;</p><p> }</p><p>}</p><p></p><p>LONGLONG CorrectDelta(LONGLONG delta)</p><p>{</p><p> return (delta*(m_llTotalSampleError+m_llTotalSampleDuration))/m_llTotalSampleDuration;</p><p>}</p><p></p><p>double Adjustment()</p><p>{</p><p> return (double) (m_llTotalSampleError+m_llTotalSampleDuration)/m_llTotalSampleDuration;</p><p>}</p><p>[/code]</p></blockquote><p></p>
[QUOTE="davidf, post: 661286, member: 19484"] [USER=10858]tourettes[/USER] 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; } [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
MediaPortal Audio renderer - better video playback quality
Contact us
RSS
Top
Bottom