Bug 335729 - Inhibit suspend while sound is playing
Summary: Inhibit suspend while sound is playing
Status: REPORTED
Alias: None
Product: Phonon
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: 4.8
Assignee: Harald Sitter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-02 22:33 UTC by Nikolay Amiantov
Modified: 2024-03-26 03:38 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Amiantov 2014-06-02 22:33:52 UTC
While playing music, for example, or watching video, system can be abruptly suspended because of no direct user activity. Can we add an option to check if some sound is playing (PulseAudio gives us a lot of information on that, for example), sound is not muted, maybe even how long has it played (if it played for 3 seconds or lesser, it is probably some notification and should be ignored) and inhibit system suspend (or lock screen) based on that? I can't think of any case in which this would not be useful (games' music? but some people like to just leave game opened and listen), and this could be optional.

Reproducible: Always

Steps to Reproduce:
1. Enable suspend-if-idle
2. Turn on music/video
3. Wait for N minutes
Actual Results:  
Computer abruptly got suspended, audio/video was cut in the middle.

Expected Results:  
No suspend.
Comment 1 Apoorv Parle 2014-09-19 18:29:22 UTC
I've a similar problem, and this feature would come in handy while listening to music on spotify or other music websites.
Comment 2 Vincent Petry 2018-11-16 09:42:20 UTC
From what I've observed in recent Plasma 5 versions (like 5.14) is that apps like Firefox, Amarok or others who play media are able to inhibit suspend already.

This might be limited to apps that can report media playback to the system and might not work with apps that run outside of this and talk directly to pulseaudio, not sure.

In general if the above is acceptable I suggest closing this old issue.
Please try again with
Comment 3 Jan Rathmann 2020-02-07 11:30:10 UTC
The reported issue that on KDE audio playback/playing music doesn't inhibit suspend still exists for me. For video playback this seems to work fine, but not for audio only.

I have tested this with this media players on my system (Kubuntu 19.10 with Backports PPA): Audacious, Cantata, VLC, SMPlayer, mpv Media Player. None of the first four were able to inhibit suspend while playing music. mpv Media Player was the only exeption - maybe because it seems to treat the use case "playing audio file" the same as "playing video" (it also inhibited the monitor from turning off, which makes not much sense when the file played contains no video).

I did also a short test under Gnome (Ubuntu 19.10, with Audacious as audio  player). Here it worked fine - when playing audio-only the monitor turned off (good), but the system was inhibited from entering standby (also good).

And I think it would be great if this would be the behaviour under KDE when playing audio while there is no user activity:
- Turn off monitor
- But don't suspend until audio playback is finished
(Or at least make this configurable somewhere)

Kind regards,
Jan
Comment 4 Pedro V 2023-11-18 10:46:48 UTC
Confirming the original "issue", some mentioned related issues may not exist anymore though.

Current status with Plasma 5.27.8 and Firefox which seems to be well behaving when it comes to inhibiting power management:
- Video in the foreground inhibits power management
- Switching to another tab while the video is still playing no longer inhibits power management, so the screen turns off
- There's no inhibitor for sleeping, so the host goes to sleep while audio is playing

It's not really an issue as I find it likely that the feature just simply doesn't exist yet in KDE, but given the report of Gnome supporting it it surely looks like it might be desirable.

Keep in mind though that it's not a universally desired feature though, it's definitely something that should be possible to toggle if ever implemented.
A good reason I can give for that is the emergence of malicious websites using whatever they can for fingerprinting, including audio. For example even right now my browser is shown to be playing audio without hearing anything, and this time I tracked it down to Aliexpress tabs which notoriously still do this, although apparently not all the time. Earlier I tracked it down to Discord doing it for a couple months before they likely tamed the malware not to keep audio in use. It's already bad enough to often have no other option but to use such hostile sites, so I would hate it if they would be able to mess with me even more.
Comment 5 Tom 2024-03-26 03:38:30 UTC
Playing a YouTube video in Firefox doesn't inhibit idle for me.  I've resorted to using https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit/ which inhibits idle while anything is playing through pipewire.  (You can whitelist or blacklist sources and sinks if you want.)  Inhibiting idle also inhibits suspend, so this is mostly good enough for me, but I'd love to see an option like that baked into KDE.  (I use kde-inhibit for the less-common cases that don't play audio.)