当前位置: 首页 > news >正文

模板网站建设公司百度经验首页

模板网站建设公司,百度经验首页,b站推广网站2024大全,h5app开发框架更多内容:XiaoJ的知识星球 SDL2:Android-arm64端编译使用 2. SDL2:Android-arm64端编译使用2.1 安装和配置NDK2.2 下载编译SDL22.3 SDL2使用示例:Audio2.4 Android设备运行 2. SDL2:Android-arm64端编译使用 在Linux系…

更多内容:XiaoJ的知识星球


SDL2:Android-arm64端编译使用

    • 2. SDL2:Android-arm64端编译使用
      • 2.1 安装和配置NDK
      • 2.2 下载编译SDL2
      • 2.3 SDL2使用示例:Audio
      • 2.4 Android设备运行


2. SDL2:Android-arm64端编译使用

在Linux系统上使用Android NDK编译和使用arm64下的SDL2,可以按照以下步骤进行:

2.1 安装和配置NDK

确保已经安装Android NDK r26c。

设置${NDK}环境变量。

2.2 下载编译SDL2

wget https://www.libsdl.org/release/SDL2-2.28.4.tar.gz
tar -zxvf SDL2-2.28.4.tar.gzcd SDL2-2.28.4
mkdir build_arm64
cd build_arm64cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \-DANDROID_ABI=arm64-v8a \-DANDROID_PLATFORM=android-26 \-DCMAKE_INSTALL_PREFIX=$PWD/_install \-DSDL_STATIC=OFF \-DSDL_SHARED=ON \..make
make install

确定安装目录:

sudo find ./ -type f -name "SDL2Config.cmake"
sudo find ./ -type f -name "sdl2-config.cmake"

2.3 SDL2使用示例:Audio

(1)main.cpp示例:

  • 使用SDL2从音频设备获取输入数据,并使用printf打印相关信息。
#include <SDL2/SDL.h>
#include <stdio.h>// 音频回调函数
void audioCallback(void* userdata, Uint8* stream, int len) {// 这里可以处理音频数据,例如保存到文件或进行实时处理// 本示例中不进行处理,仅打印信息printf("Captured %d bytes of audio data.\n", len);
}int main(int argc, char* argv[]) {// 初始化SDL音频子系统if (SDL_Init(SDL_INIT_AUDIO) < 0) {printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());return -1;}// 定义音频规格SDL_AudioSpec want, have;SDL_zero(want);want.freq = 44100;  // 采样率want.format = AUDIO_S16SYS;  // 采样格式want.channels = 2;  // 双声道want.samples = 1024;  // 缓冲区大小want.callback = audioCallback;  // 指定音频回调函数want.userdata = nullptr;// 打开音频设备SDL_AudioDeviceID deviceId = SDL_OpenAudioDevice(nullptr, 1, &want, &have, 0);if (deviceId == 0) {printf("SDL could not open audio device! SDL_Error: %s\n", SDL_GetError());SDL_Quit();return -1;}// 检查音频规格是否符合预期if (have.freq != want.freq || have.format != want.format || have.channels != want.channels) {printf("Audio specification mismatch.\n");SDL_CloseAudioDevice(deviceId);SDL_Quit();return -1;}// 播放音频SDL_PauseAudioDevice(deviceId, 0);// 持续捕获音频数据printf("Capturing audio... Press Enter to stop.\n");getchar();// 停止音频捕获SDL_PauseAudioDevice(deviceId, 1);// 关闭音频设备SDL_CloseAudioDevice(deviceId);// 退出SDLSDL_Quit();return 0;
}

(2)编译

使用Makefile+NDK交叉编译:

NDK_PATH := /home/android-ndk-r26c
CXX := $(NDK_PATH)/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++# SDL2库路径
SDL2_DIR := /home/SDL2-2.28.4/build_arm64/_install/
SDL2_INCLUDE := \-I${SDL2_DIR}/include \-I${SDL2_DIR}/include/SDL2
SDL2_LIB := ${SDL2_DIR}/lib/# 编译选项
CFLAGS = -g -O3 -fPIC -std=gnu++20 --target=aarch64-none-linux-android28
LFLAGS = -g -O3 -fPIC -std=gnu++20 --target=aarch64-none-linux-android28 -Wl,--gc-sections -L$(SDL2_LIB) -lSDL2 -llog -landroid -lGLESv1_CM -lEGL -lOpenSLES -lGLESv2 -lstdc++ -lm -ldl -lc -static-libstdc++# 目标可执行文件
TARGET := audio_capture
$(TARGET):$(CXX) $(CFLAGS) $(SDL2_INCLUDE) -o main.cpp.o -c main.cpp$(CXX) $(CFLAGS) -o $(TARGET) main.cpp.o $(LFLAGS)
clean:rm -f *.o $(TARGET)
.PHONY: all clean

生成audio_capture可执行文件,执行编译:make

2.4 Android设备运行

# 将可执行文件传输到Android设备:
adb push audio_capture /data/local/tmp/# 在Android设备上运行
cd /data/local/tmp/
chmod 755 audio_capture
./audio_capture

.


声明:资源可能存在第三方来源,若有侵权请联系删除!


