mirror of https://github.com/mpv-player/mpv
command: whitelist some blocking accesses for certain demuxers/streams
The properties/commands touched in this commit are all for obscure special inputs (BD/DVD/DVB/TV), and they all block on the demuxer/stream layer. For network streams, this blocking is very unwelcome. They will affect playback and probably introduce pauses and frame drops. The player can even freeze fully, and the logic that tries to make playback abortable even if frozen complicates the player. Since the mentioned accesses are not needed for network streams, but they will block on network streams even though they're going to fail, add a flag that coarsely enables/disables these accesses. Essentially it establishes a whitelist of demuxers/streams which support them. In theory you could to access BD/DVD images over network (or add such support, I don't think it's a thing in mpv). In these cases these controls still can block and could even "freeze" the player completely. Writing to the "program" and "cache-size" properties still can block even for network streams. Just don't use them if you don't want freezes.
This commit is contained in:
parent
b6214b2644
commit
d7ca95c3ea
|
@ -2211,6 +2211,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
|
|||
.access_references = opts->access_references,
|
||||
.events = DEMUX_EVENT_ALL,
|
||||
.duration = -1,
|
||||
.extended_ctrls = stream->extended_ctrls,
|
||||
};
|
||||
demuxer->seekable = stream->seekable;
|
||||
if (demuxer->stream->underlying && !demuxer->stream->underlying->seekable)
|
||||
|
|
|
@ -202,6 +202,7 @@ typedef struct demuxer {
|
|||
bool fully_read;
|
||||
bool is_network; // opened directly from a network stream
|
||||
bool access_references; // allow opening other files/URLs
|
||||
bool extended_ctrls; // supports some of BD/DVD/DVB/TV controls
|
||||
|
||||
// Bitmask of DEMUX_EVENT_*
|
||||
int events;
|
||||
|
|
|
@ -342,6 +342,8 @@ static int d_open(demuxer_t *demuxer, enum demux_check check)
|
|||
if (stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &len) >= 1)
|
||||
demuxer->duration = len;
|
||||
|
||||
demuxer->extended_ctrls = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -181,6 +181,8 @@ no_audio:
|
|||
if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)
|
||||
MP_WARN(tvh, "Unable to set gain control!\n");
|
||||
|
||||
demuxer->extended_ctrls = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -907,7 +907,7 @@ static int mp_property_disc_title(void *ctx, struct m_property *prop,
|
|||
{
|
||||
MPContext *mpctx = ctx;
|
||||
struct demuxer *d = mpctx->demuxer;
|
||||
if (!d)
|
||||
if (!d || !d->extended_ctrls)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
unsigned int title = -1;
|
||||
switch (action) {
|
||||
|
@ -1224,8 +1224,9 @@ static int mp_property_disc_titles(void *ctx, struct m_property *prop,
|
|||
MPContext *mpctx = ctx;
|
||||
struct demuxer *demuxer = mpctx->demuxer;
|
||||
unsigned int num_titles;
|
||||
if (!demuxer || demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_TITLES,
|
||||
&num_titles) < 1)
|
||||
if (!demuxer || !demuxer->extended_ctrls ||
|
||||
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);
|
||||
}
|
||||
|
@ -1255,8 +1256,9 @@ static int mp_property_list_disc_titles(void *ctx, struct m_property *prop,
|
|||
MPContext *mpctx = ctx;
|
||||
struct demuxer *demuxer = mpctx->demuxer;
|
||||
unsigned int num_titles;
|
||||
if (!demuxer || demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_TITLES,
|
||||
&num_titles) < 1)
|
||||
if (!demuxer || !demuxer->extended_ctrls ||
|
||||
demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_TITLES,
|
||||
&num_titles) < 1)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
return m_property_read_list(action, arg, num_titles,
|
||||
get_disc_title_entry, mpctx);
|
||||
|
@ -1291,7 +1293,7 @@ static int mp_property_angle(void *ctx, struct m_property *prop,
|
|||
{
|
||||
MPContext *mpctx = ctx;
|
||||
struct demuxer *demuxer = mpctx->demuxer;
|
||||
if (!demuxer)
|
||||
if (!demuxer || !demuxer->extended_ctrls)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
int ris, angles = -1, angle = 1;
|
||||
|
@ -3117,7 +3119,7 @@ static int mp_property_cursor_autohide(void *ctx, struct m_property *prop,
|
|||
|
||||
static int prop_stream_ctrl(struct MPContext *mpctx, int ctrl, void *arg)
|
||||
{
|
||||
if (!mpctx->demuxer)
|
||||
if (!mpctx->demuxer || !mpctx->demuxer->extended_ctrls)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
int r = demux_stream_control(mpctx->demuxer, ctrl, arg);
|
||||
switch (r) {
|
||||
|
@ -5506,7 +5508,7 @@ static void cmd_tv_last_channel(void *p)
|
|||
struct mp_cmd_ctx *cmd = p;
|
||||
struct MPContext *mpctx = cmd->mpctx;
|
||||
|
||||
if (!mpctx->demuxer) {
|
||||
if (!mpctx->demuxer || !mpctx->demuxer->extended_ctrls) {
|
||||
cmd->success = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ typedef struct stream {
|
|||
bool is_local_file : 1; // from the filesystem
|
||||
bool is_directory : 1; // directory on the filesystem
|
||||
bool access_references : 1; // open other streams
|
||||
bool extended_ctrls : 1; // supports some of BD/DVD/DVB/TV controls
|
||||
struct mp_log *log;
|
||||
struct mpv_global *global;
|
||||
|
||||
|
|
|
@ -1120,6 +1120,7 @@ static int dvb_open(stream_t *stream)
|
|||
stream->allow_caching = true;
|
||||
stream->demuxer = "lavf";
|
||||
stream->lavf_type = "mpegts";
|
||||
stream->extended_ctrls = true;
|
||||
|
||||
return STREAM_OK;
|
||||
|
||||
|
|
Loading…
Reference in New Issue