Permalink
Browse files

dtvrecorder: Flush the payload buffer whenever a new payload starts.

We start buffering at the beginning of each payload, and don't write out the
data until we know if this payload has a keyframe.  This is so a new file
(for back to back recordings) would start on a keyframe.

Further, the keyframe offset recorded in the DB, is the offset to the
beginning of the payload with the keyframe.  Or at least it was supposed to
be.  Since we were not actually flushing any data currently in the buffer at
the start of a payload, that offset could be pointing to a completely
different payload!

Fixes #11435
  • Loading branch information...
jpoet committed Jun 28, 2013
1 parent 4be52bd commit 09b787346e5de8809b3905e64c1887dd273a860e
Showing with 16 additions and 0 deletions.
  1. +16 −0 mythtv/libs/libmythtv/recorders/dtvrecorder.cpp
@@ -1358,6 +1358,14 @@ bool DTVRecorder::ProcessVideoTSPacket(const TSPacket &tspacket)
if (tspacket.HasPayload() && tspacket.PayloadStart())
{
if (_buffer_packets && _first_keyframe >= 0 && !_payload_buffer.empty())
{
// Flush the buffer
if (ringBuffer)
ringBuffer->Write(&_payload_buffer[0], _payload_buffer.size());
_payload_buffer.clear();
}
// buffer packets until we know if this is a keyframe
_buffer_packets = true;
}
@@ -1381,6 +1389,14 @@ bool DTVRecorder::ProcessAudioTSPacket(const TSPacket &tspacket)
if (tspacket.HasPayload() && tspacket.PayloadStart())
{
if (_buffer_packets && _first_keyframe >= 0 && !_payload_buffer.empty())
{
// Flush the buffer
if (ringBuffer)
ringBuffer->Write(&_payload_buffer[0], _payload_buffer.size());
_payload_buffer.clear();
}
// buffer packets until we know if this is a keyframe
_buffer_packets = true;
}

0 comments on commit 09b7873

Please sign in to comment.