[Approved] Fix for stuttering/corrupted streaming of live tv (2 Viewers)

miroslav22

Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    Home Country
    United Kingdom United Kingdom
    @disaster

    That's strange, would you mind posting the full tswriter from the server and tsreader from the client? :D

    It certainly looks like that clock jump is the cause. Does it seem to happen randomly or only on certain channels etc?

    Edit: MP pre-allocates the file size using SetEndOfFile
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Re: Fix for stuttering/corrupted streaming of live tv

    @disaster

    That's strange, would you mind posting the full tswriter from the server and tsreader from the client? :D

    It certainly looks like that clock jump is the cause. Does it seem to happen randomly or only on certain channels etc?

    Edit: MP pre-allocates the file size using SetEndOfFile

    Sorry they're gone but i can try to create new logs.

    > Edit: MP pre-allocates the file size using SetEndOfFile
    But without SPARSE file set it really needs to create a file of that size - that's reall bad. Could you point me to the line number and file? I'll then include SPARSE and see if it helps.

    Under Vista and / or Win7 it should use something like this (code borrowed from a DS Filter by me):
    Code:
    	DWORD cch = 0;
    
        if (!DeviceIoControl(m_hFileWrite, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &cch, NULL))
        {
    		Log("SetNewFileSize: Couldn't set sparse - working without sparse");
    	}
    
        LARGE_INTEGER fsize;
        fsize.QuadPart = dsize;
        if (SetFilePointerEx(m_hFileWrite, fsize, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
    	   Log("SetNewFileSize: Couldn't SetFilePointerEx of file %I64d", dsize);
           return E_FAIL;
        }
        if (!SetEndOfFile(m_hFileWrite)) {
    	   Log("SetNewFileSize: Couldn't set end of file %I64d", dsize);
           return E_FAIL;
        }
     

    miroslav22

    Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    Home Country
    United Kingdom United Kingdom
    not sure... why do you think the files should be set as sparse?

    I thought that just stopped a file physically taking up more room than it's actual written size (ie a kind of compression for say a large paging or database file). Unless i'm not understanding something?

    I haven't actually changed this part anyway, but it's in FileWriter around line 211

    Code:
    			SetFilePointer(m_chunkReserveFileSize, FILE_BEGIN);
    			SetEndOfFile(m_hFile);
    			SetFilePointer(currentPosition, FILE_BEGIN);
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    As far as i remember correctly: When you create a large file and don't create it as sparse it will take a lot of time to set SetEndOfFile. But i already modified the code and will report back if that will help - just waiting for my wife going to bed to start testing ;-)
     

    miroslav22

    Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    Home Country
    United Kingdom United Kingdom
    I think SetEndOfFile only reserves the blocks for the file so should be pretty quick. I think it might only be detrimental if the disk was very fragmented and nearly full. It's worth a try though - let me know if it helps :)
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    mhm you might be right ;-( i will try it anyway. Do you have any idea why tsreader is always jumping between the first and last ts buffer file?
     

    snowball

    Portal Pro
    December 24, 2008
    51
    12
    Home Country
    Germany Germany
    Hi,

    first many thx for this patch. running MP 1.1.2 with your V3 of the patch and mainly all problems with stuttering and artefacts have gone.
    i am experiencing only one interesting effect.
    i have multiple clients attached to the server. and when both clients are watching TV it can happen that at Client 2 the TV starts stuttering (bascially looks like only every 50 picture is shown). only thing that helps then is rewind a bit at Client 1. Then it works again at Client 2. interesting is also that it only appears at Client 2 and always client 1 has to rewind.
    i have the feeling as the internal clock or the TV on Client1runs faster and it reaches the end of the timeshift file.
    Ive activated the extra debug output in the streamingserver.dll (tsbuffer.cpp in Require) and actually it seems that the streamingserver runs at the end of the file.
    ill see that i can capture logs the next time it happens.

    does someone have the same problems?

    Cheers Snow
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    miroslav22
    main problems i'm seeing:
    1.) Tsreader isn't thread safe and the progressbar / tsduration.c does also access the same reading function like the filter itself
    2.) tsduration does seek from the 1st file and the last file about two times a second. That's why tsreader starts to jump between first and last file
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    miroslav22
    I was able to fix my stuttering with some more modifications to your patch. I would like to present a patch on top of your patch.
     

    Attachments

    • _DiscontinuityFixV3-durationfix-thredprio.patch
      6.8 KB

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    here are the binaries for 1.2 SVN - please use them only on TOP of miroslav's V3 patch.
     

    Attachments

    • binaries SVN 1.2beta.zip
      304.7 KB

    Users who are viewing this thread

    Top Bottom