matroskademux: Avoid sending EOS when in paused state

Changed the ebml reader's gst_ebml_peek_id_length() function so
that it returns the actual reason for why the peek failed, instead
of (almost) always returning GST_FLOW_UNEXPECTED. This prevents
the pulling task from sending EOS when doing a flushing seek.
This commit is contained in:
Branko Subasic 2011-09-16 15:03:23 +02:00 committed by Sebastian Dröge
parent 26ae233035
commit 11b0a0effc
3 changed files with 24 additions and 29 deletions

View file

@ -60,6 +60,7 @@ gst_ebml_peek_id_length (guint32 * _id, guint64 * _length, guint * _needed,
gint len_mask = 0x80, read = 1, n = 1, num_ffs = 0; gint len_mask = 0x80, read = 1, n = 1, num_ffs = 0;
guint64 total; guint64 total;
guint8 b; guint8 b;
GstFlowReturn ret;
g_return_val_if_fail (_id != NULL, GST_FLOW_ERROR); g_return_val_if_fail (_id != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (_length != NULL, GST_FLOW_ERROR); g_return_val_if_fail (_length != NULL, GST_FLOW_ERROR);
@ -71,10 +72,9 @@ gst_ebml_peek_id_length (guint32 * _id, guint64 * _length, guint * _needed,
/* read element id */ /* read element id */
needed = 2; needed = 2;
buf = peek (ctx, needed); ret = peek (ctx, needed, &buf);
if (!buf) if (ret != GST_FLOW_OK)
goto not_enough_data; goto peek_error;
b = GST_READ_UINT8 (buf); b = GST_READ_UINT8 (buf);
total = (guint64) b; total = (guint64) b;
while (read <= 4 && !(total & len_mask)) { while (read <= 4 && !(total & len_mask)) {
@ -86,10 +86,9 @@ gst_ebml_peek_id_length (guint32 * _id, guint64 * _length, guint * _needed,
/* need id and at least something for subsequent length */ /* need id and at least something for subsequent length */
needed = read + 1; needed = read + 1;
buf = peek (ctx, needed); ret = peek (ctx, needed, &buf);
if (!buf) if (ret != GST_FLOW_OK)
goto not_enough_data; goto peek_error;
while (n < read) { while (n < read) {
b = GST_READ_UINT8 (buf + n); b = GST_READ_UINT8 (buf + n);
total = (total << 8) | b; total = (total << 8) | b;
@ -112,10 +111,9 @@ gst_ebml_peek_id_length (guint32 * _id, guint64 * _length, guint * _needed,
num_ffs++; num_ffs++;
needed += read - 1; needed += read - 1;
buf = peek (ctx, needed); ret = peek (ctx, needed, &buf);
if (!buf) if (ret != GST_FLOW_OK)
goto not_enough_data; goto peek_error;
buf += (needed - read); buf += (needed - read);
n = 1; n = 1;
while (n < read) { while (n < read) {
@ -137,10 +135,11 @@ gst_ebml_peek_id_length (guint32 * _id, guint64 * _length, guint * _needed,
return GST_FLOW_OK; return GST_FLOW_OK;
/* ERRORS */ /* ERRORS */
not_enough_data: peek_error:
{ {
GST_WARNING_OBJECT (el, "peek failed, ret = %d", ret);
*_needed = needed; *_needed = needed;
return GST_FLOW_UNEXPECTED; return ret;
} }
invalid_id: invalid_id:
{ {
@ -190,15 +189,13 @@ gst_ebml_read_clear (GstEbmlRead * ebml)
ebml->el = NULL; ebml->el = NULL;
} }
static const guint8 * static GstFlowReturn
gst_ebml_read_peek (GstByteReader * br, guint peek) gst_ebml_read_peek (GstByteReader * br, guint peek, const guint8 ** data)
{ {
const guint8 *data = NULL; if (G_LIKELY (gst_byte_reader_peek_data (br, peek, data)))
return GST_FLOW_OK;
if (G_LIKELY (gst_byte_reader_peek_data (br, peek, &data)))
return data;
else else
return NULL; return GST_FLOW_UNEXPECTED;
} }
static GstFlowReturn static GstFlowReturn

View file

@ -59,7 +59,7 @@ typedef struct _GstEbmlRead {
GArray *readers; GArray *readers;
} GstEbmlRead; } GstEbmlRead;
typedef const guint8 * (*GstPeekData) (gpointer * context, guint peek); typedef GstFlowReturn (*GstPeekData) (gpointer * context, guint peek, const guint8 ** data);
/* returns UNEXPECTED if not enough data */ /* returns UNEXPECTED if not enough data */
GstFlowReturn gst_ebml_peek_id_length (guint32 * _id, guint64 * _length, GstFlowReturn gst_ebml_peek_id_length (guint32 * _id, guint64 * _length,

View file

@ -1639,14 +1639,12 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
return GST_FLOW_OK; return GST_FLOW_OK;
} }
static const guint8 * static GstFlowReturn
gst_matroska_read_common_peek_pull (GstMatroskaReadCommon * common, guint peek) gst_matroska_read_common_peek_pull (GstMatroskaReadCommon * common, guint peek,
guint8 ** data)
{ {
guint8 *data = NULL; return gst_matroska_read_common_peek_bytes (common, common->offset, peek,
NULL, data);
gst_matroska_read_common_peek_bytes (common, common->offset, peek, NULL,
&data);
return data;
} }
GstFlowReturn GstFlowReturn