From 5c7ecad93a771d71a773cace996afd706bbef3d2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 7 Sep 2018 22:26:48 +0200 Subject: demux: simplify API for returning cache status Instead of going through those weird DEMUXER_CTRLs, query this information directly. I'm not sure which kind of brain damage made me use CTRLs for these. Since there are no other DEMUXER_CTRLs that make sense for the frontend, remove the remaining infrastructure for them too. --- player/command.c | 28 +++++++++++----------------- player/osd.c | 4 ++-- player/playloop.c | 4 ++-- 3 files changed, 15 insertions(+), 21 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index 3621fae90c..71238e4ae1 100644 --- a/player/command.c +++ b/player/command.c @@ -1423,9 +1423,8 @@ static int mp_property_cache_speed(void *ctx, struct m_property *prop, if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; - struct demux_ctrl_reader_state s; - if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1) - return M_PROPERTY_UNAVAILABLE; + struct demux_reader_state s; + demux_get_reader_state(mpctx->demuxer, &s); uint64_t val = s.bytes_per_second; @@ -1443,9 +1442,8 @@ static int mp_property_demuxer_cache_duration(void *ctx, struct m_property *prop if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; - struct demux_ctrl_reader_state s; - if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1) - return M_PROPERTY_UNAVAILABLE; + struct demux_reader_state s; + demux_get_reader_state(mpctx->demuxer, &s); if (s.ts_duration < 0) return M_PROPERTY_UNAVAILABLE; @@ -1460,9 +1458,8 @@ static int mp_property_demuxer_cache_time(void *ctx, struct m_property *prop, if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; - struct demux_ctrl_reader_state s; - if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1) - return M_PROPERTY_UNAVAILABLE; + struct demux_reader_state s; + demux_get_reader_state(mpctx->demuxer, &s); if (s.ts_end == MP_NOPTS_VALUE) return M_PROPERTY_UNAVAILABLE; @@ -1477,9 +1474,8 @@ static int mp_property_demuxer_cache_idle(void *ctx, struct m_property *prop, if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; - struct demux_ctrl_reader_state s; - if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1) - return M_PROPERTY_UNAVAILABLE; + struct demux_reader_state s; + demux_get_reader_state(mpctx->demuxer, &s); return m_property_flag_ro(action, arg, s.idle); } @@ -1498,9 +1494,8 @@ static int mp_property_demuxer_cache_state(void *ctx, struct m_property *prop, if (action != M_PROPERTY_GET) return M_PROPERTY_NOT_IMPLEMENTED; - struct demux_ctrl_reader_state s; - if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1) - return M_PROPERTY_UNAVAILABLE; + struct demux_reader_state s; + demux_get_reader_state(mpctx->demuxer, &s); struct mpv_node *r = (struct mpv_node *)arg; node_init(r, MPV_FORMAT_NODE_MAP, NULL); @@ -3035,8 +3030,7 @@ static int mp_property_packet_bitrate(void *ctx, struct m_property *prop, return M_PROPERTY_UNAVAILABLE; double r[STREAM_TYPE_COUNT]; - if (demux_control(demuxer, DEMUXER_CTRL_GET_BITRATE_STATS, &r) < 1) - return M_PROPERTY_UNAVAILABLE; + demux_get_bitrate_stats(demuxer, r); if (r[type] < 0) return M_PROPERTY_UNAVAILABLE; diff --git a/player/osd.c b/player/osd.c index 7d24c01619..00bef58e6b 100644 --- a/player/osd.c +++ b/player/osd.c @@ -232,8 +232,8 @@ static char *get_term_status_msg(struct MPContext *mpctx) if (mpctx->demuxer && demux_is_network_cached(mpctx->demuxer)) { saddf(&line, " Cache: "); - struct demux_ctrl_reader_state s = {.ts_duration = -1}; - demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s); + struct demux_reader_state s; + demux_get_reader_state(mpctx->demuxer, &s); if (s.ts_duration < 0) { saddf(&line, "???"); diff --git a/player/playloop.c b/player/playloop.c index 0326e32779..22a9331055 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -625,8 +625,8 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx) double now = mp_time_sec(); - struct demux_ctrl_reader_state s = {.idle = true, .ts_duration = -1}; - demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s); + struct demux_reader_state s; + demux_get_reader_state(mpctx->demuxer, &s); int cache_buffer = 100; bool use_pause_on_low_cache = demux_is_network_cached(mpctx->demuxer) && -- cgit v1.2.3