Reduce duplication in graphics module handling
The following discussion from !101 (merged) should be addressed:
-
@smcv started a discussion: I think we're getting to the point where it would make sense to have an extra member
SRT_NUM_GRAPHICS_MODULES
at the end of the enum, and an array in this struct:typedef struct { GList *cached; gboolean available; } CachedModules; typedef struct { CachedModules graphics_modules[SRT_NUM_GRAPHICS_MODULES]; } Abi;
and then when we're dealing with all the graphics modules as a group (init, finalize, forget, etc.), use loops:
for (i = 0; i < G_N_ELEMENTS (abi->cached_modules); i++) g_list_free_full (abi->cached_modules[i].cached, g_object_unref);
and when we're just dealing with one flavour of graphics modules, use an index, like:
abi->cached_modules[SRT_GLX_GRAPHICS_MODULE] = _srt_list_glx_icds (self->env, self->helpers_path, multiarch_tuple);
Similarly,
_srt_list_vdpau_drivers()
and friends could become_srt_list_graphics_modules (SrtGraphicsModule, gchar **, const char *, const char *)
.I don't think this is a merge blocker, but I do think it's something we should do as a follow-up.