float mp_get_cache_percent(struct MPContext *mpctx) { if (mpctx->demuxer) { int64_t size = -1; int64_t fill = -1; 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); } return -1; }
bool mp_get_cache_idle(struct MPContext *mpctx) { int idle = 0; if (mpctx->demuxer) demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle); return idle; }
bool mp_get_cache_idle(struct MPContext *mpctx) { struct stream_cache_info info = {0}; if (mpctx->demuxer) demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &info); return info.idle; }
// 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; }
float mp_get_cache_percent(struct MPContext *mpctx) { struct stream_cache_info info = {0}; if (mpctx->demuxer) demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &info); if (info.size > 0 && info.fill >= 0) return info.fill / (info.size / 100.0); return -1; }
static void print_status(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; update_window_title(mpctx, false); update_vo_playback_state(mpctx); if (!opts->use_terminal) return; if (opts->quiet || !mpctx->playback_initialized || !mpctx->playing_msg_shown) { term_osd_set_status(mpctx, ""); return; } if (opts->status_msg) { char *r = mp_property_expand_escaped_string(mpctx, opts->status_msg); term_osd_set_status(mpctx, r); talloc_free(r); return; } char *line = NULL; // Playback status if (is_busy(mpctx)) { saddf(&line, "(...) "); } else if (mpctx->paused_for_cache && !opts->pause) { saddf(&line, "(Buffering) "); } else if (mpctx->paused) { saddf(&line, "(Paused) "); } if (mpctx->d_audio) saddf(&line, "A"); if (mpctx->d_video) saddf(&line, "V"); saddf(&line, ": "); // Playback position sadd_hhmmssff_u(&line, get_playback_time(mpctx), mpctx->opts->osd_fractions); double len = get_time_length(mpctx); if (len >= 0) { saddf(&line, " / "); sadd_hhmmssff(&line, len, mpctx->opts->osd_fractions); } sadd_percentage(&line, get_percent_pos(mpctx)); // other if (opts->playback_speed != 1) saddf(&line, " x%4.2f", opts->playback_speed); // A-V sync if (mpctx->d_audio && mpctx->d_video && mpctx->sync_audio_to_video) { saddf(&line, " A-V:%7.3f", mpctx->last_av_difference); if (fabs(mpctx->total_avsync_change) > 0.05) saddf(&line, " ct:%7.3f", mpctx->total_avsync_change); } #if HAVE_ENCODING double position = get_current_pos_ratio(mpctx, true); char lavcbuf[80]; if (encode_lavc_getstatus(mpctx->encode_lavc_ctx, lavcbuf, sizeof(lavcbuf), position) >= 0) { // encoding stats saddf(&line, " %s", lavcbuf); } else #endif { // VO stats if (mpctx->d_video) { if (mpctx->display_sync_active) { saddf(&line, " DS: %d/%"PRId64, mpctx->mistimed_frames_total, vo_get_delayed_count(mpctx->video_out)); } int64_t c = vo_get_drop_count(mpctx->video_out); if (c > 0 || mpctx->dropped_frames_total > 0) { saddf(&line, " Dropped: %"PRId64, c); if (mpctx->dropped_frames_total) saddf(&line, "/%d", mpctx->dropped_frames_total); } } } if (mpctx->demuxer) { int64_t fill = -1; demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &fill); if (fill >= 0) { saddf(&line, " Cache: "); struct demux_ctrl_reader_state s = {.ts_duration = -1}; demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s); if (s.ts_duration < 0) { saddf(&line, "???"); } else { saddf(&line, "%2ds", (int)s.ts_duration); } if (fill >= 1024 * 1024) { saddf(&line, "+%lldMB", (long long)(fill / 1024 / 1024)); } else { saddf(&line, "+%lldKB", (long long)(fill / 1024)); } } }