Add (empty) Android OpenSL ES backend

This commit is contained in:
Michael Maltese 2016-10-28 17:30:24 -07:00
parent fbf7df3b40
commit dfe2ac7f86
8 changed files with 89 additions and 5 deletions

View file

@ -36,6 +36,7 @@ option(ENABLE_PULSEAUDIO "Enable PulseAudio backend" ON)
option(ENABLE_ALSA "Enable ALSA backend" ON)
option(ENABLE_COREAUDIO "Enable CoreAudio backend" ON)
option(ENABLE_WASAPI "Enable WASAPI backend" ON)
option(ENABLE_ANDROID "Enable Android OpenSL ES backend" ON)
find_package(Threads)
if(Threads_FOUND)
@ -138,6 +139,21 @@ else()
set(SOUNDIO_HAVE_WASAPI false)
endif()
if(ENABLE_ANDROID)
find_package(AndroidOpenSLES)
if(ANDROID_OPENSLES_FOUND)
set(STATUS_ANDROID "OK")
set(SOUNDIO_HAVE_ANDROID true)
else()
set(STATUS_ANDROID "not found")
set(SOUNDIO_HAVE_ANDROID false)
set(ANDROID_OPENSLES_LIBRARY "")
endif()
else()
set(STATUS_ANDROID "disabled")
set(SOUNDIO_HAVE_ANDROID false)
set(ANDROID_OPENSLES_LIBRARY "")
endif()
set(LIBSOUNDIO_SOURCES
"${libsoundio_SOURCE_DIR}/src/soundio.c"
@ -179,6 +195,11 @@ if(SOUNDIO_HAVE_WASAPI)
"${libsoundio_SOURCE_DIR}/src/wasapi.c"
)
endif()
if(SOUNDIO_HAVE_ANDROID)
set(LIBSOUNDIO_SOURCES ${LIBSOUNDIO_SOURCES}
"${libsoundio_SOURCE_DIR}/src/android.c"
)
endif()
include_directories(
${libsoundio_SOURCE_DIR}
@ -195,6 +216,7 @@ set(LIBSOUNDIO_LIBS
${COREFOUNDATION_LIBRARY}
${AUDIOUNIT_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${ANDROID_OPENSLES_LIBRARY}
)
if(MSVC)
@ -380,9 +402,10 @@ message(
"System Dependencies\n"
"-------------------\n"
"* threads : ${STATUS_THREADS}\n"
"* JACK (optional) : ${STATUS_JACK}\n"
"* PulseAudio (optional) : ${STATUS_PULSEAUDIO}\n"
"* ALSA (optional) : ${STATUS_ALSA}\n"
"* CoreAudio (optional) : ${STATUS_COREAUDIO}\n"
"* WASAPI (optional) : ${STATUS_WASAPI}\n"
"* JACK (optional) : ${STATUS_JACK}\n"
"* PulseAudio (optional) : ${STATUS_PULSEAUDIO}\n"
"* ALSA (optional) : ${STATUS_ALSA}\n"
"* CoreAudio (optional) : ${STATUS_COREAUDIO}\n"
"* WASAPI (optional) : ${STATUS_WASAPI}\n"
"* Android OpenSL ES (optional) : ${STATUS_ANDROID}\n"
)

View file

@ -0,0 +1,16 @@
# Copyright (c) 2016 libsoundio
# This file is MIT licensed.
# See http://opensource.org/licenses/MIT
# ANDROID_OPENSLES_FOUND
# ANDROID_OPENSLES_INCLUDE_DIR
# ANDROID_OPENSLES_LIBRARY
find_path(ANDROID_OPENSLES_INCLUDE_DIR NAMES SLES/OpenSLES_Android.h)
find_library(ANDROID_OPENSLES_LIBRARY NAMES OpenSLES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ANDROID_OPENSLES DEFAULT_MSG ANDROID_OPENSLES_LIBRARY ANDROID_OPENSLES_INCLUDE_DIR)
mark_as_advanced(ANDROID_OPENSLES_INCLUDE_DIR ANDROID_OPENSLES_LIBRARY)

View file

@ -223,6 +223,7 @@ enum SoundIoBackend {
SoundIoBackendAlsa,
SoundIoBackendCoreAudio,
SoundIoBackendWasapi,
SoundIoBackendAndroid
};
enum SoundIoDeviceAim {

13
src/android.c Normal file
View file

@ -0,0 +1,13 @@
/*
* Copyright (c) 2016 libsoundio
*
* This file is part of libsoundio, which is MIT licensed.
* See http://opensource.org/licenses/MIT
*/
#include "android.h"
#include "soundio_private.h"
enum SoundIoError soundio_android_init(struct SoundIoPrivate *si) {
return SoundIoErrorInitAudioBackend;
}

16
src/android.h Normal file
View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2016 libsoundio
*
* This file is part of libsoundio, which is MIT licensed.
* See http://opensource.org/licenses/MIT
*/
#ifndef SOUNDIO_ANDROID_H
#define SOUNDIO_ANDROID_H
#include "soundio_internal.h"
struct SoundIoPrivate;
enum SoundIoError soundio_android_init(struct SoundIoPrivate *si);
#endif

View file

@ -18,5 +18,6 @@
#cmakedefine SOUNDIO_HAVE_ALSA
#cmakedefine SOUNDIO_HAVE_COREAUDIO
#cmakedefine SOUNDIO_HAVE_WASAPI
#cmakedefine SOUNDIO_HAVE_ANDROID
#endif

View file

@ -29,6 +29,9 @@ static const enum SoundIoBackend available_backends[] = {
#endif
#ifdef SOUNDIO_HAVE_WASAPI
SoundIoBackendWasapi,
#endif
#ifdef SOUNDIO_HAVE_ANDROID
SoundIoBackendAndroid,
#endif
SoundIoBackendDummy,
};
@ -67,6 +70,12 @@ static backend_init_t backend_init_fns[] = {
NULL,
#endif
#ifdef SOUNDIO_HAVE_ANDROID
soundio_android_init,
#else
NULL,
#endif
&soundio_dummy_init,
};
@ -165,6 +174,7 @@ const char *soundio_backend_name(enum SoundIoBackend backend) {
case SoundIoBackendAlsa: return "ALSA";
case SoundIoBackendCoreAudio: return "CoreAudio";
case SoundIoBackendWasapi: return "WASAPI";
case SoundIoBackendAndroid: return "Android OpenSL ES";
case SoundIoBackendDummy: return "Dummy";
}
return "(invalid backend)";

View file

@ -32,6 +32,10 @@
#include "wasapi.h"
#endif
#ifdef SOUNDIO_HAVE_ANDROID
#include "android.h"
#endif
#include "dummy.h"
union SoundIoBackendData {