summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/command.c91
-rw-r--r--player/core.h2
-rw-r--r--player/discnav.c31
-rw-r--r--player/loadfile.c64
-rw-r--r--player/misc.c10
-rw-r--r--player/playloop.c24
6 files changed, 120 insertions, 102 deletions
diff --git a/player/command.c b/player/command.c
index fffa63bb70..6b29fdc735 100644
--- a/player/command.c
+++ b/player/command.c
@@ -205,11 +205,11 @@ static int mp_property_file_size(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!mpctx->stream)
+ if (!mpctx->demuxer)
return M_PROPERTY_UNAVAILABLE;
int64_t size;
- if (stream_control(mpctx->stream, STREAM_CTRL_GET_SIZE, &size) != STREAM_OK)
+ if (demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_SIZE, &size) < 1)
return M_PROPERTY_UNAVAILABLE;
if (action == M_PROPERTY_PRINT) {
@@ -232,13 +232,6 @@ static int mp_property_media_title(void *ctx, struct m_property *prop,
name = demux_info_get(mpctx->master_demuxer, "title");
if (name && name[0])
return m_property_strdup_ro(action, arg, name);
- struct stream *stream = mpctx->master_demuxer->stream;
- if (stream_control(stream, STREAM_CTRL_GET_DISC_NAME, &name) > 0
- && name) {
- int r = m_property_strdup_ro(action, arg, name);
- talloc_free(name);
- return r;
- }
}
return mp_property_filename(ctx, prop, action, arg);
}
@@ -247,7 +240,8 @@ static int mp_property_stream_path(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct stream *stream = mpctx->stream;
+ // demuxer->stream as well as stream->url are immutable -> ok to access
+ struct stream *stream = mpctx->demuxer ? mpctx->demuxer->stream : NULL;
if (!stream || !stream->url)
return M_PROPERTY_UNAVAILABLE;
return m_property_strdup_ro(action, arg, stream->url);
@@ -257,12 +251,14 @@ static int mp_property_stream_capture(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!mpctx->stream)
+ if (!mpctx->demuxer)
return M_PROPERTY_UNAVAILABLE;
if (action == M_PROPERTY_SET) {
char *filename = *(char **)arg;
- stream_set_capture_file(mpctx->stream, filename);
+ demux_pause(mpctx->demuxer);
+ stream_set_capture_file(mpctx->demuxer->stream, filename);
+ demux_unpause(mpctx->demuxer);
// fall through to mp_property_generic_option
}
return mp_property_generic_option(mpctx, prop, action, arg);
@@ -284,14 +280,19 @@ static int mp_property_stream_pos(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct stream *stream = mpctx->stream;
- if (!stream)
+ struct demuxer *demuxer = mpctx->demuxer;
+ if (!demuxer)
return M_PROPERTY_UNAVAILABLE;
+ demux_pause(demuxer);
+ int r;
if (action == M_PROPERTY_SET) {
- stream_seek(stream, *(int64_t *) arg);
- return M_PROPERTY_OK;
+ stream_seek(demuxer->stream, *(int64_t *) arg);
+ r = M_PROPERTY_OK;
+ } else {
+ r = m_property_int64_ro(action, arg, stream_tell(demuxer->stream));
}
- return m_property_int64_ro(action, arg, stream_tell(stream));
+ demux_unpause(demuxer);
+ return r;
}
/// Stream end offset (RO)
@@ -490,14 +491,13 @@ static int mp_property_disc_title(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct demuxer *demuxer = mpctx->master_demuxer;
- if (!demuxer || !demuxer->stream)
+ struct demuxer *d = mpctx->master_demuxer;
+ if (!d)
return M_PROPERTY_UNAVAILABLE;
- struct stream *stream = demuxer->stream;
unsigned int title = -1;
switch (action) {
case M_PROPERTY_GET:
- if (stream_control(stream, STREAM_CTRL_GET_CURRENT_TITLE, &title) <= 0)
+ if (demux_stream_control(d, STREAM_CTRL_GET_CURRENT_TITLE, &title) < 0)
return M_PROPERTY_UNAVAILABLE;
*(int*)arg = title;
return M_PROPERTY_OK;
@@ -510,7 +510,7 @@ static int mp_property_disc_title(void *ctx, struct m_property *prop,
return M_PROPERTY_OK;
case M_PROPERTY_SET:
title = *(int*)arg;
- if (stream_control(stream, STREAM_CTRL_SET_CURRENT_TITLE, &title) <= 0)
+ if (demux_stream_control(d, STREAM_CTRL_SET_CURRENT_TITLE, &title) < 0)
return M_PROPERTY_NOT_IMPLEMENTED;
return M_PROPERTY_OK;
}
@@ -813,8 +813,8 @@ static int mp_property_disc_titles(void *ctx, struct m_property *prop,
MPContext *mpctx = ctx;
struct demuxer *demuxer = mpctx->master_demuxer;
unsigned int num_titles;
- if (!demuxer || stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_TITLES,
- &num_titles) < 1)
+ if (!demuxer || demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_TITLES,
+ &num_titles) < 1)
return M_PROPERTY_UNAVAILABLE;
return m_property_int_ro(action, arg, num_titles);
}
@@ -853,11 +853,11 @@ static int mp_property_angle(void *ctx, struct m_property *prop,
int ris, angles = -1, angle = 1;
- ris = stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_ANGLES, &angles);
+ ris = demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_ANGLES, &angles);
if (ris == STREAM_UNSUPPORTED)
return M_PROPERTY_UNAVAILABLE;
- ris = stream_control(demuxer->stream, STREAM_CTRL_GET_ANGLE, &angle);
+ ris = demux_stream_control(demuxer, STREAM_CTRL_GET_ANGLE, &angle);
if (ris == STREAM_UNSUPPORTED)
return -1;
@@ -878,7 +878,7 @@ static int mp_property_angle(void *ctx, struct m_property *prop,
return M_PROPERTY_ERROR;
demux_flush(demuxer);
- ris = stream_control(demuxer->stream, STREAM_CTRL_SET_ANGLE, &angle);
+ ris = demux_stream_control(demuxer, STREAM_CTRL_SET_ANGLE, &angle);
if (ris != STREAM_OK)
return M_PROPERTY_ERROR;
@@ -1111,13 +1111,14 @@ static int mp_property_cache_size(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!mpctx->stream)
+ struct demuxer *demuxer = mpctx->demuxer;
+ if (!demuxer)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_GET:
case M_PROPERTY_PRINT: {
int64_t size = -1;
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_SIZE, &size);
+ demux_stream_control(demuxer, STREAM_CTRL_GET_CACHE_SIZE, &size);
if (size <= 0)
break;
return property_int_kb_size(size / 1024, action, arg);
@@ -1131,7 +1132,7 @@ static int mp_property_cache_size(void *ctx, struct m_property *prop,
return M_PROPERTY_OK;
case M_PROPERTY_SET: {
int64_t size = *(int *)arg * 1024LL;
- int r = stream_control(mpctx->stream, STREAM_CTRL_SET_CACHE_SIZE, &size);
+ int r = demux_stream_control(demuxer, STREAM_CTRL_SET_CACHE_SIZE, &size);
if (r == STREAM_UNSUPPORTED)
break;
if (r == STREAM_OK)
@@ -1146,11 +1147,11 @@ static int mp_property_cache_used(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!mpctx->stream)
+ if (!mpctx->demuxer)
return M_PROPERTY_UNAVAILABLE;
int64_t size = -1;
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_FILL, &size);
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &size);
if (size < 0)
return M_PROPERTY_UNAVAILABLE;
return property_int_kb_size(size / 1024, action, arg);
@@ -1160,16 +1161,16 @@ static int mp_property_cache_free(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!mpctx->stream)
+ if (!mpctx->demuxer)
return M_PROPERTY_UNAVAILABLE;
int64_t size_used = -1;
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_FILL, &size_used);
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &size_used);
if (size_used < 0)
return M_PROPERTY_UNAVAILABLE;
int64_t size = -1;
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_SIZE, &size);
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_SIZE, &size);
if (size <= 0)
return M_PROPERTY_UNAVAILABLE;
@@ -2308,22 +2309,11 @@ static int mp_property_sub_pos(void *ctx, struct m_property *prop,
return property_osd_helper(mpctx, prop, action, arg);
}
-static int demux_stream_control(struct MPContext *mpctx, int ctrl, void *arg)
-{
- int r = STREAM_UNSUPPORTED;
- if (mpctx->stream)
- r = stream_control(mpctx->stream, ctrl, arg);
- if (r == STREAM_UNSUPPORTED && mpctx->demuxer) {
- struct demux_ctrl_stream_ctrl c = {ctrl, arg, STREAM_UNSUPPORTED};
- demux_control(mpctx->demuxer, DEMUXER_CTRL_STREAM_CTRL, &c);
- r = c.res;
- }
- return r;
-}
-
static int prop_stream_ctrl(struct MPContext *mpctx, int ctrl, void *arg)
{
- int r = demux_stream_control(mpctx, ctrl, arg);
+ if (!mpctx->demuxer)
+ return M_PROPERTY_UNAVAILABLE;
+ int r = demux_stream_control(mpctx->demuxer, ctrl, arg);
switch (r) {
case STREAM_OK: return M_PROPERTY_OK;
case STREAM_UNSUPPORTED: return M_PROPERTY_UNAVAILABLE;
@@ -3703,7 +3693,8 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
break;
case MP_CMD_TV_LAST_CHANNEL: {
- demux_stream_control(mpctx, STREAM_CTRL_TV_LAST_CHAN, NULL);
+ if (mpctx->demuxer)
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_TV_LAST_CHAN, NULL);
break;
}
diff --git a/player/core.h b/player/core.h
index 84b6123c1c..039f5c26cb 100644
--- a/player/core.h
+++ b/player/core.h
@@ -292,7 +292,6 @@ typedef struct MPContext {
double audio_delay;
double last_heartbeat;
- double last_metadata_update;
double last_idle_tick;
double mouse_timer;
@@ -401,6 +400,7 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
bool force);
void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e);
void mp_play_files(struct MPContext *mpctx);
+void update_demuxer_properties(struct MPContext *mpctx);
// main.c
int mpv_main(int argc, char *argv[]);
diff --git a/player/discnav.c b/player/discnav.c
index 0b52fed479..2c24fc9a42 100644
--- a/player/discnav.c
+++ b/player/discnav.c
@@ -26,6 +26,7 @@
#include "common/common.h"
#include "input/input.h"
+#include "demux/demux.h"
#include "stream/discnav.h"
#include "sub/dec_sub.h"
@@ -90,6 +91,18 @@ int mp_nav_in_menu(struct MPContext *mpctx)
return mpctx->nav_state ? mpctx->nav_state->nav_menu : -1;
}
+// If a demuxer is accessing the stream, we have to use demux_stream_control()
+// to avoid synchronization issues; otherwise access it directly.
+static int run_stream_control(struct MPContext *mpctx, int cmd, void *arg)
+{
+ if (mpctx->demuxer) {
+ return demux_stream_control(mpctx->demuxer, cmd, arg);
+ } else if (mpctx->stream) {
+ return stream_control(mpctx->stream, cmd, arg);
+ }
+ return STREAM_ERROR;
+}
+
// Allocate state and enable navigation features. Must happen before
// initializing cache, because the cache would read data. Since stream_dvdnav is
// in a mode which skips all transitions on reading data (before enabling
@@ -103,7 +116,7 @@ void mp_nav_init(struct MPContext *mpctx)
return;
struct mp_nav_cmd inp = {MP_NAV_CMD_ENABLE};
- if (stream_control(mpctx->stream, STREAM_CTRL_NAV_CMD, &inp) < 1)
+ if (run_stream_control(mpctx, STREAM_CTRL_NAV_CMD, &inp) < 1)
return;
mpctx->nav_state = talloc_zero(NULL, struct mp_nav_state);
@@ -125,14 +138,14 @@ void mp_nav_reset(struct MPContext *mpctx)
if (!nav)
return;
struct mp_nav_cmd inp = {MP_NAV_CMD_RESUME};
- stream_control(mpctx->stream, STREAM_CTRL_NAV_CMD, &inp);
+ run_stream_control(mpctx, STREAM_CTRL_NAV_CMD, &inp);
osd_set_nav_highlight(mpctx->osd, NULL);
nav->hi_visible = 0;
nav->nav_menu = false;
nav->nav_draining = false;
nav->nav_still_frame = 0;
mp_input_disable_section(mpctx->input, "discnav-menu");
- stream_control(mpctx->stream, STREAM_CTRL_RESUME_CACHE, NULL);
+ run_stream_control(mpctx, STREAM_CTRL_RESUME_CACHE, NULL);
update_state(mpctx);
}
@@ -164,11 +177,11 @@ void mp_nav_user_input(struct MPContext *mpctx, char *command)
osd_coords_to_video(mpctx->osd, vid.w, vid.h, &x, &y);
inp.u.mouse_pos.x = x;
inp.u.mouse_pos.y = y;
- stream_control(mpctx->stream, STREAM_CTRL_NAV_CMD, &inp);
+ run_stream_control(mpctx, STREAM_CTRL_NAV_CMD, &inp);
} else {
struct mp_nav_cmd inp = {MP_NAV_CMD_MENU};
inp.u.menu.action = command;
- stream_control(mpctx->stream, STREAM_CTRL_NAV_CMD, &inp);
+ run_stream_control(mpctx, STREAM_CTRL_NAV_CMD, &inp);
}
}
@@ -179,7 +192,7 @@ void mp_handle_nav(struct MPContext *mpctx)
return;
while (1) {
struct mp_nav_event *ev = NULL;
- stream_control(mpctx->stream, STREAM_CTRL_GET_NAV_EVENT, &ev);
+ run_stream_control(mpctx, STREAM_CTRL_GET_NAV_EVENT, &ev);
if (!ev)
break;
switch (ev->event) {
@@ -261,15 +274,15 @@ void mp_handle_nav(struct MPContext *mpctx)
nav->nav_still_frame = -2;
} else if (nav->nav_still_frame == -2) {
struct mp_nav_cmd inp = {MP_NAV_CMD_SKIP_STILL};
- stream_control(mpctx->stream, STREAM_CTRL_NAV_CMD, &inp);
+ run_stream_control(mpctx, STREAM_CTRL_NAV_CMD, &inp);
}
}
if (nav->nav_draining && mpctx->stop_play == AT_END_OF_FILE) {
MP_VERBOSE(nav, "execute drain\n");
struct mp_nav_cmd inp = {MP_NAV_CMD_DRAIN_OK};
- stream_control(mpctx->stream, STREAM_CTRL_NAV_CMD, &inp);
+ run_stream_control(mpctx, STREAM_CTRL_NAV_CMD, &inp);
nav->nav_draining = false;
- stream_control(mpctx->stream, STREAM_CTRL_RESUME_CACHE, NULL);
+ run_stream_control(mpctx, STREAM_CTRL_RESUME_CACHE, NULL);
}
// E.g. keep displaying still frames
if (mpctx->stop_play == AT_END_OF_FILE && !nav->nav_eof)
diff --git a/player/loadfile.c b/player/loadfile.c
index e2a1e6e145..e1ffa5d783 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -221,10 +221,15 @@ static void print_stream(struct MPContext *mpctx, struct track *t)
MP_INFO(mpctx, "%s\n", b);
}
-static void print_file_properties(struct MPContext *mpctx)
+void update_demuxer_properties(struct MPContext *mpctx)
{
struct demuxer *demuxer = mpctx->master_demuxer;
- if (demuxer->num_editions > 1) {
+ if (!demuxer)
+ return;
+ demux_update(demuxer);
+ int events = demuxer->events;
+ demuxer->events = 0;
+ if ((events & DEMUX_EVENT_INIT) && demuxer->num_editions > 1) {
for (int n = 0; n < demuxer->num_editions; n++) {
struct demux_edition *edition = &demuxer->editions[n];
char b[128] = {0};
@@ -238,10 +243,20 @@ static void print_file_properties(struct MPContext *mpctx)
MP_INFO(mpctx, "%s\n", b);
}
}
- for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
- for (int n = 0; n < mpctx->num_tracks; n++)
- if (mpctx->tracks[n]->type == t)
- print_stream(mpctx, mpctx->tracks[n]);
+ if (events & DEMUX_EVENT_STREAMS) {
+ add_demuxer_tracks(mpctx, demuxer);
+ for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
+ for (int n = 0; n < mpctx->num_tracks; n++)
+ if (mpctx->tracks[n]->type == t)
+ print_stream(mpctx, mpctx->tracks[n]);
+ }
+ }
+ struct mp_tags *info = demuxer->metadata;
+ if ((events & DEMUX_EVENT_METADATA) && info->num_keys) {
+ MP_INFO(mpctx, "File tags:\n");
+ for (int n = 0; n < info->num_keys; n++)
+ MP_INFO(mpctx, " %s: %s\n", info->keys[n], info->values[n]);
+ mp_notify(mpctx, MPV_EVENT_METADATA_UPDATE, NULL);
}
}
@@ -311,6 +326,11 @@ bool timeline_set_part(struct MPContext *mpctx, int i, bool force)
uninit_player(mpctx, INITIALIZED_VCODEC | (mpctx->opts->fixed_vo ? 0 : INITIALIZED_VO) | (mpctx->opts->gapless_audio ? 0 : INITIALIZED_AO) | INITIALIZED_ACODEC | INITIALIZED_SUB | INITIALIZED_SUB2);
mpctx->stop_play = orig_stop_play;
+ if (mpctx->demuxer) {
+ demux_stop_thread(mpctx->demuxer);
+ demux_flush(mpctx->demuxer);
+ }
+
mpctx->demuxer = n->source;
mpctx->stream = mpctx->demuxer->stream;
@@ -333,6 +353,9 @@ bool timeline_set_part(struct MPContext *mpctx, int i, bool force)
}
reselect_demux_streams(mpctx);
+ if (mpctx->demuxer && mpctx->opts->demuxer_thread)
+ demux_start_thread(mpctx->demuxer);
+
return true;
}
@@ -364,6 +387,7 @@ static int find_new_tid(struct MPContext *mpctx, enum stream_type t)
}
static struct track *add_stream_track(struct MPContext *mpctx,
+ struct demuxer *demuxer,
struct sh_stream *stream,
bool under_timeline)
{
@@ -383,7 +407,7 @@ static struct track *add_stream_track(struct MPContext *mpctx,
.attached_picture = stream->attached_picture != NULL,
.lang = stream->lang,
.under_timeline = under_timeline,
- .demuxer = stream->demuxer,
+ .demuxer = demuxer,
.stream = stream,
};
MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
@@ -398,7 +422,7 @@ static struct track *add_stream_track(struct MPContext *mpctx,
void add_demuxer_tracks(struct MPContext *mpctx, struct demuxer *demuxer)
{
for (int n = 0; n < demuxer->num_streams; n++)
- add_stream_track(mpctx, demuxer->streams[n], !!mpctx->timeline);
+ add_stream_track(mpctx, demuxer, demuxer->streams[n], !!mpctx->timeline);
}
// Result numerically higher => better match. 0 == no match.
@@ -651,9 +675,11 @@ static void open_subtitles_from_options(struct MPContext *mpctx)
void *tmp = talloc_new(NULL);
char *base_filename = mpctx->filename;
char *stream_filename = NULL;
- if (stream_control(mpctx->stream, STREAM_CTRL_GET_BASE_FILENAME,
- &stream_filename) > 0)
- base_filename = talloc_steal(tmp, stream_filename);
+ if (mpctx->demuxer) {
+ if (demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_BASE_FILENAME,
+ &stream_filename) > 0)
+ base_filename = talloc_steal(tmp, stream_filename);
+ }
struct subfn *list = find_text_subtitles(mpctx->global, base_filename);
talloc_steal(tmp, list);
for (int i = 0; list && list[i].fname; i++) {
@@ -703,7 +729,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
for (int n = 0; n < demuxer->num_streams; n++) {
struct sh_stream *sh = demuxer->streams[n];
if (sh->type == filter) {
- struct track *t = add_stream_track(mpctx, sh, false);
+ struct track *t = add_stream_track(mpctx, demuxer, sh, false);
t->is_external = true;
t->title = talloc_strdup(t, disp_filename);
t->external_filename = talloc_strdup(t, filename);
@@ -1160,6 +1186,11 @@ goto_reopen_demuxer: ;
}
reselect_demux_streams(mpctx);
+ update_demuxer_properties(mpctx);
+
+ if (mpctx->demuxer && opts->demuxer_thread)
+ demux_start_thread(mpctx->demuxer);
+
if (mpctx->current_track[0][STREAM_VIDEO] &&
mpctx->current_track[0][STREAM_VIDEO]->attached_picture)
{
@@ -1167,9 +1198,6 @@ goto_reopen_demuxer: ;
"Displaying attached picture. Use --no-audio-display to prevent this.\n");
}
- demux_info_update(mpctx->master_demuxer);
- print_file_properties(mpctx);
-
#if HAVE_ENCODING
if (mpctx->encode_lavc_ctx && mpctx->current_track[0][STREAM_VIDEO])
encode_lavc_expect_stream(mpctx->encode_lavc_ctx, AVMEDIA_TYPE_VIDEO);
@@ -1189,11 +1217,11 @@ goto_reopen_demuxer: ;
//==================== START PLAYING =======================
if (!mpctx->d_video && !mpctx->d_audio) {
- struct stream *s = mpctx->stream;
+ struct demuxer *d = mpctx->demuxer;
MP_FATAL(mpctx, "No video or audio streams selected.\n");
- if (s->uncached_type == STREAMTYPE_DVB) {
+ if (d->stream->uncached_type == STREAMTYPE_DVB) {
int dir = mpctx->last_dvb_step;
- if (stream_control(s, STREAM_CTRL_DVB_STEP_CHANNEL, &dir) > 0)
+ if (demux_stream_control(d, STREAM_CTRL_DVB_STEP_CHANNEL, &dir) > 0)
mpctx->stop_play = PT_RELOAD_DEMUXER;
}
goto terminate_playback;
diff --git a/player/misc.c b/player/misc.c
index abaf5b208a..e39175a158 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -121,11 +121,11 @@ double get_start_time(struct MPContext *mpctx)
float mp_get_cache_percent(struct MPContext *mpctx)
{
- if (mpctx->stream) {
+ if (mpctx->demuxer) {
int64_t size = -1;
int64_t fill = -1;
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_SIZE, &size);
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_FILL, &fill);
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_SIZE, &size);
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &fill);
if (size > 0 && fill >= 0)
return fill / (size / 100.0);
}
@@ -135,8 +135,8 @@ float mp_get_cache_percent(struct MPContext *mpctx)
bool mp_get_cache_idle(struct MPContext *mpctx)
{
int idle = 0;
- if (mpctx->stream)
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_IDLE, &idle);
+ if (mpctx->demuxer)
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle);
return idle;
}
diff --git a/player/playloop.c b/player/playloop.c
index 7e9b63995b..9ce4c39ed3 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -448,10 +448,9 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range)
if (len > 0 && !demuxer->ts_resets_possible) {
ans = MPCLAMP((pos - start) / len, 0, 1);
} else {
- struct stream *s = demuxer->stream;
int64_t size;
- if (stream_control(s, STREAM_CTRL_GET_SIZE, &size) > 0 && size > 0) {
- if (demuxer->filepos >= 0)
+ if (demux_stream_control(demuxer, STREAM_CTRL_GET_SIZE, &size) > 0) {
+ if (size > 0 && demuxer->filepos >= 0)
ans = MPCLAMP(demuxer->filepos / (double)size, 0, 1);
}
}
@@ -613,22 +612,13 @@ static bool handle_osd_redraw(struct MPContext *mpctx)
return true;
}
-static void handle_metadata_update(struct MPContext *mpctx)
-{
- if (mp_time_sec() > mpctx->last_metadata_update + 2) {
- if (demux_info_update(mpctx->demuxer))
- mp_notify(mpctx, MPV_EVENT_METADATA_UPDATE, NULL);
- mpctx->last_metadata_update = mp_time_sec();
- }
-}
-
static void handle_pause_on_low_cache(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
- if (!mpctx->stream)
+ if (!mpctx->demuxer)
return;
int64_t fill = -1;
- stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_FILL, &fill);
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &fill);
int cache_kb = fill > 0 ? (fill + 1023) / 1024 : -1;
bool idle = mp_get_cache_idle(mpctx);
if (mpctx->paused && mpctx->paused_for_cache) {
@@ -927,9 +917,7 @@ void run_playloop(struct MPContext *mpctx)
}
#endif
- // Add tracks that were added by the demuxer later (e.g. MPEG)
- if (!mpctx->timeline && mpctx->demuxer)
- add_demuxer_tracks(mpctx, mpctx->demuxer);
+ update_demuxer_properties(mpctx);
if (mpctx->timeline) {
double end = mpctx->timeline[mpctx->timeline_part + 1].start;
@@ -1271,8 +1259,6 @@ void run_playloop(struct MPContext *mpctx)
}
}
- handle_metadata_update(mpctx);
-
handle_pause_on_low_cache(mpctx);
handle_input_and_seek_coalesce(mpctx);