Browse Source

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

Signed-off-by: Marton Balint <cus@passwd.hu>
tags/n3.2
Marton Balint 8 years ago
parent
commit
fbf8ac7d2a
1 changed files with 10 additions and 3 deletions
  1. +10
    -3
      libavdevice/openal-dec.c

+ 10
- 3
libavdevice/openal-dec.c View File

@@ -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)


Loading…
Cancel
Save