Multimedia Support in the Linux Kernel

Kernel Sounds

© alemba_arts, Fotolia

© alemba_arts, Fotolia

Author(s):

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.

Read full article as PDF:

038-041_realtime.pdf  (511.20 kB)

Related content

  • Realtime

    Linux provides tools and patches for speeding up the priority of multimedia applications. So if you're not getting the performance you expect, try shifting into overdrive.

  • Zack's Kernel News

    Chronicler Zack Brown reports on the latest news, views, dilemmas, and developments within the Linux kernel community.

  • JACK audio server

    The JACK audio server offers a professional sound alternative for the Linux desktop.

  • Program for Eleventh Real-Time Linux Workshop

    The Open Source Automation Development Lab (OSADL) invites participants to the Real-Time Linux Foundation Workshop from September 28 through 30 in Dresden, Germany. Well-known names such as Jonathan Corbet will be present.

  • LMMS

    Linux has truly started to compete with Windows and MacOS as a platform for professional sound applications. Linux Multimedia Studio (LMMS) is a Linux sound tool that packs a variety of impressive features into a neat bundle.

comments powered by Disqus

Direct Download

Read full article as PDF:

038-041_realtime.pdf  (511.20 kB)

News