Files
miniaudio/tests/mal_duplex.c
T
David Reid 4980fcf3c5 Reorder parameters in the callback.
This swaps the order of the input and output pointers so that it's
consistent with the order used by memcpy().
2019-01-12 11:04:11 +10:00

47 lines
1.2 KiB
C

#include <stdio.h>
#define MINI_AL_IMPLEMENTATION
#include "../mini_al.h"
void on_stop(mal_device* pDevice)
{
(void)pDevice;
printf("STOPPED\n");
}
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount)
{
/* In our this test the format and channel count is the same for both input and output which means we can just memcpy(). */
mal_copy_memory(pOutput, pInput, frameCount * mal_get_bytes_per_frame(pDevice->format, pDevice->channels));
}
int main(int argc, char** argv)
{
mal_result result;
(void)argc;
(void)argv;
mal_backend backend = mal_backend_wasapi;
mal_device_config config = mal_device_config_init_default(data_callback, NULL);
config.format = mal_format_f32;
config.channels = 2;
config.sampleRate = 44100;
config.onStopCallback = on_stop;
config.bufferSizeInFrames = 16384*4;
mal_device device;
result = mal_device_init_ex(&backend, 1, NULL, mal_device_type_playback, NULL, &config, &device);
if (result != MAL_SUCCESS) {
return result;
}
mal_device_start(&device);
printf("Press Enter to quit...\n");
getchar();
mal_device_uninit(&device);
return 0;
}