LINUX REALTIME AUDIO PLAYBACK
Thomas M. Sailer
sailer@ife.ee.ethz.ch
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.6.rar_MP3解码_amp open source mp3_linux mp3_mp3解码器
版权申诉
90 浏览量
2022-09-24
12:27:20
上传
评论
收藏 110KB RAR 举报
JonSco
- 粉丝: 67
- 资源: 1万+
最新资源
- 笔记实验六,spark,大数据分析
- ####蓝桥杯python的详细的信息介绍
- 电子万年历软件仿真(经过多次修改,保证正确性)
- Unity XR 手势射击控制脚本(适用于任何可手势识别的设备)
- 机械设计全自动电表(NB和IC卡表)控制和上壳装配线sw16可编辑非常好的设计图纸100%好用.zip
- 基于matlab的EAN-13条形码识别系统GUI界面.zip代码53
- matlab基于bp神经网络交通信号标志识别GUI界面13个标志.zip代码54
- 电子万年历答辩实物展示视频mp4格式
- 基于python实现的程序,包括哈希感知算法cvHash,图像切割cvsplit,固定目标检测cvRec(附文档ppt)等
- 计算0-10000之间所有偶数的和
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