Multimedia Support in the Linux Kernel
Kernel Sounds
We'll show you how to tune up your Linux system for multimedia applications.
In the late 1960s, "multimedia" was a new term connected typically to the work of artists such as Andy Warhol. Although Warhol was not the only artist working in this domain, his Exploding Plastic Inevitable performances defined the multimedia event. An EPI show simultaneously included film, projected images, dancers, music, recitations, and so on, for an effect calculated to overwhelm the senses. By comparison, the multimedia experience on your computer is relatively restrained, but it can be colorful and exciting.
A computer-based multimedia production comprises text, graphics, sound, and video, but these elements can be combined into a media-rich presentation, an interactive audio/video installation, or a stroke-inducing first-person action game. Each combination is a true multimedia production. Like the original multimedia events, they require abundant resources. Modern machines have plenty of drive space and RAM, fast CPUs, and powerful video capabilities, but modern multimedia software can test the performance envelope of even the most powerful desktop computer.
In this article, I look at the Linux kernel's integral support for the hardware and software required by machines intended for the production and presentation of rich media formats. Because of space limitations, I can only touch on some of the factors required to optimize that support, but I hope my efforts inspire you to compile your own media-optimized kernel. The source code is free, the build process isn't terribly complicated, and the results can yield a considerable improvement in audio and video performance.
Configuring the Kernel for Multimedia Machines
The Linux kernel provides support for multimedia with drivers for a variety of devices (sound cards, video boards, graphics tablets, etc.) and code for features of various motherboard chipsets. The kernel's openness and modularity invite extension by developers who want to add new capabilities to the existing kernel services.
Before you compile the kernel, you must configure its options, usually with the help of a menu-based utility that presents the configuration options and preferences in an organized GUI (Figure 1). The scope of this article is restricted to those parts of the kernel configuration that apply to the topic (i.e., support for multimedia), and the following descriptions and explanations assume some experience in compiling programs from source code. However, even if you're a complete novice, Google can direct you to text and video guides for the process. It's not terribly difficult, and if you're patient and thorough, it might be fun.
CPU Type
The first settings will be made in the Processor type and features section. The processor type is an easy choice, but if you're not sure what CPU is in your machine, just issue the uname -a command at a terminal prompt.
This tool will respond by listing various facts about your hardware and its operating system. For example, on my notebook, I'm running Ubuntu 8.10 with a kernel patched for real-time operation. The uname utility reports the following information about my system:
dlphilp@maximus:~$ uname -a Linux maximus 2.6.27-3-rt #1 PREEMPT RT Mon Oct 27 03:05:19 UTC 2008 i686 GNU/Linux
From this report, I learn that my kernel is numbered 2.6.27-3-rt, that it's running on the first (#1) of a dual-core machine, and that it has been compiled for full preemption. Also, I know that my CPU type is an i686, a post-Pentium processor type. Actually, it's an AMD Turion-X2, configured as a single-core 32-bit i686 (with the CONFIG_X86 kernel option) so that I can use certain software that will not run on a dual-core 64-bit machine.
Kernel Timers
Successful multimedia performance of any kind is critically dependent on timing. Audio and video need tight synchronization, and sound needs to be free of dropouts and spurious noise. Fortunately, the modern Linux kernel provides the necessary components, but your distribution might not have the options enabled for those timers. To acquire the benefits of better timing, you might need to recompile your kernel.
The high-resolution timers option (CONFIG_HIGH_RES_TIMERS) enables a "tickless" system with a timing accuracy of about 1msec on most contemporary machines – a considerable improvement over the standard hertz-based timer resolution. Introduced in kernel 2.6.21, the tickless system reduces the load on the system clock by shutting off the timer interrupt (the tick) whenever the system idles. This process saves power on laptops and notebooks and improves multi-tasking performance. The option for high-resolution timers can be enabled without the tickless system, but in an optimal multimedia system, make sure that CONFIG_NO_HZ is set to true.
The high-performance event timer (HPET) was once known as the multimedia timer. According to its entry in Wikipedia, this timer "… can produce periodic interrupts at a much higher resolution than the RTC [real-time clock] and is often used to synchronize multimedia streams, providing smooth playback and reducing the need to use other timestamp calculations." The option (CONFIG_HPET_TIMER) is machine dependent and will not work on older hardware or operating systems, including the Linux 2.4 series. It also requires the rtc-cmos driver instead of the traditional RTC driver discussed next.
Which of these timers should you use? On my JAD 1.0 box (openSUSE 10.2), the HPET and the high-resolution timer options are both compiled into the kernel. Clocks and timers operate transparently on Linux, so don't worry about loading modules or installing other control software. The kernel module loader handles everything. You did enable the support for loadable modules, didn't you?
At this point, I'll include a word about Ye Olde Way of configuring high-resolution timing at the kernel level. Users of pre-2.6 kernels might not have access to the new timers, but they can still set up their kernels for enhanced resolution. The CONFIG_HZ option allows frequency settings for 100, 250, and 1,000Hz, the last of which is the preferred resolution for any system running audio and MIDI applications. Conventional wisdom advises compiling the RTC driver, again a necessity for high-resolution audio and MIDI event timing. Note that the timer frequency option is available in the Processor type and features section of your kernel configuration, but the RTC driver is selected in the Device Drivers section.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.