int RingBuffer::ReadFromBuf(void *buf, int count) { if (commserror) { fprintf (stderr,"comms error\n"); return 0; } bool readone = false; int readErr = 0; if (readaheadpaused && stopreads) { readone = true; Unpause(); } else { while (!readsallowed && !stopreads) { if (!readsAllowedWait.wait(1000)) { VERBOSE(VB_IMPORTANT, LOC + "Taking too long to be allowed to read.."); readErr++; // HACK Sometimes the readhead thread gets borked on startup. /* if ((readErr % 2) && (rbrpos ==0)) { VERBOSE(VB_IMPORTANT, "restarting readhead thread.."); KillReadAheadThread(); StartupReadAheadThread(); } */ if (readErr > 10) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Took more than " "10 seconds to be allowed to read, aborting."); wanttoread = 0; stopreads = true; fprintf (stderr,"Took more than 10 secs\n"); return 0; } } } } int avail = ReadBufAvail(); if (ateof && avail < count) count = avail; MythTimer t; t.start(); while (avail < count && !stopreads) { availWaitMutex.lock(); wanttoread = count; if (!availWait.wait(&availWaitMutex, 250)) { int elapsed = t.elapsed(); if (((elapsed > 2000) && (elapsed < 2250)) || ((elapsed > 4000) && (elapsed < 4250)) || ((elapsed > 8000) && (elapsed < 8250))) { VERBOSE(VB_IMPORTANT, LOC + "Waited " + QString("%1").arg(elapsed/1000) + " seconds for data to become available..."); } bool quit = false; if (livetvchain) { livetvchain->ReloadAll(); quit = livetvchain->HasNext(); } if (elapsed > 16000 || quit) { if (!quit) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Waited " + QString("%1").arg(elapsed/1000) + " seconds for data, aborting."); } ateof = true; wanttoread = 0; stopreads = true; availWaitMutex.unlock(); fprintf (stderr,"waited too long\n"); return 0; } } wanttoread = 0; availWaitMutex.unlock(); avail = ReadBufAvail(); if (ateof && avail < count) count = avail; if (commserror) { fprintf (stderr,"commserror\n"); return 0; } } if ((ateof || stopreads) && avail < count) count = avail; if (rbrpos + count > (int) kBufferSize) { int firstsize = kBufferSize - rbrpos; int secondsize = count - firstsize; memcpy(buf, readAheadBuffer + rbrpos, firstsize); memcpy((char *)buf + firstsize, readAheadBuffer, secondsize); } else memcpy(buf, readAheadBuffer + rbrpos, count); readAheadLock.lock(); rbrpos = (rbrpos + count) % kBufferSize; readAheadLock.unlock(); if (readone) { Pause(); WaitForPause(); } fprintf (stderr,"count %d\n",count); return count; } 2006-02-02 22:03:39.015 Using protocol version 26 2006-02-02 22:03:39.046 TV: Attempting to change from None to WatchingLiveTV 2006-02-02 22:03:39.058 Using protocol version 26 count 2048 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 waited too long av_read_packet -2 av_read_packet -2 count 0 count 0 0: start_time: -9223372036854.775 duration: -9223372036854.775 stream: start_time: -9223372036854.775 duration: -9223372036854.775 bitrate=0 kb/s 2006-02-02 22:03:40.288 AFD: Opened codec 0x82b1a50, id(MPEG1VIDEO) type(Video) 2006-02-02 22:03:40.288 NVP: Disabling Audio, params(-1,-1,-1) 2006-02-02 22:03:40.288 NVP: Disabling Audio, params(0,-1,-1) 2006-02-02 22:03:40.946 TV: Changing from None to WatchingLiveTV count 0 av_read_packet -2 2006-02-02 22:03:40.958 New DB connection, total: 3 2006-02-02 22:03:40.959 Connected to database 'mythconverg' at host: localhost 2006-02-02 22:03:40.960 Realtime priority would require SUID as root. count 2048 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 count 32768 2006-02-02 22:03:41.070 Video timing method: RTC 2006-02-02 22:03:41.114 rebuffering (10645 32768) waited too long av_read_packet -2 av_read_packet -2 error code =-1 2006-02-02 22:03:41.300 AFD Error: Could not find codec parameters. file was "/var/video/1012_20060202220340.mpg". 2006-02-02 22:03:41.300 Couldn't open decoder for: /var/video/1012_20060202220340.mpg 2006-02-02 22:03:41.300 NVP, Error: Unknown error, exiting decoder