why do elements disappear?
Hi,
a mixer app of mine (you know, one of those controlling volumes) is updating itself (if other apps change settings) by continuously running get-volume (et al) on all mixer elements every once in a while (10Hz). Right, so I could use signals or whatever it is that libalsa provides, but this is what OSS and such require, so I'm using this for now. This all works really well, except if new applications are started accessing the soundcard and the soundcard is a sb!live (which is true for quite a bunch of people). It will then sometimes crash. Backtraces look like this:
#3 <signal handler called> #4 0x001ef7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #5 0x023cb955 in raise () from /lib/tls/libc.so.6 #6 0x023cd319 in abort () from /lib/tls/libc.so.6 #7 0x023c4f41 in __assert_fail () from /lib/tls/libc.so.6 #8 0x00b5e237 in snd_mixer_selem_get_playback_volume ()
from /lib/libasound.so.2
Here's some more debug on the track we're accessing (this is GStreamer information, but you'll get the idea):
(gdb) print *alsa_track
$1 = {parent = {parent = {g_type_instance = {g_class = 0x8a37870}, ref_count = 3, qdata = 0x8ab1528}, label = 0x8a63488 "EMU10K1 PCM", flags = GST_MIXER_TRACK_OUTPUT, num_channels = 3, min_volume = 0, max_volume = 65535}, element = 0x8a7bb00, track_num = 40, alsa_flags = 2, volumes = {65535, 65535, 65535, 0 <repeats 29 times>}}
OK, so this is specific to the EMU10K1 PCM tracks (there's 32 of them). Those are *not* the first elements, definately, I don't know what they do exactly though though... But it's something specific to them.
I figured I could be an idiot, so here's valgrind:
==20529== Invalid read of size 4
==20529== at 0x1BB870B0: snd_mixer_selem_has_playback_switch (in/lib/libasound.so.2.0.0)
==20529== by 0x1D01AB2B: gst_alsa_mixer_update (gstalsamixer.c:412)
==20529== by 0x1D01AC4A: gst_alsa_mixer_get_volume
(gstalsamixer.c:439)
==20529== by 0x1C416998: gst_mixer_get_volume (mixer.c:185)
==20529== Address 0x1CE2B678 is 0 bytes inside a block of size 44 free'd
==20529== at 0x1B904FB1: free (vg_replace_malloc.c:153)
==20529== by 0x1BB8390C: snd_mixer_elem_remove (in/lib/libasound.so.2.0.0)
==20529== by 0x1BB86630: (within /lib/libasound.so.2.0.0)
==20529== by 0x1BB8668C: (within /lib/libasound.so.2.0.0)
It appears that alsa removes the EMU10K1 PCM elements when I call snd_mixer_handle_events(). Why does it do that, how do I make it stop doing it and/or how do I handle this?
Thanks,
Ronald
Signature · 9 lines
Ronald S. Bultje <[email protected]> ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
At Tue, 15 Feb 2005 22:12:53 +0100,
Quoted 6 lines · Ronald S. Bultje
Hi,
a mixer app of mine (you know, one of those controlling volumes) is updating itself (if other apps change settings) by continuously running get-volume (et al) on all mixer elements every once in a while (10Hz).
Well, this isn't a good idea. You should do update passively via poll(). The exception is a control with VOLATILE flag like VU meter, which won't send change notification. But normal controls send notification if the value is changed, or the control is created/deleted, so that the app can react.
Quoted 46 lines
Right, so I could use signals or whatever it is that libalsa provides, but this is what OSS and such require, so I'm using this for now. This all works really well, except if new applications are started accessing the soundcard and the soundcard is a sb!live (which is true for quite a bunch of people). It will then sometimes crash. Backtraces look like this:
#3 <signal handler called> #4 0x001ef7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #5 0x023cb955 in raise () from /lib/tls/libc.so.6 #6 0x023cd319 in abort () from /lib/tls/libc.so.6 #7 0x023c4f41 in __assert_fail () from /lib/tls/libc.so.6 #8 0x00b5e237 in snd_mixer_selem_get_playback_volume ()from
/lib/libasound.so.2Here's some more debug on the track we're accessing (this is GStreamer information, but you'll get the idea):
(gdb) print
*alsa_track
$1 = {parent = {parent = {g_type_instance= {g_class=0x8a37870},ref_count= 3, qdata =0x8ab1528}, label =0x8a63488"EMU10K1 PCM", flags =GST_MIXER_TRACK_OUTPUT,num_channels= 3,min_volume= 0,max_volume= 65535}, element =0x8a7bb00,track_num= 40,alsa_flags= 2, volumes = {65535, 65535, 65535, 0 <repeats 29 times>}}OK, so this is specific to the EMU10K1 PCM tracks (there's 32 of them). Those are *not* the first elements, definately, I don't know what they do exactly though though... But it's something specific to them.
I figured I could be an idiot, so here's valgrind:
==20529== Invalid read of size 4
==20529== at0x1BB870B0:snd_mixer_selem_has_playback_switch(in/lib/libasound.so.2.0.0)
==20529== by0x1D01AB2B:gst_alsa_mixer_update(gstalsamixer.c:412)
==20529== by0x1D01AC4A:gst_alsa_mixer_get_volume
(gstalsamixer.c:439)
==20529== by0x1C416998:gst_mixer_get_volume(mixer.c:185)
==20529== Address0x1CE2B678is 0 bytes inside a block of size 44 free'd
==20529== at0x1B904FB1: free (vg_replace_malloc.c:153)
==20529== by0x1BB8390C:snd_mixer_elem_remove(in/lib/libasound.so.2.0.0)
==20529== by0x1BB86630: (within/lib/libasound.so.2.0.0)
==20529== by0x1BB8668C: (within/lib/libasound.so.2.0.0)
Quoted 3 lines
It appears that alsa removes the EMU10K1 PCM elements when I call
snd_mixer_handle_events(). Why does it do that, how do I make it stop doing it and/or how do I handle this?
EMU10K1 PCM control is dynamically added/removed when the corresponding PCM is opened/closed (more precisely, INACTIVE flag is removed/added at each open/close).
If the app is programmed in a passive manner, it will receive the ADD and REMOVE events when new controls are created/deleted. Then the app has to take the corresponding action.
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
A message that is not in the archive (sent off-list or not yet received): [email protected]
At Wed, 16 Feb 2005 12:49:26 +0100,
Quoted 14 lines · Thierry Vignaud
Quoted 10 lines · Takashi Iwai
Quoted 4 lines
a mixer app of mine (you know, one of those controlling volumes) is updating itself (if other apps change settings) by continuously running get-volume (et al) on all mixer elements every once in a while (10Hz).
Well, this isn't a good idea. You should do update passively via
poll(). The exception is a control with VOLATILE flag like VU meter, which won't send change notification. But normal controls send notification if the value is changed, or the control is created/deleted, so that the app can react.
Quoted 6 lines
is this the same bug that affects totem?
see totem's gdb trace at
http://qa.mandrakesoft.com/show_bug.cgi?id=13045 and xine strace at
http://qa.mandrakesoft.com/show_bug.cgi?id=13449
(http://qa.mandrakesoft.com/attachment.cgi?id=2444)
They are slightly different problems. I guess it's indeed a bug of alsa-lib, which was fixed recently on CVS.
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 13 lines · Takashi Iwai
Quoted 13 lines
Quoted 10 lines
Quoted 4 lines
a mixer app of mine (you know, one of those controlling volumes) is updating itself (if other apps change settings) by continuously running get-volume (et al) on all mixer elements every once in a while (10Hz).
Well, this isn't a good idea. You should do update passively via
poll(). The exception is a control with VOLATILE flag like VU meter, which won't send change notification. But normal controls send notification if the value is changed, or the control is created/deleted, so that the app can react.is this the same bug that affects totem?
Quoted 7 lines
Quoted 4 lines
see totem's gdb trace at
http://qa.mandrakesoft.com/show_bug.cgi?id=13045 and xine strace at
http://qa.mandrakesoft.com/show_bug.cgi?id=13449
(http://qa.mandrakesoft.com/attachment.cgi?id=2444)They are slightly different problems. I guess it's indeed a bug of alsa-lib, which was fixed recently on CVS.
could you point to the relevant fix?
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
At Wed, 16 Feb 2005 13:14:04 +0100,
Quoted 21 lines · Thierry Vignaud
Quoted 18 lines · Takashi Iwai
Quoted 17 lines
Quoted 10 lines
Quoted 4 lines
a mixer app of mine (you know, one of those controlling volumes) is updating itself (if other apps change settings) by continuously running get-volume (et al) on all mixer elements every once in a while (10Hz).
Well, this isn't a good idea. You should do update passively via
poll(). The exception is a control with VOLATILE flag like VU meter, which won't send change notification. But normal controls send notification if the value is changed, or the control is created/deleted, so that the app can react.is this the same bug that affects totem?
see totem's gdb trace at
http://qa.mandrakesoft.com/show_bug.cgi?id=13045 and xine strace at
http://qa.mandrakesoft.com/show_bug.cgi?id=13449
(http://qa.mandrakesoft.com/attachment.cgi?id=2444)
Quoted 5 lines
Quoted 2 lines
They are slightly different problems. I guess it's indeed a bug of alsa-lib, which was fixed recently on CVS.
could you point to the relevant fix?
alsa-lib/src/mixer/mixer.c:
revision 1.70
date: 2005/02/04 19:18:49; author: tiwai; state: Exp; lines: +2 -2
Summary: Use bag_for_each_safe() for event handling loop
Use bag_for_each_safe() for event handling loop. Event callbacks may be destructive.
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 6 lines · Takashi Iwai
Quoted 5 lines
Quoted 2 lines
They are slightly different problems. I guess it's indeed a bug of alsa-lib, which was fixed recently on CVS.
could you point to the relevant fix?
Quoted 8 lines
alsa-lib/src/mixer/mixer.c:revision 1.70
date: 2005/02/04 19:18:49; author: tiwai; state: Exp; lines: +2 -2
Summary: Usebag_for_each_safe()for event handling loopUse
bag_for_each_safe()for event handling loop. Event callbacks may be destructive.
thanks
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Hi Takashi,
I tried playing with what you said but must have misunderstood.
Quoted 6 lines · Takashi Iwai
At Tue, 15 Feb 2005 22:12:53 +0100,
Quoted 3 lines · Ronald S. Bultje
It appears that alsa removes the EMU10K1 PCM elements when I call
snd_mixer_handle_events(). Why does it do that, how do I make it stop doing it and/or how do I handle this?
Quoted 7 lines
EMU10K1 PCM control is dynamically added/removed when the corresponding PCM is opened/closed (more precisely, INACTIVE flag is removed/added at each open/close).
If the app is programmed in a passive manner, it will receive the ADD and REMOVE events when new controls are created/deleted. Then the app has to take the corresponding action.
I'm probably hitting a wall here, because I cannot really find any sample code (google) or API docs (alsa website) on this. I tried setting a snd_mixer_set_callback() [that's the right function, right?], and I get a bunch of 'event number 4' when I start the mixer (did I mention that the masks are undocumented? :) ). But nothing more. And a crash at the end, still. What other function should I use to listen for removed/added elements? Is there working sample code?
Honestly, at this point, I don't mind a quick hack (to do the right thing later) if there is one and it's simpler.
Thanks,
Ronald
Signature · 9 lines
Ronald S. Bultje <[email protected]> ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 19 lines · Ronald S. Bultje
Hi Takashi,
I tried playing with what you said but must have misunderstood.
Quoted 6 lines · Takashi Iwai
At Tue, 15 Feb 2005 22:12:53 +0100,
Quoted 3 lines · Ronald S. Bultje
It appears that alsa removes the EMU10K1 PCM elements when I call
snd_mixer_handle_events(). Why does it do that, how do I make it stop doing it and/or how do I handle this?Quoted 7 lines
EMU10K1 PCM control is dynamically added/removed when the corresponding PCM is opened/closed (more precisely, INACTIVE flag is removed/added at each open/close).
If the app is programmed in a passive manner, it will receive the ADD and REMOVE events when new controls are created/deleted. Then the app has to take the corresponding action.
Quoted 5 lines
I'm probably hitting a wall here, because I cannot really find any sample code (google) or API docs (alsa website) on this. I tried setting a
snd_mixer_set_callback()[that's the right function, right?], and I get a bunch of 'event number 4' when I start the mixer (did I mention that the masks are undocumented? :) ). But nothing more. And a crash at
Any patches for alsa-lib providing better documentation are appreciated.
Quoted 5 lines
the end, still. What other function should I use to listen for removed/added elements? Is there working sample code?
Honestly, at this point, I don't mind a quick hack (to do the right thing later) if there is one and it's simpler.
alsa-utils/amixer
Look for sevents() function.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Hi,
Quoted 1 line · Jaroslav Kysela
Any patches for alsa-lib providing better documentation are appreciated.
You probably don't want that. The documentation that I would provide with my current knowledge of ALSA would suck so badly that it'd cause only more uproar. ;).
Anyway, what I'm trying to say is: thanks for the docs so far, they've continued to improve all the time since a few years back (when I first looked at ALSA), and I think that's great. Through this, I'm trying to provide constructive criticism, not slay you guys down, so that it will get yet better from here on. You guys are doing good work and I'm happy with that.
Quoted 1 line
Look for
sevents()function.
Thanks.
Ronald
Signature · 9 lines
Ronald S. Bultje <[email protected]> ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 6 lines · On 03-Mar-2005 Ronald S. Bultje wrote:
Quoted 3 lines
If the app is programmed in a passive manner, it will receive the ADD and REMOVE events when new controls are created/deleted. Then the app has to take the corresponding action.
I'm probably hitting a wall here, because I cannot really find any sample code (google) or API docs (alsa website) on this. [...]
I'm working on the same stuff because echomixer ignores events and it's not good. Some sample code is here:
cd alsa-tools-1.0.8/
grep -r poll_descriptors .
--
Giuliano.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click