Ubuntu PA

From OMAPpedia

Jump to: navigation, search

Contents

[edit] Pulseaudio on Ubuntu for OMAP 4

[edit] What is Pulseaudio?

Some insights of what is PA and what you can do with it:

http://pulseaudio.org/wiki/AboutPulseAudio

http://en.wikipedia.org/wiki/PulseAudio#cite_note-8

And a diagram will also be useful:

http://en.wikipedia.org/wiki/File:Pulseaudio-diagram.svg

[edit] Setting up PA for OMAP4

Please make sure you have similar settings in your PA daemon configuration file. Uncomment/change the following lines from /etc/pulse/daemon.conf accordingly:

resample-method = speex-fixed-1
default-fragments = 2
default-fragment-size-msec = 10

You may want also to try:

resample-method = ffmpeg

instead of speex libraries.

Check also for the modules you use to launch PA server. You may want to have these modules NOT loaded at your /etc/pulse/default.pa, so be sure to comment them out:

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
#load-module module-console-kit
### Cork music streams when a phone stream is active
#load-module module-cork-music-on-phone
# X11 modules should not be started from default.pa so that one daemon
# can be shared by multiple sessions.
### Load X11 bell module
#load-module module-x11-bell sample=bell-windowing-system
### Register ourselves in the X11 session manager
#load-module module-x11-xsmp
### Publish connection data in the X11 root window
#.ifexists module-x11-publish.so
#.nofail
#load-module module-x11-publish
#.fail
#.endif


To start pulseadio (on a per-user basis) just run:

pulseaudio --start --log-target=syslog --exit-idle-time=-1

To shutdown pulseaudio sound server:

pulseaudio -k

[edit] Recording with PA

To get audio record from gst-pulse plugin (pulsesrc) working you have to specify which input you'll use. You can do it like this:

First figure out the name of the ALSA input device...run:

$ LANG=C pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2
alsa_output.platform-soc-audio.analog-stereo.monitor
alsa_input.platform-soc-audio.analog-stereo

Now, there are a couple of ways to setup gst-pulse to use the right ALSA input. The easiest way could be to export the PA source env variable with the alsa input device name, e.g.:

export PULSE_SOURCE=alsa_input.platform-soc-audio.analog-stereo

Then run gst command line like this:

gst-launch pulsesrc ! audio/x-raw-int,rate=8000,channels=1,width=16 ! queue ! audioconvert ! wavenc ! filesink location=rec.wav

Another option is to specify the ALSA input at the gst cmd line like this:

gst-launch pulsesrc device=alsa_input.platform-soc-audio.analog-stereo ! audio/x-raw-int,rate=8000,channels=1,width=16 ! queue ! audioconvert ! wavenc ! filesink location=rec.wav

Another way to specify the ALSA input device is to configure it statically at PA module loading initialization. Shutdown the PA server:

pulseaudio -k

Changes to /etc/pulse/default.pa require to tell PA server which ALSA hardware device represents the on-board microphone:

### Load audio drivers statically (it's probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
load-module module-alsa-source device=hw:0,2 source_name=input

Then you can make it the default input source like this (add this line in your /etc/pulse/default.pa):

### Make some devices default
set-default-source input

Restart PA server:

pulseaudio --start --log-target=syslog --exit-idle-time=-1

Then at gst level you'll only need to specify the device you'll use with the pulsesrc plugin:

gst-launch pulsesrc ! audio/x-raw-int,rate=8000,channels=1,width=16 ! queue ! audioconvert ! wavenc ! filesink location=rec.wav

[edit] PA through HDMI

One way to route the audio through HDMI is to configure PA to use HDMI output by default. Comment out this line in PA configuration file (/etc/pulse/default.pa):

#load-module module-udev-detect

Then in the same file instruct PA to route audio through the HDMI ALSA device:

load-module module-alsa-sink device=plughw:0,5 sink_name=output

And make it the default:

### Make some devices default
set-default-sink output

Then just restart PA daemon to make these changes take effect.

