problems with ALSA

214 views
Skip to first unread message

Murali K. Vemuri

unread,
Dec 22, 2010, 5:57:08 AM12/22/10
to android...@googlegroups.com
Hello group,

I am using LINUX with Android on OMAP3530 and am finding Audio is not working.
I tried checking the "logcat" and the output:

W/AudioHardwareALSA( 1020): Unable to attach mixer to device AndroidOut: Invalid argument                                                                                                               
W/AudioHardwareALSA( 1020): Unable to attach mixer to device AndroidIn: Invalid argument                                                                                                                
I/CameraService( 1020): CameraService started: pid=1020                                                                                                                                                 
D/AudioHardwareALSA( 1020): openOutputStream called for devices: 0x00000002                                                                                                                             
D/ALSAModule( 1020): open called for devices 00000002 in mode 0...                                                                                                                                      
E/ALSALib ( 1020): external/alsa-lib/src/pcm/pcm.c:2201:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker_normal                                                                              
E/ALSALib ( 1020): external/alsa-lib/src/pcm/pcm.c:2201:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker                                                                                     
E/ALSALib ( 1020): external/alsa-lib/src/pcm/pcm.c:2201:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback                                                                                             
D/AndroidRuntime( 1018): --- registering native functions ---                                                                                                                                           
I/ALSAModule( 1020): Initialized ALSA PLAYBACK device default                                                                                                                                           
I/AudioFlinger( 1020): AudioFlinger's thread 0x53018 ready to run                                                                                                                                       
D/ALSAModule( 1020): route called for devices 00000002 in mode 0...    

Any pointers????

Thanks & regards
Murali

srinath ramini

unread,
Dec 22, 2010, 10:14:06 AM12/22/10
to vemuri.mur...@gmail.com, android...@googlegroups.com
Hi Murali,
 
Please check your /etc/asound.conf file. File should conatin Hardware configuration details.
 
Regards,
Sreenath


Murali K. Vemuri

unread,
Dec 25, 2010, 7:11:53 AM12/25/10
to srinath ramini, android...@googlegroups.com
Hello there,
Sorry for the delayed reply. I see these log messages on "logcat":

E/AudioHardwareALSA( 1031): ERROR PIPE (underflow), resetting to RECOVER!!                                                                                                                                                                 
E/AudioHardwareALSA( 1031): 

and since I am not very familiar with the android config files, I am attaching my default config file. Can someone help me?

Thanks &regards
Murali
asound.conf

srinath ramini

unread,
Dec 27, 2010, 9:48:01 AM12/27/10
to Murali K. Vemuri, android...@googlegroups.com
Hi Murali,
 
In your asound.conf file AndroidPlayback pcm configuration details are not avilable. 
 
Replace your asound.conf with the following content and try it. 

##

## Mixer Devices

##

ctl.AndroidPlayback {

type hw

card 1

device 0

}

ctl.AndroidCapture {

type hw

card 1

device 0

}

 ##

## Playback Devices

##

pcm.AndroidPlayback {

type hw

card 1

device 0

}

 ##

## Recording device

##

pcm.AndroidCapture {

type hw

card 1

device 0

}

 

Regards,

Sreenath

Murali K. Vemuri

unread,
Jan 2, 2011, 8:04:27 AM1/2/11
to srinath ramini, android...@googlegroups.com
Hello Srinath and group,
 
I made the changes in asound.conf and also I found some h/w errors and also some issues at driver, and fixed one by one. Finally I checked the BIT(or Serial) CLK & LR (Left-Right) CLK for my codec, once I got all these right, now I have the "logcat" filled with these log messages.
 
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioFlinger( 1054): write blocked for 9999 msecs, 5 delayed writes, thread 0x539c0
W/AudioFlinger( 1054): write blocked for 9999 msecs, 6 delayed writes, thread 0x539c0
W/AudioFlinger( 1054): write blocked for 9999 msecs, 7 delayed writes, thread 0x539c0
W/AudioFlinger( 1054): write blocked for 9999 msecs, 8 delayed writes, thread 0x539c0
I googled on this, but nothing much I could use on this error.
 
Any pointers???
Thanks & regards
Murali
--
न चोर हार्यं न च राजहार्यं 
न भ्रातृभाज्यं न च भारकारी 
व्ययी कृते वर्धत एव नित्यं 
विद्या धनं सर्व धनं प्रधानं 
Thieves cannot steal it, Kings cannot tax it, 
Siblings cannot demand a share in it, and it does not weigh a lot, 
The more you spend it, increases every day, 
the wealth of knowledge is the PRIME WEALTH .

Amit Pundir

unread,
Jan 3, 2011, 2:15:23 AM1/3/11
to vemuri.mur...@gmail.com, srinath ramini, android...@googlegroups.com
On Sun, Jan 2, 2011 at 6:34 PM, Murali K. Vemuri <vemuri.mur...@gmail.com> wrote:
Hello Srinath and group,
 
