diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-10-21 04:55:41 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-11-05 17:36:17 +0000 |
commit | 174df99ffa53f1091589eaa4fa0c16cdd55a9326 (patch) | |
tree | 3a60d45615f18beed98a9b08267c28ed7e05dd5f /video/hwdec.c | |
parent | 3a8b107f6216b38a151d5ca1e9d4f2727e3418f5 (diff) | |
download | mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.bz2 mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.xz |
ALL: use new mp_thread abstraction
Diffstat (limited to 'video/hwdec.c')
-rw-r--r-- | video/hwdec.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/video/hwdec.c b/video/hwdec.c index 246117a4f1..f397f3bafb 100644 --- a/video/hwdec.c +++ b/video/hwdec.c @@ -1,14 +1,13 @@ -#include <pthread.h> #include <assert.h> #include <libavutil/hwcontext.h> #include "config.h" - #include "hwdec.h" +#include "osdep/threads.h" struct mp_hwdec_devices { - pthread_mutex_t lock; + mp_mutex lock; struct mp_hwdec_ctx **hwctxs; int num_hwctxs; @@ -21,7 +20,7 @@ struct mp_hwdec_devices { struct mp_hwdec_devices *hwdec_devices_create(void) { struct mp_hwdec_devices *devs = talloc_zero(NULL, struct mp_hwdec_devices); - pthread_mutex_init(&devs->lock, NULL); + mp_mutex_init(&devs->lock); return devs; } @@ -31,7 +30,7 @@ void hwdec_devices_destroy(struct mp_hwdec_devices *devs) return; assert(!devs->num_hwctxs); // must have been hwdec_devices_remove()ed assert(!devs->load_api); // must have been unset - pthread_mutex_destroy(&devs->lock); + mp_mutex_destroy(&devs->lock); talloc_free(devs); } @@ -39,7 +38,7 @@ struct mp_hwdec_ctx *hwdec_devices_get_by_imgfmt(struct mp_hwdec_devices *devs, int hw_imgfmt) { struct mp_hwdec_ctx *res = NULL; - pthread_mutex_lock(&devs->lock); + mp_mutex_lock(&devs->lock); for (int n = 0; n < devs->num_hwctxs; n++) { struct mp_hwdec_ctx *dev = devs->hwctxs[n]; if (dev->hw_imgfmt == hw_imgfmt) { @@ -47,7 +46,7 @@ struct mp_hwdec_ctx *hwdec_devices_get_by_imgfmt(struct mp_hwdec_devices *devs, break; } } - pthread_mutex_unlock(&devs->lock); + mp_mutex_unlock(&devs->lock); return res; } @@ -58,29 +57,29 @@ struct mp_hwdec_ctx *hwdec_devices_get_first(struct mp_hwdec_devices *devs) struct mp_hwdec_ctx *hwdec_devices_get_n(struct mp_hwdec_devices *devs, int n) { - pthread_mutex_lock(&devs->lock); + mp_mutex_lock(&devs->lock); struct mp_hwdec_ctx *res = n < devs->num_hwctxs ? devs->hwctxs[n] : NULL; - pthread_mutex_unlock(&devs->lock); + mp_mutex_unlock(&devs->lock); return res; } void hwdec_devices_add(struct mp_hwdec_devices *devs, struct mp_hwdec_ctx *ctx) { - pthread_mutex_lock(&devs->lock); + mp_mutex_lock(&devs->lock); MP_TARRAY_APPEND(devs, devs->hwctxs, devs->num_hwctxs, ctx); - pthread_mutex_unlock(&devs->lock); + mp_mutex_unlock(&devs->lock); } void hwdec_devices_remove(struct mp_hwdec_devices *devs, struct mp_hwdec_ctx *ctx) { - pthread_mutex_lock(&devs->lock); + mp_mutex_lock(&devs->lock); for (int n = 0; n < devs->num_hwctxs; n++) { if (devs->hwctxs[n] == ctx) { MP_TARRAY_REMOVE_AT(devs->hwctxs, devs->num_hwctxs, n); break; } } - pthread_mutex_unlock(&devs->lock); + mp_mutex_unlock(&devs->lock); } void hwdec_devices_set_loader(struct mp_hwdec_devices *devs, |