Permalink
Browse files

OpenSL backend now works on both OpenSL ES 1.0.1 (android-9) and 1.1

  • Loading branch information...
1 parent a207f76 commit 651f52df1201368524ca0df825f95afeba962fa3 @AerialX committed Sep 18, 2011
Showing with 18 additions and 1 deletion.
  1. +11 −1 Alc/backends/opensl.c
  2. +4 −0 CMakeLists.txt
  3. +3 −0 config.h.in
View
@@ -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;
@@ -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";
}
@@ -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;
View
@@ -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})
View
@@ -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

0 comments on commit 651f52d

Please sign in to comment.