[vlc-commits] va: simplify using vlc_module_{match,map}
Rémi Denis-Courmont
git at videolan.org
Sat Sep 26 08:44:05 CEST 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Sep 25 22:02:31 2020 +0300| [4decf8c4a4323572cebf6d604083f1bc1b5b2302] | committer: Rémi Denis-Courmont
va: simplify using vlc_module_{match,map}
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4decf8c4a4323572cebf6d604083f1bc1b5b2302
---
modules/codec/avcodec/va.c | 38 +++++++++++++++-----------------------
1 file changed, 15 insertions(+), 23 deletions(-)
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index 855d5a67bf..b9bfe7b101 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -99,22 +99,6 @@ bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt)
}
}
-static int vlc_va_Start(void *func, bool forced, va_list ap)
-{
- vlc_va_t *va = va_arg(ap, vlc_va_t *);
- AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
- enum PixelFormat hwfmt = va_arg(ap, enum PixelFormat);
- const AVPixFmtDescriptor *src_desc = va_arg(ap, const AVPixFmtDescriptor *);
- const es_format_t *fmt_in = va_arg(ap, const es_format_t *);
- vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
- video_format_t *fmt_out = va_arg(ap, video_format_t *);
- vlc_video_context **vtcx_out = va_arg(ap, vlc_video_context **);
- vlc_va_open open = func;
-
- (void) forced;
- return open(va, ctx, hwfmt, src_desc, fmt_in, device, fmt_out, vtcx_out);
-}
-
vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
enum PixelFormat hwfmt, const AVPixFmtDescriptor *src_desc,
const es_format_t *fmt_in, vlc_decoder_device *device,
@@ -124,16 +108,24 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
if (unlikely(va == NULL))
return NULL;
+ module_t **mods;
+ ssize_t total = vlc_module_match("hw decoder", "any", false, &mods, NULL);
- if (vlc_module_load(va, "hw decoder", NULL, true,
- vlc_va_Start, va, avctx, hwfmt, src_desc, fmt_in, device,
- fmt_out, vtcx_out) == NULL)
- {
- vlc_object_delete(va);
- va = NULL;
+ for (ssize_t i = 0; i < total; i++) {
+ vlc_va_open open = vlc_module_map(obj->logger, mods[i]);
+
+ if (open != NULL && open(va, avctx, hwfmt, src_desc, fmt_in, device,
+ fmt_out, vtcx_out) == VLC_SUCCESS) {
+ free(mods);
+ return va;
+ }
}
- return va;
+ if (likely(total >= 0))
+ free(mods);
+
+ vlc_object_delete(va);
+ return NULL;
}
void vlc_va_Delete(vlc_va_t *va)
More information about the vlc-commits
mailing list