Skip to content

Commit

Permalink
OpenSL backend now works on both OpenSL ES 1.0.1 (android-9) and 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AerialX committed Sep 21, 2011
1 parent a207f76 commit 651f52d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Alc/backends/opensl.c
Expand Up @@ -28,7 +28,7 @@


#include <SLES/OpenSLES.h>
#if 1
#ifdef HAVE_ANDROID
#include <SLES/OpenSLES_Android.h>
#else
extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
Expand Down Expand Up @@ -152,9 +152,11 @@ static const char *res_str(SLresult result)
case SL_RESULT_UNKNOWN_ERROR: return "Unknown error";
case SL_RESULT_OPERATION_ABORTED: return "Operation aborted";
case SL_RESULT_CONTROL_LOST: return "Control lost";
#ifdef HAVE_OPENSL_1_1
case SL_RESULT_READONLY: return "ReadOnly";
case SL_RESULT_ENGINEOPTION_UNSUPPORTED: return "Engine option unsupported";
case SL_RESULT_SOURCE_SINK_INCOMPATIBLE: return "Source/Sink incompatible";
#endif
}
return "Unknown error code";
}
Expand Down Expand Up @@ -292,7 +294,15 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device)
format_pcm.bitsPerSample = BytesFromDevFmt(Device->FmtType) * 8;
format_pcm.containerSize = format_pcm.bitsPerSample;
format_pcm.channelMask = GetChannelMask(Device->FmtChans);
#ifdef HAVE_OPENSL_1_1
format_pcm.endianness = SL_BYTEORDER_NATIVE;
#else
#if _BYTE_ORDER == _BIG_ENDIAN
format_pcm.endianness = SL_BYTEORDER_BIGENDIAN;
#else
format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
#endif
#endif

audioSrc.pLocator = &loc_bufq;
audioSrc.pFormat = &format_pcm;
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -612,6 +612,10 @@ IF(OPENSL)
CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
IF(HAVE_LIBOPENSLES)
SET(HAVE_OPENSL 1)
CHECK_SYMBOL_EXISTS(SL_BYTEORDER_NATIVE "SLES/OpenSLES.h" HAVE_OPENSLES_1_1)
IF (HAVE_OPENSLES_1_1)
SET(HAVE_OPENSL_1_1 1)
ENDIF()
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c)
SET(BACKENDS "${BACKENDS} OpenSL,")
SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
Expand Down
3 changes: 3 additions & 0 deletions config.h.in
Expand Up @@ -38,6 +38,9 @@
/* Define if we have the OpenSL backend */
#cmakedefine HAVE_OPENSL

/* Define if we have the OpenSL 1.1 backend */
#cmakedefine HAVE_OPENSL_1_1

/* Define if we have the Android backend */
#cmakedefine HAVE_ANDROID

Expand Down

0 comments on commit 651f52d

Please sign in to comment.