int read_pause_return;
AVFormatContext *ic;
int realtime;
+ int audio_finished;
+ int video_finished;
Clock audclk;
Clock vidclk;
if(avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt) < 0)
return 0;
+ if (!got_picture && !pkt->data)
+ is->video_finished = *serial;
+
if (got_picture) {
int ret = 1;
double dpts = NAN;
pkt_temp->size -= len1;
if (pkt_temp->data && pkt_temp->size <= 0 || !pkt_temp->data && !got_frame)
pkt_temp->stream_index = -1;
+ if (!pkt_temp->data && !got_frame)
+ is->audio_finished = is->audio_pkt_temp_serial;
if (!got_frame)
continue;
SDL_UnlockMutex(wait_mutex);
continue;
}
+ if (!is->paused &&
+ (!is->audio_st || is->audio_finished == is->audioq.serial) &&
+ (!is->video_st || (is->video_finished == is->videoq.serial && is->pictq_size == 0))) {
+ if (loop != 1 && (!loop || --loop)) {
+ stream_seek(is, start_time != AV_NOPTS_VALUE ? start_time : 0, 0, 0);
+ } else if (autoexit) {
+ ret = AVERROR_EOF;
+ goto fail;
+ }
+ }
if (eof) {
if (is->video_stream >= 0) {
av_init_packet(pkt);
packet_queue_put(&is->audioq, pkt);
}
SDL_Delay(10);
- if (is->audioq.size + is->videoq.size + is->subtitleq.size == 0) {
- if (loop != 1 && (!loop || --loop)) {
- stream_seek(is, start_time != AV_NOPTS_VALUE ? start_time : 0, 0, 0);
- } else if (autoexit) {
- ret = AVERROR_EOF;
- goto fail;
- }
- }
eof=0;
continue;
}