mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
API CHANGE: Move pUserData from device_init() to device_config_init().
This change makes it consistent with mal_pcm_converter, mal_src, etc.
This commit is contained in:
@@ -91,9 +91,9 @@ int main(int argc, char** argv)
|
||||
mal_backend_pulseaudio,
|
||||
mal_backend_alsa,
|
||||
mal_backend_jack,
|
||||
mal_backend_aaudio
|
||||
mal_backend_opensl,
|
||||
mal_backend_openal,
|
||||
mal_backend_sdl,
|
||||
mal_backend_webaudio,
|
||||
mal_backend_null // Lowest priority.
|
||||
};
|
||||
|
||||
@@ -134,7 +134,7 @@ int main(int argc, char** argv)
|
||||
// initialize a config object called mal_device_config_init(). There are an additional two helper APIs to make
|
||||
// it easy for you to initialize playback or capture configs specifically: mal_device_config_init_playback()
|
||||
// and mal_device_config_init_capture().
|
||||
mal_device_config deviceConfig = mal_device_config_init(mal_format_s16, 2, 48000, NULL, on_send_frames_to_device);
|
||||
mal_device_config deviceConfig = mal_device_config_init(mal_format_s16, 2, 48000, NULL, on_send_frames_to_device, NULL);
|
||||
|
||||
// Applications can specify a callback for when a device is stopped.
|
||||
deviceConfig.onStopCallback = on_device_stop;
|
||||
@@ -174,7 +174,7 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
mal_device playbackDevice;
|
||||
if (mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, NULL, &playbackDevice) != MAL_SUCCESS) {
|
||||
if (mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, &playbackDevice) != MAL_SUCCESS) {
|
||||
printf("Failed to initialize playback device.\n");
|
||||
mal_context_uninit(&context);
|
||||
return -7;
|
||||
|
||||
@@ -53,11 +53,11 @@ int main()
|
||||
return -1;
|
||||
}
|
||||
|
||||
mal_device_config config = mal_device_config_init(mal_format_s16, 2, 48000, on_recv_frames, on_send_frames);
|
||||
mal_device_config config = mal_device_config_init(mal_format_s16, 2, 48000, on_recv_frames, on_send_frames, NULL);
|
||||
|
||||
printf("Recording...\n");
|
||||
mal_device captureDevice;
|
||||
if (mal_device_init(&context, mal_device_type_capture, NULL, &config, NULL, &captureDevice) != MAL_SUCCESS) {
|
||||
if (mal_device_init(&context, mal_device_type_capture, NULL, &config, &captureDevice) != MAL_SUCCESS) {
|
||||
mal_context_uninit(&context);
|
||||
printf("Failed to initialize capture device.\n");
|
||||
return -2;
|
||||
@@ -79,7 +79,7 @@ int main()
|
||||
|
||||
printf("Playing...\n");
|
||||
mal_device playbackDevice;
|
||||
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, NULL, &playbackDevice) != MAL_SUCCESS) {
|
||||
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, &playbackDevice) != MAL_SUCCESS) {
|
||||
mal_context_uninit(&context);
|
||||
printf("Failed to initialize playback device.\n");
|
||||
return -4;
|
||||
|
||||
@@ -38,10 +38,11 @@ int main(int argc, char** argv)
|
||||
decoder.outputFormat,
|
||||
decoder.outputChannels,
|
||||
decoder.outputSampleRate,
|
||||
on_send_frames_to_device);
|
||||
on_send_frames_to_device,
|
||||
&decoder);
|
||||
|
||||
mal_device device;
|
||||
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &decoder, &device) != MAL_SUCCESS) {
|
||||
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device) != MAL_SUCCESS) {
|
||||
printf("Failed to open playback device.\n");
|
||||
mal_decoder_uninit(&decoder);
|
||||
return -3;
|
||||
|
||||
@@ -34,9 +34,9 @@ int main(int argc, char** argv)
|
||||
mal_sine_wave sineWave;
|
||||
mal_sine_wave_init(0.2, 400, DEVICE_SAMPLE_RATE, &sineWave);
|
||||
|
||||
mal_device_config config = mal_device_config_init_playback(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, on_send_frames_to_device);
|
||||
mal_device_config config = mal_device_config_init_playback(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, on_send_frames_to_device, &sineWave);
|
||||
mal_device device;
|
||||
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &sineWave, &device) != MAL_SUCCESS) {
|
||||
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device) != MAL_SUCCESS) {
|
||||
printf("Failed to open playback device.\n");
|
||||
return -4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user