Browse code

lavd/lavfi: compute and use the used samples buffer size for the output audio packet size

Do not assume the used size is the same of the allocated size, as it was
wrongly assumed. Fix audio playback when the two values differ.

Stefano Sabatini authored on 2011/10/16 17:35:07
Showing 1 changed files
... ...
@@ -299,7 +299,9 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
299 299
         avpicture_layout(&pict, ref->format, ref->video->w,
300 300
                          ref->video->h, pkt->data, size);
301 301
     } else if (ref->audio) {
302
-        size = ref->linesize[0];
302
+        size = ref->audio->nb_samples *
303
+            av_get_bytes_per_sample(ref->format) *
304
+            av_get_channel_layout_nb_channels(ref->audio->channel_layout);
303 305
         if ((ret = av_new_packet(pkt, size)) < 0)
304 306
             return ret;
305 307
         memcpy(pkt->data, ref->data[0], size);