[alsa-devel] Alsa: Get Playback Volume fails if set by outside source

Jaroslav Kysela perex at perex.cz
Fri May 16 09:42:21 CEST 2008


On Fri, 16 May 2008, Ashwin Chandra wrote:

> Hello,
> 
> I am having an issue with the Alsa mixer. Currenty I have a function
> that gets the volume via snd_mixer_selem_get_playback_volume. This
> function works fine to get the last-set volume if my application is
> setting the volume. However if I change the volume using an outside
> source, such as alsamixer or gnome-volume-control and then I run the
> above function, the old volume that my application had set last is
> returned.
> 
> Now I edited amixer's source code to put a while(1) around the same
> functions (the snd_mixer_selem_get_playback_volume), and it too does not
> get the correct volume if set from an outside source. Alsamixer on the
> other hand seems to work find, but I am not quite sure how they do it. I
> thought maybe I had to reinitialize the alsa interface (ie.
> snd_mixer_close...and then open, attach, register, etc), but it doesn't
> seem that alsamixer does that. 
> 
> Does anyone have any suggestions about what I can do to get the correct
> volume if set by an outside source??

snd_mixer_handle_events() is function which updates changed controls. 
Values are cached.

						Jaroslav

-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.



More information about the Alsa-devel mailing list