How to configure&use audio manager

Audio Manager

Introduction

Audio manager could be used to give different priorities to different audio streams, so that AM could pause/mute resume/unmute according to properties of audio streams. NOTE: pause/resume need app's cooperation, AM send out DBUS signals, AM compliant app should listen to signals and perform pause/resume actions; if app is not AM-compliant, their audio stream will only be muted/unmuted. This document illustrates how to configure different audio apps to different properties for AM.

Audio Manager Configuration

Basically, audio manager is a module of Pulse Audio, and it needs an argument when loading, this argument is the file path of the AM configuration file.
In /etc/pulse/default.pa, user could add one line
load-module module-audiomanager conf_path="/etc/pulse/policy.conf"
The policy.conf file contains detailed information, below is a simple example of policy.conf, and then each section will be explained.

[device]
{
  name = MUSIC
  prio = 3
}

[app]
{
  name = seek
  mixable = FALSE
  action = pause
  device = MUSIC
  media_role=ringtone
  exceptions=(seek2,seek3)
}

[app]
{
  name = seek1
  mixable = TRUE
  action = pause
  device = MUSIC
  media_role=game
}

[app]
{
  name = seek2
  mixable = TRUE
  action = mute
  attenuation=10
  media_role=music
}

[priority_mapping]
{
  alert_high = 5
  alert_med = 4
  alert_low = 2
  ringtone=5
  music = 4
  video = 4
  voip = 3
  csv = 2
  game= 1
}

Audio Manager Configuration Syntax

device

The device section actually is to give different device different priorities, so that when an app has no preferred device set(device property in app section is not set), AM will choose a device of highest priority among all available devices. NOTE: If AM general module is not co-working with any platform specific modules, this section is useless. and if AM general module is co-working with platform specific module, such as MRST platform specific module, to configure the priority of the device reported by MRST module, the name property in device section should be the same as the device name reported by MRST specific module. It is not recommended to configure device priority, because when MRST module report devices, it has already given proper priorities to all devices.

app

The app section is to configure app to different properties, such as priority, prefered device, willing to mix or not...

  • name - the binary name of the app; when AM detects an incoming stream, AM will check where the audio stream come from, if the binary name of the audio stream is the same as the name here, AM will attach all properties configured here to that audio stream.
  • mixable - [TRUE|FALSE] whether the app willing to mix or not
  • action - [pause|mute] the action to perform when this app is determined to obey to other apps. if pause is configured, AM will not only mute(with ramping) the app's stream internally, but also send out DBUS signal to notify app to do pause; and when this app could resume, AM will not only unmute(with ramping) the app's stream, but also send out DBUS signal to notify app to do resume
  • device - the preferred device of app; if app has a preferred device, AM will always try to satify its preference as long as other stream of higher priority choose the other device which could co-exist with this preferred device; if app has no prefered device, AM will choose a device of highest priority among all available devices
  • media_role - the media role of the app, actually represents its priority
  • attenuation - [1-99] the volume when app's stream is running together with a stream of higher priority. 10 represents 10%; if attenuation is set, the app's volume will be decreased when running together with other streams of higher priority, if attenuation is not set, the app's volume remains the same when running with other streams of higher priority
  • exceptions - the exception list of app. if app is configured be mixable, the exception list is a list that app *not* willing to mix with, if app is configured to be unmixable, the exception list is a list that app willing to mix with

priority_mapping

This section actually gives out the mapping between media_role and priority. The higher the value, the higher the priority.

Example Explaination

  1. seek is of highest priority, and not willing to mix; so that when the audio stream of seek is running, the audio streams of seek1, and seek2 will be affected; seek1 will be paused, but seek2 will only be volume down, since seek2 is inside seek's exception list
  2. If a BT headset is connected, only audio stream of seek2 will be transported to BT headset; because both seek and seek1 has prefered device set, their preferred device will always be satisfied in the first place. but for seek2, AM always choose a device of highest priority among all available devices, since BT become available, AM will move audio stream of seek2 to BT headset