summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2022-04-06 16:58:32 -0500
committerDudemanguy <random342@airmail.cc>2022-04-11 18:14:22 +0000
commitfe6d9b6962dededc14d161e522e5f44c1ca2cd60 (patch)
tree916afeb652e5ce1642770813c76fb105b4fbd3b4 /player
parent2c2a856f2512843d12931a1f6f5b15ea76db8502 (diff)
downloadmpv-fe6d9b6962dededc14d161e522e5f44c1ca2cd60.tar.bz2
mpv-fe6d9b6962dededc14d161e522e5f44c1ca2cd60.tar.xz
player: rearrange video sync opts/enums/defines
The video sync logic for mpv lies completely within its core at essentially the highest layer of abstraction. The problem with this is that it is impossible for VOs to know what video sync mode mpv is currently using since it has no access to the opts. Because different video sync modes completely changes how mpv's render loop operates, it's reasonable that a VO may want to change how it renders based on the current mode (see the next commit for an example). Let's just move the video sync option to mp_vo_opts. MPContext, of course, can still access the value of the option so it only requires minor changes in player/video.c. Additionally, move the VS_IS_DISP define from to player/core.h to common/common.h. All VOs already have access to common/common.h, and there's no need for them to gain access to everything that's in player/core.h.
Diffstat (limited to 'player')
-rw-r--r--player/audio.c2
-rw-r--r--player/core.h18
-rw-r--r--player/video.c6
3 files changed, 4 insertions, 22 deletions
diff --git a/player/audio.c b/player/audio.c
index 0c9d878496..06ea1262a6 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -64,7 +64,7 @@ static void update_speed_filters(struct MPContext *mpctx)
speed = 1.0;
}
- if (mpctx->display_sync_active && mpctx->opts->video_sync == VS_DISP_ADROP) {
+ if (mpctx->display_sync_active && mpctx->video_out->opts->video_sync == VS_DISP_ADROP) {
drop *= speed * resample;
resample = speed = 1.0;
}
diff --git a/player/core.h b/player/core.h
index b59713721e..71595ef4f6 100644
--- a/player/core.h
+++ b/player/core.h
@@ -92,24 +92,6 @@ struct seek_params {
unsigned flags; // MPSEEK_FLAG_*
};
-enum video_sync {
- VS_DEFAULT = 0,
- VS_DISP_RESAMPLE,
- VS_DISP_RESAMPLE_VDROP,
- VS_DISP_RESAMPLE_NONE,
- VS_DISP_ADROP,
- VS_DISP_VDROP,
- VS_DISP_NONE,
- VS_NONE,
-};
-
-#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE || \
- (x) == VS_DISP_RESAMPLE_VDROP || \
- (x) == VS_DISP_RESAMPLE_NONE || \
- (x) == VS_DISP_ADROP || \
- (x) == VS_DISP_VDROP || \
- (x) == VS_DISP_NONE)
-
// Information about past video frames that have been sent to the VO.
struct frame_info {
double pts;
diff --git a/player/video.c b/player/video.c
index cae23df1c8..6400979438 100644
--- a/player/video.c
+++ b/player/video.c
@@ -583,7 +583,7 @@ static void update_avsync_before_frame(struct MPContext *mpctx)
if (mpctx->video_status < STATUS_READY) {
mpctx->time_frame = 0;
- } else if (mpctx->display_sync_active || opts->video_sync == VS_NONE) {
+ } else if (mpctx->display_sync_active || vo->opts->video_sync == VS_NONE) {
// don't touch the timing
} else if (mpctx->audio_status == STATUS_PLAYING &&
mpctx->video_status == STATUS_PLAYING &&
@@ -737,7 +737,7 @@ static double compute_audio_drift(struct MPContext *mpctx, double vsync)
static void adjust_audio_resample_speed(struct MPContext *mpctx, double vsync)
{
struct MPOpts *opts = mpctx->opts;
- int mode = opts->video_sync;
+ int mode = mpctx->video_out->opts->video_sync;
if (mode != VS_DISP_RESAMPLE || mpctx->audio_status != STATUS_PLAYING) {
mpctx->speed_factor_a = mpctx->speed_factor_v;
@@ -797,7 +797,7 @@ static void handle_display_sync_frame(struct MPContext *mpctx,
{
struct MPOpts *opts = mpctx->opts;
struct vo *vo = mpctx->video_out;
- int mode = opts->video_sync;
+ int mode = vo->opts->video_sync;
if (!mpctx->display_sync_active) {
mpctx->display_sync_error = 0.0;