LINUX REALTIME AUDIO PLAYBACK
Thomas M. Sailer
[email protected]
Typical Unix schedulers go to great lengths to allow batch processing jobs
to run on a machine while still providing interactivity. They do it by
enhancing the priority of short bursty tasks. While this works well for
many important tasks (such as X, xterm and compiling new kernel releases :-)),
it does not fit the behaviour of a MPEG player. The tasks of a MPEG player
have a "soft" deadline; if it is not met, no nuclear power plant blows up,
but still it can be heard as an annoying artifact. That's what the POSIX.1b
realtime scheduling extensions promise to remedy.
rtbuf.c is an implementation of a buffering scheme using the POSIX realtime
features. Its aim is to provide smooth playback of MPEG audio streams
even on a very heavily loaded machine. It uses many advanced features
of the operating system:
- System V shared memory
- POSIX.1b realtime scheduling extensions
- POSIX.1b memory locking
- Sound Driver DMA buffer mapping into the user proces space
Make sure that you have enabled these features! The downside
of these features is that they can only be used if the process has
root permissions. Using realtime features is somewhat dangerous, since
a realtime process can eat all the CPU time, rendering the machine
unresponsive. So don't try this on your server!
This implementation creates three processes:
- The command line parse/control process. It runs continuously as root.
- The MPEG decode/playback process. It revokes root rights as soon as it
has enabled the realtime features, to minimize the risk for a security
hole
- The prefetch process. Its only purpose is to load the input file into
a memory region shared with the decode process. It also revokes root
rights.
The MPEG decode process writes its output data directly into the soundcard
DMA buffer, which is mmap'ed into process memory. This minimizes operating
system overhead.
To use this:
Type
./configure --enable-realtime
make
chown root.root amp
chmod u+s amp
This buffering only works on Linux (maybe also on FreeBSD, but I don't
know...) Other operating systems do not (yet) support the required
features.
A warning: The buffering might not work on an SMP system. This could
be solved by making the macros atomic_set and atomic_read SMP safe.
Have fun
Tom
amp-0.7.5-99_unix.rar_mp3播放器
版权申诉
185 浏览量
2022-09-19
12:39:37
上传
评论
收藏 159KB RAR 举报
JaniceLu
- 粉丝: 78
- 资源: 1万+
最新资源
- Unity 插件之移动端影子生成插件(Mobile Fast Shadow 1.0.6)
- A.E.003.102 平面下客按钮(横标)B11E02-3818520F A1.dwg
- DoTween-PhotoWall-0701.unitypackage unity动态照片墙
- MT4946-VB一款2个N-Channel沟道SOP8的MOSFET晶体管参数介绍与应用说明
- 使用Unity开发的跳一跳小游戏
- OpenCV for Unity 2.6.0.unitypackage
- Unity 资源插件之僵尸模型资源包
- 0515student的一对多 多对多关系项目包
- 基于Hadoop的分布式并行增量爬虫技术研究.docx
- 基于Hadoop的海量数据存储平台设计与开发.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