I ran into an interesting problem today.

I noticed I don't have a "Master" channel in amixer. I only have PCM. And changing the volume on PCM is really finicky. It seems only 85%+ is actually audible, even though 100% is too loud.

I started poking around to see if I could figure out how to add the "Master" channel, and something broke with my audio. When I start playing something (via omxplayer or mpg123 or whatever), it ignores my current volume setting and plays at 100%. I can look at amixer during playback and see that my volume setting is still as I left it.

The volume will play at 100% regardless of the setting before playback. However, I can change the volume with amixer during playback, and it will work as expected.

Does anybody know what's going on?

  • I don't mean to try to turn you away, but it sounds like the sound output is working and you can control the volume in a limited way. You might have better luck with answers to this question on the linux/unix stack exchange unix.stackexchange.com/ also could you mention which distro you're using? – Dan B Jul 25 '12 at 14:03
  • I'm using Raspbian. – user433194 Jul 25 '12 at 14:27

First of all, omxplayer does not use ALSA at all. It bypasses it using OpenMAX IL so you can't control it's volume using amixer. There is known bug in RPi ALSA driver that ignores volume settings at the start of playback and always plays at max volume. You can only change the volume after playback is started. There was a patch that may fix this to the kernel recently (August 07), here is the link to to github. You should be able to test it after updating your firmware files to the newest ones from github (i.e. using rpi-update tool).

  • Aha, thank you very much! I'll try this when I get home from work. That bug sounds like exactly what I'm experiencing. – user433194 Aug 13 '12 at 19:09

I struggled with this problem over the weekend and found a workaround - before seeing the answer here concerning the patch. Ah well.

For my application, I am only using the line out jack, and nothing is connected to the HDMI port that has audio output capability. So a workaround in this case would be:

  1. Switch the audio to the unused output with sudo amixer cset numid=3 <n> - where is 0=auto, 1=headphones, 2=hdmi. For me, n=2
  2. Start the audio player
  3. Set the volume with amixer to whatever volume you want
  4. Set the audio to the desired output with same command as in 1, but change to that output you want.

I am using pianobar, so there a moment between starting it and audio coming out where you can execute these commands and not be the wiser. I don't have the experience to tell you how this might work if you wanted audio output at the correct volume very shortly after starting your particular audio player.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.