alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: perex@perex.cz
Cc: alsa-devel@alsa-project.org
Subject: attach/detach by mixer class implementation of alsa-lib mixer API
Date: Sat, 25 Jun 2022 20:28:39 +0900	[thread overview]
Message-ID: <YrbxZ2b+3rIdi7Ut@workstation> (raw)

Hi Jaroslav,

Recent years I'm bothered about unexpected abort of pulseaudio and
pipewire processes when testing user-defined control element set.
They aborts at element removal event.

```
pulseaudio: mixer.c:149: hctl_elem_event_handler: Assertion `bag_empty(bag)' failed.
wireplumber: mixer.c:149: hctl_elem_event_handler: Assertion `bag_empty(bag)' failed.
```

Would I ask your opinion about the design of alsa-lib mixer API?

As long as I investigate, these programs seem to have careless coding as
alsa-lib mixer API application. Both of them attaches an instance of
snd_mixer_elem_t to an instance of snd_hctl_elem_t by calling
snd_mixer_elem_attach() when detecting element addition, but never detach
it even if detecting element removal.

In the case, the link list (=bag) of mixer API internal never becomes empty.
It has link entries as much as the number of registered mixer classes which
attaches snd_mixer_elem_t. Then it hits the assertion.

I think the design of alsa-lib mixer API demands mixer class implementation
to detach at element removal which attached at element addition. But I have
less conviction about it since enough unfamiliar.

I'm glad if receiving your opinion about it.

I wrote test program for the issued behaviour:
 - https://gist.github.com/takaswie/8378fe3bc04652d83428694cd7573bc0

For test, please use sample script in alsa-gobject project:
 - https://github.com/alsa-project/alsa-gobject/blob/master/samples/ctl

The patches for pulseaudio/pipewire are prepared:
 - https://gitlab.freedesktop.org/takaswie/pulseaudio/-/commit/topic/fix-wrong-handling-alsa-ctl-event
 - https://gitlab.freedesktop.org/takaswie/pipewire/-/commits/topic/fix-wrong-handling-alsa-ctl-event


Regards

Takashi Sakamoto

             reply	other threads:[~2022-06-25 11:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-25 11:28 Takashi Sakamoto [this message]
2022-06-26 17:23 ` attach/detach by mixer class implementation of alsa-lib mixer API Jaroslav Kysela
2022-06-27  1:28   ` Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YrbxZ2b+3rIdi7Ut@workstation \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).