|
@@ -41,7 +41,6 @@ int ReadThread::loop_read()
|
|
|
if (!pkt) {
|
|
if (!pkt) {
|
|
|
av_log(nullptr, AV_LOG_FATAL, "Could not allocate packet.\n");
|
|
av_log(nullptr, AV_LOG_FATAL, "Could not allocate packet.\n");
|
|
|
ret = AVERROR(ENOMEM);
|
|
ret = AVERROR(ENOMEM);
|
|
|
- qCWarning(playerControllerReadThread) << "[ReadThread] av_packet_alloc failed!";
|
|
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
qCDebug(playerControllerReadThread) << "[ReadThread] loop_read start, file:"
|
|
qCDebug(playerControllerReadThread) << "[ReadThread] loop_read start, file:"
|
|
@@ -132,6 +131,21 @@ int ReadThread::loop_read()
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!is->paused
|
|
|
|
|
+ && (!is->audio_st
|
|
|
|
|
+ || (is->auddec.finished == is->audioq.serial
|
|
|
|
|
+ && frame_queue_nb_remaining(&is->sampq) == 0))
|
|
|
|
|
+ && (!is->video_st
|
|
|
|
|
+ || (is->viddec.finished == is->videoq.serial
|
|
|
|
|
+ && frame_queue_nb_remaining(&is->pictq) == 0))) {
|
|
|
|
|
+ if (is->loop) {
|
|
|
|
|
+ stream_seek(is, 0, 0, 0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // autoexit
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ret = av_read_frame(is->ic, pkt);
|
|
ret = av_read_frame(is->ic, pkt);
|
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
|
char buf[256] = {0};
|
|
char buf[256] = {0};
|
|
@@ -150,13 +164,14 @@ int ReadThread::loop_read()
|
|
|
packet_queue_put_nullpacket(&is->audioq, pkt, is->audio_stream);
|
|
packet_queue_put_nullpacket(&is->audioq, pkt, is->audio_stream);
|
|
|
if (is->subtitle_stream >= 0)
|
|
if (is->subtitle_stream >= 0)
|
|
|
packet_queue_put_nullpacket(&is->subtitleq, pkt, is->subtitle_stream);
|
|
packet_queue_put_nullpacket(&is->subtitleq, pkt, is->subtitle_stream);
|
|
|
-
|
|
|
|
|
- if (is->loop) {
|
|
|
|
|
- stream_seek(is, 0, 0, 0);
|
|
|
|
|
- } else {
|
|
|
|
|
- is->eof = 1;
|
|
|
|
|
- break; // added for auto exit read thread
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ is->eof = 1;
|
|
|
|
|
+
|
|
|
|
|
+ // if (is->loop) {
|
|
|
|
|
+ // stream_seek(is, 0, 0, 0);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // is->eof = 1;
|
|
|
|
|
+ // break; // added for auto exit read thread
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
if (is->ic->pb && is->ic->pb->error) {
|
|
if (is->ic->pb && is->ic->pb->error) {
|
|
|
qCWarning(playerControllerReadThread) << "[ReadThread] IO error detected.";
|
|
qCWarning(playerControllerReadThread) << "[ReadThread] IO error detected.";
|
|
@@ -207,6 +222,8 @@ int ReadThread::loop_read()
|
|
|
qCDebug(playerControllerReadThread) << "[ReadThread] loop_read exit, set read_thread_exit = -1";
|
|
qCDebug(playerControllerReadThread) << "[ReadThread] loop_read exit, set read_thread_exit = -1";
|
|
|
is->read_thread_exit = -1;
|
|
is->read_thread_exit = -1;
|
|
|
|
|
|
|
|
|
|
+ if (!is->ic)
|
|
|
|
|
+ avformat_close_input(&is->ic);
|
|
|
av_packet_free(&pkt);
|
|
av_packet_free(&pkt);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|