Message ID | 1475267743-17200-1-git-send-email-cus@passwd.hu |
---|---|
State | Accepted |
Commit | fbf8ac7d2a37b6069bb462df15e18472df004a6f |
Headers | show |
On Fri, 30 Sep 2016, Marton Balint wrote: > Signed-off-by: Marton Balint <cus@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
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)
Signed-off-by: Marton Balint <cus@passwd.hu> --- libavdevice/openal-dec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)