}
}
-
pthread_mutex_lock(&io->mutex);
while(!scf_list_empty(&io->vout)) {
l = scf_list_head(&io->vout);
while (av_audio_fifo_size(priv->afifo) > 0) {
- if (0 == io->error && io->flush) {
+ ret = av_audio_fifo_read(priv->afifo, (void**)priv->aframe->data, 1024);
+ if (ret < 0) {
+ scf_loge("ret: %d\n", ret);
+ io->error = ret;
+ break;
+ }
- ret = av_audio_fifo_read(priv->afifo, (void**)priv->aframe->data, 1024);
- if (ret < 0) {
- scf_loge("ret: %d\n", ret);
- io->error = ret;
- break;
- }
+ priv->nb_samples += priv->aframe->nb_samples;
+ priv->aframe->pts = priv->nb_samples;
- priv->nb_samples += priv->aframe->nb_samples;
- priv->aframe->pts = priv->nb_samples;
+ scf_logd("aframe->pts: %ld\n", priv->aframe->pts);
- scf_logd("aframe->pts: %ld\n", priv->aframe->pts);
+ if (0 == io->error && io->flush) {
ret = __ffmpeg_encode(io, priv->acodec_ctx, priv->apkt, priv->aframe, priv->aidx);
if (ret < 0) {
io->abuffersrc_ctx = NULL;
io->vbuffersrc_ctx = NULL;
+ if (flush)
+ io->flush = 1;
+
simp_avio_close(io);
io = NULL;
}
io = scf_list_data(l, simp_avio_t, list);
l = scf_list_next(l);
+ if (flush)
+ io->flush = 1;
+
scf_list_del(&io->list);
simp_avio_close(io);
io = NULL;
pthread_mutex_unlock(&io->mutex);
vf = NULL;
}
+
+ if (f->flush)
+ io->flush = 1;
}
av_frame_unref(f->vframe);