From d2763e2401188696b39ba02e8257560d8aebb9bd Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Tue, 16 Jun 2026 18:20:19 +0100
Subject: [PATCH] cmake: Avoid misleading messages when smoke-testing library
`Mix_Init(0)` doesn't attempt to initialize anything, so it's legitimate
for it to return 0, and if it does, the error indicator won't be set,
potentially leaving it with an unrelated (and benign) error message. Use
a somewhat more realistic startup pattern: ask for an audio format that
in practice is usually supported, and see whether it is.
(If SDL_mixer is compiled without Ogg Vorbis support, that isn't an
error, and this test will still succeed.)
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
cmake/test/main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cmake/test/main.c b/cmake/test/main.c
index abc296c1b..4e498518a 100644
--- a/cmake/test/main.c
+++ b/cmake/test/main.c
@@ -9,8 +9,10 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "SDL_Init: could not initialize SDL: %s\n", SDL_GetError());
return 1;
}
- if (Mix_Init(0) == 0) {
- fprintf(stderr, "Mix_Init: no sound/music loaders supported (%s)\n", Mix_GetError());
+ if (Mix_Init(MIX_INIT_OGG) & MIX_INIT_OGG) {
+ fprintf(stderr, "Mix_Init: Ogg Vorbis supported\n");
+ } else {
+ fprintf(stderr, "Mix_Init: Ogg Vorbis not supported (%s)\n", Mix_GetError());
}
Mix_Quit();
SDL_Quit();