Hi all, Welcome everybody, as this is my first mail to the list. I am trying to write my first ALSA audio program, and I have intermittent issues I can't explain. I connect to a Windows Server 2008 R2 RDSH server, play mp3 file in Windows Media Player. Before apply the patch, underrun occurs much in the beginning, and less after a while. R/ChipCommunity: This is the home of the community centered around the C.H.I.P. Single-board computer made by Next Thing Co. Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts. ALSA lib pcm.c:7843:(sndpcmrecover) underrun occurred? Am I the only one getting this error?
The ALSA library API is the interface to the ALSA drivers. Developers need to use the functions in this API to achieve native ALSA support for their applications. The ALSA lib documentation is a valuable developer reference to the available functions. In many ways it is a tutorial. Clone via HTTPS Clone with Git or checkout with SVN using the repository’s web address.
Sound configuration on Raspberry Pi with ALSA
While setting up a Raspberry Pi to play streamed music usingUPnP,I have had quite a bit of trouble understanding how to configure thesound on my Raspberry Pi. This is partly because I am running it inheadless mode (no graphical desktop) and partly because sound on Linuxis fiendishlycomplicated.
Anyway, I am making progress in understanding what’s going on but I amno expert. Here are my findings on how to control the ALSA system fromthe command line. All I am focussed on here is getting control of thesound output by the 3.5mm stereo socket. If you want to control theoutput over the HDMI socket or an external USB sound card then you’llneed to do some of your own investigation.
ALSA is the lowest level of the Linux sound stack. The alsa-utilspackage comes ready installed on the debian wheezy distribution I amusing (2012-12-16-wheezy-raspbian.zip). It provides some usefulcommands: amixer, alsamixer, alsactl, aplay and speaker-test.
Testing
It’s good to be able to test things as you go a long to see what affectconfiguration changes have. You can do this with the speaker-testcommand for one, which will by default play white (actually pink) noiseout of the speakers. Press Ctrl-C to stop it.
Another command to try is aplay. This command will play WAV files forinstance as well as lots of other basic sound file types (but not thingswith complex compression such as MP3, FLAC, OGG, etc). The Pi comes withsome sound files already present, for instance in/usr/share/scratch/Media/Sounds. Try:
Feb 28, 2019 While unc0ver jailbreak is highly stable, you are just an incompatible tweak away from making it unstable. Here’s how you can delete unc0ver jailbreak from your iPhone or iPad on iOS 12 and start afresh. And once unc0ver release public version, 3uTools will add support as soon as possible. Unc0ver jailbreak 11.4-12.4 3utools jailbreak. Posted on October 14, 2019 by anusha7 — No Comments ↓ 3utools jailbreak ios 12.4. Ios users who like to customize their idevice using beyond the Apple app store install cydia apps need to jailbreak their i-device. Unc0ver with 3utools. Posted by 4 months ago. Unc0ver with 3utools. How can I install unc0ver on my phone (not jailbreaking installing uncover) 7 comments. Save hide report. 100% Upvoted. Log in or sign up to leave a comment log in sign up. Top (suggested) level 1. 3utools unc0ver 13.3. Aug 19, 2019 Along with the update of unc0ver, you can now jailbreak your iOS 12.4 devices on 3uTools. For those who are interested, we are writing this tutorial to help you out. Supported systems: iOS 12.4. Supported devices: A7 - A11 (A12 is not supported).
To get more information while the sound is playing, use the “-v” and“-V” options, e.g.
That will print a lot of info about the sound file and what device it isbeing sent to as well as a VU meter as the sound plays.
To see the available devices, use aplay -L. My machine gives thisoutput (since installing PulseAudio):
It shows that the default device to use is directly to the ALSA device.Interestingly, if I try to play via PulseAudio using aplay with aplay-D pulse then I get a bit of a pop but no sound…
amixer
Looking at the top part of the output, we can see that the playbackvolume for the left and right channels are both at maximum (65536, whichis 2^16) and are both unmuted (“on”).
To control these settings we can use the alsamixer command which gives agraphical display (in your terminal) or the amixer command. Let’s lookat amixer first:
That’s the list of things you can change (control) through the command.We can look at the playback volume in more detail:
This shows the maximum and minimum values for the playback volume andthat it is actually a pair of values (for left and right channels). Forinstance, to change the playback volume we can do:
If you wanted to change the left channel to 50% and the right to 100%for some reason then this command is for you:
To mute the sound you can you control 4:
This also affects the volume values on control 3:
However, the value of the volumes must be stored somewhere because whenyou unmute it again it restores them.
I have found odd effects when changing the volume while it is muted sobest to avoid doing that.
Alsa_dev C Pb_thread_func Underrun For SaleSaving the ALSA state
The operating system saves the ALSA sound configuration when you turn itoff and restores it when you turn it on. This is done with the/etc/init.d/alsa-utils script. The state is stored and restored usingthis file: /var/lib/alsa/asound.state
Once you have the sound configuration as you want it you can store itthere using the alsactl command which you have to run with rootpermissions as it changes a protected file. Let’s set the volume to max,unmute it and store it:
Alsa_dev C Pb_thread_func Underrun Mean
For me, this gives this changes /var/lib/alsa/asound.state to be:
Alsa_dev C Pb_thread_func Underrun File
If we mute it then have another look, line 5 changes to “value -10239”,line 13 changes to “dbvalue.0 -9999999” and line 19 changes to “false”.
If we were to unmute and then set the volume to 50% (as described above)then line 5 changes to “value -1405” and line 13 to “dbvalue.0 -1405”(with line 19 being now set to “true”). Not quite sure where thesenumbers come from, they are probably the decibel volumes which arelogarithmic, but let’s not go there…
If you want to stop the current state being saved when the machine shutsdown then you need to disable the alsa-utils init script from runningwhen the machine enters runlevel 0 (halt) and 6(reboot). Aslightly hacky way of doing this is to execute these commands:
Note that the files have been renamed to have a lowercase “k” at thestart. When the machine enters runlevel 0 for instance (it does thiswhen shutting down) all the scripts starting with “K” in the /etc/rc0.dfolder are executed. By renaming it to start with a lowercase “k” thefile is ignored and the ALSA state is not saved.
alsamixer
As well as using amixer on the command line to change the volumes and soon, you can also use a slightly graphical utility called alsamixer. Justtype alsamixer and you’ll get something like the screenshot shown below:
In this utility you can move the volume up and down using the up anddown cursor keys, mute and unmute using the “m” key and move from onedevice to another (if you have them) using the left and right cursorkeys. Press the Esc key to exit. If you play with this and then typeamixer once you’ve exited then you’ll see that the changes arereflected in the output of that command as well.
Final thoughts
I hope that’s useful to someone like me who is struggling to understandall this. It is only one part of the stack, so I hope to look intoPulseAudio in more detail another time as I think that’s where myproblems are at the moment.
One last thing: if you completely mess things up then this commandshould sort it all out and make things sane again (sets volume to 44%for me):
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2020
Categories |