2010-11-02, 02:58
Check CXBMCRenderManager::WaitPresentTime in RenderManager.cpp in trunk (not Dharma), if it's set to false it adjusts the clock speed to the video timestamps, instead of calculating an offset.
bobo1on1 Wrote:Check CXBMCRenderManager::WaitPresentTime in RenderManager.cpp in trunk (not Dharma), if it's set to false it adjusts the clock speed to the video timestamps, instead of calculating an offset.
TheSwissKnife Wrote:I see that - and it uses FineAdjust so it changes a little how the video clock works, but what I don't see is how the audio is then sync'd (as per the description in DVDClock.h "CDVDPayerAudio synchronzies the audio stream to the clock"... etc.) - or this comment misleading?It changes the clock speed to match the timestamps, so it automatically corrects for any errors due to rounding and loss of precision, audio is still kept in sync in the same way.
Quote:EDIT: I just had a go with the changes you suggested but now my audio discontinuities have become +6 to +15ms per minute (with no change to my refresh rate or file). I will look into it in more detail tomorrow but it looks even more broken now. Is that the clock fighting you were referring to (as I still have my code to detect 1ms+ discontinuities)?That's why I increased the discontinuity limit to one refresh period, if you get a discontinuity the error will wrap in the rendermanager and the two sync methods won't fight each other.
Quote:And this time the vblank count was 270355 for the same period! How can this code change affect the number of vblanks?How are you counting them?
Quote:EDIT2: Discount this for now as I have noticed that my monthly filesystem maintenance kicked off (zfs scrub) around the time and still going after 10 hours. I have now stopped it and will re-test. It does raise the question though if the backend file feed can't keep up where is that logged (possibly "CDVDPlayer::SetCaching")?You'll see this in the log:
WARNING: CDVDMessageQueue(audio)::Get - asked for new data packet, with nothing available
WARNING: CDVDMessageQueue(video)::Get - asked for new data packet, with nothing available
Quote:It changes the clock speed to match the timestamps, so it automatically corrects for any errors due to rounding and loss of precision, audio is still kept in sync in the same way.
Quote:That's why I increased the discontinuity limit to one refresh period, if you get a discontinuity the error will wrap in the rendermanager and the two sync methods won't fight each other.
Quote:How are you counting them?
bobo1on1 Wrote:You'll see this in the log:
Code:WARNING: CDVDMessageQueue(audio)::Get - asked for new data packet, with nothing available
WARNING: CDVDMessageQueue(video)::Get - asked for new data packet, with nothing available
15:03:22 T:2934545264 M:1901268992 DEBUG: CDVDPlayerAudio:: Discontinuity - was:0.000000, should be:0.000000, error:0.000000
15:37:57 T:2934545264 M:1833664512 DEBUG: CDVDPlayerAudio:: Discontinuity - was:2075698637.491000, should be:2075656669.265578, error:-41968.225422 limit: 41707.664833
16:06:30 T:2934545264 M:1817104384 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3788534762.494578, should be:3787317333.333333, error:-1217429.161245
16:06:35 T:2934545264 M:1829789696 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3792116573.237333, should be:3792288000.000000, error:171426.762667
16:06:36 T:2934545264 M:1831751680 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3793332832.424000, should be:3793261485.646985, error:-71346.777015 limit: 41707.664833
16:06:40 T:2934545264 M:1840873472 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3797306818.733984, should be:3797184041.665852, error:-122777.068132
16:07:16 T:2934545264 M:1840123904 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3833079161.175852, should be:3832085333.333333, error:-993827.842519
16:07:30 T:2934545264 M:1841221632 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3846215973.713334, should be:3846048000.000000, error:-167973.713334
16:07:31 T:2934545264 M:1840078848 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3847091229.105000, should be:3847044327.445144, error:-46901.659856 limit: 41707.664833
16:07:40 T:2934545264 M:1830346752 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3855854583.656144, should be:3856000000.000000, error:145416.343856
16:07:46 T:2934545264 M:1838960640 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3862191040.870000, should be:3862144441.800484, error:-46599.069516 limit: 41707.664833
16:07:50 T:2934545264 M:1839161344 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3866739231.793484, should be:3866016000.000000, error:-723231.793484
16:09:26 T:2934545264 M:1850634240 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3962291684.802000, should be:3962249736.958576, error:-41947.843424 limit: 41707.664833
TheSwissKnife Wrote:So the header file comment is very misleading.I don't see how it's misleading, it just states that the rendermanager needs to know if CDVDPlayerAudio is changing the audio stream to keep it in sync with the clock (by using the resample or drop dupe sync method), or if it's changing the clock to keep it in sync with the audio (by using the audio clock sync method).
Quote:I haven't got my head around that yet...I am sure it will sink in soon. But I think you are saying that I can't now try to keep the discontinuities within 1ms with this method. But I am trying to make the sync more smooth and track the drift -so this isn't helping much. Which issue is this trying to fix - just the rounding error sync drift?Yes, it wants every presenttime to fall exactly in between two vertical blank timestamps, it does this by changing the clock speed of the videoreferenceclock slightly.
Quote:VblankCount in RunGLX. Also checking the missed value too and various other places.That's a system counter, you need to check how much it increments over a given period, and even if that value is wrong I have no control over it.
TheSwissKnife Wrote:Playing for one hour with no master clock and the frametime cap as per the patch (without my 1ms code)...here is the debug for the discontinuities. It does not look pretty.
Code:15:03:22 T:2934545264 M:1901268992 DEBUG: CDVDPlayerAudio:: Discontinuity - was:0.000000, should be:0.000000, error:0.000000
15:37:57 T:2934545264 M:1833664512 DEBUG: CDVDPlayerAudio:: Discontinuity - was:2075698637.491000, should be:2075656669.265578, error:-41968.225422 limit: 41707.664833
16:06:30 T:2934545264 M:1817104384 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3788534762.494578, should be:3787317333.333333, error:-1217429.161245
16:06:35 T:2934545264 M:1829789696 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3792116573.237333, should be:3792288000.000000, error:171426.762667
16:06:36 T:2934545264 M:1831751680 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3793332832.424000, should be:3793261485.646985, error:-71346.777015 limit: 41707.664833
16:06:40 T:2934545264 M:1840873472 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3797306818.733984, should be:3797184041.665852, error:-122777.068132
16:07:16 T:2934545264 M:1840123904 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3833079161.175852, should be:3832085333.333333, error:-993827.842519
16:07:30 T:2934545264 M:1841221632 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3846215973.713334, should be:3846048000.000000, error:-167973.713334
16:07:31 T:2934545264 M:1840078848 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3847091229.105000, should be:3847044327.445144, error:-46901.659856 limit: 41707.664833
16:07:40 T:2934545264 M:1830346752 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3855854583.656144, should be:3856000000.000000, error:145416.343856
16:07:46 T:2934545264 M:1838960640 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3862191040.870000, should be:3862144441.800484, error:-46599.069516 limit: 41707.664833
16:07:50 T:2934545264 M:1839161344 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3866739231.793484, should be:3866016000.000000, error:-723231.793484
16:09:26 T:2934545264 M:1850634240 DEBUG: CDVDPlayerAudio:: Discontinuity - was:3962291684.802000, should be:3962249736.958576, error:-41947.843424 limit: 41707.664833
bobo1on1 Wrote:I don't see how it's misleading, it just states that the rendermanager needs to know if CDVDPlayerAudio is changing the audio stream to keep it in sync with the clock (by using the resample or drop dupe sync method), or if it's changing the clock to keep it in sync with the audio (by using the audio clock sync method).
Quote:There's really no use for doing 1 ms discontinuities, a new videoframe will only be presented on the screen after a vertical blank, those happen at a fixed interval, XBMC has no control over it, so if you set the clock back by 1 ms a frame won't be presented 1 ms earlier.
You need to realize that all this a/v sync stuff consists of compromises, you have a soundcard that plays at a fixed rate, you have a display that refreshes at a fixed rate, those two are running from different clocks and are not synchronized to each other, and you have no control over either.
Quote:That's a system counter, you need to check how much it increments over a given period, and even if that value is wrong I have no control over it.
Quote:That doesn't look right, it could be a bug somewhere, did you revert your changes regarding the window size?
double speed = (double)rate / (fps * weight);
[b]if ( abs(speed - 1.001) < 0.00000003 )
speed = 1.001;[/b]
[b]int64_t m_CurrTimeFine;[/b]
m_CurrTime = Now + m_ClockOffset;
[b]m_CurrTimeFine = m_CurrTime * 1000;[/b]
[b]m_CurrTimeFine += (int64_t)NrVBlanks * (int64_t)((double)(m_AdjustedFrequency * 1000) * m_fineadjust) / m_RefreshRate;
m_CurrTime = (m_CurrTimeFine / 1000)[/b];