* why do elements disappear?
@ 2005-02-15 21:12 Ronald S. Bultje
2005-02-16 10:42 ` Takashi Iwai
0 siblings, 1 reply; 10+ messages in thread
From: Ronald S. Bultje @ 2005-02-15 21:12 UTC (permalink / raw)
To: alsa-devel
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
--
Ronald S. Bultje <rbultje@ronald.bitfreak.net>
-------------------------------------------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: why do elements disappear?
2005-02-15 21:12 why do elements disappear? Ronald S. Bultje
@ 2005-02-16 10:42 ` Takashi Iwai
[not found] ` <m2r7jgpvw9.fsf@vador.mandrakesoft.com>
2005-03-03 8:57 ` Ronald S. Bultje
0 siblings, 2 replies; 10+ messages in thread
From: Takashi Iwai @ 2005-02-16 10:42 UTC (permalink / raw)
To: Ronald S. Bultje; +Cc: alsa-devel
At Tue, 15 Feb 2005 22:12:53 +0100,
Ronald S. Bultje wrote:
>
> 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.
> 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?
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
^ permalink raw reply [flat|nested] 10+ messages in thread[parent not found: <m2r7jgpvw9.fsf@vador.mandrakesoft.com>]
* Re: why do elements disappear?
[not found] ` <m2r7jgpvw9.fsf@vador.mandrakesoft.com>
@ 2005-02-16 11:52 ` Takashi Iwai
2005-02-16 12:14 ` Thierry Vignaud
0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2005-02-16 11:52 UTC (permalink / raw)
To: Thierry Vignaud; +Cc: alsa-devel
At Wed, 16 Feb 2005 12:49:26 +0100,
Thierry Vignaud wrote:
>
> Takashi Iwai <tiwai@suse.de> writes:
>
> > > 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)
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: why do elements disappear?
2005-02-16 11:52 ` Takashi Iwai
@ 2005-02-16 12:14 ` Thierry Vignaud
2005-02-16 12:12 ` Takashi Iwai
0 siblings, 1 reply; 10+ messages in thread
From: Thierry Vignaud @ 2005-02-16 12:14 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
Takashi Iwai <tiwai@suse.de> writes:
> > > > 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)
>
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: why do elements disappear?
2005-02-16 12:14 ` Thierry Vignaud
@ 2005-02-16 12:12 ` Takashi Iwai
2005-02-16 12:31 ` Thierry Vignaud
0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2005-02-16 12:12 UTC (permalink / raw)
To: Thierry Vignaud; +Cc: alsa-devel
At Wed, 16 Feb 2005 13:14:04 +0100,
Thierry Vignaud wrote:
>
> Takashi Iwai <tiwai@suse.de> writes:
>
> > > > > 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)
> >
> > 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: why do elements disappear?
2005-02-16 12:12 ` Takashi Iwai
@ 2005-02-16 12:31 ` Thierry Vignaud
0 siblings, 0 replies; 10+ messages in thread
From: Thierry Vignaud @ 2005-02-16 12:31 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
Takashi Iwai <tiwai@suse.de> writes:
> > > 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.
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: why do elements disappear?
2005-02-16 10:42 ` Takashi Iwai
[not found] ` <m2r7jgpvw9.fsf@vador.mandrakesoft.com>
@ 2005-03-03 8:57 ` Ronald S. Bultje
2005-03-03 9:17 ` Jaroslav Kysela
2005-03-04 9:15 ` Giuliano Pochini
1 sibling, 2 replies; 10+ messages in thread
From: Ronald S. Bultje @ 2005-03-03 8:57 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
Hi Takashi,
I tried playing with what you said but must have misunderstood.
On Wed, 2005-02-16 at 11:42, Takashi Iwai wrote:
> At Tue, 15 Feb 2005 22:12:53 +0100,
> Ronald S. Bultje wrote:
> > 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.
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
--
Ronald S. Bultje <rbultje@ronald.bitfreak.net>
-------------------------------------------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: why do elements disappear?
2005-03-03 8:57 ` Ronald S. Bultje
@ 2005-03-03 9:17 ` Jaroslav Kysela
2005-03-03 12:25 ` Ronald S. Bultje
2005-03-04 9:15 ` Giuliano Pochini
1 sibling, 1 reply; 10+ messages in thread
From: Jaroslav Kysela @ 2005-03-03 9:17 UTC (permalink / raw)
To: Ronald S. Bultje; +Cc: Takashi Iwai, alsa-devel
On Thu, 3 Mar 2005, Ronald S. Bultje wrote:
> Hi Takashi,
>
> I tried playing with what you said but must have misunderstood.
>
> On Wed, 2005-02-16 at 11:42, Takashi Iwai wrote:
> > At Tue, 15 Feb 2005 22:12:53 +0100,
> > Ronald S. Bultje wrote:
> > > 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.
>
> 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.
> 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 <perex@suse.cz>
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: why do elements disappear?
2005-03-03 9:17 ` Jaroslav Kysela
@ 2005-03-03 12:25 ` Ronald S. Bultje
0 siblings, 0 replies; 10+ messages in thread
From: Ronald S. Bultje @ 2005-03-03 12:25 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel
Hi,
On Thu, 2005-03-03 at 10:17, Jaroslav Kysela wrote:
> 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.
> Look for sevents() function.
Thanks.
Ronald
--
Ronald S. Bultje <rbultje@ronald.bitfreak.net>
-------------------------------------------------------
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: why do elements disappear?
2005-03-03 8:57 ` Ronald S. Bultje
2005-03-03 9:17 ` Jaroslav Kysela
@ 2005-03-04 9:15 ` Giuliano Pochini
1 sibling, 0 replies; 10+ messages in thread
From: Giuliano Pochini @ 2005-03-04 9:15 UTC (permalink / raw)
To: Ronald S. Bultje; +Cc: alsa-devel
On 03-Mar-2005 Ronald S. Bultje wrote:
>> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-03-04 9:15 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-15 21:12 why do elements disappear? Ronald S. Bultje
2005-02-16 10:42 ` Takashi Iwai
[not found] ` <m2r7jgpvw9.fsf@vador.mandrakesoft.com>
2005-02-16 11:52 ` Takashi Iwai
2005-02-16 12:14 ` Thierry Vignaud
2005-02-16 12:12 ` Takashi Iwai
2005-02-16 12:31 ` Thierry Vignaud
2005-03-03 8:57 ` Ronald S. Bultje
2005-03-03 9:17 ` Jaroslav Kysela
2005-03-03 12:25 ` Ronald S. Bultje
2005-03-04 9:15 ` Giuliano Pochini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.