However there is another way, this time we'll setup the "default" PA sink dynamically. First let's setup the audio drivers statically instead of using the udev module. So be sure to include these lines on your /etc/pulse/default.conf:

load-module module-alsa-sink device=hw:0,5 sink_name=hdmi sink_properties=device.description=HDMI
load-module module-alsa-sink device=hw:0,0 sink_name=onboard format=s32le rate=48000 channels=2 sink_properties=device.description=Onboard_speakers

And comment out the udev module recognition:

#load-module module-udev-detect

Also add this parameter to the module-stream-restore:

load-module module-stream-restore restore_device=false

Restart PA.

Then to change to HDMI output run:

pacmd set-default-sink hdmi

And to get back onboard speakers run:

pacmd set-default-sink onboard

[edit] Volume control through ALSA

Setting the right volume of your board can be done in several ways.

[edit] Using alsamixer

This is by far the easiest way to set up your volume controls. Just run:

alsamixer

The alsamixer is self explanatory just make sure you turn on at least the HF Left and Right DACs, HS Left and Right DACs and adjust the respective volumes.

[edit] Using the cmd line

Run the amixer.sh script

amixer.sh -a

You should not see any error/warning messages. That should be enough to set up the proper volumes of the devices. To query the state of your devices run:

amixer controls

You should see something similar to this:

numid=3,iface=MIXER,name='Aux FM Volume'
numid=1,iface=MIXER,name='Capture Preamplifier Volume'
numid=2,iface=MIXER,name='Capture Volume'
numid=21,iface=MIXER,name='Analog Left Capture Route'
numid=20,iface=MIXER,name='Analog Right Capture Route'
numid=19,iface=MIXER,name='DL1 Mixer Multimedia'
numid=18,iface=MIXER,name='DL1 Mixer Multimedia Uplink'
numid=16,iface=MIXER,name='DL1 Mixer Tones'
numid=17,iface=MIXER,name='DL1 Mixer Voice'
numid=15,iface=MIXER,name='DL2 Mixer Multimedia'
numid=14,iface=MIXER,name='DL2 Mixer Multimedia Uplink'
numid=12,iface=MIXER,name='DL2 Mixer Tones'
numid=13,iface=MIXER,name='DL2 Mixer Voice'
numid=7,iface=MIXER,name='Earphone Driver Switch'
numid=6,iface=MIXER,name='Earphone Playback Volume'
numid=11,iface=MIXER,name='HF Left Playback'
numid=10,iface=MIXER,name='HF Right Playback'
numid=9,iface=MIXER,name='HS Left Playback'
numid=8,iface=MIXER,name='HS Right Playback'
numid=5,iface=MIXER,name='Handsfree Playback Volume'
numid=4,iface=MIXER,name='Headset Playback Volume'
numid=22,iface=MIXER,name='TWL6040 Power Mode'

So lets see if the head set left playback DAC is turned on:

amixer cget numid=9

You should see something similar:

numid=9,iface=MIXER,name='HS Left Playback'
  ; type=ENUMERATED,access=rw------,values=1,items=3
  ; Item #0 'Off'
  ; Item #1 'HS DAC'
  ; Item #2 'Line-In amp'
  : values=1

The "values=1" field indicate that the 'HS DAC' (HeadSet DAC) is turned on. You can check the HS right DAC in a similar way. To change the value, let's say turn it off run:

amixer cset numid=9 0

Now if you want to change the volume look at the numid for 'Handsfree Playback Volume' which in this case is numid=5, and you can change it this way:

amixer cset numid=5 20

This will increase/decrease the volume to 20 from it's previous value. If you query for the volume value do it this way:

amixer cget numid=5
numid=5,iface=MIXER,name='Handsfree Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=29,step=0
  : values=20,20
  | dBscale-min=-52.00dB,step=2.00dB,mute=0

And you should be able to see the "values=20,20" field set to the specified value.

Personal tools
Namespaces
Variants
Views
  • Read
  • Edit
  • View history
Actions
Navigation
Toolbox
  • What links here
  • Related changes
  • Special pages
  • Printable version