From b7ad0968ad3e4fde2112b146c51eea7832b6bd8f Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:06:55 -0400 Subject: dec_sub: don't use recursive mutex 92a9f11a0b4fda60c8880014be5920dcf3e95253 added locking for dec_sub. At that time, because the lock was exposed to the outside world, a recursive mutex was used. However, this is no longer true after e9e883e3b2a64867aae014fb8a1416d0177fe493, when the public locking functions were removed. This means that the lock is now private. Unlike input.c, dec_sub already enforces said call hierarchy, so combined with the aforementioned change, the lock is only ever called once and never recursively. Thus the lock can be converted to a normal mutex. --- sub/dec_sub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sub/dec_sub.c b/sub/dec_sub.c index dab5abc69a..a8746a27ed 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -123,7 +123,7 @@ static void wakeup_demux(void *ctx) mp_dispatch_interrupt(q); } -static void sub_destroy_cached_pkts(struct dec_sub *sub) +static void destroy_cached_pkts(struct dec_sub *sub) { int index = 0; while (index < sub->num_cached_pkts) { @@ -204,7 +204,7 @@ struct dec_sub *sub_create(struct mpv_global *global, struct track *track, }; sub->opts = sub->opts_cache->opts; sub->shared_opts = sub->shared_opts_cache->opts; - mp_mutex_init_type(&sub->lock, MP_MUTEX_RECURSIVE); + mp_mutex_init(&sub->lock); sub->sd = init_decoder(sub); if (sub->sd) { @@ -476,7 +476,7 @@ void sub_reset(struct dec_sub *sub) sub->sd->driver->reset(sub->sd); sub->last_pkt_pts = MP_NOPTS_VALUE; sub->last_vo_pts = MP_NOPTS_VALUE; - sub_destroy_cached_pkts(sub); + destroy_cached_pkts(sub); TA_FREEP(&sub->new_segment); mp_mutex_unlock(&sub->lock); } -- cgit v1.2.3