-
-
Notifications
You must be signed in to change notification settings - Fork 491
Closed
Description
Hi!
I'm using miniaudio on Android together with the AAudio backend and engines. I used the advanced_engine example as a base and modified it just a little:
ma_result result;
ma_resource_manager_config resourceManagerConfig;
resourceManagerConfig = ma_resource_manager_config_init();
resourceManagerConfig.decodedFormat = ma_format_f32; /* ma_format_f32 should almost always be used as that's what the engine (and most everything else) uses for mixing. */
resourceManagerConfig.decodedChannels = 0; /* Setting the channel count to 0 will cause sounds to use their native channel count. */
resourceManagerConfig.decodedSampleRate = 48000; /* Using a consistent sample rate is useful for avoiding expensive resampling in the audio thread. This will result in resampling being performed by the loading thread(s). */
result = ma_resource_manager_init(&resourceManagerConfig, &resourceManager);
if (result != MA_SUCCESS) {
logMsg("Failed to initialize resource manager.");
return;
}
/* We're going to want a context so we can enumerate our playback devices. */
result = ma_context_init(NULL, 0, NULL, &context);
if (result != MA_SUCCESS) {
logMsg("Failed to initialize context.");
return;
}
ma_device_config deviceConfig;
ma_engine_config engineConfig;
deviceConfig = ma_device_config_init(ma_device_type_playback);
deviceConfig.playback.pDeviceID = NULL;
deviceConfig.playback.format = resourceManager.config.decodedFormat;
deviceConfig.playback.channels = 0;
deviceConfig.capture.format = resourceManager.config.decodedFormat;
deviceConfig.capture.channels = 2;
deviceConfig.capture.pDeviceID = NULL;
deviceConfig.sampleRate = resourceManager.config.decodedSampleRate;
deviceConfig.dataCallback = NativeMultiTrackPlayerTurboModule::playbackCallback;
deviceConfig.pUserData = this;
result = ma_device_init(&context, &deviceConfig, &device);
if (result != MA_SUCCESS) {
logMsg("Failed to initialize device. %d", 1);
return;
}
engineConfig = ma_engine_config_init();
engineConfig.pDevice = &device;
engineConfig.pResourceManager = &resourceManager;
engineConfig.noAutoStart = MA_TRUE; /* Don't start the engine by default - we'll do that manually below. */
result = ma_engine_init(&engineConfig, &engine);
if (result != MA_SUCCESS) {
logMsg("Failed to initialize engine.");
ma_device_uninit(&device);
return;
}
result = ma_engine_start(&engine);
But I always see this log: Failed to initialize device. -1.
Is duplex mode together with engines generally not allowed or does AAudio/the Device (using an android emulator) not support duplex mode? Thanks already in advance for your help!
Metadata
Metadata
Assignees
Labels
No labels