mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
player: cosmetics: async/non-blocking -> reentrant
These functions do blocking work on a separate thread, but wait until they return. So they are not async or non-blocking. But they do react to user-input and client API accesses, which makes them reentrant.
This commit is contained in:
parent
3c9344a1a9
commit
2c305d5b29
@ -415,7 +415,7 @@ bool mp_get_cache_idle(struct MPContext *mpctx);
|
|||||||
void update_window_title(struct MPContext *mpctx, bool force);
|
void update_window_title(struct MPContext *mpctx, bool force);
|
||||||
void error_on_track(struct MPContext *mpctx, struct track *track);
|
void error_on_track(struct MPContext *mpctx, struct track *track);
|
||||||
void stream_dump(struct MPContext *mpctx);
|
void stream_dump(struct MPContext *mpctx);
|
||||||
int mpctx_run_non_blocking(struct MPContext *mpctx, void (*thread_fn)(void *arg),
|
int mpctx_run_reentrant(struct MPContext *mpctx, void (*thread_fn)(void *arg),
|
||||||
void *thread_arg);
|
void *thread_arg);
|
||||||
struct mpv_global *create_sub_global(struct MPContext *mpctx);
|
struct mpv_global *create_sub_global(struct MPContext *mpctx);
|
||||||
|
|
||||||
|
@ -939,7 +939,7 @@ static void open_stream_thread(void *pctx)
|
|||||||
args->cancel, args->global);
|
args->cancel, args->global);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct stream *open_stream_async(struct MPContext *mpctx,
|
static struct stream *open_stream_reentrant(struct MPContext *mpctx,
|
||||||
char *filename, int stream_flags)
|
char *filename, int stream_flags)
|
||||||
{
|
{
|
||||||
struct stream_open_args args = {
|
struct stream_open_args args = {
|
||||||
@ -948,7 +948,7 @@ static struct stream *open_stream_async(struct MPContext *mpctx,
|
|||||||
.filename = filename,
|
.filename = filename,
|
||||||
.stream_flags = stream_flags,
|
.stream_flags = stream_flags,
|
||||||
};
|
};
|
||||||
mpctx_run_non_blocking(mpctx, open_stream_thread, &args);
|
mpctx_run_reentrant(mpctx, open_stream_thread, &args);
|
||||||
if (args.stream) {
|
if (args.stream) {
|
||||||
talloc_steal(args.stream, args.global);
|
talloc_steal(args.stream, args.global);
|
||||||
} else {
|
} else {
|
||||||
@ -971,11 +971,11 @@ static void open_demux_thread(void *pctx)
|
|||||||
args->demux = demux_open(s, global->opts->demuxer_name, NULL, global);
|
args->demux = demux_open(s, global->opts->demuxer_name, NULL, global);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct demuxer *open_demux_async(struct MPContext *mpctx,
|
static struct demuxer *open_demux_reentrant(struct MPContext *mpctx,
|
||||||
struct stream *stream)
|
struct stream *stream)
|
||||||
{
|
{
|
||||||
struct demux_open_args args = {stream, create_sub_global(mpctx)};
|
struct demux_open_args args = {stream, create_sub_global(mpctx)};
|
||||||
mpctx_run_non_blocking(mpctx, open_demux_thread, &args);
|
mpctx_run_reentrant(mpctx, open_demux_thread, &args);
|
||||||
if (args.demux) {
|
if (args.demux) {
|
||||||
talloc_steal(args.demux, args.global);
|
talloc_steal(args.demux, args.global);
|
||||||
} else {
|
} else {
|
||||||
@ -1086,7 +1086,7 @@ static void play_current_file(struct MPContext *mpctx)
|
|||||||
int stream_flags = STREAM_READ;
|
int stream_flags = STREAM_READ;
|
||||||
if (!opts->load_unsafe_playlists)
|
if (!opts->load_unsafe_playlists)
|
||||||
stream_flags |= mpctx->playing->stream_flags;
|
stream_flags |= mpctx->playing->stream_flags;
|
||||||
mpctx->stream = open_stream_async(mpctx, mpctx->stream_open_filename,
|
mpctx->stream = open_stream_reentrant(mpctx, mpctx->stream_open_filename,
|
||||||
stream_flags);
|
stream_flags);
|
||||||
if (!mpctx->stream)
|
if (!mpctx->stream)
|
||||||
goto terminate_playback;
|
goto terminate_playback;
|
||||||
@ -1113,7 +1113,7 @@ goto_reopen_demuxer: ;
|
|||||||
|
|
||||||
mp_nav_reset(mpctx);
|
mp_nav_reset(mpctx);
|
||||||
|
|
||||||
mpctx->demuxer = open_demux_async(mpctx, mpctx->stream);
|
mpctx->demuxer = open_demux_reentrant(mpctx, mpctx->stream);
|
||||||
if (!mpctx->demuxer) {
|
if (!mpctx->demuxer) {
|
||||||
MP_ERR(mpctx, "Failed to recognize file format.\n");
|
MP_ERR(mpctx, "Failed to recognize file format.\n");
|
||||||
mpctx->error_playing = MPV_ERROR_UNKNOWN_FORMAT;
|
mpctx->error_playing = MPV_ERROR_UNKNOWN_FORMAT;
|
||||||
|
@ -283,7 +283,7 @@ static void *thread_wrapper(void *pctx)
|
|||||||
|
|
||||||
// Run the thread_fn in a new thread. Wait until the thread returns, but while
|
// Run the thread_fn in a new thread. Wait until the thread returns, but while
|
||||||
// waiting, process input and input commands.
|
// waiting, process input and input commands.
|
||||||
int mpctx_run_non_blocking(struct MPContext *mpctx, void (*thread_fn)(void *arg),
|
int mpctx_run_reentrant(struct MPContext *mpctx, void (*thread_fn)(void *arg),
|
||||||
void *thread_arg)
|
void *thread_arg)
|
||||||
{
|
{
|
||||||
struct wrapper_args args = {mpctx, thread_fn, thread_arg};
|
struct wrapper_args args = {mpctx, thread_fn, thread_arg};
|
||||||
|
Loading…
Reference in New Issue
Block a user