[mythtv] [PATCH] less crashes when no connection can be made tobackend

Tako Schotanus quintesse at palacio-cristal.com
Fri Oct 3 03:23:35 EDT 2003

Ok, things I've found out so far:

- if you have a corrupt .nuv, the AvFormatDecoder in 
NuppelVideoPlayer::OpenFile will sometimes mistakingly (I think) believe 
that it can handle the data
- on trying to play it will show:
       Waited 2 seconds for data to become available, waiting again...
       Waited 2 seconds for data to become available, waiting again...
        could not find codec parameters: 
        Couldn't open decoder for: 
- it will then try to delete the AvFormatDecoder which has no codec set 
although the destructor wants to delete it. This results in a crash.

Changing line 395 in libavcodec/utils.c from

    if (avctx->codec->close)


    if (avctx->codec && avctx->codec->close)

will fix that.

I'm still trying to get rid of those 2 waits that happen each time. What 
seems to happen is that the .nuv file got truncated because of a crash 
while recording. But reading it still expects the data to be there so it 
keeps trying to read data that isn't there (the while in int 
RingBuffer::safe_read(int fd, void *data, unsigned sz)).

Is there maybe a way to know if somebody is still writing to the file 
that is being read from? If so it might be better to just exit the while 
loop the moment the read function returns 0.

Hope this helps a bit, let me know if you had a chance to look at it 
otherwise I'll continue where I left off tomorrow.


PS: This is different from the VIA-related bug I told you before. That's 
actually the next file it crashes on :-)

Isaac Richards wrote:

>On Thursday 02 October 2003 05:37 am, Tako Schotanus wrote:
>>Not yet, I can keep it from crashing but some parts of the code will
>>just start waiting on other parts.
>>What I tried doing was ussuing a StopReads() the moment the RingBuffer's
>>safe_read() notices that the connection to the backend has been lost.
>>That works and the user will just see a blank screen instead of a crash.
>>But it seems that I have to bubble up an error code/state somehow
>>because what I get are rebuffering pauses and stuff like that. So I
>>guess other parts of the code just think the connection is slow instead
>>of gone.
>Might be just as easy as setting eof to true in the ringbuffer..  I'll 
>hopefully have time to look into this tonight sometime, but I've promised 
>Kevin Thayer that I'd look into some issues with the pvr-350 decoder support 
>mythtv-dev mailing list
>mythtv-dev at mythtv.org

More information about the mythtv-dev mailing list