mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user