diff options
author | Marton Balint | 2016-09-30 11:08:51 +0200 |
---|---|---|
committer | Marton Balint | 2016-10-03 21:15:48 +0200 |
commit | fbf8ac7d2a37b6069bb462df15e18472df004a6f (patch) | |
tree | fb70ff8df52c5469d58f81a1abe61143847b7d7e /libavdevice/openal-dec.c | |
parent | 2face3e7b568daf70f3115126b81d5793301569c (diff) |
lavd/openal: don't return zero sized packet if no samples are available
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavdevice/openal-dec.c')
-rw-r--r-- | libavdevice/openal-dec.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c index 0647952f9c..6eb0efe38f 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) |