I made the changes in asound.conf and also I found some h/w errors and also some issues at driver, and fixed one by one. Finally I checked the BIT(or Serial) CLK & LR (Left-Right) CLK for my codec, once I got all these right, now I have the "logcat" filled with these log messages.
 
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioTrack( 1054): obtainBuffer timed out (is the CPU pegged?) 0x61e60 user=00003000, server=00001000
W/AudioFlinger( 1054): write blocked for 9999 msecs, 5 delayed writes, thread 0x539c0
W/AudioFlinger( 1054): write blocked for 9999 msecs, 6 delayed writes, thread 0x539c0
W/AudioFlinger( 1054): write blocked for 9999 msecs, 7 delayed writes, thread 0x539c0
W/AudioFlinger( 1054): write blocked for 9999 msecs, 8 delayed writes, thread 0x539c0
I googled on this, but nothing much I could use on this error.

Hi Murali,

I got a similar issue sometime back on a different platform. In my case the issue was with my audio driver which was not able to reset the device properly. This causes the write to the Audio device to block indefinitely and the buffers never got freed and thats why I was getting "unable to obtain buffer, cpu pegged?" error.

1) Recommended solution is to debug your audio driver and check if it handles suspend/resume mode properly.
2) A quick fix is to modify the Android user space and don't let your audio go in stand-by mode.

As far as OMAP3 is concerned try Rowboat, Android port http://code.google.com/p/rowboat/ which has
Android base port available for TI OMAP35x, AM35x, AM37x and DM37x platforms.

Regards,
Amit Pundir

Murali K. Vemuri

unread,
Jan 4, 2011, 9:50:56 PM1/4/11
to Amit Pundir, srinath ramini, android...@googlegroups.com
Okay, 
I kept digging further and finally found that my driver is going to XRUNs whenever I try to load any piece of audio .

when my board completed booting, the params look like:

#cat /proc/asound/card0/pcm0p/sub0/status
state: PREPARED
owner_pid   : 1055
trigger_time: 0.000000000
tstamp      : 10.809844973
delay       : 0
avail       : 2048
avail_max   : 0
-----
hw_ptr      : 0
appl_ptr    : 0

But when android tries to play the booting sound, it immediately changes to the following. And is not able to recover .

#cat /proc/asound/card0/pcm0p/sub0/status
state: XRUN
owner_pid   : 1055
trigger_time: 30.074615484
tstamp      : 39.793883833
delay       : 0
avail       : 2048
avail_max   : 2083
-----
hw_ptr      : 2048
appl_ptr    : 2048


I am using Android RowBoat version and I am not sure if it is a known issue or has some_fix_I_did_not_adapt.

any ideas?

Thanks & regards
Murali

Amit Pundir

unread,
Jan 5, 2011, 1:07:15 AM1/5/11
to Murali K. Vemuri, android...@googlegroups.com, row...@googlegroups.com
looping in rowboat mailing list.

Which Android version(Eclair, Froyo etc) are you using? Are you building the images yourself or using the pre-built images?

You don't need asound.conf for Android 2.2(Froyo) Rowboat port AFAIR. I have used Rowboat froyo port on OMAP3EVM and Beagleboard as well and found no such issues with sound.

Regards,
Amit Pundir
 

Murali K. Vemuri

unread,
Jan 5, 2011, 1:45:16 AM1/5/11
to Amit Pundir, android...@googlegroups.com, row...@googlegroups.com
Hi Amit & group,
I am using Eclair. 

My board is a custom board and I am making changes in the EVM kernel to match to my board.
my Audio Codec is WM8993 (WolfSon Microelectronics). Little more info into the pin connections is:

1. I connected the OMAP 3530 MCBSP2  (phys_base: 0x49022000) to WM8993 for Audio data. (MCBSP2 DX2 --> AUDIO CODEC DX) & (MCBSP2 DR2 --> AUDIO CODEC DR)
2. WM8993 is Clock master, and sends the SCLK (MCBSP FSX) & LRCLK (MCBSP CLKX) to MCBSP. I checked with Oscilloscope that these clocks are fine.
3. WM8993 is controlled using the I2C3 of OMAP.
4. Data format between MCBSP and Audio CODEC is I2S  (with no companding)