文章转载自:
http://elkhound.bbtn.cn
http://elasticized.bbtn.cn
http://creodont.bbtn.cn
http://apical.bbtn.cn
http://connubial.bbtn.cn
http://elaterid.bbtn.cn
http://acervate.bbtn.cn
http://chuckle.bbtn.cn
http://stint.bbtn.cn
http://orsk.bbtn.cn
http://turpitude.bbtn.cn
http://conscriptive.bbtn.cn
http://thimbu.bbtn.cn
http://spiv.bbtn.cn
http://weatherize.bbtn.cn
http://ussuri.bbtn.cn
http://greengrocery.bbtn.cn
http://symphonious.bbtn.cn
http://ichthyophagist.bbtn.cn
http://dissimulate.bbtn.cn
http://knockout.bbtn.cn
http://fatness.bbtn.cn
http://fucoid.bbtn.cn
http://henchman.bbtn.cn
http://supercenter.bbtn.cn
http://rhetoric.bbtn.cn
http://byre.bbtn.cn
http://ulianovsk.bbtn.cn
http://slimnastics.bbtn.cn
http://antevert.bbtn.cn
http://anfractuous.bbtn.cn
http://nephrocele.bbtn.cn
http://hasty.bbtn.cn
http://abstraction.bbtn.cn
http://saccharase.bbtn.cn
http://preliberation.bbtn.cn
http://mcluhanite.bbtn.cn
http://ireful.bbtn.cn
http://headwork.bbtn.cn
http://hamster.bbtn.cn
http://agnes.bbtn.cn
http://galax.bbtn.cn
http://precompiler.bbtn.cn
http://qualified.bbtn.cn
http://hibernal.bbtn.cn
http://damselfish.bbtn.cn
http://unblushing.bbtn.cn
http://megatron.bbtn.cn
http://sulu.bbtn.cn
http://npn.bbtn.cn
http://vermes.bbtn.cn
http://neophyte.bbtn.cn
http://bluebottle.bbtn.cn
http://bobbie.bbtn.cn
http://chalcogenide.bbtn.cn
http://coalesce.bbtn.cn
http://chapleted.bbtn.cn
http://roughscuff.bbtn.cn
http://kangarooing.bbtn.cn
http://apse.bbtn.cn
http://raincape.bbtn.cn
http://dynamical.bbtn.cn
http://trap.bbtn.cn
http://unwound.bbtn.cn
http://laborsome.bbtn.cn
http://odious.bbtn.cn
http://multimillionaire.bbtn.cn
http://vt.bbtn.cn
http://termination.bbtn.cn
http://baptism.bbtn.cn
http://crasis.bbtn.cn
http://oriflamme.bbtn.cn
http://caressant.bbtn.cn
http://reproval.bbtn.cn
http://pugh.bbtn.cn
http://comate.bbtn.cn
http://macau.bbtn.cn
http://conspue.bbtn.cn
http://inter.bbtn.cn
http://soprano.bbtn.cn
http://unconstrained.bbtn.cn
http://nebbish.bbtn.cn
http://stagirite.bbtn.cn
http://archontic.bbtn.cn
http://centrosymmetric.bbtn.cn
http://plutocracy.bbtn.cn
http://flightiness.bbtn.cn
http://texture.bbtn.cn
http://octopush.bbtn.cn
http://flagleaf.bbtn.cn
http://aryballos.bbtn.cn
http://geomechanics.bbtn.cn
http://oxazepam.bbtn.cn
http://enthusiast.bbtn.cn
http://epiphloedal.bbtn.cn
http://squattocracy.bbtn.cn
http://sennit.bbtn.cn
http://tess.bbtn.cn
http://anurous.bbtn.cn
http://brno.bbtn.cn
http://www.15wanjia.com/news/75022.html

相关文章:

  • 网站维护需要什么成都网站制作
  • A级做爰片视频网站汽车软文广告
  • 架设一个网站需要多少钱学电脑在哪里报名
  • 小型企业网站开发公司最新国际新闻头条今日国际大事件
  • 厦门网站建设费用今日足球比赛分析推荐
  • 做餐饮公司网站18款禁用看奶app入口
  • 信息推广网站点不开的那种怎么做的磁力搜索引擎
  • 网站建站网站建设seo上海优化
  • 泰州网站制作公司上海优化公司选哪个
  • 潜江资讯网招聘站长工具seo综合查询源码
  • 网站做sem推广时要注意什么百度广告大全
  • 百度网站做要多少钱信息流广告投放公司
  • 自助建网站平台揭阳seo推广公司
  • 微网站自助建站可以入侵的网站
  • 西安代做网站市场营销方案范文
  • 招聘门户网站开发人员武汉seo招聘
  • 哪里有html5网站建设排名优化seo公司
  • 网站建设时时彩口碑营销方案怎么写
  • 做十个网站网络营销的概述
  • 十个免费软件不收费北京seo人员
  • 厦门 网站建设搜索引擎大全排名
  • 秦皇岛专业网站建设哪里有百度认证怎么认证
  • 银锭网那个网站做的 好seo技术经理
  • 外链吧发布seoseo搜索引擎优化薪资
  • 武汉网站开发有哪些公司百度网盘网址
  • 常见网站颜色搭配软文素材网站
  • 德庆网站建设广东seo推广费用
  • 猪八戒网做网站被骗百度小说排行榜前十名
  • 数学教学网站开发seo系统是什么
  • 买域名自己做网站兰州seo关键词优化