LWN.net Logo

Development

TDC: Audio routing for vehicles

By Nathan Willis
May 30, 2013

One of the oft-cited tensions in the Tizen project (as in its predecessor, MeeGo) is that the end goal is to offer a common application platform for some Linux systems that are strikingly different under the hood. That is, application developers are understandably interested in offering their social networking apps and games on phones, smart TVs, and in-vehicle entertainment units—but the hardware and environments defining these products can be radically different. Phones have battery life and tiny screens to consider; smart TVs have the "ten foot UI" and users' aversion to keyboards. But perhaps the clearest challenge in this space has always been in-vehicle infotainment (IVI) systems, where audio routing is the canonical illustration of how different the car is from a desktop Linux system. Media playback, hands-free phone calls, navigation, and alert messages all contend for the right to deliver audio to the driver and passengers, without distracting the driver.

Intel's Jaska Uimonen presented the solution in the works for Tizen IVI at the 2013 Tizen Developer Conference in San Francisco. The audio management problem, he explained, comes down to three core issues: routing, policy-controlled volume, and policy-controlled preemption. The routing issue involves multiplexing the multiple audio input and output points of a vehicle (such as speaker sets for front and rear seats, headphone jacks, hands-free microphones, traditional audio dash-units, and hot-pluggable Bluetooth devices—a category that can include headsets and mobile phones). The users' expectation is that audio will always be routed to the correct zone, but a wide array of combinations is possible, and configuration can change on the fly. For example, an incoming hands-free phone call may need to target the driver alone, while the radio continues to play to the other seats (perhaps including the front passenger seat). This differs from mobile device audio management, Uimonen said, which typically makes a "select and route" decision; IVI audio requires a full switching matrix.

But there is still more. In addition to simply connecting each audio stream to the appropriate port, Uimonen said, the audio manager must also mix the volumes of the audio streams in a useful and safe manner. Turn-by-turn navigation directions are more important to hear than the radio, and thus the radio volume should dip momentarily for each navigation instruction—and hopefully do so smoothly. Then again, there are also situations when one audio stream may need to preempt others entirely, such as a safety alarm. Exactly which preemption and volume scenarios are appropriate is a system policy decision, of course, which will likely vary from manufacturer to manufacturer. Thus Tizen IVI's audio management framework needs to be flexible enough to support configurable policies.

Sound off

The audio management solution developed for Tizen IVI uses PulseAudio for routing, which is not surprising, although it does introduce some new code to support the notion of audio "zones" (e.g., driver, passenger, rear seat entertainment unit, etc.) which is not found in PulseAudio on the desktop. It implements the necessary policy-based decision making with Murphy, a relatively new "resource routing" engine started in 2012.

Murphy maintains an internal database of system state for whichever resources it is responsible for routing (audio, video, and network streams are the example uses). Policies for resource control are described in Lua statements, and separate plugins can implement control for each resource Murphy monitors. The Murphy daemon will listen for events from different sources (such as udev or Websockets), and can execute scripts or C programs to re-route resources in response.

For example, in the IVI audio scenario, a Bluetooth headset appearing or disappearing would trigger a D-Bus event from BlueZ, while a speed-sensitive volume adjustment might read speedometer data from the vehicle's CAN bus or Automotive Message Broker. The Murphy-driven audio manager runs as a plugin to PulseAudio; thus when a Murphy policy rule dictates routing a particular input to a particular output, the plugin should connect the associated PulseAudio sources and sinks.

But the actual implementation is a bit more complicated, because PulseAudio does not natively support certain useful options, such as combining sinks and sources or combining multiple sinks. Thus, the Tizen IVI audio manager adds the concept of "nodes"—essentially an abstraction layer, nodes represent a "routing endpoint" which might have a source (e.g., microphone) and a sink (e.g., speaker). A telephony application needs both to function, so the routing policy treats them as a single object. Playing audio over all of the speaker sets in the vehicle might actually involve routing the same audio stream to multiple independent speaker clusters, so the routing policy offers a "combined" node that serves them all.

The audio policies are based around tagging each audio stream with a class; for example, "music," "navigation," or "ui event." The system integrator can then write routing, volume, and preemption rules based on the class of the stream and the various nodes in the car. Obviously not every possible node will be present when the car leaves the factory (Bluetooth headsets and portable music players being the most obvious examples), but there are generally a fixed number of speaker and microphone devices, and only a handful of well-understood hot-pluggable device types to worry about.

When an application creates a new audio stream, the system automatically creates a default route for it based on its class (which might specify that "music" streams are routed to the whole-car speaker system, but "navigation" streams are routed to the front-seat speakers only). Users can request an explicit route to override the default if desired, assuming there is application support, that is.

