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
+9 -2
View File
@@ -47,9 +47,16 @@ mal_uint32 on_send_frames(mal_device* pDevice, mal_uint32 frameCount, void* pSam
int main()
{
mal_device_config config;
config.format = mal_format_f32;
config.channels = 2;
config.sampleRate = 48000;
config.bufferSizeInFrames = 0; // Use default.
config.periods = 0; // Use default.
printf("Recording...\n");
mal_device captureDevice;
if (mal_device_init(&captureDevice, mal_device_type_capture, NULL, mal_format_f32, 2, 48000, 0, 0, NULL)) {
if (mal_device_init(&captureDevice, mal_device_type_capture, NULL, &config, NULL, NULL)) {
printf("Failed to initialize capture device.\n");
return -2;
}
@@ -64,7 +71,7 @@ int main()
printf("Playing...\n");
mal_device playbackDevice;
if (mal_device_init(&playbackDevice, mal_device_type_playback, NULL, mal_format_f32, 2, 48000, 0, 0, NULL)) {
if (mal_device_init(&playbackDevice, mal_device_type_playback, NULL, &config, NULL, NULL)) {
printf("Failed to initialize playback device.\n");
return -3;
}