适用于 Android 的低延迟音频 API? [英] Low latency audio api for Android?

查看:32
本文介绍了适用于 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