Posts: 64
Joined: Wed Jun 13, 2012 6:06 am

SEVERE bug in sound driver

Fri Jul 20, 2012 11:46 pm

I just switched to raspbian today and noticed a very dangerous little bug. The sound driver doesn't seem to be able to keep the volume of the soundcard at a set level. I've looked around a bit for anyone having a similar problem and seemed to notice most people had "no sound" or "not the best sound" and that luckily nobody else has managed to almost blow out their eardrums. Hopefully I've posted this before anybody gets hurt.

Story goes as follows

Flashed Raspbian to card
first order of business is to play music
taking lessons from previous experience with command line music, alsamixer, set master volume to 15% for safety.
omxplayer Music/song.mp3
playback at 100% volume
check alsamixer, volume reads at 15%
okay, we have a little problem.

I now have a severe pain in my left ear and sensitivity to sound. Permanent damage? probably not. Should we fix this before giving it to school children? Definitely!

I haven't gotten past being able to reproduce bug on demand yet, as I went strait for posting it after a few tests. However I will be happy to post the required information on demand, I'm a linux power user so don't be afraid to ask for even the most obscure of system logs.

However, I will post the results of my tests to date.

After a first fruitless attempt at using vlc, I chmod 7777 the /dev/snd directory and everything in it. This worked, vlc played sound. The volume is set to 15% for safety but playback is at maximum. I open lxterminal and run alsamixer.I jab the 2 key quick to drop down to 20% the volume quickly starts behaving itself until the song finishes and vlc moves on to the next one. I am forced to alsamixer the sound down to 20% again even though it shows the mixer being at that level already. I drop down to a console and test with omxplayer. The sound is at 100% again. close out of omxplayer to check levels in alsamixer still at 20%. I install oss-compat so I can compile and run an mp3 player I wrote in C that uses hip_decode from libmp3lame. pumping decoded pcm buffers into /dev/dsp at 44khz, stereo, signed 16bit little endian samples produces the same general behavior as omxplayer. Here I start to suspect the driver itself rather than any particular player. and then it was over to raspberrypi forum.

Anybody else experiencing this bug? Any particular information you would like me to post? Thanks in advance.

Posts: 64
Joined: Wed Jun 13, 2012 6:06 am

Re: SEVERE bug in sound driver

Fri Jul 20, 2012 11:54 pm

Actually I should probably add that I was using a DVI monitor through the hdmi port (not using hdmi sound) and that I was using headphones on the analogue (I lacked a proper set of speakers).

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5664
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: SEVERE bug in sound driver

Sat Jul 21, 2012 9:21 am

omxplayer doesn't use ALSA, so it's unlikely it will ever use the alsamixer volume setting.

Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: SEVERE bug in sound driver

Sat Jul 21, 2012 12:39 pm

That explains the issue with omxplayer. I did check the problem with mplayer on my system and I can confirm that I do have the same issue. No matter what value the volume is set to, music is loud. I have to go to alsamixer and change the value a little and the volume instantly changes to the proper one.

Posts: 46
Joined: Sun Jun 24, 2012 11:29 pm

Re: SEVERE bug in sound driver

Sat Jul 21, 2012 5:51 pm

I believe the problem is caused by the initial volume value set by snd_bcm2835_new_pcm(...) in bcm2835-pcm.c (at the end). The value is 100, out of a range from -10320 to 400. That's about 97%, so it's no wonder it's loud. A value of -5000 would be safer, but maybe too soft for people to notice.

I'll do some testing of this later today; I already have a kernel compiled with audio debugging enabled, so creating a new snd_bcm2835 module shouldn't take too long.

Posts: 14
Joined: Mon Mar 05, 2012 3:47 pm

Re: SEVERE bug in sound driver

Sat Jul 21, 2012 10:39 pm

Install the Alsaplayer, I manage to play mp3 with that and the volumn is fine.

Return to “Raspberry Pi OS”