The packet serial can be used instead to detect when a flush is needed.
Signed-off-by: Marton Balint <cus@passwd.hu>
static int is_full_screen;
static int64_t audio_callback_time;
static int is_full_screen;
static int64_t audio_callback_time;
-static AVPacket flush_pkt;
-
#define FF_QUIT_EVENT (SDL_USEREVENT + 2)
static SDL_Window *window;
#define FF_QUIT_EVENT (SDL_USEREVENT + 2)
static SDL_Window *window;
return -1;
pkt1->pkt = *pkt;
pkt1->next = NULL;
return -1;
pkt1->pkt = *pkt;
pkt1->next = NULL;
- if (pkt == &flush_pkt)
- q->serial++;
pkt1->serial = q->serial;
if (!q->last_pkt)
pkt1->serial = q->serial;
if (!q->last_pkt)
ret = packet_queue_put_private(q, pkt);
SDL_UnlockMutex(q->mutex);
ret = packet_queue_put_private(q, pkt);
SDL_UnlockMutex(q->mutex);
- if (pkt != &flush_pkt && ret < 0)
av_packet_unref(pkt);
return ret;
av_packet_unref(pkt);
return ret;
q->nb_packets = 0;
q->size = 0;
q->duration = 0;
q->nb_packets = 0;
q->size = 0;
q->duration = 0;
SDL_UnlockMutex(q->mutex);
}
SDL_UnlockMutex(q->mutex);
}
{
SDL_LockMutex(q->mutex);
q->abort_request = 0;
{
SDL_LockMutex(q->mutex);
q->abort_request = 0;
- packet_queue_put_private(q, &flush_pkt);
SDL_UnlockMutex(q->mutex);
}
SDL_UnlockMutex(q->mutex);
}
av_packet_move_ref(&pkt, &d->pkt);
d->packet_pending = 0;
} else {
av_packet_move_ref(&pkt, &d->pkt);
d->packet_pending = 0;
} else {
+ int old_serial = d->pkt_serial;
if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0)
return -1;
if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0)
return -1;
+ if (old_serial != d->pkt_serial) {
+ avcodec_flush_buffers(d->avctx);
+ d->finished = 0;
+ d->next_pts = d->start_pts;
+ d->next_pts_tb = d->start_pts_tb;
+ }
}
if (d->queue->serial == d->pkt_serial)
break;
av_packet_unref(&pkt);
} while (1);
}
if (d->queue->serial == d->pkt_serial)
break;
av_packet_unref(&pkt);
} while (1);
- if (pkt.data == flush_pkt.data) {
- avcodec_flush_buffers(d->avctx);
- d->finished = 0;
- d->next_pts = d->start_pts;
- d->next_pts_tb = d->start_pts_tb;
- } else {
if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
int got_frame = 0;
ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, &pkt);
if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
int got_frame = 0;
ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, &pkt);
} else {
if (is->audio_stream >= 0) {
packet_queue_flush(&is->audioq);
} else {
if (is->audio_stream >= 0) {
packet_queue_flush(&is->audioq);
- packet_queue_put(&is->audioq, &flush_pkt);
}
if (is->subtitle_stream >= 0) {
packet_queue_flush(&is->subtitleq);
}
if (is->subtitle_stream >= 0) {
packet_queue_flush(&is->subtitleq);
- packet_queue_put(&is->subtitleq, &flush_pkt);
}
if (is->video_stream >= 0) {
packet_queue_flush(&is->videoq);
}
if (is->video_stream >= 0) {
packet_queue_flush(&is->videoq);
- packet_queue_put(&is->videoq, &flush_pkt);
}
if (is->seek_flags & AVSEEK_FLAG_BYTE) {
set_clock(&is->extclk, NAN, 0);
}
if (is->seek_flags & AVSEEK_FLAG_BYTE) {
set_clock(&is->extclk, NAN, 0);
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
- av_init_packet(&flush_pkt);
- flush_pkt.data = (uint8_t *)&flush_pkt;
-
if (!display_disable) {
int flags = SDL_WINDOW_HIDDEN;
if (alwaysontop)
if (!display_disable) {
int flags = SDL_WINDOW_HIDDEN;
if (alwaysontop)