📄 linuxrealtime.txt
字号:
LINUX REALTIME AUDIO PLAYBACK Thomas M. Sailer sailer@ife.ee.ethz.chTypical Unix schedulers go to great lengths to allow batch processing jobsto run on a machine while still providing interactivity. They do it byenhancing the priority of short bursty tasks. While this works well formany 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 playerhave 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.1brealtime scheduling extensions promise to remedy.rtbuf.c is an implementation of a buffering scheme using the POSIX realtimefeatures. Its aim is to provide smooth playback of MPEG audio streamseven on a very heavily loaded machine. It uses many advanced featuresof 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 spaceMake sure that you have enabled these features! The downsideof these features is that they can only be used if the process hasroot permissions. Using realtime features is somewhat dangerous, sincea realtime process can eat all the CPU time, rendering the machineunresponsive. 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 soundcardDMA buffer, which is mmap'ed into process memory. This minimizes operatingsystem overhead.To use this:Type ./configure --enable-realtimemakechown root.root ampchmod u+s ampThis buffering only works on Linux (maybe also on FreeBSD, but I don'tknow...) Other operating systems do not (yet) support the requiredfeatures.A warning: The buffering might not work on an SMP system. This couldbe solved by making the macros atomic_set and atomic_read SMP safe.Have funTom
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -