summaryrefslogtreecommitdiffstats
path: root/ext/flac
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2006-01-02 19:38:32 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-01-02 19:38:32 +0000
commit87afc118d1f0b773b2711c27d64025b053ff6b46 (patch)
treea7f60dd3b37acbdaa8d0fa7a17647daf3c450996 /ext/flac
parentee9cc278335214af6300e62206345d9a177fc96a (diff)
ext/flac/gstflacdec.c: Don't g_assert() where we should just return FALSE; remove unnecessary g_assert(); initialize ...
Original commit message from CVS: Reviewed by: Tim-Philipp Müller <tim at centricular dot net> * 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.
Diffstat (limited to 'ext/flac')
-rw-r--r--ext/flac/gstflacdec.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c
index e473c298..836eadce 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);
}