#include "libavutil/samplefmt.h"
#include "libavutil/avassert.h"
#include "libavutil/time.h"
+#include "libavutil/bprint.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
static float seek_interval = 10;
static int display_disable;
static int borderless;
+static int alwaysontop;
static int startup_volume = 100;
-static int show_status = 1;
+static int show_status = -1;
static int av_sync_type = AV_SYNC_AUDIO_MASTER;
static int64_t start_time = AV_NOPTS_VALUE;
static int64_t duration = AV_NOPTS_VALUE;
if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0)
return -1;
}
- } while (d->queue->serial != d->pkt_serial);
+ 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);
}
is->force_refresh = 0;
if (show_status) {
+ AVBPrint buf;
static int64_t last_time;
int64_t cur_time;
int aqsize, vqsize, sqsize;
av_diff = get_master_clock(is) - get_clock(&is->vidclk);
else if (is->audio_st)
av_diff = get_master_clock(is) - get_clock(&is->audclk);
- av_log(NULL, AV_LOG_INFO,
- "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r",
- get_master_clock(is),
- (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")),
- av_diff,
- is->frame_drops_early + is->frame_drops_late,
- aqsize / 1024,
- vqsize / 1024,
- sqsize,
- is->video_st ? is->viddec.avctx->pts_correction_num_faulty_dts : 0,
- is->video_st ? is->viddec.avctx->pts_correction_num_faulty_pts : 0);
- fflush(stdout);
+
+ av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprintf(&buf,
+ "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r",
+ get_master_clock(is),
+ (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")),
+ av_diff,
+ is->frame_drops_early + is->frame_drops_late,
+ aqsize / 1024,
+ vqsize / 1024,
+ sqsize,
+ is->video_st ? is->viddec.avctx->pts_correction_num_faulty_dts : 0,
+ is->video_st ? is->viddec.avctx->pts_correction_num_faulty_pts : 0);
+
+ if (show_status == 1 && AV_LOG_INFO > av_log_get_level())
+ fprintf(stderr, "%s", buf.str);
+ else
+ av_log(NULL, AV_LOG_INFO, "%s", buf.str);
+
+ fflush(stderr);
+ av_bprint_finalize(&buf, NULL);
+
last_time = cur_time;
}
}
if (force_output_format) {
channel_layouts[0] = is->audio_tgt.channel_layout;
- channels [0] = is->audio_tgt.channels;
+ channels [0] = is->audio_tgt.channel_layout ? -1 : is->audio_tgt.channels;
sample_rates [0] = is->audio_tgt.freq;
if ((ret = av_opt_set_int(filt_asink, "all_channel_counts", 0, AV_OPT_SEARCH_CHILDREN)) < 0)
goto end;
}
memset(st_index, -1, sizeof(st_index));
- is->last_video_stream = is->video_stream = -1;
- is->last_audio_stream = is->audio_stream = -1;
- is->last_subtitle_stream = is->subtitle_stream = -1;
is->eof = 0;
ic = avformat_alloc_context();
}
if (is->queue_attachments_req) {
if (is->video_st && is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC) {
- AVPacket copy = { 0 };
+ AVPacket copy;
if ((ret = av_packet_ref(©, &is->video_st->attached_pic)) < 0)
goto fail;
packet_queue_put(&is->videoq, ©);
packet_queue_put_nullpacket(&is->subtitleq, is->subtitle_stream);
is->eof = 1;
}
- if (ic->pb && ic->pb->error)
- break;
+ if (ic->pb && ic->pb->error) {
+ if (autoexit)
+ goto fail;
+ else
+ break;
+ }
SDL_LockMutex(wait_mutex);
SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
SDL_UnlockMutex(wait_mutex);
is = av_mallocz(sizeof(VideoState));
if (!is)
return NULL;
+ is->last_video_stream = is->video_stream = -1;
+ is->last_audio_stream = is->audio_stream = -1;
+ is->last_subtitle_stream = is->subtitle_stream = -1;
is->filename = av_strdup(filename);
if (!is->filename)
goto fail;
break;
case SDL_WINDOWEVENT:
switch (event.window.event) {
- case SDL_WINDOWEVENT_RESIZED:
+ case SDL_WINDOWEVENT_SIZE_CHANGED:
screen_width = cur_stream->width = event.window.data1;
screen_height = cur_stream->height = event.window.data2;
if (cur_stream->vis_texture) {
{ "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set seek interval for left/right keys, in seconds", "seconds" },
{ "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" },
{ "noborder", OPT_BOOL, { &borderless }, "borderless window" },
+ { "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" },
{ "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" },
{ "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" },
{ "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" },
if (!display_disable) {
int flags = SDL_WINDOW_HIDDEN;
+ if (alwaysontop)
+#if SDL_VERSION_ATLEAST(2,0,5)
+ flags |= SDL_WINDOW_ALWAYS_ON_TOP;
+#else
+ av_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
+#endif
if (borderless)
flags |= SDL_WINDOW_BORDERLESS;
else