This explicit routing feature is designed to work with GENIVI's audio management system, although GENIVI's system is not currently built for Tizen images. However, the GENIVI system does define the client-side interface through which applications can request specific audio routing, and since GENIVI is an industry-wide effort, the Tizen system supports the interface. As for application support within the existing Tizen application ecosystem, Uimonen noted that Tizen's WebKit runtime has been patched to support tagging streams with classes; HTML5 applications can tag their <audio> and <video> elements. There is no word yet on progress of the feature in Tizen's native application APIs.

The answer is simple. Volume.

The volume and preemption rules for audio streams prioritize certain classes over others, Uimonen explained, but the audio manager's decision to lower the volume of a stream is hidden from the application itself. Permitting applications to know when their volume level was being lowered in the mix might have some unwanted effects, he said—misbehaving applications might fight it by raising the volume of the stream, which is dangerous on its own but could also potentially lead to race conditions between competing applications.

The audio manager also adds one more feature to PulseAudio: the ability to smoothly ramp up or ramp down the volume of a stream. The plan is to send that patch upstream, Uimonen said, although it has not been sent yet. The other code is available in the Tizen repositories under the "IVI" profile. All of the code to implement the audio manager will be open source, however, the actual policies and configurations are hardware-specific; as with other such system configuration points, it may be expected that many auto manufacturers will choose not to release their audio routing config files or scripts.

Uimonen commented that the volume ramping work and the other additions to PulseAudio are hopefully going to be merged with the project upstream, because there are use cases outside of the IVI context that would benefit from the ability to perform more complex audio routing. That list might include home theater systems or whole-house audio setups, but even the basic desktop configuration these days is likely to incorporate multiple sound devices (Bluetooth, USB audio adapters, and so on). For the moment, then, the unusual demands of the IVI industry may be pushing development, but ultimately everyone stands to gain.

[The author wishes to thank the Linux Foundation for travel assistance to Tizen Dev Con.]

Comments (12 posted)

Brief items

Quotes of the week

I put the Web APIs at the end of the outline. With any luck, we'll run out of time before we get to them.
— Bob Spencer, presenting at Tizen Dev Con's hands-on development lab.

Any advanced postfix configuration (even from the official documentation) looks like McGyver was out of duct-tape but had to build a nuclear reactor from kitchen parts with only the transparent tape for office use.
Bernhard R. Link

Comments (2 posted)

LibreOffice 4.1.0 Beta1 available

The Document Foundation has announced the first Beta release of LibreOffice 4.1. "The upcoming 4.1 will be our sixth major release in two and a half years, and comes with a nice set of new features." See the list of known bugs before you start testing.

Comments (59 posted)

Git v1.8.3 released

Git version 1.8.3 is out. This release incorporates quite a few small changes over 1.8.2; users are encouraged to read the full release notes for details. A backward-compatibility note for Git 2.0 is also included.

Full Story (comments: none)

Elpy 1.0 available

Jorgen Schäfer has released version 1.0 of Elpy, the Python development environment for Emacs. In addition to standard IDE features like code completion and auto-indentation, Elpy supports inline documentation, on-the-fly checks with flymake, snippet expansion, and code refactoring.

Comments (none posted)

Source code available for Samsung's Android-based cameras

Imaging Resource covers the availability of source code for Samsung's Android-based NX300 and NX2000 digital cameras. In contrast, Canon cameras, which have active third-party replacement firmware projects, require reverse-engineering. In theory, the source should make writing CHDK or Magic Lantern–like firmware for these devices a simpler affair. (Thanks to Ted Clark)

Comments (3 posted)

OpenRelativity and A Slower Speed of Light

MIT's Game Lab has released a new beta of its relativistic physics simulation "game" A Slower Speed of Light; this edition runs on Linux in addition to other platforms. More interestingly, the Game Lab has also released the underlying physics engine, OpenRelativity, as an open source library—under the MIT License, which in this case is a relatively predictable choice.

Comments (none posted)

Newsletters and articles

Development newsletters from the past week

Comments (none posted)

Google Summer of Code 2013 projects unveiled

The list of accepted projects for Google Summer of Code (GSoC) 2013 has been posted online. Many mentoring organizations have written their own blog announcements, of course, but the full catalog is visible—and sortable—on the official page.

Comments (none posted)

Software Freedom Law Center Says Google's Draft VP8 Cross License is Compatible With FOSS Licensing (Groklaw)

Groklaw examines recent comments from the Software Freedom Law Center (SFLC) over the recently posted patent cross-license draft for Google's VP8 codec. The story quotes SFLC's Aaron Williamson on the subject, who notes that the agreement is "not perfect, but no other modern web video format provides nearly the same degree of protection for FOSS implementations."

Comments (none posted)

Page editor: Nathan Willis
Next page: Announcements>>

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds