Add support for Android x86_64 and ARM64
This commit is contained in:
parent
671dbaaf77
commit
7604ae6761
|
@ -101,17 +101,21 @@ if [ x$SSL = "xno" ]; then
|
||||||
export OPTIONS="${OPTIONS} --without-ssl"
|
export OPTIONS="${OPTIONS} --without-ssl"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for arch in armv5te armv7-a armv7-a-neon x86
|
for arch in armv5te armv7-a armv7-a-neon arm64 x86 x64
|
||||||
do
|
do
|
||||||
if [ $arch = "x86" ]; then \
|
if [ $arch = "x86" ]; then \
|
||||||
export HOST=i686-linux-android; \
|
export HOST=i686-linux-android; \
|
||||||
|
elif [ $arch = "x64" ]; then \
|
||||||
|
export HOST=x86_64-linux-android; \
|
||||||
|
elif [ $arch = "arm64" ]; then \
|
||||||
|
export HOST=aarch64-linux-android; \
|
||||||
else \
|
else \
|
||||||
export HOST=arm-linux-androideabi; \
|
export HOST=arm-linux-androideabi; \
|
||||||
fi \
|
fi \
|
||||||
|
|
||||||
echo -e building for ARCH="$arch, OPTIONS=$OPTIONS.... \n"
|
echo -e building for ARCH="$arch, OPTIONS=$OPTIONS.... \n"
|
||||||
|
|
||||||
./configure --host=$HOST --with-android-cpu=$arch --prefix=$HOME/$arch --without-pic --enable-nonfree=$ENABLE_NONFREE --enable-gpl=$ENABLE_GPL --enable-debug=$DEBUG $OPTIONS
|
./configure --host=$HOST --with-android-cpu=$arch --prefix=$HOME/$arch --with-pic --enable-nonfree=$ENABLE_NONFREE --enable-gpl=$ENABLE_GPL --enable-debug=$DEBUG $OPTIONS
|
||||||
make clean
|
make clean
|
||||||
make uninstall
|
make uninstall
|
||||||
make all
|
make all
|
||||||
|
@ -124,7 +128,9 @@ done
|
||||||
|
|
||||||
mkdir -p $HOME/imsdroid/libs/armeabi
|
mkdir -p $HOME/imsdroid/libs/armeabi
|
||||||
mkdir -p $HOME/imsdroid/libs/armeabi-v7a
|
mkdir -p $HOME/imsdroid/libs/armeabi-v7a
|
||||||
|
mkdir -p $HOME/imsdroid/libs/arm64-v8a
|
||||||
mkdir -p $HOME/imsdroid/libs/x86
|
mkdir -p $HOME/imsdroid/libs/x86
|
||||||
|
mkdir -p $HOME/imsdroid/libs/x86_64
|
||||||
mkdir -p $HOME/imsdroid/libs/mips
|
mkdir -p $HOME/imsdroid/libs/mips
|
||||||
|
|
||||||
cp --force $HOME/armv5te/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi/libtinyWRAP.so
|
cp --force $HOME/armv5te/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi/libtinyWRAP.so
|
||||||
|
@ -134,7 +140,13 @@ cp --force $HOME/armv7-a/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7
|
||||||
cp --force $HOME/armv7-a/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7a/libplugin_audio_opensles.so
|
cp --force $HOME/armv7-a/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7a/libplugin_audio_opensles.so
|
||||||
cp --force $HOME/armv7-a-neon/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7a/libtinyWRAP_neon.so
|
cp --force $HOME/armv7-a-neon/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/armeabi-v7a/libtinyWRAP_neon.so
|
||||||
|
|
||||||
|
cp --force $HOME/arm64/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/arm64-v8a/libtinyWRAP.so
|
||||||
|
cp --force $HOME/arm64/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/arm64-v8a/libplugin_audio_opensles.so
|
||||||
|
|
||||||
cp --force $HOME/x86/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/x86/libtinyWRAP.so
|
cp --force $HOME/x86/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/x86/libtinyWRAP.so
|
||||||
cp --force $HOME/x86/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/x86/libplugin_audio_opensles.so
|
cp --force $HOME/x86/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/x86/libplugin_audio_opensles.so
|
||||||
|
|
||||||
|
cp --force $HOME/x64/lib/libtinyWRAP.so.0.0.0 $HOME/imsdroid/libs/x86_64/libtinyWRAP.so
|
||||||
|
cp --force $HOME/x64/lib/libplugin_audio_opensles.so.0.0.0 $HOME/imsdroid/libs/x86_64/libplugin_audio_opensles.so
|
||||||
|
|
||||||
|
|
||||||
|
|
44
configure.ac
44
configure.ac
|
@ -22,7 +22,15 @@ case "$host" in
|
||||||
target_os=android
|
target_os=android
|
||||||
android_cpu=armv5te
|
android_cpu=armv5te
|
||||||
;;
|
;;
|
||||||
i686-*-linux-android)
|
aarch64-*-linux-android)
|
||||||
|
target_os=android
|
||||||
|
android_cpu=arm64
|
||||||
|
;;
|
||||||
|
x86_64-*-linux-android)
|
||||||
|
target_os=android
|
||||||
|
android_cpu=x64
|
||||||
|
;;
|
||||||
|
i686-*-linux-android)
|
||||||
target_os=android
|
target_os=android
|
||||||
android_cpu=x86
|
android_cpu=x86
|
||||||
;;
|
;;
|
||||||
|
@ -37,7 +45,9 @@ AC_ARG_WITH(android-cpu,
|
||||||
armv5te: ARMv5TE
|
armv5te: ARMv5TE
|
||||||
armv7-a: ARMv7-a *without* NEON
|
armv7-a: ARMv7-a *without* NEON
|
||||||
armv7-a-neon: ARMv7-a *with* NEON
|
armv7-a-neon: ARMv7-a *with* NEON
|
||||||
x86: X86],
|
arm64: aarch64
|
||||||
|
x86: X86
|
||||||
|
x64: X86_64],
|
||||||
[ android_cpu=$withval ])
|
[ android_cpu=$withval ])
|
||||||
|
|
||||||
### ANDROID-TOOLCHAIN (http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html)
|
### ANDROID-TOOLCHAIN (http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html)
|
||||||
|
@ -48,14 +58,31 @@ if test "$target_os" = "android"; then
|
||||||
export ANDROID_PREFIX=i686-linux-android
|
export ANDROID_PREFIX=i686-linux-android
|
||||||
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
|
||||||
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --arch=x86 --install-dir=$ANDROID_TOOLCHAIN
|
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --arch=x86 --install-dir=$ANDROID_TOOLCHAIN
|
||||||
|
export CFLAGS='-DANDROID=1'
|
||||||
AC_SUBST(TARGET_ARCH, "x86")
|
AC_SUBST(TARGET_ARCH, "x86")
|
||||||
;;
|
;;
|
||||||
|
x64)
|
||||||
|
export SYSROOT=$NDK/platforms/android-21/arch-x86_64
|
||||||
|
export ANDROID_PREFIX=x86_64-linux-android
|
||||||
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86_64
|
||||||
|
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86_64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
|
||||||
|
export CFLAGS='-DANDROID=1'
|
||||||
|
AC_SUBST(TARGET_ARCH, "x86")
|
||||||
|
;;
|
||||||
|
arm64)
|
||||||
|
export ANDROID_PREFIX=aarch64-linux-android
|
||||||
|
export SYSROOT=$NDK/platforms/android-21/arch-arm64
|
||||||
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-arm64
|
||||||
|
$NDK/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
|
||||||
|
export CFLAGS='-DANDROID=1 -D__ARMEL__'
|
||||||
|
AC_SUBST(TARGET_ARCH, "arm")
|
||||||
|
;;
|
||||||
armv7-a)
|
armv7-a)
|
||||||
export ANDROID_PREFIX=arm-linux-androideabi
|
export ANDROID_PREFIX=arm-linux-androideabi
|
||||||
export SYSROOT=$NDK/platforms/android-3/arch-arm
|
export SYSROOT=$NDK/platforms/android-3/arch-arm
|
||||||
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a
|
||||||
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
|
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
|
||||||
export CFLAGS='-march=armv7-a -mfloat-abi=softfp'
|
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -DANDROID=1 -D__ARMEL__'
|
||||||
export LDFLAGS='-Wl,--fix-cortex-a8'
|
export LDFLAGS='-Wl,--fix-cortex-a8'
|
||||||
AC_SUBST(TARGET_ARCH, "arm")
|
AC_SUBST(TARGET_ARCH, "arm")
|
||||||
;;
|
;;
|
||||||
|
@ -64,7 +91,7 @@ if test "$target_os" = "android"; then
|
||||||
export SYSROOT=$NDK/platforms/android-3/arch-arm
|
export SYSROOT=$NDK/platforms/android-3/arch-arm
|
||||||
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a-neon
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a-neon
|
||||||
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
|
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
|
||||||
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
|
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon -DANDROID=1'
|
||||||
export LDFLAGS='-Wl,--fix-cortex-a8'
|
export LDFLAGS='-Wl,--fix-cortex-a8'
|
||||||
AC_SUBST(TARGET_ARCH, "arm")
|
AC_SUBST(TARGET_ARCH, "arm")
|
||||||
;;
|
;;
|
||||||
|
@ -73,13 +100,14 @@ if test "$target_os" = "android"; then
|
||||||
export SYSROOT=$NDK/platforms/android-3/arch-arm
|
export SYSROOT=$NDK/platforms/android-3/arch-arm
|
||||||
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-armv5te
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-armv5te
|
||||||
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
|
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --arch=arm --install-dir=$ANDROID_TOOLCHAIN
|
||||||
|
export CFLAGS='-DANDROID=1 -D__ARMEL__'
|
||||||
AC_SUBST(TARGET_ARCH, "arm")
|
AC_SUBST(TARGET_ARCH, "arm")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
AC_SUBST(NDK, $NDK)
|
AC_SUBST(NDK, $NDK)
|
||||||
|
|
||||||
export CFLAGS="${CFLAGS} -DANDROID=1"
|
export CFLAGS="${CFLAGS} -fPIC"
|
||||||
export CPPFLAGS=$CFLAGS
|
export CPPFLAGS=$CFLAGS
|
||||||
export LDFLAGS="${LDFLAGS} -lc -lm -lgcc"
|
export LDFLAGS="${LDFLAGS} -lc -lm -lgcc"
|
||||||
|
|
||||||
|
@ -401,10 +429,10 @@ AC_ARG_WITH(ssl,
|
||||||
if test $want_ssl != no; then
|
if test $want_ssl != no; then
|
||||||
# check for lib and headers
|
# check for lib and headers
|
||||||
AC_CHECK_HEADERS(openssl/ssl.h,
|
AC_CHECK_HEADERS(openssl/ssl.h,
|
||||||
AC_CHECK_LIB(ssl, SSL_library_init, AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 1, HAVE_OPENSSL) [have_ssl=yes] LIBSSL_LIBADD="${LIBSSL_LIBADD} -lssl",
|
AC_CHECK_LIB(ssl, SSL_connect, AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 1, HAVE_OPENSSL) [have_ssl=yes] LIBSSL_LIBADD="${LIBSSL_LIBADD} -lssl",
|
||||||
AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 0, HAVE_OPENSSL) [have_ssl=no], [-lcrypto]
|
AC_DEFINE_UNQUOTED(HAVE_OPENSSL, 0, HAVE_OPENSSL) [have_ssl=no], [-lcrypto]
|
||||||
))
|
))
|
||||||
AC_CHECK_LIB(crypto, BN_init,
|
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data,
|
||||||
LIBSSL_LIBADD="${LIBSSL_LIBADD} -lcrypto"
|
LIBSSL_LIBADD="${LIBSSL_LIBADD} -lcrypto"
|
||||||
AC_CHECK_LIB(ssl, SSL_CTX_set_tlsext_use_srtp, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS_SRTP, 1, HAVE_OPENSSL_DTLS_SRTP) [have_dtls_srtp=yes],[],[-lcrypto])
|
AC_CHECK_LIB(ssl, SSL_CTX_set_tlsext_use_srtp, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS_SRTP, 1, HAVE_OPENSSL_DTLS_SRTP) [have_dtls_srtp=yes],[],[-lcrypto])
|
||||||
AC_CHECK_LIB(ssl, DTLSv1_method, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS, 1, HAVE_OPENSSL_DTLS) [have_dtls=yes],[],[-lcrypto])
|
AC_CHECK_LIB(ssl, DTLSv1_method, AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DTLS, 1, HAVE_OPENSSL_DTLS) [have_dtls=yes],[],[-lcrypto])
|
||||||
|
@ -465,7 +493,7 @@ AM_CONDITIONAL([USE_FFMPEG], [test $have_ffmpeg = yes])
|
||||||
########################################################
|
########################################################
|
||||||
# X264
|
# X264
|
||||||
########################################################
|
########################################################
|
||||||
AM_CONDITIONAL(USE_X264, [test $target_os:$enable_gpl = android:yes]) # X264 is always there for Android and statically linked
|
AM_CONDITIONAL(USE_X264, [test $target_os:$enable_gpl:$have_ffmpeg = android:yes:yes]) # X264 is always there for Android and statically linked
|
||||||
AC_SUBST(LIBX264_LIBADD, "-lx264")
|
AC_SUBST(LIBX264_LIBADD, "-lx264")
|
||||||
AC_ARG_WITH(x264, [ --with-x264 IMPORTANT: deprecated to be removed ],[], [])
|
AC_ARG_WITH(x264, [ --with-x264 IMPORTANT: deprecated to be removed ],[], [])
|
||||||
|
|
||||||
|
|
|
@ -30,60 +30,60 @@
|
||||||
#include "tsk_debug.h"
|
#include "tsk_debug.h"
|
||||||
|
|
||||||
typedef enum PLUGIN_INDEX_E {
|
typedef enum PLUGIN_INDEX_E {
|
||||||
PLUGIN_INDEX_AUDIO_CONSUMER,
|
PLUGIN_INDEX_AUDIO_CONSUMER,
|
||||||
PLUGIN_INDEX_AUDIO_PRODUCER,
|
PLUGIN_INDEX_AUDIO_PRODUCER,
|
||||||
PLUGIN_INDEX_COUNT
|
PLUGIN_INDEX_COUNT
|
||||||
}
|
}
|
||||||
PLUGIN_INDEX_T;
|
PLUGIN_INDEX_T;
|
||||||
|
|
||||||
|
|
||||||
int __plugin_get_def_count()
|
int __plugin_get_def_count()
|
||||||
{
|
{
|
||||||
return PLUGIN_INDEX_COUNT;
|
return PLUGIN_INDEX_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk_plugin_def_type_t __plugin_get_def_type_at(int index)
|
tsk_plugin_def_type_t __plugin_get_def_type_at(int index)
|
||||||
{
|
{
|
||||||
switch(index) {
|
switch (index) {
|
||||||
case PLUGIN_INDEX_AUDIO_CONSUMER:
|
case PLUGIN_INDEX_AUDIO_CONSUMER:
|
||||||
return tsk_plugin_def_type_consumer;
|
return tsk_plugin_def_type_consumer;
|
||||||
case PLUGIN_INDEX_AUDIO_PRODUCER:
|
case PLUGIN_INDEX_AUDIO_PRODUCER:
|
||||||
return tsk_plugin_def_type_producer;
|
return tsk_plugin_def_type_producer;
|
||||||
default: {
|
default: {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
|
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
|
||||||
return tsk_plugin_def_type_none;
|
return tsk_plugin_def_type_none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
|
tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
|
||||||
{
|
{
|
||||||
switch(index) {
|
switch (index) {
|
||||||
case PLUGIN_INDEX_AUDIO_CONSUMER:
|
case PLUGIN_INDEX_AUDIO_CONSUMER:
|
||||||
case PLUGIN_INDEX_AUDIO_PRODUCER: {
|
case PLUGIN_INDEX_AUDIO_PRODUCER: {
|
||||||
return tsk_plugin_def_media_type_audio;
|
return tsk_plugin_def_media_type_audio;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
|
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
|
||||||
return tsk_plugin_def_media_type_none;
|
return tsk_plugin_def_media_type_none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
|
tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
|
||||||
{
|
{
|
||||||
switch(index) {
|
switch (index) {
|
||||||
case PLUGIN_INDEX_AUDIO_CONSUMER: {
|
case PLUGIN_INDEX_AUDIO_CONSUMER: {
|
||||||
return audio_consumer_opensles_plugin_def_t;
|
return audio_consumer_opensles_plugin_def_t;
|
||||||
}
|
}
|
||||||
case PLUGIN_INDEX_AUDIO_PRODUCER: {
|
case PLUGIN_INDEX_AUDIO_PRODUCER: {
|
||||||
return audio_producer_opensles_plugin_def_t;
|
return audio_producer_opensles_plugin_def_t;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
|
AUDIO_OPENSLES_DEBUG_ERROR("No plugin at index %d", index);
|
||||||
return tsk_null;
|
return tsk_null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -91,25 +91,25 @@ tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
|
||||||
//
|
//
|
||||||
|
|
||||||
typedef struct audio_opensles_instance_s {
|
typedef struct audio_opensles_instance_s {
|
||||||
TSK_DECLARE_OBJECT;
|
TSK_DECLARE_OBJECT;
|
||||||
|
|
||||||
uint64_t sessionId;
|
uint64_t sessionId;
|
||||||
|
|
||||||
bool isStarted;
|
bool isStarted;
|
||||||
|
|
||||||
bool isConsumerPrepared;
|
bool isConsumerPrepared;
|
||||||
bool isConsumerStarted;
|
bool isConsumerStarted;
|
||||||
bool isProducerPrepared;
|
bool isProducerPrepared;
|
||||||
bool isProducerStarted;
|
bool isProducerStarted;
|
||||||
|
|
||||||
bool isSpeakerAvailable;
|
bool isSpeakerAvailable;
|
||||||
bool isPlayoutAvailable;
|
bool isPlayoutAvailable;
|
||||||
bool isRecordingAvailable;
|
bool isRecordingAvailable;
|
||||||
|
|
||||||
SLAudioDevice* device;
|
SLAudioDevice* device;
|
||||||
SLAudioDeviceCallbackImpl* callback;
|
SLAudioDeviceCallbackImpl* callback;
|
||||||
|
|
||||||
TSK_DECLARE_SAFEOBJ;
|
TSK_DECLARE_SAFEOBJ;
|
||||||
}
|
}
|
||||||
audio_opensles_instance_t;
|
audio_opensles_instance_t;
|
||||||
typedef tsk_list_t audio_opensles_instances_L_t;
|
typedef tsk_list_t audio_opensles_instances_L_t;
|
||||||
|
@ -118,442 +118,442 @@ static audio_opensles_instances_L_t* __audioInstances = tsk_null;
|
||||||
|
|
||||||
static tsk_object_t* audio_opensles_instance_ctor(tsk_object_t * self, va_list * app)
|
static tsk_object_t* audio_opensles_instance_ctor(tsk_object_t * self, va_list * app)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
|
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
|
||||||
if(audioInstance) {
|
if (audioInstance) {
|
||||||
tsk_safeobj_init(audioInstance);
|
tsk_safeobj_init(audioInstance);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
static tsk_object_t* audio_opensles_instance_dtor(tsk_object_t * self)
|
static tsk_object_t* audio_opensles_instance_dtor(tsk_object_t * self)
|
||||||
{
|
{
|
||||||
AUDIO_OPENSLES_DEBUG_INFO("Audio Instance destroyed");
|
AUDIO_OPENSLES_DEBUG_INFO("Audio Instance destroyed");
|
||||||
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
|
audio_opensles_instance_t* audioInstance = (audio_opensles_instance_t*)self;
|
||||||
if(audioInstance) {
|
if (audioInstance) {
|
||||||
tsk_safeobj_lock(audioInstance);
|
tsk_safeobj_lock(audioInstance);
|
||||||
if(audioInstance->device) {
|
if (audioInstance->device) {
|
||||||
audioInstance->device->SetCallback(NULL);
|
audioInstance->device->SetCallback(NULL);
|
||||||
audioInstance->device->Terminate();
|
audioInstance->device->Terminate();
|
||||||
delete audioInstance->device;
|
delete audioInstance->device;
|
||||||
audioInstance->device = tsk_null;
|
audioInstance->device = tsk_null;
|
||||||
}
|
}
|
||||||
if(audioInstance->callback) {
|
if (audioInstance->callback) {
|
||||||
delete audioInstance->callback;
|
delete audioInstance->callback;
|
||||||
audioInstance->callback = tsk_null;
|
audioInstance->callback = tsk_null;
|
||||||
}
|
}
|
||||||
tsk_safeobj_unlock(audioInstance);
|
tsk_safeobj_unlock(audioInstance);
|
||||||
|
|
||||||
tsk_safeobj_deinit(audioInstance);
|
tsk_safeobj_deinit(audioInstance);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
static int audio_opensles_instance_cmp(const tsk_object_t *_ai1, const tsk_object_t *_ai2)
|
static int audio_opensles_instance_cmp(const tsk_object_t *_ai1, const tsk_object_t *_ai2)
|
||||||
{
|
{
|
||||||
return ((int)_ai1 - (int)_ai2);
|
return (int)((uintptr_t)_ai1 - (uintptr_t)_ai2);
|
||||||
}
|
}
|
||||||
static const tsk_object_def_t audio_opensles_instance_def_s = {
|
static const tsk_object_def_t audio_opensles_instance_def_s = {
|
||||||
sizeof(audio_opensles_instance_t),
|
sizeof(audio_opensles_instance_t),
|
||||||
audio_opensles_instance_ctor,
|
audio_opensles_instance_ctor,
|
||||||
audio_opensles_instance_dtor,
|
audio_opensles_instance_dtor,
|
||||||
audio_opensles_instance_cmp,
|
audio_opensles_instance_cmp,
|
||||||
};
|
};
|
||||||
const tsk_object_def_t *audio_opensles_instance_def_t = &audio_opensles_instance_def_s;
|
const tsk_object_def_t *audio_opensles_instance_def_t = &audio_opensles_instance_def_s;
|
||||||
|
|
||||||
|
|
||||||
audio_opensles_instance_handle_t* audio_opensles_instance_create(uint64_t sessionId)
|
audio_opensles_instance_handle_t* audio_opensles_instance_create(uint64_t sessionId)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* audioInstance = tsk_null;
|
audio_opensles_instance_t* audioInstance = tsk_null;
|
||||||
|
|
||||||
// create list used to hold instances
|
// create list used to hold instances
|
||||||
if(!__audioInstances && !(__audioInstances = tsk_list_create())) {
|
if (!__audioInstances && !(__audioInstances = tsk_list_create())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new list");
|
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new list");
|
||||||
return tsk_null;
|
return tsk_null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//= lock the list
|
//= lock the list
|
||||||
tsk_list_lock(__audioInstances);
|
tsk_list_lock(__audioInstances);
|
||||||
|
|
||||||
// find the instance from the list
|
// find the instance from the list
|
||||||
const tsk_list_item_t* item;
|
const tsk_list_item_t* item;
|
||||||
tsk_list_foreach(item, __audioInstances) {
|
tsk_list_foreach(item, __audioInstances) {
|
||||||
if(((audio_opensles_instance_t*)item->data)->sessionId == sessionId) {
|
if (((audio_opensles_instance_t*)item->data)->sessionId == sessionId) {
|
||||||
audioInstance = (audio_opensles_instance_t*)tsk_object_ref(item->data);
|
audioInstance = (audio_opensles_instance_t*)tsk_object_ref(item->data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!audioInstance) {
|
if (!audioInstance) {
|
||||||
audio_opensles_instance_t* _audioInstance;
|
audio_opensles_instance_t* _audioInstance;
|
||||||
if(!(_audioInstance = (audio_opensles_instance_t*)tsk_object_new(&audio_opensles_instance_def_s))) {
|
if (!(_audioInstance = (audio_opensles_instance_t*)tsk_object_new(&audio_opensles_instance_def_s))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new audio instance");
|
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create new audio instance");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(_audioInstance->device = new SLAudioDevice())) {
|
if (!(_audioInstance->device = new SLAudioDevice())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio device");
|
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio device");
|
||||||
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(_audioInstance->callback = new SLAudioDeviceCallbackImpl())) {
|
if (!(_audioInstance->callback = new SLAudioDeviceCallbackImpl())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio transport");
|
AUDIO_OPENSLES_DEBUG_ERROR("Failed to create audio transport");
|
||||||
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if((_audioInstance->device->SetCallback(_audioInstance->callback))) {
|
if ((_audioInstance->device->SetCallback(_audioInstance->callback))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::RegisterAudioCallback() failed");
|
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::RegisterAudioCallback() failed");
|
||||||
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((_audioInstance->device->Init())) {
|
if ((_audioInstance->device->Init())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::Init() failed");
|
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::Init() failed");
|
||||||
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
TSK_OBJECT_SAFE_FREE(_audioInstance);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
_audioInstance->sessionId = sessionId;
|
_audioInstance->sessionId = sessionId;
|
||||||
audioInstance = _audioInstance;
|
audioInstance = _audioInstance;
|
||||||
tsk_list_push_back_data(__audioInstances, (void**)&_audioInstance);
|
tsk_list_push_back_data(__audioInstances, (void**)&_audioInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
//= unlock the list
|
//= unlock the list
|
||||||
tsk_list_unlock(__audioInstances);
|
tsk_list_unlock(__audioInstances);
|
||||||
|
|
||||||
return audioInstance;
|
return audioInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_prepare_consumer(audio_opensles_instance_handle_t* _self, tmedia_consumer_t** _consumer)
|
int audio_opensles_instance_prepare_consumer(audio_opensles_instance_handle_t* _self, tmedia_consumer_t** _consumer)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
const struct audio_consumer_opensles_s* consumer = (const struct audio_consumer_opensles_s*)*_consumer;
|
const struct audio_consumer_opensles_s* consumer = (const struct audio_consumer_opensles_s*)*_consumer;
|
||||||
if(!self || !self->device || !self->callback || !_consumer || !*_consumer) {
|
if (!self || !self->device || !self->callback || !_consumer || !*_consumer) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->isConsumerPrepared) {
|
if (self->isConsumerPrepared) {
|
||||||
AUDIO_OPENSLES_DEBUG_WARN("Consumer already prepared");
|
AUDIO_OPENSLES_DEBUG_WARN("Consumer already prepared");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
bool _bool;
|
bool _bool;
|
||||||
|
|
||||||
tsk_safeobj_lock(self);
|
tsk_safeobj_lock(self);
|
||||||
|
|
||||||
self->callback->SetConsumer(consumer);
|
self->callback->SetConsumer(consumer);
|
||||||
|
|
||||||
if((ret = self->device->SpeakerIsAvailable(&_bool))) {
|
if ((ret = self->device->SpeakerIsAvailable(&_bool))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() failed with error code=%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() failed with error code=%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!_bool) {
|
if (!_bool) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() returned false");
|
AUDIO_OPENSLES_DEBUG_ERROR("SpeakerIsAvailable() returned false");
|
||||||
}
|
}
|
||||||
self->isSpeakerAvailable = _bool;
|
self->isSpeakerAvailable = _bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = self->device->InitSpeaker())) {
|
if ((ret = self->device->InitSpeaker())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("InitSpeaker() failed with error code=%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("InitSpeaker() failed with error code=%d", ret);
|
||||||
}
|
}
|
||||||
else if((ret = self->device->SetSpeakerOn(audio_consumer_opensles_is_speakerOn(consumer)))) {
|
else if ((ret = self->device->SetSpeakerOn(audio_consumer_opensles_is_speakerOn(consumer)))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SetSpeakerOn() failed with error code=%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("SetSpeakerOn() failed with error code=%d", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = self->device->PlayoutIsAvailable(&_bool))) {
|
if ((ret = self->device->PlayoutIsAvailable(&_bool))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() failed with error code =%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() failed with error code =%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!_bool) {
|
if (!_bool) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() returned false");
|
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutIsAvailable() returned false");
|
||||||
}
|
}
|
||||||
self->isPlayoutAvailable = _bool;
|
self->isPlayoutAvailable = _bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = self->device->SetStereoPlayout(((*_consumer)->audio.in.channels == 2)))) {
|
if ((ret = self->device->SetStereoPlayout(((*_consumer)->audio.in.channels == 2)))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoPlayout(%d==2) failed with error code=%d", (*_consumer)->audio.in.channels, ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoPlayout(%d==2) failed with error code=%d", (*_consumer)->audio.in.channels, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if((ret = self->device->SetPlayoutBuffer(AudioDeviceModule::kFixedBufferSize, (*_consumer)->audio.ptime))){
|
//if((ret = self->device->SetPlayoutBuffer(AudioDeviceModule::kFixedBufferSize, (*_consumer)->audio.ptime))){
|
||||||
// AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", (*_consumer)->audio.ptime, ret);
|
// AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", (*_consumer)->audio.ptime, ret);
|
||||||
//}
|
//}
|
||||||
// always request 10ms buffers
|
// always request 10ms buffers
|
||||||
if((ret = self->device->SetPlayoutBuffer(10))) {
|
if ((ret = self->device->SetPlayoutBuffer(10))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", 10, ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutBuffer(%d ms) failed with error code=%d", 10, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int playoutSampleRate = (*_consumer)->audio.out.rate ? (*_consumer)->audio.out.rate : (*_consumer)->audio.in.rate;
|
int playoutSampleRate = (*_consumer)->audio.out.rate ? (*_consumer)->audio.out.rate : (*_consumer)->audio.in.rate;
|
||||||
if((ret = self->device->SetPlayoutSampleRate(playoutSampleRate))) {
|
if ((ret = self->device->SetPlayoutSampleRate(playoutSampleRate))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutSampleRate(%d) failed with error code=%d", playoutSampleRate, ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("SetPlayoutSampleRate(%d) failed with error code=%d", playoutSampleRate, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = self->device->InitPlayout())) {
|
if ((ret = self->device->InitPlayout())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitPlayout() failed with error code = %d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitPlayout() failed with error code = %d", ret);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// init output parameters
|
// init output parameters
|
||||||
if((ret = self->device->StereoPlayout(&_bool))) {
|
if ((ret = self->device->StereoPlayout(&_bool))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("StereoPlayout() failed with error code=%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("StereoPlayout() failed with error code=%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*_consumer)->audio.out.channels = (_bool ? 2 : 1);
|
(*_consumer)->audio.out.channels = (_bool ? 2 : 1);
|
||||||
}
|
}
|
||||||
if((ret = self->device->PlayoutSampleRate(&playoutSampleRate))) {
|
if ((ret = self->device->PlayoutSampleRate(&playoutSampleRate))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutSampleRate() failed with error code=%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("PlayoutSampleRate() failed with error code=%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*_consumer)->audio.out.rate = playoutSampleRate;
|
(*_consumer)->audio.out.rate = playoutSampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tsk_safeobj_unlock(self);
|
tsk_safeobj_unlock(self);
|
||||||
|
|
||||||
self->isConsumerPrepared = (ret == 0);
|
self->isConsumerPrepared = (ret == 0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_prepare_producer(audio_opensles_instance_handle_t* _self, tmedia_producer_t** _producer)
|
int audio_opensles_instance_prepare_producer(audio_opensles_instance_handle_t* _self, tmedia_producer_t** _producer)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
if(!self || !self->device || !self->callback || !_producer || !*_producer) {
|
if (!self || !self->device || !self->callback || !_producer || !*_producer) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->isProducerPrepared) {
|
if (self->isProducerPrepared) {
|
||||||
AUDIO_OPENSLES_DEBUG_WARN("Producer already prepared");
|
AUDIO_OPENSLES_DEBUG_WARN("Producer already prepared");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
bool _bool;
|
bool _bool;
|
||||||
|
|
||||||
tsk_safeobj_lock(self);
|
tsk_safeobj_lock(self);
|
||||||
|
|
||||||
self->callback->SetProducer((const struct audio_producer_opensles_s*)*_producer);
|
self->callback->SetProducer((const struct audio_producer_opensles_s*)*_producer);
|
||||||
|
|
||||||
if((ret = self->device->RecordingIsAvailable(&_bool))) {
|
if ((ret = self->device->RecordingIsAvailable(&_bool))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() failed with error code =%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() failed with error code =%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!_bool) {
|
if (!_bool) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() returned false");
|
AUDIO_OPENSLES_DEBUG_ERROR("RecordingIsAvailable() returned false");
|
||||||
}
|
}
|
||||||
self->isRecordingAvailable = _bool;
|
self->isRecordingAvailable = _bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = self->device->MicrophoneIsAvailable(&_bool))) {
|
if ((ret = self->device->MicrophoneIsAvailable(&_bool))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() failed with error code =%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() failed with error code =%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!_bool) {
|
if (!_bool) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() returned false");
|
AUDIO_OPENSLES_DEBUG_ERROR("MicrophoneIsAvailable() returned false");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if((ret = self->device->InitMicrophone())) {
|
if ((ret = self->device->InitMicrophone())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("InitMicrophone() failed with error code =%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("InitMicrophone() failed with error code =%d", ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = self->device->SetStereoRecording(((*_producer)->audio.channels == 2)))) {
|
if ((ret = self->device->SetStereoRecording(((*_producer)->audio.channels == 2)))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoRecording(%d==2) failed with error code=%d", (*_producer)->audio.channels, ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("SetStereoRecording(%d==2) failed with error code=%d", (*_producer)->audio.channels, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int recordingSampleRate = (*_producer)->audio.rate;
|
int recordingSampleRate = (*_producer)->audio.rate;
|
||||||
if((ret = self->device->SetRecordingSampleRate(recordingSampleRate))) {
|
if ((ret = self->device->SetRecordingSampleRate(recordingSampleRate))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("SetRecordingSampleRate(%d) failed with error code=%d", recordingSampleRate, ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("SetRecordingSampleRate(%d) failed with error code=%d", recordingSampleRate, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = self->device->InitRecording())) {
|
if ((ret = self->device->InitRecording())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitRecording() failed with error code = %d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("AudioDeviceModule::InitRecording() failed with error code = %d", ret);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// init output parameters
|
// init output parameters
|
||||||
if((ret = self->device->StereoRecording(&_bool))) {
|
if ((ret = self->device->StereoRecording(&_bool))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("StereoRecording() failed with error code=%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("StereoRecording() failed with error code=%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*_producer)->audio.channels = (_bool ? 2 : 1);
|
(*_producer)->audio.channels = (_bool ? 2 : 1);
|
||||||
}
|
}
|
||||||
if((ret = self->device->RecordingSampleRate(&recordingSampleRate))) {
|
if ((ret = self->device->RecordingSampleRate(&recordingSampleRate))) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("RecordingSampleRate() failed with error code=%d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("RecordingSampleRate() failed with error code=%d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*_producer)->audio.rate = recordingSampleRate;
|
(*_producer)->audio.rate = recordingSampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tsk_safeobj_unlock(self);
|
tsk_safeobj_unlock(self);
|
||||||
|
|
||||||
self->isProducerPrepared = (ret == 0);
|
self->isProducerPrepared = (ret == 0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_start_consumer(audio_opensles_instance_handle_t* _self)
|
int audio_opensles_instance_start_consumer(audio_opensles_instance_handle_t* _self)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
if(!self || !self->device || !self->callback) {
|
if (!self || !self->device || !self->callback) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk_safeobj_lock(self);
|
tsk_safeobj_lock(self);
|
||||||
if(!self->isConsumerPrepared) {
|
if (!self->isConsumerPrepared) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Consumer not prepared");
|
AUDIO_OPENSLES_DEBUG_ERROR("Consumer not prepared");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->isConsumerStarted) {
|
if (self->isConsumerStarted) {
|
||||||
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
|
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->isPlayoutAvailable) {
|
if (self->isPlayoutAvailable) {
|
||||||
int ret;
|
int ret;
|
||||||
if((ret = self->device->StartPlayout())) {
|
if ((ret = self->device->StartPlayout())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("StartPlayout() failed with error code = %d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("StartPlayout() failed with error code = %d", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->isConsumerStarted = self->device->Playing();
|
self->isConsumerStarted = self->device->Playing();
|
||||||
AUDIO_OPENSLES_DEBUG_INFO("isPlaying=%s", (self->isConsumerPrepared ? "true" : "false"));
|
AUDIO_OPENSLES_DEBUG_INFO("isPlaying=%s", (self->isConsumerPrepared ? "true" : "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tsk_safeobj_unlock(self);
|
tsk_safeobj_unlock(self);
|
||||||
return (self->isConsumerStarted ? 0 : -1);
|
return (self->isConsumerStarted ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_start_producer(audio_opensles_instance_handle_t* _self)
|
int audio_opensles_instance_start_producer(audio_opensles_instance_handle_t* _self)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
if(!self || !self->device || !self->callback) {
|
if (!self || !self->device || !self->callback) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk_safeobj_lock(self);
|
tsk_safeobj_lock(self);
|
||||||
if(!self->isProducerPrepared) {
|
if (!self->isProducerPrepared) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Producer not prepared");
|
AUDIO_OPENSLES_DEBUG_ERROR("Producer not prepared");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->isProducerStarted) {
|
if (self->isProducerStarted) {
|
||||||
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
|
AUDIO_OPENSLES_DEBUG_WARN("Consumer already started");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->isRecordingAvailable) {
|
if (self->isRecordingAvailable) {
|
||||||
int ret;
|
int ret;
|
||||||
if((ret = self->device->StartRecording())) {
|
if ((ret = self->device->StartRecording())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("StartRecording() failed with error code = %d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("StartRecording() failed with error code = %d", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->isProducerStarted = self->device->Recording();
|
self->isProducerStarted = self->device->Recording();
|
||||||
AUDIO_OPENSLES_DEBUG_INFO("isRecording=%s", (self->isProducerStarted ? "true" : "false"));
|
AUDIO_OPENSLES_DEBUG_INFO("isRecording=%s", (self->isProducerStarted ? "true" : "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tsk_safeobj_unlock(self);
|
tsk_safeobj_unlock(self);
|
||||||
return (self->isProducerStarted ? 0 : -1);
|
return (self->isProducerStarted ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_stop_consumer(audio_opensles_instance_handle_t* _self)
|
int audio_opensles_instance_stop_consumer(audio_opensles_instance_handle_t* _self)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
if(!self || !self->device || !self->callback) {
|
if (!self || !self->device || !self->callback) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk_safeobj_lock(self);
|
tsk_safeobj_lock(self);
|
||||||
|
|
||||||
if(!self->isConsumerStarted) {
|
if (!self->isConsumerStarted) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
if((ret = self->device->StopPlayout())) {
|
if ((ret = self->device->StopPlayout())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("StopPlayout() failed with error code = %d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("StopPlayout() failed with error code = %d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self->isConsumerStarted = self->device->Playing();
|
self->isConsumerStarted = self->device->Playing();
|
||||||
self->isConsumerPrepared = false;
|
self->isConsumerPrepared = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tsk_safeobj_unlock(self);
|
tsk_safeobj_unlock(self);
|
||||||
return (self->isConsumerStarted ? -1 : 0);
|
return (self->isConsumerStarted ? -1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_stop_producer(audio_opensles_instance_handle_t* _self)
|
int audio_opensles_instance_stop_producer(audio_opensles_instance_handle_t* _self)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
if(!self || !self->device || !self->callback) {
|
if (!self || !self->device || !self->callback) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk_safeobj_lock(self);
|
tsk_safeobj_lock(self);
|
||||||
|
|
||||||
if(!self->isProducerStarted) {
|
if (!self->isProducerStarted) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
if((ret = self->device->StopRecording())) {
|
if ((ret = self->device->StopRecording())) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("StopRecording() failed with error code = %d", ret);
|
AUDIO_OPENSLES_DEBUG_ERROR("StopRecording() failed with error code = %d", ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self->isProducerStarted = self->device->Recording();
|
self->isProducerStarted = self->device->Recording();
|
||||||
self->isProducerPrepared = false;
|
self->isProducerPrepared = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tsk_safeobj_unlock(self);
|
tsk_safeobj_unlock(self);
|
||||||
return (self->isProducerStarted ? -1 : 0);
|
return (self->isProducerStarted ? -1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_set_speakerOn(audio_opensles_instance_handle_t* _self, bool speakerOn)
|
int audio_opensles_instance_set_speakerOn(audio_opensles_instance_handle_t* _self, bool speakerOn)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
if(!self || !self->device ) {
|
if (!self || !self->device) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return self->device->SetSpeakerOn(speakerOn);
|
return self->device->SetSpeakerOn(speakerOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_set_microphone_volume(audio_opensles_instance_handle_t* _self, int32_t volume)
|
int audio_opensles_instance_set_microphone_volume(audio_opensles_instance_handle_t* _self, int32_t volume)
|
||||||
{
|
{
|
||||||
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
audio_opensles_instance_t* self = (audio_opensles_instance_t*)_self;
|
||||||
if(!self || !self->device ) {
|
if (!self || !self->device) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return self->device->SetMicrophoneVolume(volume);
|
return self->device->SetMicrophoneVolume(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_opensles_instance_destroy(audio_opensles_instance_handle_t** _self)
|
int audio_opensles_instance_destroy(audio_opensles_instance_handle_t** _self)
|
||||||
{
|
{
|
||||||
if(!_self || !*_self) {
|
if (!_self || !*_self) {
|
||||||
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
|
AUDIO_OPENSLES_DEBUG_ERROR("Invalid parameter");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tsk_list_lock(__audioInstances);
|
tsk_list_lock(__audioInstances);
|
||||||
if(tsk_object_get_refcount(*_self)==1) {
|
if (tsk_object_get_refcount(*_self) == 1) {
|
||||||
tsk_list_remove_item_by_data(__audioInstances, *_self);
|
tsk_list_remove_item_by_data(__audioInstances, *_self);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tsk_object_unref(*_self);
|
tsk_object_unref(*_self);
|
||||||
}
|
}
|
||||||
tsk_list_unlock(__audioInstances);
|
tsk_list_unlock(__audioInstances);
|
||||||
*_self = tsk_null;
|
*_self = tsk_null;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
export NDK=/home/android-ndk-r10e
|
export NDK=/home/android-ndk-r10e
|
||||||
export PREFIX_BASE=/home/openssl-1.1.0h/android
|
export PREFIX_BASE=$(pwd)/android
|
||||||
export HOST=arm-linux-androideabi
|
export HOST=arm-linux-androideabi
|
||||||
export CPU=ARM
|
export CPU=ARM
|
||||||
|
|
||||||
if [ w$1 = "wx86" ]
|
if [ w$1 = "wx64" ]
|
||||||
|
then
|
||||||
|
echo "************************"
|
||||||
|
echo " X64 "
|
||||||
|
echo "************************"
|
||||||
|
export HOST=x86_64-linux-android
|
||||||
|
export CPU=x86_64
|
||||||
|
export SYSROOT=$NDK/platforms/android-21/arch-x86_64
|
||||||
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86_64
|
||||||
|
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86_64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
|
||||||
|
export CFLAGS='-fPIC' # For FFmpeg: '-fno-PIC'
|
||||||
|
export LDFLAGS=''
|
||||||
|
export OS=android64
|
||||||
|
elif [ w$1 = "wx86" ]
|
||||||
then
|
then
|
||||||
echo "************************"
|
echo "************************"
|
||||||
echo " X86 "
|
echo " X86 "
|
||||||
|
@ -14,10 +27,23 @@ then
|
||||||
export CPU=x86
|
export CPU=x86
|
||||||
export SYSROOT=$NDK/platforms/android-9/arch-x86
|
export SYSROOT=$NDK/platforms/android-9/arch-x86
|
||||||
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
|
||||||
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86 --platform=android-9 --arch=x86 --install-dir=$ANDROID_TOOLCHAIN
|
$NDK/build/tools/make-standalone-toolchain.sh --arch=x86 --platform=android-9 --install-dir=$ANDROID_TOOLCHAIN
|
||||||
export CFLAGS='-fPIC' # For FFmpeg: '-fno-PIC'
|
export CFLAGS='-fPIC' # For FFmpeg: '-fno-PIC'
|
||||||
export LDFLAGS=''
|
export LDFLAGS=''
|
||||||
export OS=android-x86
|
export OS=android-x86
|
||||||
|
elif [ w$1 = "warm64" ]
|
||||||
|
then
|
||||||
|
echo "************************"
|
||||||
|
echo " ARM64 "
|
||||||
|
echo "************************"
|
||||||
|
export HOST=aarch64-linux-android
|
||||||
|
export CPU=arm64
|
||||||
|
export SYSROOT=$NDK/platforms/android-21/arch-arm64
|
||||||
|
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-arm64
|
||||||
|
$NDK/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=$ANDROID_TOOLCHAIN
|
||||||
|
export CFLAGS='-fPIC -D__ARMEL__ -DWEBRTC_DETECT_ARM_NEON -DWEBRTC_ARCH_ARM_NEON' # For FFmpeg: '-fno-PIC'
|
||||||
|
export LDFLAGS=''
|
||||||
|
export OS=android64-aarch64
|
||||||
elif [ w$1 = "warmv7a" ]
|
elif [ w$1 = "warmv7a" ]
|
||||||
then
|
then
|
||||||
echo "************************"
|
echo "************************"
|
||||||
|
@ -68,6 +94,9 @@ export CXX=$ANDROID_TOOLCHAIN/bin/$HOST-g++
|
||||||
export AS=$ANDROID_TOOLCHAIN/bin/$HOST-gcc
|
export AS=$ANDROID_TOOLCHAIN/bin/$HOST-gcc
|
||||||
export RANLIB=$ANDROID_TOOLCHAIN/bin/$HOST-ranlib
|
export RANLIB=$ANDROID_TOOLCHAIN/bin/$HOST-ranlib
|
||||||
|
|
||||||
|
export CFLAGS="${CFLAGS} -DANDROID=1 -fPIC"
|
||||||
|
export CPPFLAGS=$CFLAGS
|
||||||
|
|
||||||
./Configure -no-shared --prefix=$PREFIX_BASE/$CPU --openssldir=$PREFIX_BASE/$CPU/openssl $OS -I$ANDROID_TOOLCHAIN/sysroot/ -I$ANDROID_TOOLCHAIN/sysroot/usr/include
|
./Configure -no-shared --prefix=$PREFIX_BASE/$CPU --openssldir=$PREFIX_BASE/$CPU/openssl $OS -I$ANDROID_TOOLCHAIN/sysroot/ -I$ANDROID_TOOLCHAIN/sysroot/usr/include
|
||||||
make clean
|
make clean
|
||||||
make
|
make
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue