Add helper APIs for initializing device configs.

* mal_device_config_init()
 * mal_device_config_init_capture()
 * mal_device_config_init_playback()
This commit is contained in:
David Reid
2017-06-18 21:25:01 +10:00
parent acb5ce1595
commit 0f21153ffe
4 changed files with 166 additions and 73 deletions
+1 -13
View File
@@ -36,19 +36,7 @@ int main(int argc, char** argv)
return -3;
}
// 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_s16;
config.channels = wav.channels;
config.sampleRate = wav.sampleRate;
config.channelMap[0] = MAL_CHANNEL_FRONT_LEFT;
config.channelMap[1] = MAL_CHANNEL_FRONT_RIGHT;
config.bufferSizeInFrames = 0; // Use default.
config.periods = 0; // Use default.
config.onRecvCallback = NULL; // Not used for playback.
config.onSendCallback = on_send_frames_to_device;
config.onStopCallback = NULL;
config.onLogCallback = NULL;
mal_device_config config = mal_device_config_init_playback(mal_format_s16, wav.channels, wav.sampleRate, on_send_frames_to_device);
mal_device device;
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, &wav, &device) != MAL_SUCCESS) {