summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-28 21:17:55 +0100
committerwm4 <wm4@nowhere>2020-02-29 01:23:20 +0100
commitb0b5de306387f03f7f79a34ecc7d2aaf223f180a (patch)
tree40fa6a05b16e4e79829e0acc6434edf8100f046e /player
parenta8f4ca587dba1c1579e20b3361196c78babab7fa (diff)
downloadmpv-b0b5de306387f03f7f79a34ecc7d2aaf223f180a.tar.bz2
mpv-b0b5de306387f03f7f79a34ecc7d2aaf223f180a.tar.xz
f_decoder_wrapper: replace most public fields with setters/getters
I may (optionally) move decoding to a separate thread in a future change. It's a bit attractive to move the entire decoder wrapper to there, so if the demuxer has a new packet, it doesn't have to wake up the main thread, and can directly wake up the decoder. (Although that's bullshit, since there's a queue in between, and libavcodec's multi-threaded decoding plays cross-threads ping pong with packets anyway. On the other hand, the main thread would still have to shuffle the packets around, so whatever, just seems like better design.) As preparation, there shouldn't be any mutable state exposed by the wrapper. But there's still a large number of corner-caseish crap, so just use setters/getters for them. This recorder thing will inherently not work, so it'll have to be disabled if threads are used. This is a bit painful, but probably still the right thing. Like speculatively pulling teeth.
Diffstat (limited to 'player')
-rw-r--r--player/audio.c10
-rw-r--r--player/command.c21
-rw-r--r--player/osd.c3
-rw-r--r--player/playloop.c2
-rw-r--r--player/video.c9
5 files changed, 26 insertions, 19 deletions
diff --git a/player/audio.c b/player/audio.c
index 8aba3d860b..cde444ffb4 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -190,7 +190,7 @@ void reset_audio_state(struct MPContext *mpctx)
ao_chain_reset_state(mpctx->ao_chain);
struct track *t = mpctx->ao_chain->track;
if (t && t->dec)
- t->dec->play_dir = mpctx->play_dir;
+ mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
}
mpctx->audio_status = mpctx->ao_chain ? STATUS_SYNCING : STATUS_EOF;
mpctx->delay = 0;
@@ -389,7 +389,7 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
MP_VERBOSE(mpctx, "Falling back to PCM output.\n");
ao_c->spdif_passthrough = false;
ao_c->spdif_failed = true;
- ao_c->track->dec->try_spdif = false;
+ mp_decoder_wrapper_set_spdif_flag(ao_c->track->dec, false);
if (!mp_decoder_wrapper_reinit(ao_c->track->dec))
goto init_error;
reset_audio_state(mpctx);
@@ -441,7 +441,7 @@ int init_audio_decoder(struct MPContext *mpctx, struct track *track)
goto init_error;
if (track->ao_c)
- track->dec->try_spdif = true;
+ mp_decoder_wrapper_set_spdif_flag(track->dec, true);
if (!mp_decoder_wrapper_reinit(track->dec))
goto init_error;
@@ -776,7 +776,7 @@ void reload_audio_output(struct MPContext *mpctx)
if (dec && ao_c->spdif_failed) {
ao_c->spdif_passthrough = true;
ao_c->spdif_failed = false;
- dec->try_spdif = true;
+ mp_decoder_wrapper_set_spdif_flag(ao_c->track->dec, true);
if (!mp_decoder_wrapper_reinit(dec)) {
MP_ERR(mpctx, "Error reinitializing audio.\n");
error_on_track(mpctx, ao_c->track);
@@ -836,7 +836,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
}
if (mpctx->vo_chain && ao_c->track && ao_c->track->dec &&
- ao_c->track->dec->pts_reset)
+ mp_decoder_wrapper_get_pts_reset(ao_c->track->dec))
{
MP_WARN(mpctx, "Reset playback due to audio timestamp reset.\n");
reset_playback_state(mpctx);
diff --git a/player/command.c b/player/command.c
index 9e0f4f64e9..fb28b285e1 100644
--- a/player/command.c
+++ b/player/command.c
@@ -674,7 +674,8 @@ static int mp_property_frame_drop_dec(void *ctx, struct m_property *prop,
if (!dec)
return M_PROPERTY_UNAVAILABLE;
- return m_property_int_ro(action, arg, dec->dropped_frames);
+ return m_property_int_ro(action, arg,
+ mp_decoder_wrapper_get_frames_dropped(dec));
}
static int mp_property_mistimed_frame_count(void *ctx, struct m_property *prop,
@@ -1753,8 +1754,10 @@ static int mp_property_audio_codec(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
struct track *track = mpctx->current_track[0][STREAM_AUDIO];
- const char *c = track && track->dec ? track->dec->decoder_desc : NULL;
- return m_property_strdup_ro(action, arg, c);
+ char desc[256] = "";
+ if (track && track->dec)
+ mp_decoder_wrapper_get_desc(track->dec, desc, sizeof(desc));
+ return m_property_strdup_ro(action, arg, desc[0] ? desc : NULL);
}
static int property_audiofmt(struct mp_aframe *fmt, int action, void *arg)
@@ -1904,9 +1907,9 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
struct mp_codec_params p =
track->stream ? *track->stream->codec : (struct mp_codec_params){0};
- const char *decoder_desc = NULL;
+ char decoder_desc[256];
if (track->dec)
- decoder_desc = track->dec->decoder_desc;
+ mp_decoder_wrapper_get_desc(track->dec, decoder_desc, sizeof(decoder_desc));
bool has_rg = track->stream && track->stream->codec->replaygain_data;
struct replaygain_data rg = has_rg ? *track->stream->codec->replaygain_data
@@ -1940,7 +1943,7 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
.unavailable = !track->external_filename},
{"ff-index", SUB_PROP_INT(track->ff_index)},
{"decoder-desc", SUB_PROP_STR(decoder_desc),
- .unavailable = !decoder_desc},
+ .unavailable = !decoder_desc[0]},
{"codec", SUB_PROP_STR(p.codec),
.unavailable = !p.codec},
{"demux-w", SUB_PROP_INT(p.disp_w), .unavailable = !p.disp_w},
@@ -2106,8 +2109,10 @@ static int mp_property_video_codec(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
- const char *c = track && track->dec ? track->dec->decoder_desc : NULL;
- return m_property_strdup_ro(action, arg, c);
+ char desc[256] = "";
+ if (track && track->dec)
+ mp_decoder_wrapper_get_desc(track->dec, desc, sizeof(desc));
+ return m_property_strdup_ro(action, arg, desc[0] ? desc : NULL);
}
static int property_imgparams(struct mp_image_params p, int action, void *arg)
diff --git a/player/osd.c b/player/osd.c
index ff9bd9b429..0e8fd2a0e7 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -220,7 +220,8 @@ static char *get_term_status_msg(struct MPContext *mpctx)
int64_t c = vo_get_drop_count(mpctx->video_out);
struct mp_decoder_wrapper *dec = mpctx->vo_chain->track
? mpctx->vo_chain->track->dec : NULL;
- int dropped_frames = dec ? dec->dropped_frames : 0;
+ int dropped_frames =
+ dec ? mp_decoder_wrapper_get_frames_dropped(dec) : 0;
if (c > 0 || dropped_frames > 0) {
saddf(&line, " Dropped: %"PRId64, c);
if (dropped_frames)
diff --git a/player/playloop.c b/player/playloop.c
index c8c74edb64..9660a5b6ad 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -229,7 +229,7 @@ void reset_playback_state(struct MPContext *mpctx)
struct track *t = mpctx->tracks[n];
// (Often, but not always, this is redundant and also done elsewhere.)
if (t->dec)
- t->dec->play_dir = mpctx->play_dir;
+ mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
if (t->d_sub)
sub_set_play_dir(t->d_sub, mpctx->play_dir);
}
diff --git a/player/video.c b/player/video.c
index d1e1554ef0..2e0c8f6460 100644
--- a/player/video.c
+++ b/player/video.c
@@ -101,7 +101,7 @@ void reset_video_state(struct MPContext *mpctx)
vo_chain_reset_state(mpctx->vo_chain);
struct track *t = mpctx->vo_chain->track;
if (t && t->dec)
- t->dec->play_dir = mpctx->play_dir;
+ mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
}
for (int n = 0; n < mpctx->num_next_frames; n++)
@@ -259,7 +259,8 @@ void reinit_video_chain_src(struct MPContext *mpctx, struct track *track)
goto err_out;
vo_c->dec_src = track->dec->f->pins[0];
- vo_c->filter->container_fps = track->dec->fps;
+ vo_c->filter->container_fps =
+ mp_decoder_wrapper_get_container_fps(track->dec);
vo_c->is_coverart = !!track->stream->attached_picture;
vo_c->is_sparse = track->stream->still_image || vo_c->is_coverart;
@@ -323,8 +324,8 @@ static void check_framedrop(struct MPContext *mpctx, struct vo_chain *vo_c)
return;
double frame_time = 1.0 / fps;
// try to drop as many frames as we appear to be behind
- vo_c->track->dec->attempt_framedrops =
- MPCLAMP((mpctx->last_av_difference - 0.010) / frame_time, 0, 100);
+ mp_decoder_wrapper_set_frame_drops(vo_c->track->dec,
+ MPCLAMP((mpctx->last_av_difference - 0.010) / frame_time, 0, 100));
}
}