高性能音频开裂/ prevent从downclocking一个CPU核心 [英] High Performance Audio Cracking / Prevent a CPU core from downclocking

查看:133
本文介绍了高性能音频开裂/ prevent从downclocking一个CPU核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是非常具体的,仍试图问:

This may be very specific, still trying to ask:

我热合成,软件音乐合成器为Android的创始人。 ( https://play.google.com/store/应用程序/详细信息?ID = com.nilsschneider.heat.demo

I'm founder of Heat Synthesizer, a software music synthesizer for Android. (https://play.google.com/store/apps/details?id=com.nilsschneider.heat.demo)

这个应用程序实时生成的音频信号,需要做繁重的数学计算来做到这一点。

This app generates audio signals in realtime and needs to do heavy math calculations to do so.

在看到关于高性能音频Android上的在谷歌I / O 2013的谈话( HTTP ?://www.youtube.com/watch v = d3kfEeMZ65c ),我很兴奋地实现它,因为他们的建议,但我一直有问题,噼里啪啦

Having seen the talk on Google I/O 2013 about "High Performance Audio on Android" (http://www.youtube.com/watch?v=d3kfEeMZ65c), I was excited to implement it as they suggested, but I keep having problems with crackling.

我有大约50%上的Nexus 7(2012)单核的CPU使用率,似乎一切会好起来为止。锁定已被减少到最低限度,并大部分$ C $的c完成无锁

I have a CPU usage of a single core of about 50% on a Nexus 7 (2012), everything seems to be okay so far. Locking has been reduced to a minimum and most of the code is done lock-free.

使用被称为Usemon一个应用程序,我可以看到我使用的处理核心只用50%甚至被内核downclocked,因为我的CPU使用率不够高。

Using an app that is called Usemon, I can see that the core I use for processing is used only 50% and is even being downclocked by the kernel because my CPU usage is not high enough.

不过,这个核心速度的变化导致音频噼里啪啦的,因为不计算速度不够快,因为我的核心降频下一个音频块。

However, this core speed changes result in crackling of the audio, because the next audio block is not calculated fast enough because my core is underclocked.

有什么办法prevent更改它的时钟频率的核心是什么?

Is there any way to prevent a core from changing it's clock frequency?

推荐答案

FWIW,我推荐使用systrace的(的文档解释,的例如)进行这种分析。在一个根深蒂固的设备,你可以启用频率标签,显示各种组件的时钟频率。最好的作品在Android 4.3及更高版本。

FWIW, I recommend the use of systrace (docs, explanation, example) for this sort of analysis. On a rooted device you can enable the "freq" tags, which show the clock frequencies of various components. Works best on Android 4.3 and later.

该hackish的电池不友好的方式来处理,这是启动不做任何事,但旋转,而你的计算是正在进行的第二个线程。理论上,这不应该工作(因为你是在一个不同的核心旋转),但实际上它通常能够完成任务。请务必验证该设备具有多个内核(调用Runtime.getRuntime()。availableProcessors()或NDK当量),作为单核设备上这样做会很糟糕

The hackish battery-unfriendly way to deal with this is to start up a second thread that does nothing but spin while your computations are in progress. In theory this shouldn't work (since you're spinning on a different core), but in practice it usually gets the job done. Make sure you verify that the device has multiple cores (Runtime.getRuntime().availableProcessors() or NDK equivalent), as doing this on a single-core device would be bad.

假设你的计算都在一个单独的线程异步执行,你可以通过从改变工作线程好一点的计算,然后等待工作到计算,那么轮询工作的模式。再次,远不如高效电池明智的,但如果你从来没有再睡觉内核将假设你正在努力工作,需要保持核心全速。确保你砸出来的轮询模式如果没有任何实际的工作要做(即你打输入结束)。

Assuming your computations are performed asynchronously in a separate thread, you can do a bit better by changing the worker thread from a "compute, then wait for work" to a "compute, then poll for work" model. Again, far less efficient battery-wise, but if you never sleep then the kernel will assume you're working hard and needs to keep the core at full speed. Make sure you drop out of polling mode if there isn't any actual work to do (i.e. you hit the end of input).

这篇关于高性能音频开裂/ prevent从downclocking一个CPU核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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