Skip to content
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!

(cherry picked from commit 09b7873)
(cherry picked from commit 10e87f5)
  • Loading branch information...
1 parent df9f50e commit 8d4cae284f47039c8c748610974535c5619c2fc0 @jpoet jpoet committed with tralph Jun 28, 2013
Showing with 16 additions and 0 deletions.
  1. +16 −0 mythtv/libs/libmythtv/dtvrecorder.cpp
View
16 mythtv/libs/libmythtv/dtvrecorder.cpp
@@ -1317,6 +1317,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;
}
@@ -1340,6 +1348,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 8d4cae2

Please sign in to comment.
Something went wrong with that request. Please try again.