This is the MCBSP register dump:
omap-mcbsp omap-mcbsp.2: **** McBSP2 regs ****
omap-mcbsp omap-mcbsp.2: DRR2:  0xddbe3b7d
omap-mcbsp omap-mcbsp.2: DRR1:  0x0000
omap-mcbsp omap-mcbsp.2: DXR2:  0x0000
omap-mcbsp omap-mcbsp.2: DXR1:  0x0000
omap-mcbsp omap-mcbsp.2: SPCR2: 0x02f5
omap-mcbsp omap-mcbsp.2: SPCR1: 0x0030
omap-mcbsp omap-mcbsp.2: RCR2:  0x8041
omap-mcbsp omap-mcbsp.2: RCR1:  0x0040
omap-mcbsp omap-mcbsp.2: XCR2:  0x8041
omap-mcbsp omap-mcbsp.2: XCR1:  0x0040
omap-mcbsp omap-mcbsp.2: SRGR2: 0x001f
omap-mcbsp omap-mcbsp.2: SRGR1: 0x0f00
omap-mcbsp omap-mcbsp.2: PCR0:  0x0a0f
omap-mcbsp omap-mcbsp.2: ***********************

please let me know if you need more info.
Thanks & regards
Murali

ani

unread,
Jan 6, 2011, 10:09:41 AM1/6/11
to android-porting
Hello Murali,

Generally XRUN happens due to improper buffer size settings.Try
changing your buffer size.
You can use aplay utility to check different buffer sizes and for
recording you can use arecord.

Still if it doesn't work then it would be better if you can show us
the driver logs.Enable logs in your audio driver and ALSA core.

^^^keep trying^^^

On Jan 5, 11:45 am, "Murali K. Vemuri"
> >>>http://code.google.com/p/rowboat/which has Android base port available
> >>>>> vemuri.muralikris...@gmail.com> wrote:
>
> >>>>>> Hello there,
> >>>>>> Sorry for the delayed reply. I see these log messages on "logcat":
>
> >>>>>> E/AudioHardwareALSA( 1031): ERROR PIPE (underflow), resetting to
> >>>>>> RECOVER!!
>
> >>>>>> E/AudioHardwareALSA( 1031):
>
> >>>>>> and since I am not very familiar with the android config files, I am
> >>>>>> attaching my default config file. Can someone help me?
>
> >>>>>> Thanks &regards
> >>>>>> Murali
>
> >>>>>> On Thu, Dec 23, 2010 at 12:14 AM, srinath ramini <
> >>>>>> raminisrin...@gmail.com> wrote:
>
> >>>>>>> Hi Murali,
>
> >>>>>>> Please check your /etc/asound.conf file. File should conatin Hardware
> >>>>>>> configuration details.
>
> >>>>>>> Regards,
> >>>>>>> Sreenath
>
> >>>>>>>   On Wed, Dec 22, 2010 at 4:27 PM, Murali K. Vemuri <
> >>>>>>>> unsubscribe: android-porti...@googlegroups.com<android-porting%2Bunsu...@googlegroups.com>
> >>>>>>>> website:http://groups.google.com/group/android-porting
>
> >>>> --
> >>>> न चोर हार्यं न च राजहार्यं
> >>>> न भ्रातृभाज्यं न च भारकारी
> >>>> व्ययी कृते वर्धत एव नित्यं
> >>>> विद्या धनं सर्व धनं प्रधानं
> >>>> Thieves cannot steal it, Kings cannot tax it,
> >>>> Siblings cannot demand a share in it, and it does not weigh a lot,
> >>>> The more you spend it, increases every day,
> >>>> the wealth of knowledge is the PRIME WEALTH .
>
> >>>>  --
> >>>> unsubscribe: android-porti...@googlegroups.com<android-porting%2Bunsu...@googlegroups.com>
> >>>> website:http://groups.google.com/group/android-porting
>
> >> --
> >> न चोर हार्यं न च राजहार्यं
> >> न भ्रातृभाज्यं न च भारकारी
> >> व्ययी कृते वर्धत एव नित्यं
>
> ...
>
> read more »

Murali K. Vemuri

unread,
Jan 18, 2011, 4:11:23 AM1/18/11
to anish198...@gmail.com, android-porting
Hello group,
Its been a while since I had a word with the group. 

Finally I have to say, my AUDIO is working. If interested, please read through.

1. I am not sure if anybody remembered my h/w configuration, I have connected WM8993 Audio Codec on OMAP3530 MCBSP2.
2.for the Serial CLK (BCLK) & LR CLK (Frame sync clock) WM8993 is master and OMAP MCBSP2 is slave.

Apart from  n number of H/W issues my board ran into, the most important change from MCBSP side:

PCR0 & XCCR  registers of MCBSP.  For my setup, PCR0: 0x000f &  XCCR: 0x1808 were the working values.

Once this was set, it got rid of all the stupid errors I was previously getting like "obtainBuffer timed out" or "ERROR PIPE (underflow), resetting to RECOVER!!"

after that, I had to correct a few registers on the WM8993 as well to get the audio output.

So, the key lesson is:

1. Check the H/W connections a thousand times
2. Check the MCBSP registers, especially SPCR1, SPCR2, PCR0, XCCR, SRGR1, SRGR2.
3. Check your audio codec and the configuration for the codec.

Thanks & regards
Murali


Reply all
Reply to author
Forward
0 new messages