From 5c7bb0dc9882d3e3b45e46582d6f88fbe04bcbdb Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 11 Nov 2017 17:58:40 +1000 Subject: [PATCH] Update the advanced config example with backend selection. --- examples/advanced_config.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/advanced_config.c b/examples/advanced_config.c index 80e8cd40..fc6fb9fa 100644 --- a/examples/advanced_config.c +++ b/examples/advanced_config.c @@ -43,8 +43,22 @@ int main(int argc, char** argv) // Typical installations of ALSA include a null device. The config below will exclude it from enumeration. contextConfig.alsa.excludeNullDevice = MAL_TRUE; + // The prioritization of backends can be controlled by the application. You need only specify the backends + // you care about. If the context cannot be initialized for any of the specified backends mal_context_init() + // will fail. + mal_backend backends[] = { + mal_backend_wasapi, // Higest priority. + mal_backend_dsound, + mal_backend_winmm, + mal_backend_alsa, + mal_backend_oss, + mal_backend_opensl, + mal_backend_openal, + mal_backend_null // Lowest priority. + }; + mal_context context; - if (mal_context_init(NULL, 0, &contextConfig, &context) != MAL_SUCCESS) { + if (mal_context_init(backends, sizeof(backends)/sizeof(backends[0]), &contextConfig, &context) != MAL_SUCCESS) { printf("Failed to initialize context."); return -2; }