mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
audioencoder: Don't try to get buffers from an empty adapter
This commit is contained in:
parent
f5eebb27a2
commit
56add20dc7
1 changed files with 12 additions and 7 deletions
|
@ -805,25 +805,30 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
|
||||||
}
|
}
|
||||||
/* advance sample view */
|
/* advance sample view */
|
||||||
if (G_UNLIKELY (samples * ctx->info.bpf > priv->offset)) {
|
if (G_UNLIKELY (samples * ctx->info.bpf > priv->offset)) {
|
||||||
|
guint avail = gst_adapter_available (priv->adapter);
|
||||||
|
|
||||||
if (G_LIKELY (!priv->force)) {
|
if (G_LIKELY (!priv->force)) {
|
||||||
/* we should have received EOS to enable force */
|
/* we should have received EOS to enable force */
|
||||||
goto overflow;
|
goto overflow;
|
||||||
} else {
|
} else {
|
||||||
priv->offset = 0;
|
priv->offset = 0;
|
||||||
if (samples * ctx->info.bpf >= gst_adapter_available (priv->adapter)) {
|
if (avail > 0 && samples * ctx->info.bpf >= avail) {
|
||||||
inbuf =
|
inbuf = gst_adapter_take_buffer_fast (priv->adapter, avail);
|
||||||
gst_adapter_take_buffer_fast (priv->adapter,
|
|
||||||
gst_adapter_available (priv->adapter));
|
|
||||||
gst_adapter_clear (priv->adapter);
|
gst_adapter_clear (priv->adapter);
|
||||||
} else {
|
} else if (avail > 0) {
|
||||||
inbuf =
|
inbuf =
|
||||||
gst_adapter_take_buffer_fast (priv->adapter,
|
gst_adapter_take_buffer_fast (priv->adapter,
|
||||||
samples * ctx->info.bpf);
|
samples * ctx->info.bpf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inbuf =
|
guint avail = gst_adapter_available (priv->adapter);
|
||||||
gst_adapter_take_buffer_fast (priv->adapter, samples * ctx->info.bpf);
|
|
||||||
|
if (avail > 0) {
|
||||||
|
inbuf =
|
||||||
|
gst_adapter_take_buffer_fast (priv->adapter,
|
||||||
|
samples * ctx->info.bpf);
|
||||||
|
}
|
||||||
priv->offset -= samples * ctx->info.bpf;
|
priv->offset -= samples * ctx->info.bpf;
|
||||||
/* avoid subsequent stray prev_ts */
|
/* avoid subsequent stray prev_ts */
|
||||||
if (G_UNLIKELY (gst_adapter_available (priv->adapter) == 0))
|
if (G_UNLIKELY (gst_adapter_available (priv->adapter) == 0))
|
||||||
|
|
Loading…
Reference in a new issue