Ticket #7861: unstick_captions.patch

File unstick_captions.patch, 1.7 KB (added by Jim Stichnoth <stichnot@…>, 12 years ago)
  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    14921492    if (len > text_size)
    14931493        len = text_size;
    14941494
     1495    int num_validcaptions = tbuffer_numvalid();
     1496    text_buflock.lock();
     1497    int prev_rtxt = (rtxt - 1 + MAXTBUFFER) % MAXTBUFFER;
     1498    /* Check whether the reader appears to be waiting on a caption
     1499       whose timestamp is too large.  We can guess this is the case
     1500       if we are adding a timestamp that is smaller than timestamp
     1501       being waited on but larger than the timestamp before that.
     1502       Note that even if the text buffer is full, the entry at index
     1503       rtxt-1 should still be valid.
     1504    */
     1505    if (num_validcaptions > 0 &&
     1506        txtbuffers[rtxt].timecode > timecode &&
     1507        timecode > txtbuffers[prev_rtxt].timecode)
     1508    {
     1509        /* If so, reset the timestamp that the reader is waiting on
     1510           to a value reasonably close to the previously read
     1511           timestamp.  This will probably cause one or more captions
     1512           to appear rapidly, but at least the captions won't
     1513           appear to be stuck.
     1514        */
     1515        VERBOSE(VB_VBI,
     1516                QString("Writing caption timecode %1 but waiting on %2")
     1517                .arg(timecode).arg(txtbuffers[rtxt].timecode));
     1518        txtbuffers[rtxt].timecode = txtbuffers[prev_rtxt].timecode + 500;
     1519    }
     1520
    14951521    txtbuffers[wtxt].timecode = timecode;
    14961522    txtbuffers[wtxt].type = type;
    14971523    txtbuffers[wtxt].len = len;
    14981524    memset(txtbuffers[wtxt].buffer, 0, text_size);
    14991525    memcpy(txtbuffers[wtxt].buffer, buffer, len);
    15001526
    1501     text_buflock.lock();
    15021527    wtxt = (wtxt+1) % MAXTBUFFER;
    15031528    text_buflock.unlock();
    15041529}