Commit 477718f4 authored by Stefano Sabatini's avatar Stefano Sabatini

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.
parent 6bca574a
...@@ -299,7 +299,9 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) ...@@ -299,7 +299,9 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
avpicture_layout(&pict, ref->format, ref->video->w, avpicture_layout(&pict, ref->format, ref->video->w,
ref->video->h, pkt->data, size); ref->video->h, pkt->data, size);
} else if (ref->audio) { } else if (ref->audio) {
size = ref->linesize[0]; size = ref->audio->nb_samples *
av_get_bytes_per_sample(ref->format) *
av_get_channel_layout_nb_channels(ref->audio->channel_layout);
if ((ret = av_new_packet(pkt, size)) < 0) if ((ret = av_new_packet(pkt, size)) < 0)
return ret; return ret;
memcpy(pkt->data, ref->data[0], size); memcpy(pkt->data, ref->data[0], size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment