ALSA headache Raspberry Pi

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I never have not so and probably will never fully understand alsa,
frankly it and I do not get along.........

I have a process that has opened alsa blocking
rc = snd_pcm_open (&playback_handle, device, SND_PCM_STREAM_PLAYBACK, 0);


Then its done a lot of tedious setup.

Then I :
reta = snd_pcm_writei (playback_handle, bufptr, numrecs);               // Write interleaved

Ok, all plays ok.

But every so often the process underruns, freezes and does "weird shit".

In my main playback loop I do this :
  framesleft=snd_pcm_avail (playback_handle);
  printf("framesleft=%d\n",framesleft);

And get every growing numbers, followed by an underrum then growing numbers again ?

I can not understand why ! 

If snd_pcm_writei blocks until it has enough room in whatever cache its
using then WHY is the cache size growing, I should only be able to stuff
data in at the playback rate (at least once the cache is filled and its
only 80ms long) ?

"Frames ready to be written" ? Is this not the cache line length in some
way ?

Anyone know what is wrong?

The problem is on the raspberry Pi board, the PC gives this :

framesleft=3693
framesleft=3181
framesleft=2669
framesleft=2157
framesleft=1645
framesleft=1133
framesleft=621
framesleft=109
framesleft=3581
framesleft=3069
framesleft=2557
framesleft=2045
framesleft=1533
framesleft=1021
framesleft=509
framesleft=3911
framesleft=3399

Ok, jittery but plausible.

The Pi gives this :

framesleft=1138212
framesleft=1138212
framesleft=1139096
framesleft=1139536
framesleft=1139976
framesleft=1141300
framesleft=1141300
framesleft=1141740
framesleft=1142180
framesleft=1142624
framesleft=1143064
framesleft=1143944
framesleft=1143944
framesleft=-32
player: playsample() - underrun,  ALSA lib pcm.c:7339:(snd_pcm_recover)
underrun occurred
 OK, managed recover !   
framesleft=5160
framesleft=5160


Any ideas ?

And for many tedious reasons I cant simply use the callback, I am
compiling multiple versions of the application,  writing data to 2 other
sound systems and at least one of them I have to poll.....

Thanks,
Jon



------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user




[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux