diff --git a/demux/demux.c b/demux/demux.c index 6c4f9542f8..3aade0f200 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1878,6 +1878,7 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds) // This implies this function is actually called from "the" user thread. if (pkt->pos >= ds->in->d_user->filepos) ds->in->d_user->filepos = pkt->pos; + ds->in->d_user->filesize = ds->in->stream_size; pkt->pts = MP_ADD_PTS(pkt->pts, ds->in->ts_offset); pkt->dts = MP_ADD_PTS(pkt->dts, ds->in->ts_offset); @@ -3114,31 +3115,10 @@ static void update_cache(struct demux_internal *in) pthread_mutex_unlock(&in->lock); } -// must be called locked -static int cached_stream_control(struct demux_internal *in, int cmd, void *arg) -{ - switch (cmd) { - case STREAM_CTRL_GET_SIZE: - if (in->stream_size < 0) - return STREAM_UNSUPPORTED; - *(int64_t *)arg = in->stream_size; - return STREAM_OK; - } - return STREAM_ERROR; -} - // must be called locked static int cached_demux_control(struct demux_internal *in, int cmd, void *arg) { switch (cmd) { - case DEMUXER_CTRL_STREAM_CTRL: { - struct demux_ctrl_stream_ctrl *c = arg; - int r = cached_stream_control(in, c->ctrl, c->arg); - if (r == STREAM_ERROR) - break; - c->res = r; - return CONTROL_OK; - } case DEMUXER_CTRL_GET_BITRATE_STATS: { double *rates = arg; for (int n = 0; n < STREAM_TYPE_COUNT; n++) @@ -3217,14 +3197,6 @@ static void thread_demux_control(void *p) pthread_mutex_unlock(&in->lock); - if (cmd == DEMUXER_CTRL_STREAM_CTRL) { - struct demux_ctrl_stream_ctrl *c = arg; - if (in->threading) - MP_VERBOSE(demuxer, "blocking for STREAM_CTRL %d\n", c->ctrl); - c->res = stream_control(demuxer->stream, c->ctrl, c->arg); - if (c->res != STREAM_UNSUPPORTED) - r = CONTROL_OK; - } if (r != CONTROL_OK) { if (in->threading) MP_VERBOSE(demuxer, "blocking for DEMUXER_CTRL %d\n", cmd); @@ -3272,13 +3244,6 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg) return r; } -int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg) -{ - struct demux_ctrl_stream_ctrl c = {ctrl, arg, STREAM_UNSUPPORTED}; - demux_control(demuxer, DEMUXER_CTRL_STREAM_CTRL, &c); - return c.res; -} - bool demux_cancel_test(struct demuxer *demuxer) { return mp_cancel_test(demuxer->cancel); diff --git a/demux/demux.h b/demux/demux.h index b8d5cb5ee0..1bb8e2f7c8 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -32,8 +32,6 @@ enum demux_ctrl { DEMUXER_CTRL_SWITCHED_TRACKS = 1, - DEMUXER_CTRL_IDENTIFY_PROGRAM, - DEMUXER_CTRL_STREAM_CTRL, DEMUXER_CTRL_GET_READER_STATE, DEMUXER_CTRL_GET_BITRATE_STATS, // double[STREAM_TYPE_COUNT] DEMUXER_CTRL_REPLACE_STREAM, @@ -192,6 +190,7 @@ typedef struct demuxer { const demuxer_desc_t *desc; ///< Demuxer description structure const char *filetype; // format name when not identified by demuxer (libavformat) int64_t filepos; // input stream current pos. + int64_t filesize; char *filename; // same as stream->url bool seekable; bool partially_seekable; // true if _maybe_ seekable; implies seekable=true @@ -243,7 +242,6 @@ typedef struct demuxer { // Since the demuxer can run in its own thread, and the stream is not // thread-safe, only the demuxer is allowed to access the stream directly. - // You can freely use demux_stream_control() to send STREAM_CTRLs. // Also note that the stream can get replaced if fully_read is set. struct stream *stream; } demuxer_t; @@ -308,8 +306,6 @@ int demuxer_add_chapter(demuxer_t *demuxer, char *name, void demux_set_stream_tags(struct demuxer *demuxer, struct sh_stream *sh, struct mp_tags *tags); -int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg); - void demux_metadata_changed(demuxer_t *demuxer); void demux_update(demuxer_t *demuxer); diff --git a/player/command.c b/player/command.c index dacdbed3f8..3621fae90c 100644 --- a/player/command.c +++ b/player/command.c @@ -557,9 +557,7 @@ static int mp_property_file_size(void *ctx, struct m_property *prop, if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; - int64_t size; - if (demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_SIZE, &size) < 1) - return M_PROPERTY_UNAVAILABLE; + int64_t size = mpctx->demuxer->filesize; if (action == M_PROPERTY_PRINT) { *(char **)arg = format_file_size(size); diff --git a/player/playloop.c b/player/playloop.c index 85cc9f7faf..0326e32779 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -519,11 +519,9 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range) if (len > 0) ans = MPCLAMP((pos - start) / len, 0, 1); if (ans < 0 || demuxer->ts_resets_possible) { - int64_t size; - 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); - } + int64_t size = demuxer->filesize; + if (size > 0 && demuxer->filepos >= 0) + ans = MPCLAMP(demuxer->filepos / (double)size, 0, 1); } if (use_range) { if (mpctx->opts->play_frames > 0)