From 87afc118d1f0b773b2711c27d64025b053ff6b46 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 2 Jan 2006 19:38:32 +0000 Subject: [PATCH] ext/flac/gstflacdec.c: Don't g_assert() where we should just return FALSE; remove unnecessary g_assert(); initialize ... MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Original commit message from CVS: Reviewed by: Tim-Philipp Müller * ext/flac/gstflacdec.c: (gst_flac_dec_write), (gst_flac_dec_convert_src), (gst_flac_dec_src_query), (gst_flac_dec_change_state): Don't g_assert() where we should just return FALSE; remove unnecessary g_assert(); initialize some fields properly in state change function (fixes #325504). Also, use GST_DEBUG_OBJECT in two more places. --- ChangeLog | 12 ++++++++++++ ext/flac/gstflacdec.c | 28 ++++++++++++++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f7ece9..1ceecf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-01-02 Alessandro Decina + + Reviewed by: Tim-Philipp Müller + + * ext/flac/gstflacdec.c: (gst_flac_dec_write), + (gst_flac_dec_convert_src), (gst_flac_dec_src_query), + (gst_flac_dec_change_state): + Don't g_assert() where we should just return FALSE; remove + unnecessary g_assert(); initialize some fields properly in + state change function (fixes #325504). Also, use + GST_DEBUG_OBJECT in two more places. + 2005-12-30 Stefan Kost * configure.ac: diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index e473c29..836eadc 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -482,8 +482,6 @@ gst_flac_dec_write (const FLAC__SeekableStreamDecoder * decoder, flacdec->need_newsegment = FALSE; } - g_assert (width % 8 == 0); /* width must be a multiple of 8 */ - ret = gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad, flacdec->segment.last_stop, samples * channels * (width / 8), GST_PAD_CAPS (flacdec->srcpad), &outbuf); @@ -658,9 +656,12 @@ gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, guint bytes_per_sample; guint scale = 1; - g_assert (flacdec->width > 0); - g_assert (flacdec->width % 8 == 0); - g_assert (flacdec->channels > 0); + if (flacdec->width == 0 || flacdec->channels == 0 || + flacdec->sample_rate == 0) { + /* no frame decoded yet */ + GST_DEBUG_OBJECT (flacdec, "cannot convert: not set up yet"); + return FALSE; + } bytes_per_sample = flacdec->channels * (flacdec->width / 8); @@ -668,8 +669,6 @@ gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, case GST_FORMAT_BYTES:{ switch (*dest_format) { case GST_FORMAT_DEFAULT: - if (bytes_per_sample == 0) - return FALSE; *dest_value = gst_util_uint64_scale_int (src_value, 1, bytes_per_sample); break; @@ -677,9 +676,6 @@ gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, { gint byterate = bytes_per_sample * flacdec->sample_rate; - if (byterate == 0) - return FALSE; - *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND, byterate); break; @@ -695,8 +691,6 @@ gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, *dest_value = src_value * bytes_per_sample; break; case GST_FORMAT_TIME: - if (flacdec->sample_rate == 0) - return FALSE; *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND, flacdec->sample_rate); break; @@ -754,7 +748,8 @@ gst_flac_dec_src_query (GstPad * pad, GstQuery * query) if (fmt != GST_FORMAT_DEFAULT) { if (!gst_flac_dec_convert_src (flacdec->srcpad, GST_FORMAT_DEFAULT, flacdec->segment.last_stop, &fmt, &pos)) { - GST_DEBUG ("failed to convert position into format %d", fmt); + GST_DEBUG_OBJECT (flacdec, "failed to convert position into %s " + "format", gst_format_get_name (fmt)); res = FALSE; goto done; } @@ -796,7 +791,8 @@ gst_flac_dec_src_query (GstPad * pad, GstQuery * query) if (fmt != GST_FORMAT_DEFAULT) { if (!gst_flac_dec_convert_src (flacdec->srcpad, GST_FORMAT_DEFAULT, flacdec->segment.duration, &fmt, &len)) { - GST_DEBUG ("failed to convert duration into format %d", fmt); + GST_DEBUG_OBJECT (flacdec, "failed to convert duration into %s " + "format", gst_format_get_name (fmt)); res = FALSE; goto done; } @@ -1062,6 +1058,10 @@ gst_flac_dec_change_state (GstElement * element, GstStateChange transition) flacdec->segment.last_stop = 0; flacdec->need_newsegment = TRUE; flacdec->seeking = FALSE; + flacdec->channels = 0; + flacdec->depth = 0; + flacdec->width = 0; + flacdec->sample_rate = 0; if (flacdec->init == FALSE) { FLAC__seekable_stream_decoder_reset (flacdec->decoder); } -- 2.7.4