适用于 Android 的低延迟音频 API?

编程入门 行业动态 更新时间:2024-10-23 11:24:41
本文介绍了适用于 Android 的低延迟音频 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在 Android 设备上以最少的延迟播放同步音频有哪些选择?我会从罐装 SDK 中得到任何半体面的东西,还是要求太多?该文档声称 SoundPool 类能够以相对较好的性能同时播放多个声音,但在模拟器和物理设备上运行一些测试后,它似乎很弱.可能有什么技巧,还是我必须为这种事情使用低得多的api?我尝试使用加载了多个样本的单个声音池,并且尝试了多个声音池,每个声音池管理一个样本.我正在预加载所有内容,因此当我尝试播放时,除了调用 SoundPool.play() 之外,没有其他代码正在执行.

What are my options for playing simultaneous audio on an Android device with the least amount of latency? Am I going to get anything half decent out of the canned SDK, or is that asking too much? The documentation claims that the SoundPool class is capable of playing multiple sounds simultaneously with relatively good performance, but after running some tests in the emulator and on a physical device it seems pretty weak. Is there maybe a trick to it, or do I have to go to a much lower level api for this kind of thing? I've tried using a single sound pool with multiple samples loaded, and I've tried multiple sound pools each managing a single sample. I'm preloading everything, so that when I attempt to play back I have no additional code being executed other than the call to SoundPool.play().

推荐答案

Android 2.3 现在支持对低延迟应用程序的音频 API(通过 OpenSL)进行本机访问.

Android 2.3 now supports native access to audio APIs (via OpenSL) for low latency applications.

但是,并非所有硬件设备都具有低延迟音频功能配置文件.因此,需要低延迟音频的应用程序应通过在清单中指定以下内容来过滤 Android 市场中不支持它的设备:

However, not all hardware devices will have the a low latency audio feature profile. Thus applications requiring low latency audio shouuld filter devices not supporting it in the Android market by specifying the following in the manifest:

<uses-feature android:name="android.hardware.audio.low_latency"/>

更多推荐

适用于 Android 的低延迟音频 API?

本文发布于:2023-11-23 14:08:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621715.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   音频   Android   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!