IVI/Genivi Audio Manager & Murphy Demo

From Tizen Wiki
< IVI
Jump to: navigation, search

Genivi Audio Manager PoC with Murphy

Summary

This wiki will provide you with instructions how to setup a demo with Genivi Audio Manager and Murphy.

Architecture

The idea in this demo is the co-existence of Tizen and Genivi way of audio management and playback. In Tizen we have native applications and webapps playing to pulseaudio with Murphy controlling the routing and audio policy automatically. In Genivi world apps are specifying themselves their routing target through Genivi Audio Manager and audio streaming interface and policy management engine is not specified. In this demo Murphy is acting as the policy backend of both Genivi and Tizen worlds (see fig 1).

POC architecture

When you are trying to run the demo, please connect your usb headset to the device, because otherwise the "dsp" pulseaudio is not able tot start!


For more detailed description of the ideas behind the demo see Janos Kovacs' presentation in ALS 2014 Tokyo:

File:Genivi-Tizen-harmonisation-with-Murphy-AGL-2014-Tokyo.pdf

Demo setup

In Tizen IVI reference hardware we don't have easy access to possible audio DSP resources so we are emulating the DSP part of the system with another Pulseaudio instance. We are also using Alsa Loopback device to act as a gateway between the MCU and DSP side pulseaudio instances. We have also done a generic Dbus routing daemon for Genivi Audio Manager to handle the dsp side routing and gateway registration.

To setup the demo you need to install couple of packages and some configuration files which you can found in the attached tarball (behind a link). In the tarball there's also a setup and remove shell scripts to help with the installation.


https://01.org/murphy/downloads/genivi-audio-manager-tizen-demo-configuration-files


1) zypper install genivi-audio-manager (comes with Murphy control plugin and generic dbus routing daemon)

2) zypper install murphy-gam (Murphy side plugin for genivi audio manager control)

3) copy the gam_demo.tar.gz to the device and extract it to some folder

4) run the setup.sh script to copy the contents to correct folders in the system

5) reboot

How do you know that the demo is running (and working)?

1. Check that you have all the necessary daemons running (for example with ps)

  - Murphy
  - 2 instances of pulseaudio's
  - AudioManager
  - domain-manager

2. Playback audio

Tizen player

For Tizen type of audio playback you can just use pulseaudio's paplay command line tool:


paplay --property=media.role=music test.wav


In this command you are specifying the stream type as "music" and Murphy will handle the routing for you.

Genivi player

In this demo "Genivi player" is a player that uses Genivi Audio Manager command interface for audio routing and stream state management. Genivi player is also outputting the audio to alsa by explicitly defining the alsa device. There is not too much this kind of example software existing so we created a Python script genivi.py to act as the Genivi player. The script is using the Genivi Audio Manager Dbus command interface.


python genivi.py -i radio -o speakers -f test.wav -d hw:Loopback,0,7


In this command line we are pretending to be the radio and we are trying to connect it to the speakers. File to be played is specified with -f and with -d you have to specify the alsa device you are going to use. In this setup we know that the particular alsa loopback device is "the" radio input.


Python has very good support for Dbus and all the dbus related packages are in Tizen, but unfortunately the audio stack is abstracted away so you can't choose easily what audio stack you would like to use. In the player script we are using:


http://pyalsaaudio.sourceforge.net/pyalsaaudio.html


Unfortunately this piece of sw is not part of Tizen, so you have to download the tar ball, transfer it to your device and compile and install it. However this should be rather easy and straight forward:

After you have moved and extracted the tar to the device:

zypper install gcc Python-devel libasound-devel

python setup.py build

python setup.py install

How to debug the demo

Well for this you need quite many ssh terminals but it is possible. There are some tricky environment variable settings you have to remember to do to get things working. You can use gdb in the normal fashion for all related components.

terminal 1:
murphyd -f -vvvv


terminal 2:
su -l app
export XDG_RUNTIME_DIR=/run/user/5000/
PULSE_SCRIPT=/etc/pulse/default.pa.mcu pulseaudio -vvvv


terminal 3:
su -l app
export XDG_RUNTIME_DIR=/run/user/5000/foo/
PULSE_SCRIPT=/etc/pulse/default.pa.dsp pulseaudio -vvvv


terminal 4:
su -l app
export XDG_RUNTIME_DIR=/run/user/5000/
AudioManager -V -c /usr/lib/audioManager/control/libPluginControlInterfaceMurphy.so


terminal 5:
su -l app
export XDG_RUNTIME_DIR=/run/user/5000/
domain-manager /etc/pulse/gam-demo.ini


terminal 6:
su -l app
export XDG_RUNTIME_DIR=/run/user/5000/
paplay --property=media.role=music test.wav


Configuration files in the tarball

  - alsa-aloop.service - systemd script to load alsa loopback module
  - pulseaudio-dsp.service & pulseaudio-mcu.service - 2 systemd scripts to start 2 instances of pulseaudio (mcu and dsp)
  - default.pa.dsp & default.pa.mcu - 2 pulseaudio configuration files for mcu and dsp pulseaudio's
  - audiomanager.service systemd script to launch genivi audio manager with Murphy controller plugin
  - domainmanager.service - systemd script to start the generic dbus routing daemon for genivi audio manager (called domainmanager)
  - gam-demo.ini - configuration file for the domainmanager to load correct sink, sources and gateways
  - connect-dsp.sh & disconnect-dsp.sh - scripts for the domain manager to route in the dsp domain
  - genivi.py - python script to emulate genivi application by using genivi audio manager and alsa
  - setup.sh & remove.sh - shell scripts to copy and remove the above files to correct places in the system

Configuration of the audio system and policy logic

Currently it is not very easy to change the configuration of the demo audio system or the policy logic related to it. We are working on a "semi-automated" tool to make the configuration easier.