From 56edbd0fa3c6bdbfeed4cc29a3489f3b9223ce1e Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Tue, 15 Mar 2011 19:36:01 +0200 Subject: [PATCH] speexdec: silence warning message when appropriate If we did not know how many frames to expect, then we get an unexpected end of stream when trying to decode more frames that are there, if there are leftover bits to pad to the next byte --- ext/speex/gstspeexdec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ext/speex/gstspeexdec.c b/ext/speex/gstspeexdec.c index c866ef8fe6..0c8c3434ee 100644 --- a/ext/speex/gstspeexdec.c +++ b/ext/speex/gstspeexdec.c @@ -665,7 +665,8 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf, fpp = dec->header->frames_per_packet; bits = &dec->bits; - GST_DEBUG_OBJECT (dec, "received buffer of size %u, fpp %d", size, fpp); + GST_DEBUG_OBJECT (dec, "received buffer of size %u, fpp %d, %d bits", size, + fpp, speex_bits_remaining (bits)); } else { /* concealment data, pass NULL as the bits parameters */ GST_DEBUG_OBJECT (dec, "creating concealment data"); @@ -680,7 +681,8 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf, gint16 *out_data; gint ret; - GST_LOG_OBJECT (dec, "decoding frame %d/%d", i, fpp); + GST_LOG_OBJECT (dec, "decoding frame %d/%d, %d bits remaining", i, fpp, + bits ? speex_bits_remaining (bits) : -1); res = gst_pad_alloc_buffer_and_set_caps (dec->srcpad, GST_BUFFER_OFFSET_NONE, dec->frame_size * dec->header->nb_channels * 2, @@ -696,7 +698,12 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf, ret = speex_decode_int (dec->state, bits, out_data); if (ret == -1) { /* uh? end of stream */ - GST_WARNING_OBJECT (dec, "Unexpected end of stream found"); + if (fpp == 0 && speex_bits_remaining (bits) < 8) { + /* if we did not know how many frames to expect, then we get this + at the end if there are leftover bits to pad to the next byte */ + } else { + GST_WARNING_OBJECT (dec, "Unexpected end of stream found"); + } gst_buffer_unref (outbuf); outbuf = NULL; break;