[FFmpeg-cvslog] lavd/openal: don't return zero sized packet if no samples are available

Marton Balint git at videolan.org
Mon Oct 3 23:34:43 EEST 2016


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Fri Sep 30 11:08:51 2016 +0200| [fbf8ac7d2a37b6069bb462df15e18472df004a6f] | committer: Marton Balint

lavd/openal: don't return zero sized packet if no samples are available

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fbf8ac7d2a37b6069bb462df15e18472df004a6f
---

 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)



More information about the ffmpeg-cvslog mailing list