diff --git a/thirdparty/openal-soft/HPKBUILD b/thirdparty/openal-soft/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..6d53b35f79b40e5ffee7dc331fca9cb212a0962d --- /dev/null +++ b/thirdparty/openal-soft/HPKBUILD @@ -0,0 +1,91 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Contributor: TangShaoteng +# Maintainer: TangShaoteng +pkgname=openal-soft +pkgver=1.23.1 +pkgrel=0 +pkgdesc="OpenAL Soft is an LGPL-licensed, cross-platform, software implementation of the OpenAL 3D audio API." +url="https://openal-soft.org" +archs=("armeabi-v7a" "arm64-v8a") +license=("LGPLv2") +depends=("pulseaudio" "libsndfile") +makedepends=() + +source="https://github.com/kcat/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +patchflag=true + +builddir=${pkgname}-${pkgver} +packagename=$builddir.tar.gz + +prepare() { + if $patchflag + then + cd $builddir + # 添加控制动态库的符号可见性开关 + patch -p1 < `pwd`/../openal-soft_oh_pkg.patch + # patch只需要打一次,关闭打patch + patchflag=false + cd $OLDPWD + fi + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -DSNDFILE_FOUND=TRUE -DALSOFT_INSTALL_EXAMPLES=ON \ + -DALSOFT_REQUIRE_PULSEAUDIO=ON -DVISIBILITY_PRESET_HIDDEN=OFF -B$ARCH-build -S./ -L > `pwd`/$ARCH-build/build.log 2>&1 + make VERBOSE=1 -j4 -C $ARCH-build >> `pwd`/$ARCH-build/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + make -C $ARCH-build install >> `pwd`/$ARCH-build/build.log 2>&1 + cd $OLDPWD +} + +check() { + if [ $ARCH == "armeabi-v7a" ] + then + cp ${OHOS_SDK}/native/llvm/lib/arm-linux-ohos/libc++_shared.so $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib/ + elif [ $ARCH == "arm64-v8a" ] + then + cp ${OHOS_SDK}/native/llvm/lib/aarch64-linux-ohos/libc++_shared.so $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib/ + else + echo "${ARCH} not support" + return -1 + fi + echo "The test must be on an OpenHarmony device!" + # real test cmd + # ./openal-info + # ./alrecord -c 2 -b 16 -r 44100 -t 5 -o record.wav + # ./alplay record.wav + # ./altonegen + # ./alstream /system/etc/graphic/bootsound.wav + # ./alhrtf /system/etc/graphic/bootsound.wav + # ./allatency /system/etc/graphic/bootsound.wav + # ./alreverb /system/etc/graphic/bootsound.wav + # ./almultireverb /system/etc/graphic/bootsound.wav +} + +# 清理环境 +cleanbuild() { + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} + diff --git a/thirdparty/openal-soft/HPKCHECK b/thirdparty/openal-soft/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..c06f05f04abebf23b0fa0394bd85088d6dfbb14e --- /dev/null +++ b/thirdparty/openal-soft/HPKCHECK @@ -0,0 +1,144 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Contributor: TangShaoteng +# Maintainer: TangShaoteng + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log +tmppath= + +checkprepare() { + # 添加pulseaudio库的lib/pulseaudio目录下的库路径到环境变量 + tmppath=$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=${LYCIUM_ROOT}/usr/pulseaudio/${ARCH}/lib/pulseaudio:$tmppath +} + +checkunprepare() { + # 恢复为测试前的环境变量 + export LD_LIBRARY_PATH=$tmppath + unset tmppath +} + +openharmonycheck() { + res=0 + cd ${LYCIUM_ROOT}/usr/openal-soft/$ARCH/bin + mkdir ${LYCIUM__MANUAL_CONFIRM_PATH}/${pkgname} + + # 测试项1:openal声卡详细信息 + ./openal-info > ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "openal-info test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + # 测试项2:录音 + ./alrecord -c 2 -b 16 -r 44100 -t 5 -o record.wav >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "alrecord test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + cp record.wav ${LYCIUM__MANUAL_CONFIRM_PATH}/${pkgname}/ + + # 测试项3:播放 + ./alplay record.wav >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "alplay test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + # 测试项4:音调发生器测试 + ./altonegen >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "altonegen test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + # 测试项5:音频流示例 + ./alstream /system/etc/graphic/bootsound.wav >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "alstream test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + # 测试项6:HRTF示例 + ./alhrtf /system/etc/graphic/bootsound.wav >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "alhrtf test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + # 测试项7:源延迟示例 + ./allatency /system/etc/graphic/bootsound.wav >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "allatency test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + # 测试项8:混响示例 + ./alreverb /system/etc/graphic/bootsound.wav >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "alreverb test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + # 测试项9:多区域混响示例 + ./almultireverb /system/etc/graphic/bootsound.wav >> ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + echo "almultireverb test failed" >> ${logfile} 2>&1 + cd $OLDPWD + checkunprepare + return res + fi + + cp ${logfile} ${LYCIUM__MANUAL_CONFIRM_PATH}/${pkgname}/ + + cd $OLDPWD + + checkunprepare + + return $res +} diff --git a/thirdparty/openal-soft/OAT.xml b/thirdparty/openal-soft/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..00f4c47405081491b05af1251a48f342c410298a --- /dev/null +++ b/thirdparty/openal-soft/OAT.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/thirdparty/openal-soft/README.OpenSource b/thirdparty/openal-soft/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..616e11058475dab4aad8eb5f123f72fb915fdf81 --- /dev/null +++ b/thirdparty/openal-soft/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "openal-soft", + "License": "LGPLv2", + "License File": "https://github.com/kcat/openal-soft/blob/master/COPYING", + "Version Number": "1.23.1", + "Owner": "tangshaoteng@163.com", + "Upstream URL": "https://github.com/kcat/openal-soft/archive/refs/tags/1.23.1.tar.gz", + "Description": "OpenAL Soft is a software implementation of the OpenAL 3D audio API." + } +] diff --git a/thirdparty/openal-soft/README_zh.md b/thirdparty/openal-soft/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..be85de9b4433773b49c7ed4e73d74fd97874a618 --- /dev/null +++ b/thirdparty/openal-soft/README_zh.md @@ -0,0 +1,11 @@ +# openal-soft三方库说明 +## 功能简介 +OpenAL Soft是OpenAL 3D音频API的软件实现。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 4.0.8.1 (API Version 10 Release) +- 三方库版本:1.23.1 +- 当前适配的功能:OpenAL Soft是OpenAL 3D音频API的软件实现。 + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/openal-soft/SHA512SUM b/thirdparty/openal-soft/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..a36faa3eaac1dc5580533eeb9ca97f3337a9f6d0 --- /dev/null +++ b/thirdparty/openal-soft/SHA512SUM @@ -0,0 +1 @@ +21f768484978e4321b733004988cb5ecf43d908e7e08f2d421a338633fcfb2ade722d035de73742470ff135ab538d6b9b56df14020976adb1d1e081dfb095c6b openal-soft-1.23.1.tar.gz diff --git a/thirdparty/openal-soft/docs/hap_integrate.md b/thirdparty/openal-soft/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..387278664803906959beec718277fd0aae52f041 --- /dev/null +++ b/thirdparty/openal-soft/docs/hap_integrate.md @@ -0,0 +1,135 @@ +# openal-soft集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 4.0.8.1 (API Version 10 Release)](https://gitee.com/link?target=http%3A%2F%2Fdownload.ci.openharmony.cn%2Fversion%2FMaster_Version%2FOpenHarmony_4.0.8.1%2F20230608_091058%2Fversion-Master_Version-OpenHarmony_4.0.8.1-20230608_091058-ohos-sdk-public.tar.gz) +- [DevEco Studio 3.1 Release](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2F81%2Fv3%2FtgRUB84wR72nTfE8Ir_xMw%2Fdevecostudio-windows-3.1.0.501.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230621T074329Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D22F6787DF6093ECB4D4E08F9379B114280E1F65DA710599E48EA38CB24F3DBF2) +- [准备三方库构建环境](../../../lycium/README.md#1编译环境准备) +- [准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/openal-soft #三方库openal-soft的目录结构如下 + ├── openal-soft_oh_pkg.patch #构建patch文件 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #自动化测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库说明文档 + ├── OAT.xml #开源扫描相关文件 + ``` + +- 在tpc_c_cplusplus/lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd tpc_c_cplusplus/lycium + ./build.sh openal-soft + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库和头文件 + + ```shell + openal-soft/arm64-v8a openal-soft/armeabi-v7a + libsndfile/arm64-v8a libsndfile/armeabi-v7a + pulseaudio/arm64-v8a pulseaudio/armeabi-v7a + ``` +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录 +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + +  ![thirdparty_install_dir01](pic/openal-soft_install_dir01.png) + +  ![thirdparty_install_dir02](pic/openal-soft_install_dir02.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libopenal.so.1) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include/openal-soft/${OHOS_ARCH} + ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include/libsndfile/${OHOS_ARCH} + ) + ``` + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + + 进入到安装目录tpc_c_cplusplus/lycium/usr/openal-soft/${OHOS_ARCH}/bin,执行如下操作步骤: + +- 配置环境变量 + 执行如下命令: + + ```shell + export LD_LIBRARY_PATH=${LYCIUM_ROOT}/usr/openal-soft/${ARCH}/lib:${LYCIUM_ROOT}/usr/pulseaudio/${ARCH}/lib:${LYCIUM_ROOT}/usr/pulseaudio/${ARCH}/lib/pulseaudio:$LD_LIBRARY_PATH + ``` + > 注意:LYCIUM_ROOT代表lycium所在目录的绝对路径;ARCH代表构建架构,64位为arm64-v8a,32位为armeabi-v7a。 + +- 执行测试项: + + ```shell + ./openal-info + ``` +  ![openal-soft_test_01](pic/openal-soft_test_01.png) + ```shell + ./alrecord -c 2 -b 16 -r 44100 -t 5 -o record.wav + ``` +  ![openal-soft_test_02](pic/openal-soft_test_02.png) + ```shell + ./alplay record.wav + ``` +  ![openal-soft_test_03](pic/openal-soft_test_03.png) + ```shell + ./altonegen + ``` +  ![openal-soft_test_04](pic/openal-soft_test_04.png) + ```shell + ./alstream /system/etc/graphic/bootsound.wav + ``` +  ![openal-soft_test_05](pic/openal-soft_test_05.png) + ```shell + ./alhrtf /system/etc/graphic/bootsound.wav + ``` +  ![openal-soft_test_06](pic/openal-soft_test_06.png) + ```shell + ./allatency /system/etc/graphic/bootsound.wav + ``` +  ![openal-soft_test_07](pic/openal-soft_test_07.png) + ```shell + ./alreverb /system/etc/graphic/bootsound.wav + ``` +  ![openal-soft_test_08](pic/openal-soft_test_08.png) + ```shell + ./almultireverb /system/etc/graphic/bootsound.wav + ``` +  ![openal-soft_test_09](pic/openal-soft_test_09.png) + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_install_dir01.png b/thirdparty/openal-soft/docs/pic/openal-soft_install_dir01.png new file mode 100644 index 0000000000000000000000000000000000000000..835390a70d75ef4abfd008e72637a8f7700afadf Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_install_dir01.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_install_dir02.png b/thirdparty/openal-soft/docs/pic/openal-soft_install_dir02.png new file mode 100644 index 0000000000000000000000000000000000000000..54ee04c998d59ca78d370aa945fcaf730842ca1e Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_install_dir02.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_01.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_01.png new file mode 100644 index 0000000000000000000000000000000000000000..cc336c034a91a983249b69764d90c1ae25941b49 Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_01.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_02.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_02.png new file mode 100644 index 0000000000000000000000000000000000000000..d348781847f6b858ca26b73424e2d21f75815ec5 Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_02.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_03.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_03.png new file mode 100644 index 0000000000000000000000000000000000000000..5beb815049ce2f8460d7705e6c38a9d1a3b438a6 Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_03.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_04.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_04.png new file mode 100644 index 0000000000000000000000000000000000000000..a971c10336fea58c6716f54ef43a677be22fdaa4 Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_04.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_05.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_05.png new file mode 100644 index 0000000000000000000000000000000000000000..343e8405bee5995267440e6d3ae88c4640d93948 Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_05.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_06.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_06.png new file mode 100644 index 0000000000000000000000000000000000000000..f968169f8181da09eca271861b580849fba197ea Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_06.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_07.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_07.png new file mode 100644 index 0000000000000000000000000000000000000000..b36c818c2a47a7d73a39106a881e066aca4e91f9 Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_07.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_08.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_08.png new file mode 100644 index 0000000000000000000000000000000000000000..4605fa6750f94bfe2ac392d26a21ea909add6cb1 Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_08.png differ diff --git a/thirdparty/openal-soft/docs/pic/openal-soft_test_09.png b/thirdparty/openal-soft/docs/pic/openal-soft_test_09.png new file mode 100644 index 0000000000000000000000000000000000000000..f3b59e66a1f3756814dedd71ec8df5e1b22ecd0a Binary files /dev/null and b/thirdparty/openal-soft/docs/pic/openal-soft_test_09.png differ diff --git a/thirdparty/openal-soft/openal-soft_oh_pkg.patch b/thirdparty/openal-soft/openal-soft_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..f5373751b38b42c8f12f27df04acb65f4212a3fd --- /dev/null +++ b/thirdparty/openal-soft/openal-soft_oh_pkg.patch @@ -0,0 +1,16 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b231a1e..8e3d6ca 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -30,8 +30,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + endif() + endif() + ++option(VISIBILITY_PRESET_HIDDEN "set the library visibility preset to hidden" ON) ++if(VISIBILITY_PRESET_HIDDEN) + set(CMAKE_C_VISIBILITY_PRESET hidden) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) ++endif() + + if(COMMAND CMAKE_POLICY) + cmake_policy(SET CMP0003 NEW)