Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No updates in listen when switching between microphones #68

Open
marioortizmanero opened this issue Jul 3, 2022 · 9 comments
Open

No updates in listen when switching between microphones #68

marioortizmanero opened this issue Jul 3, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@marioortizmanero
Copy link
Owner

marioortizmanero commented Jul 3, 2022

The PR #64 introduced the on client pattern to the command in grep. However, that ends up consuming lots of CPU power even when the script isn't being used. For instance, I get on client events when playing music, which shouldn't update.

The easy fix would be to just remove on client from the patterns. However, we added that because without it, the microphone listen function didn't work in some specific cases. I'm still not sure which cases these are, though.

This was reported by Viterzgir at https://aur.archlinux.org/packages/pulseaudio-control.

/cc @Aerion

@marioortizmanero
Copy link
Owner Author

marioortizmanero commented Jul 3, 2022

Can confirm that removing on client fixes the issue. I can release a new version without it for now, but that breaks listen for microphone switching on my machine...

@marioortizmanero
Copy link
Owner Author

I guess the only solution is to have a named FIFO or similar where we notify of our own events, and then we could also read from it in listen.

Another option is to report this behavior in pactl as a bug, but it might actually be how it's supposed to work. We could figure out another way to get notified of events that does work and investigate more, because I'm not actually sure why this happens.

We can't use polybar's integrated IPC here because we should also update when events occur outside the script.

@Aerion
Copy link
Contributor

Aerion commented Jul 3, 2022

If it leads to high cpu, I agree that it would be better to remove listening on on client for now, push a quick fix, and find a clean way to have the microphone feature working.

@marioortizmanero
Copy link
Owner Author

On it, that'll be v3.0.1.

@Aerion
Copy link
Contributor

Aerion commented Jul 3, 2022

FYI in i3blocks-contrib, they're filtering on Event 'change' (which is not triggered by the client events). So I guess the same issue would be present with your setup.

Another option is to report this behavior in pactl as a bug, but it might actually be how it's supposed to work.

I quickly tested python-pulse-control which subscribes to PulseAudio's events via the C api, and I see the same events as pactl subscribe (just in a different format).
So, it may be (to verify) that pulseaudio doesn't emit events on default source being set, and not an issue with pactl. Then, it may be an expected behavior 🤷

In fact, I think we're both running pipewire, it may be an issue with pipewire-pulseaudio's implementation, something like https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1391

@marioortizmanero marioortizmanero changed the title High CPU consumption because of on client grep No updates in listen when switching between microphones Jul 5, 2022
@marioortizmanero marioortizmanero pinned this issue Jul 5, 2022
@marioortizmanero
Copy link
Owner Author

marioortizmanero commented Jul 5, 2022

Yeah a good idea would definitely be to see if this still happens with raw pulseaudio, rather than pipewire. I'll try it when I have a bit more time. It would also be interesting to actually learn how pactl subscribe works, which isn't described very well in the docs.

If the behavior is different we can report it as an issue, but I'm guessing that will take time to release in a new pipewire version anyway.

@marioortizmanero marioortizmanero added the bug Something isn't working label Jul 5, 2022
@lzhoucs
Copy link

lzhoucs commented Jul 6, 2022

I am using raw pulseaudio and can confirm it's working for me. So this issue might only affect pipewire users. Also noticed one minor documentation thing, --node-blacklist should be used for next-node rather than listen for the --node-type input example:

# Use --node-blacklist to remove the unwanted PulseAudio .monitor that are child of sinks
exec = pulseaudio-control  --node-type input ... --node-blacklist "*.monitor" listen

@marioortizmanero
Copy link
Owner Author

Hah, I think this was fixed in the last pipewire version, 0.3.54. I was checking out the release notes and they include:

Card properties are now also added to sinks and sources, just like
in pulseaudio.

I have updated and it does work for me, at least. Can you confirm, @Aerion?

@Aerion
Copy link
Contributor

Aerion commented Jul 10, 2022

Hah, I think this was fixed in the last pipewire version, 0.3.54. I was checking out the release notes and they include:

Card properties are now also added to sinks and sources, just like
in pulseaudio.

I have updated and it does work for me, at least. Can you confirm, @Aerion?

On my side, muting triggers a change on source/card, but switching sink if I never played a sound, or switching input only triggers the change on server event.

Thus the on client doesn't seem necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants