API CHANGE: Pass config properties to mal_device_init() via a structure.

Rationale:
1) The number of parameters is just getting too much.
2) It makes it a bit easier to add new configuration properties in the
   future. In particular, there's a chance there will be support added
   for backend-specific properties.
This commit is contained in:
David Reid
2016-10-26 10:40:27 +10:00
parent 2fad235932
commit cba66e9bae
3 changed files with 86 additions and 47 deletions
+8 -1
View File
@@ -31,8 +31,15 @@ int main(int argc, char** argv)
}
// In this example we use the default playback device with a default buffer size and period count.
mal_device_config config;
config.format = mal_format_f32;
config.channels = wav.channels;
config.sampleRate = wav.sampleRate;
config.bufferSizeInFrames = 0; // Use default.
config.periods = 0; // Use default.
mal_device device;
if (mal_device_init(&device, mal_device_type_playback, NULL, mal_format_f32, wav.channels, wav.sampleRate, 0, 0, NULL) != MAL_SUCCESS) {
if (mal_device_init(&device, mal_device_type_playback, NULL, &config, NULL, NULL) != MAL_SUCCESS) {
printf("Failed to open playback device.");
drwav_uninit(&wav);
return -3;