Showing the changes to libavdevice (1 of 1 file). Show all
Unified · Split
| @@ -187,9 +187,16 @@ static int read_packet(AVFormatContext* ctx, AVPacket *pkt) · 186 unmodified lines | ||
| 187 | 187 | const char *error_msg; |
| 188 | 188 | ALCint nb_samples; |
| 189 | 189 | |
| 190 | − /* Get number of samples available */ | |
| 191 | − alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples); | |
| 192 | − if (error = al_get_error(ad->device, &error_msg)) goto fail; | |
| 190 | + for (;;) { | |
| 191 | + /* Get number of samples available */ | |
| 192 | + alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples); | |
| 193 | + if (error = al_get_error(ad->device, &error_msg)) goto fail; | |
| 194 | + if (nb_samples > 0) | |
| 195 | + break; | |
| 196 | + if (ctx->flags & AVFMT_FLAG_NONBLOCK) | |
| 197 | + return AVERROR(EAGAIN); | |
| 198 | + av_usleep(1000); | |
| 199 | + } | |
| 193 | 200 | |
| 194 | 201 | /* Create a packet of appropriate size */ |
| 195 | 202 | if ((error = av_new_packet(pkt, nb_samples*ad->sample_step)) < 0) |