mirror of
https://github.com/mpv-player/mpv
synced 2025-03-30 23:38:10 +00:00
player: rename "lock" to "abort_lock"
If a struct as large as MPContext contains a field named "lock", it creates the impression that it is the primary lock for MPContext. This is wrong, the lock just protects a single field.
This commit is contained in:
parent
7f91e2684e
commit
ce1f5e78c2
@ -438,9 +438,9 @@ typedef struct MPContext {
|
||||
|
||||
struct mp_ipc_ctx *ipc_ctx;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
pthread_mutex_t abort_lock;
|
||||
|
||||
// --- The following fields are protected by lock
|
||||
// --- The following fields are protected by abort_lock
|
||||
struct mp_cancel *demuxer_cancel; // cancel handle for MPContext.demuxer
|
||||
|
||||
// --- Owned by MPContext
|
||||
|
@ -66,10 +66,10 @@ void mp_abort_playback_async(struct MPContext *mpctx)
|
||||
{
|
||||
mp_cancel_trigger(mpctx->playback_abort);
|
||||
|
||||
pthread_mutex_lock(&mpctx->lock);
|
||||
pthread_mutex_lock(&mpctx->abort_lock);
|
||||
if (mpctx->demuxer_cancel)
|
||||
mp_cancel_trigger(mpctx->demuxer_cancel);
|
||||
pthread_mutex_unlock(&mpctx->lock);
|
||||
pthread_mutex_unlock(&mpctx->abort_lock);
|
||||
}
|
||||
|
||||
static void uninit_demuxer(struct MPContext *mpctx)
|
||||
@ -96,10 +96,10 @@ static void uninit_demuxer(struct MPContext *mpctx)
|
||||
free_demuxer_and_stream(mpctx->demuxer);
|
||||
mpctx->demuxer = NULL;
|
||||
|
||||
pthread_mutex_lock(&mpctx->lock);
|
||||
pthread_mutex_lock(&mpctx->abort_lock);
|
||||
talloc_free(mpctx->demuxer_cancel);
|
||||
mpctx->demuxer_cancel = NULL;
|
||||
pthread_mutex_unlock(&mpctx->lock);
|
||||
pthread_mutex_unlock(&mpctx->abort_lock);
|
||||
}
|
||||
|
||||
#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
|
||||
@ -936,9 +936,9 @@ static void open_demux_reentrant(struct MPContext *mpctx)
|
||||
start_open(mpctx, url, mpctx->playing->stream_flags);
|
||||
|
||||
// User abort should cancel the opener now.
|
||||
pthread_mutex_lock(&mpctx->lock);
|
||||
pthread_mutex_lock(&mpctx->abort_lock);
|
||||
mpctx->demuxer_cancel = mpctx->open_cancel;
|
||||
pthread_mutex_unlock(&mpctx->lock);
|
||||
pthread_mutex_unlock(&mpctx->abort_lock);
|
||||
|
||||
while (!atomic_load(&mpctx->open_done)) {
|
||||
mp_idle(mpctx);
|
||||
@ -954,9 +954,9 @@ static void open_demux_reentrant(struct MPContext *mpctx)
|
||||
mpctx->open_cancel = NULL;
|
||||
} else {
|
||||
mpctx->error_playing = mpctx->open_res_error;
|
||||
pthread_mutex_lock(&mpctx->lock);
|
||||
pthread_mutex_lock(&mpctx->abort_lock);
|
||||
mpctx->demuxer_cancel = NULL;
|
||||
pthread_mutex_unlock(&mpctx->lock);
|
||||
pthread_mutex_unlock(&mpctx->abort_lock);
|
||||
}
|
||||
|
||||
cancel_open(mpctx); // cleanup
|
||||
|
@ -189,7 +189,7 @@ void mp_destroy(struct MPContext *mpctx)
|
||||
uninit_libav(mpctx->global);
|
||||
|
||||
mp_msg_uninit(mpctx->global);
|
||||
pthread_mutex_destroy(&mpctx->lock);
|
||||
pthread_mutex_destroy(&mpctx->abort_lock);
|
||||
talloc_free(mpctx);
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ struct MPContext *mp_create(void)
|
||||
.thread_pool = mp_thread_pool_create(mpctx, 0, 1, 30),
|
||||
};
|
||||
|
||||
pthread_mutex_init(&mpctx->lock, NULL);
|
||||
pthread_mutex_init(&mpctx->abort_lock, NULL);
|
||||
|
||||
mpctx->global = talloc_zero(mpctx, struct mpv_global);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user