diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/decode/dec_audio.c | 6 | ||||
-rw-r--r-- | audio/filter/af_lavfi.c | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index b004664474..6f07b4729d 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -275,10 +275,14 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf, filter_data.rate = da->afilter->input.rate; // due to playback speed change len = MPMIN(filter_data.samples, len); filter_data.samples = len; + bool eof = filter_data.samples == 0 && error < 0; - if (af_filter(da->afilter, &filter_data, 0) < 0) + if (af_filter(da->afilter, &filter_data, eof ? AF_FILTER_FLAG_EOF : 0) < 0) return -1; + mp_audio_buffer_append(outbuf, &filter_data); + if (eof && filter_data.samples > 0) + error = 0; // don't end playback yet // remove processed data from decoder buffer: mp_audio_buffer_skip(da->decode_buffer, len); diff --git a/audio/filter/af_lavfi.c b/audio/filter/af_lavfi.c index 7f0aad2c36..ab5b8d5495 100644 --- a/audio/filter/af_lavfi.c +++ b/audio/filter/af_lavfi.c @@ -210,7 +210,7 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags) { struct priv *p = af->priv; struct mp_audio *r = af->data; - + bool eof = data->samples == 0 && (flags & AF_FILTER_FLAG_EOF); AVFilterLink *l_in = p->in->outputs[0]; AVFrame *frame = av_frame_alloc(); @@ -229,7 +229,7 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags) frame->data[n] = data->planes[n]; frame->linesize[0] = frame->nb_samples * data->sstride; - if (av_buffersrc_add_frame(p->in, frame) < 0) { + if (av_buffersrc_add_frame(p->in, eof ? NULL : frame) < 0) { av_frame_free(&frame); return -1; } |