faad: correctly estimate average bps
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 10 Feb 2010 21:14:07 +0000 (22:14 +0100)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Thu, 11 Feb 2010 21:22:51 +0000 (22:22 +0100)
Count consumed bytes and corresponding duration atomically,
rather than letting bytecount run ahead of what has been decoded.

Fixes #440476.

ext/faad/gstfaad.c

index 1b570922b329bd9b3e84a0b4ab72a3ea523d125f..4f0fca6bb87fbfd0a60f462bd610f015127021dc 100644 (file)
@@ -1002,10 +1002,6 @@ gst_faad_chain (GstPad * pad, GstBuffer * buffer)
     faad->discont = TRUE;
   }
 
-  GST_OBJECT_LOCK (faad);
-  faad->bytes_in += GST_BUFFER_SIZE (buffer);
-  GST_OBJECT_UNLOCK (faad);
-
   gst_adapter_push (faad->adapter, buffer);
   buffer = NULL;
 
@@ -1151,6 +1147,7 @@ gst_faad_chain (GstPad * pad, GstBuffer * buffer)
         GST_OBJECT_LOCK (faad);
         faad->next_ts += GST_BUFFER_DURATION (outbuf);
         faad->sum_dur_out += GST_BUFFER_DURATION (outbuf);
+        faad->bytes_in += info.bytesconsumed;
         GST_OBJECT_UNLOCK (faad);
 
         if ((outbuf = gst_audio_buffer_clip (outbuf, &faad->segment,