diff --git a/src/android.c b/src/android.c index 016627c..bd48519 100644 --- a/src/android.c +++ b/src/android.c @@ -14,6 +14,8 @@ static void destroy_android(struct SoundIoPrivate *si) { if (sia->cond) soundio_os_cond_destroy(sia->cond); + if (sia->engineObject) + (*sia->engineObject)->Destroy(sia->engineObject); } static void flush_events_android(struct SoundIoPrivate *si) { @@ -44,6 +46,21 @@ enum SoundIoError soundio_android_init(struct SoundIoPrivate *si) { struct SoundIo *soundio = &si->pub; struct SoundIoAndroid *sia = &si->backend_data.android; + if (slCreateEngine(&sia->engineObject, 0, NULL, 0, NULL, NULL) != SL_RESULT_SUCCESS) + return SoundIoErrorInitAudioBackend; + + if ((*sia->engineObject)->Realize(sia->engineObject, SL_BOOLEAN_FALSE) != SL_RESULT_SUCCESS) + { + destroy_android(si); + return SoundIoErrorInitAudioBackend; + } + + if ((*sia->engineObject)->GetInterface(sia->engineObject, SL_IID_ENGINE, &sia->engineEngine) != SL_RESULT_SUCCESS) + { + destroy_android(si); + return SoundIoErrorInitAudioBackend; + } + sia->cond = soundio_os_cond_create(); if (!sia->cond) { destroy_android(si); diff --git a/src/android.h b/src/android.h index a71ef9b..d6a2ffc 100644 --- a/src/android.h +++ b/src/android.h @@ -8,6 +8,8 @@ #ifndef SOUNDIO_ANDROID_H #define SOUNDIO_ANDROID_H +#include + #include "os.h" #include "soundio_internal.h" @@ -17,6 +19,9 @@ enum SoundIoError soundio_android_init(struct SoundIoPrivate *si); struct SoundIoAndroid { struct SoundIoOsCond *cond; bool devices_emitted; + + SLObjectItf engineObject; + SLEngineItf engineEngine; }; #endif