summaryrefslogtreecommitdiffstats
path: root/player/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/misc.c')
-rw-r--r--player/misc.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/player/misc.c b/player/misc.c
index f6a63ec7ef..1b265e11fa 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -20,7 +20,6 @@
#include <errno.h>
#include <assert.h>
-#include "config.h"
#include "mpv_talloc.h"
#include "osdep/io.h"
@@ -45,6 +44,12 @@
#include "core.h"
#include "command.h"
+const int num_ptracks[STREAM_TYPE_COUNT] = {
+ [STREAM_VIDEO] = 1,
+ [STREAM_AUDIO] = 1,
+ [STREAM_SUB] = 2,
+};
+
double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t)
{
double length = get_time_length(mpctx);
@@ -142,7 +147,12 @@ double get_track_seek_offset(struct MPContext *mpctx, struct track *track)
if (track->type == STREAM_AUDIO)
return -opts->audio_delay;
if (track->type == STREAM_SUB)
- return -opts->subs_rend->sub_delay;
+ {
+ for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
+ if (mpctx->current_track[n][STREAM_SUB] == track)
+ return -opts->subs_shared->sub_delay[n];
+ }
+ }
}
return 0;
}
@@ -163,6 +173,20 @@ void issue_refresh_seek(struct MPContext *mpctx, enum seek_precision min_prec)
queue_seek(mpctx, MPSEEK_ABSOLUTE, get_current_time(mpctx), min_prec, 0);
}
+void update_content_type(struct MPContext *mpctx, struct track *track)
+{
+ enum mp_content_type content_type;
+ if (!track || !track->vo_c) {
+ content_type = MP_CONTENT_NONE;
+ } else if (track->image) {
+ content_type = MP_CONTENT_IMAGE;
+ } else {
+ content_type = MP_CONTENT_VIDEO;
+ }
+ if (mpctx->video_out)
+ vo_control(mpctx->video_out, VOCTRL_CONTENT_TYPE, &content_type);
+}
+
void update_vo_playback_state(struct MPContext *mpctx)
{
if (mpctx->video_out && mpctx->video_out->config_ok) {
@@ -228,7 +252,8 @@ void error_on_track(struct MPContext *mpctx, struct track *track)
if (track->type == STREAM_VIDEO)
MP_INFO(mpctx, "Video: no video\n");
if (mpctx->opts->stop_playback_on_init_failure ||
- !(mpctx->vo_chain || mpctx->ao_chain))
+ (!mpctx->current_track[0][STREAM_AUDIO] &&
+ !mpctx->current_track[0][STREAM_VIDEO]))
{
if (!mpctx->stop_play)
mpctx->stop_play = PT_ERROR;
@@ -298,6 +323,18 @@ void merge_playlist_files(struct playlist *pl)
edl = talloc_strdup_append_buffer(edl, e->filename);
}
playlist_clear(pl);
- playlist_add_file(pl, edl);
+ playlist_append_file(pl, edl);
talloc_free(edl);
}
+
+const char *mp_status_str(enum playback_status st)
+{
+ switch (st) {
+ case STATUS_SYNCING: return "syncing";
+ case STATUS_READY: return "ready";
+ case STATUS_PLAYING: return "playing";
+ case STATUS_DRAINING: return "draining";
+ case STATUS_EOF: return "eof";
+ default: return "bug";
+ }
+}