提交 74590fa5 编写于 作者: Z Zhang Rui

ff_ffplay: only one stream can trigger buffering

上级 ebec392d
...@@ -270,7 +270,7 @@ static int packet_queue_get_or_buffering(FFPlayer *ffp, PacketQueue *q, AVPacket ...@@ -270,7 +270,7 @@ static int packet_queue_get_or_buffering(FFPlayer *ffp, PacketQueue *q, AVPacket
if (new_packet < 0) if (new_packet < 0)
return -1; return -1;
else if (new_packet == 0) { else if (new_packet == 0) {
if (!*finished) if (q->is_buffer_indicator && !*finished)
ffp_toggle_buffering(ffp, 1); ffp_toggle_buffering(ffp, 1);
new_packet = packet_queue_get(q, pkt, 1, serial); new_packet = packet_queue_get(q, pkt, 1, serial);
if (new_packet < 0) if (new_packet < 0)
...@@ -2366,6 +2366,15 @@ static int read_thread(void *arg) ...@@ -2366,6 +2366,15 @@ static int read_thread(void *arg)
ret = -1; ret = -1;
goto fail; goto fail;
} }
if (is->audio_stream >= 0) {
is->audioq.is_buffer_indicator = 1;
is->buffer_indicator_queue = &is->audioq;
} else if (is->video_stream >= 0) {
is->videoq.is_buffer_indicator = 1;
is->buffer_indicator_queue = &is->videoq;
} else {
assert("invalid streams");
}
if (ffp->infinite_buffer < 0 && is->realtime) if (ffp->infinite_buffer < 0 && is->realtime)
ffp->infinite_buffer = 1; ffp->infinite_buffer = 1;
...@@ -3349,8 +3358,11 @@ void ffp_check_buffering_l(FFPlayer *ffp) ...@@ -3349,8 +3358,11 @@ void ffp_check_buffering_l(FFPlayer *ffp)
hwm_in_ms = ffp->max_high_water_mark_in_ms; hwm_in_ms = ffp->max_high_water_mark_in_ms;
ffp->current_high_water_mark_in_ms = hwm_in_ms; ffp->current_high_water_mark_in_ms = hwm_in_ms;
if (is->buffer_indicator_queue && is->buffer_indicator_queue->nb_packets > 0) {
ffp_toggle_buffering(ffp, 0); ffp_toggle_buffering(ffp, 0);
} }
}
} }
int ffp_video_thread(FFPlayer *ffp) int ffp_video_thread(FFPlayer *ffp)
......
...@@ -104,6 +104,8 @@ typedef struct PacketQueue { ...@@ -104,6 +104,8 @@ typedef struct PacketQueue {
MyAVPacketList *recycle_pkt; MyAVPacketList *recycle_pkt;
int recycle_count; int recycle_count;
int alloc_count; int alloc_count;
int is_buffer_indicator;
} PacketQueue; } PacketQueue;
// #define VIDEO_PICTURE_QUEUE_SIZE 3 // #define VIDEO_PICTURE_QUEUE_SIZE 3
...@@ -322,6 +324,8 @@ typedef struct VideoState { ...@@ -322,6 +324,8 @@ typedef struct VideoState {
int dropping_frame; int dropping_frame;
int is_video_high_fps; // above 30fps int is_video_high_fps; // above 30fps
int is_video_high_res; // above 1080p int is_video_high_res; // above 1080p
PacketQueue *buffer_indicator_queue;
} VideoState; } VideoState;
/* options specified by the user */ /* options specified by the user */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册