1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 15:22:09 +00:00

demux: add a "cancel" field

Instead of relying on demuxer->stream->cancel. This is better because
the stream is potentially closed and replaced.
This commit is contained in:
wm4 2018-05-18 15:48:14 +02:00
parent a0cce7f775
commit f9713921a3
5 changed files with 8 additions and 5 deletions

View File

@ -2200,6 +2200,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
*demuxer = (struct demuxer) {
.desc = desc,
.stream = stream,
.cancel = stream->cancel,
.seekable = stream->seekable,
.filepos = -1,
.global = global,
@ -3136,7 +3137,7 @@ int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg)
bool demux_cancel_test(struct demuxer *demuxer)
{
return mp_cancel_test(demuxer->stream->cancel);
return mp_cancel_test(demuxer->cancel);
}
struct demux_chapter *demux_copy_chapter_data(struct demux_chapter *c, int num)

View File

@ -233,6 +233,9 @@ typedef struct demuxer {
struct mp_tags **update_stream_tags;
int num_update_stream_tags;
// Triggered when ending demuxing forcefully. Usually bound to the stream too.
struct mp_cancel *cancel;
// 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.

View File

@ -775,8 +775,7 @@ static void update_metadata(demuxer_t *demuxer)
static int interrupt_cb(void *ctx)
{
struct demuxer *demuxer = ctx;
lavf_priv_t *priv = demuxer->priv;
return mp_cancel_test(priv->stream->cancel);
return mp_cancel_test(demuxer->cancel);
}
static int block_io_open(struct AVFormatContext *s, AVIOContext **pb,

View File

@ -167,7 +167,7 @@ static void reopen_lazy_segments(struct demuxer *demuxer)
.skip_lavf_probing = true,
};
p->current->d = demux_open_url(p->current->url, &params,
demuxer->stream->cancel, demuxer->global);
demuxer->cancel, demuxer->global);
if (!p->current->d && !demux_cancel_test(demuxer))
MP_ERR(demuxer, "failed to load segment\n");
if (p->current->d)

View File

@ -14,7 +14,7 @@ struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log,
*tl = (struct timeline){
.global = global,
.log = log,
.cancel = demuxer->stream->cancel,
.cancel = demuxer->cancel,
.demuxer = demuxer,
.track_layout = demuxer,
};