summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-02-10 21:37:12 +0100
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-02-11 22:22:51 +0100
commitb4739124dcbf0139ac0d9ed10a5e72c8594f2ba7 (patch)
treef8f708570f4af872930ba9f799d57e8492321f3e
parent159fe8a1a086508ca0f90bdc0d53ebcafe065c6c (diff)
faad: do not attempt to sync indefinitely
-rw-r--r--ext/faad/gstfaad.c17
-rw-r--r--ext/faad/gstfaad.h1
2 files changed, 17 insertions, 1 deletions
diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c
index 3ae535620..b4f1246e2 100644
--- a/ext/faad/gstfaad.c
+++ b/ext/faad/gstfaad.c
@@ -246,6 +246,7 @@ gst_faad_reset (GstFaad * faad)
faad->bytes_in = 0;
faad->sum_dur_out = 0;
faad->error_count = 0;
+ faad->sync_flush = 0;
gst_adapter_clear (faad->adapter);
clear_queued (faad);
}
@@ -971,6 +972,8 @@ looks_like_valid_header (guint8 * input_data, guint input_size)
return FALSE;
}
+#define FAAD_MAX_SYNC 10 * 8 * 1024
+
static GstFlowReturn
gst_faad_chain (GstPad * pad, GstBuffer * buffer)
{
@@ -1021,9 +1024,14 @@ gst_faad_chain (GstPad * pad, GstBuffer * buffer)
if (!faad->packetised) {
if (!gst_faad_sync (faad, input_data, input_size, &sync_off)) {
+ faad->sync_flush += sync_off;
input_size -= sync_off;
- goto out;
+ if (faad->sync_flush > FAAD_MAX_SYNC)
+ goto parse_failed;
+ else
+ goto out;
} else {
+ faad->sync_flush = 0;
input_data += sync_off;
input_size -= sync_off;
}
@@ -1203,6 +1211,13 @@ sample_overflow:
ret = GST_FLOW_ERROR;
goto out;
}
+parse_failed:
+ {
+ GST_ELEMENT_ERROR (faad, STREAM, DECODE, (NULL),
+ ("failed to parse non-packetized stream"));
+ ret = GST_FLOW_ERROR;
+ goto out;
+ }
}
static gboolean
diff --git a/ext/faad/gstfaad.h b/ext/faad/gstfaad.h
index 486061d4b..b13f0e76b 100644
--- a/ext/faad/gstfaad.h
+++ b/ext/faad/gstfaad.h
@@ -68,6 +68,7 @@ typedef struct _GstFaad {
guint64 sum_dur_out; /* sum of durations of decoded buffers we sent out */
gint error_count;
gboolean discont;
+ gint sync_flush;
/* segment handling */
GstSegment segment;