-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[pulseaudio] Add "idle timeout" to Pulseaudio audio sink #10731
[pulseaudio] Add "idle timeout" to Pulseaudio audio sink #10731
Conversation
9c7e34b
to
9ca3c9b
Compare
…onnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu>
e3755d5
to
b3840f9
Compare
I managed to get the build green. Some unrelated test (from the homematic binding) has been failing for quite some time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Dbzman,
Code looks good to me and the feature makes imho sense as you nicely explain.
I have only a very very small review comment and we should be good to merge.
<parameter name="simpleProtocolSinkIdleTimeout" type="integer" required="false"> | ||
<label>Idle Timeout</label> | ||
<description>Timeout in ms after which the connection will be closed when no stream is running. | ||
This ensures that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These line breaks look a bit weird here. Could you clean this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. The linter complained about it and I ran mvn spotless:apply
which resulted in this weirdly formatted code. I tried to make it a bit nicer without the linter going nuts.
Signed-off-by: Timo Litzius <dev@dbzman-online.eu>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks!
@kaikreuzer Thanks for the review and merge! :) |
* Add "idle timeout" to pulseaudio audio sink to allow the sink to disconnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu>
* Add "idle timeout" to pulseaudio audio sink to allow the sink to disconnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu> Signed-off-by: Luca Calcaterra <calcaterra.luca@gmail.com>
* Add "idle timeout" to pulseaudio audio sink to allow the sink to disconnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu> Signed-off-by: Luca Calcaterra <calcaterra.luca@gmail.com>
* Add "idle timeout" to pulseaudio audio sink to allow the sink to disconnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu> Signed-off-by: Luca Calcaterra <calcaterra.luca@gmail.com>
* Add "idle timeout" to pulseaudio audio sink to allow the sink to disconnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu>
* Add "idle timeout" to pulseaudio audio sink to allow the sink to disconnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu>
* Add "idle timeout" to pulseaudio audio sink to allow the sink to disconnect after being idle Signed-off-by: Timo Litzius <dev@dbzman-online.eu>
What?
This PR allows the Pulseaudio audio sink to disconnect after a configured period of being idle.
Why?
I use Pulseaudio with a Raspberry and a speaker to announce events via TTS and noticed that the speaker never goes to sleep and constantly produces high pitch noise.
Solution
After digging through the code the most obvious and simplest option was to disconnect immediately after a stream has finished. This worked initially but had a big drawback when issuing multiple "say" (TTS) commands in a row. There a new connection has been made for every "say" command which resulted in an overlap of the streams. This was not a problem previously because the same socket connection was used and the Pulseaudio server played this consecutively.
The solution I came up with is simple enough and works quite well. After each "thing save" and/or stream command a disconnect is scheduled with a configured delay (30s is the default). So for 30s a connection is reused and after that it will disconnect if no other stream started in the meantime.
If you have suggestions or notes, don't hesitate to approach me.
Cheers and thanks!