mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-08-04 17:01:29 +00:00
Android: create and destroy OpenSL ES engine
This commit is contained in:
parent
e75329f585
commit
852403f405
|
@ -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);
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#ifndef SOUNDIO_ANDROID_H
|
||||
#define SOUNDIO_ANDROID_H
|
||||
|
||||
#include <SLES/OpenSLES.h>
|
||||
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue