[FFmpeg-devel] [PATCH] lavd/openal: don't return zero sized packet if no samples are available
Marton Balint
cus at passwd.hu
Mon Oct 3 23:40:23 EEST 2016
On Fri, 30 Sep 2016, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavdevice/openal-dec.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c
> index 0647952..6eb0efe 100644
> --- a/libavdevice/openal-dec.c
> +++ b/libavdevice/openal-dec.c
> @@ -187,9 +187,16 @@ static int read_packet(AVFormatContext* ctx, AVPacket *pkt)
> const char *error_msg;
> ALCint nb_samples;
>
> - /* Get number of samples available */
> - alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);
> - if (error = al_get_error(ad->device, &error_msg)) goto fail;
> + for (;;) {
> + /* Get number of samples available */
> + alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);
> + if (error = al_get_error(ad->device, &error_msg)) goto fail;
> + if (nb_samples > 0)
> + break;
> + if (ctx->flags & AVFMT_FLAG_NONBLOCK)
> + return AVERROR(EAGAIN);
> + av_usleep(1000);
> + }
>
> /* Create a packet of appropriate size */
> if ((error = av_new_packet(pkt, nb_samples*ad->sample_step)) < 0)
> --
Nobody seemed interested in openal, and the EAGAIN issue pointed out by
Nicolas is fixed, so I pushed this.
Regards,
Marton
More information about the ffmpeg-devel
mailing list