Skip to content

pulse: connect recording stream only when recording is allowed #164

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marmarek
Copy link
Member

This makes streams list in pulseaudio/pipewire less cluttered (no
streams that wouldn't really record), but also fixes recording
indicator in xfce (which looks at connected streams, regardless of their
corked state).

More details in the commit message.

This requires a bit more testing, and also updating automated tests (they do assume currently the recording stream is always there).
And also some extra review would be nice.

Fixes QubesOS/qubes-issues#9999

This makes streams list in pulseaudio/pipewire less cluttered (no
streams that wouldn't really record), but also fixes recording
indicator in xfce (which looks at connected streams, regardless of their
corked state).

Move stream creation to a separate function
(connect_disconnect_rec_stream) and call it instead of just uncorking
the stream. And also, still call it on pulseaudio connection, if
recording was allowed initially. Since the stream connection is
asynchronous, the "allow recording" logic is split into two parts, and
both are put into connect_disconnect_rec_stream - selected by the
state_callback parameter.

This mechanism is a bit fragile, as there are quite a few states.
Introduce rec_stream_connect_in_progress variable that is set when
stream connect/disconnect is in progress. In that case, do not schedule
another connect/disconnect, but at stream state change callback will
check if the requested state didn't change in the meantime. This also
means that if rec_stream_connect_in_progress is set, the rec_allowed
value is unreliable (it may be a stream that is created but not
connected yet for example) - so, if rec_stream_connect_in_progress is
set, do not send any data.

Since recording stream isn't initially connected now, decouple adding
recording vchan callback from it - since that vchan is also used for
commands. And adjust that callback to not assume the stream is always
connected (do not use pa_stream_is_corked, don't assert for stream
before checking if recording is allowed etc).

And also drop pa_stream_cork in vchan error hander - the process quits
few lines below anyway.

Fixes QubesOS/qubes-issues#9999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not connect recording stream unless recording is enabled
1 participant