Commit fbf8ac7d authored by Marton Balint's avatar Marton Balint

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

Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 2face3e7
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment