summaryrefslogtreecommitdiff
path: root/ext/ofa
diff options
context:
space:
mode:
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2011-08-16 18:34:59 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2011-08-16 20:12:38 +0100
commit5a0a0aac192e732e248d6b15343643d01a297817 (patch)
tree0fb9f6c24251832e2b606e0527d20c96d00902ca /ext/ofa
parent743b4677a2293b4ec7f5504b8fdf67504e2caeb5 (diff)
downloadgstreamer-plugins-bad-5a0a0aac192e732e248d6b15343643d01a297817.tar.gz
ofa: don't crash when there's no data to create a fingerprint from
Fixes a crash when no data flowed through. https://bugzilla.gnome.org/show_bug.cgi?id=656641
Diffstat (limited to 'ext/ofa')
-rw-r--r--ext/ofa/gstofa.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/ext/ofa/gstofa.c b/ext/ofa/gstofa.c
index d1be48635..a18d7e352 100644
--- a/ext/ofa/gstofa.c
+++ b/ext/ofa/gstofa.c
@@ -117,16 +117,27 @@ create_fingerprint (GstOFA * ofa)
GstBuffer *buf;
gint rate = GST_AUDIO_FILTER (ofa)->format.rate;
gint channels = GST_AUDIO_FILTER (ofa)->format.channels;
- gint endianness =
- (GST_AUDIO_FILTER (ofa)->format.
- bigend) ? OFA_BIG_ENDIAN : OFA_LITTLE_ENDIAN;
+ gint endianness;
GstTagList *tags;
+ guint available;
+
+ available = gst_adapter_available (ofa->adapter);
+
+ if (available == 0) {
+ GST_WARNING_OBJECT (ofa, "No data to take fingerprint from");
+ ofa->record = FALSE;
+ return;
+ }
+
+ if (GST_AUDIO_FILTER (ofa)->format.bigend)
+ endianness = OFA_BIG_ENDIAN;
+ else
+ endianness = OFA_LITTLE_ENDIAN;
+
GST_DEBUG ("Generating fingerprint");
- buf =
- gst_adapter_take_buffer (ofa->adapter,
- gst_adapter_available (ofa->adapter));
+ buf = gst_adapter_take_buffer (ofa->adapter, available);
ofa->fingerprint = g_strdup (ofa_create_print (GST_BUFFER_DATA (buf),
endianness, GST_BUFFER_SIZE (buf) / 2, rate,