[FFmpeg-devel] [PATCH] lavd/openal: don't return zero sized packet if no samples are available
Marton Balint
cus at passwd.hu
Fri Sep 30 23:35:43 EEST 2016
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)
--
2.6.6
More information about the ffmpeg-devel
mailing list