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
This commit is contained in:
Vincent Penquerc'h 2011-08-16 18:34:59 +01:00 committed by Tim-Philipp Müller
parent 743b4677a2
commit 5a0a0aac19

View file

@ -117,16 +117,27 @@ create_fingerprint (GstOFA * ofa)
GstBuffer *buf; GstBuffer *buf;
gint rate = GST_AUDIO_FILTER (ofa)->format.rate; gint rate = GST_AUDIO_FILTER (ofa)->format.rate;
gint channels = GST_AUDIO_FILTER (ofa)->format.channels; gint channels = GST_AUDIO_FILTER (ofa)->format.channels;
gint endianness = gint endianness;
(GST_AUDIO_FILTER (ofa)->format.
bigend) ? OFA_BIG_ENDIAN : OFA_LITTLE_ENDIAN;
GstTagList *tags; 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"); GST_DEBUG ("Generating fingerprint");
buf = buf = gst_adapter_take_buffer (ofa->adapter, available);
gst_adapter_take_buffer (ofa->adapter,
gst_adapter_available (ofa->adapter));
ofa->fingerprint = g_strdup (ofa_create_print (GST_BUFFER_DATA (buf), ofa->fingerprint = g_strdup (ofa_create_print (GST_BUFFER_DATA (buf),
endianness, GST_BUFFER_SIZE (buf) / 2, rate, endianness, GST_BUFFER_SIZE (buf) / 2, rate,