From 0fcaa49875bf0c994bb5c604320454ef72e6ba8b Mon Sep 17 00:00:00 2001 From: Lemmy Date: Wed, 8 Apr 2026 19:12:07 -0400 Subject: [PATCH] Revert "fix(media): gate spectrum pipeline on playback to cut idle CPU" This reverts commit a0093e509b6be49eec355d9a07d7f2d0864dd40e. --- Modules/Bar/Widgets/AudioVisualizer.qml | 18 ++++++------------ Modules/Bar/Widgets/MediaMini.qml | 6 +++--- Modules/Cards/MediaCard.qml | 4 ++-- .../Widgets/DesktopAudioVisualizer.qml | 4 ++-- .../Widgets/DesktopMediaPlayer.qml | 2 +- Modules/LockScreen/LockScreen.qml | 2 +- Modules/LockScreen/LockScreenPanel.qml | 6 +++--- Modules/Panels/Media/MediaPlayerPanel.qml | 2 +- 8 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Modules/Bar/Widgets/AudioVisualizer.qml b/Modules/Bar/Widgets/AudioVisualizer.qml index 30ea55c75..f13701d3a 100644 --- a/Modules/Bar/Widgets/AudioVisualizer.qml +++ b/Modules/Bar/Widgets/AudioVisualizer.qml @@ -45,27 +45,21 @@ Item { readonly property bool shouldShow: (currentVisualizerType !== "" && currentVisualizerType !== "none") && (!hideWhenIdle || MediaService.isPlaying) - readonly property bool needsSpectrum: root.shouldShow && MediaService.isPlaying - // Register/unregister with SpectrumService based on visibility (use screenName — screen can be null after DPMS/output changes) readonly property string spectrumComponentId: "bar:audiovisualizer:" + screenName + ":" + root.section + ":" + root.sectionWidgetIndex - onNeedsSpectrumChanged: { - if (root.needsSpectrum) { + onShouldShowChanged: { + if (root.shouldShow) { SpectrumService.registerComponent(root.spectrumComponentId); } else { SpectrumService.unregisterComponent(root.spectrumComponentId); } } - Component.onCompleted: { - if (root.needsSpectrum) { - SpectrumService.registerComponent(root.spectrumComponentId); - } - } - Component.onDestruction: { - SpectrumService.unregisterComponent(root.spectrumComponentId); + if (root.shouldShow) { + SpectrumService.unregisterComponent(root.spectrumComponentId); + } } // Content dimensions for implicit sizing @@ -110,7 +104,7 @@ Item { id: visualizerLoader anchors.fill: parent anchors.margins: Style.marginS - active: root.needsSpectrum + active: shouldShow asynchronous: true sourceComponent: { diff --git a/Modules/Bar/Widgets/MediaMini.qml b/Modules/Bar/Widgets/MediaMini.qml index 8e27aa6fd..d7b6b74aa 100644 --- a/Modules/Bar/Widgets/MediaMini.qml +++ b/Modules/Bar/Widgets/MediaMini.qml @@ -75,7 +75,7 @@ Item { // SpectrumService registration for visualizer readonly property string spectrumComponentId: "bar:mediamini:" + root.screen?.name + ":" + root.section + ":" + root.sectionWidgetIndex - readonly property bool needsSpectrum: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && !root.isHidden && MediaService.isPlaying + readonly property bool needsSpectrum: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && !root.isHidden Layout.preferredHeight: isVertical ? -1 : Style.getBarHeightForScreen(screenName) Layout.preferredWidth: isVertical ? Style.getBarHeightForScreen(screenName) : -1 @@ -265,10 +265,10 @@ Item { y: Style.pixelAlignCenter(parent.height, height) width: Style.toOdd(parent.width) height: Style.toOdd(parent.height) - active: root.needsSpectrum + active: showVisualizer z: 0 sourceComponent: { - if (!root.needsSpectrum) + if (!showVisualizer) return null; if (visualizerType === "linear") return linearSpectrum; diff --git a/Modules/Cards/MediaCard.qml b/Modules/Cards/MediaCard.qml index 7526d4f97..ab604be12 100644 --- a/Modules/Cards/MediaCard.qml +++ b/Modules/Cards/MediaCard.qml @@ -16,7 +16,7 @@ NBox { readonly property bool hasActivePlayer: MediaService.currentPlayer && MediaService.canPlay // SpectrumService registration for visualizer - readonly property bool needsSpectrum: Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none" && MediaService.isPlaying + readonly property bool needsSpectrum: Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none" onNeedsSpectrumChanged: { if (root.needsSpectrum) { @@ -138,7 +138,7 @@ NBox { // Background visualizer on top of the artwork Loader { anchors.fill: parent - active: root.needsSpectrum + active: Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none" sourceComponent: { switch (Settings.data.audio.visualizerType) { diff --git a/Modules/DesktopWidgets/Widgets/DesktopAudioVisualizer.qml b/Modules/DesktopWidgets/Widgets/DesktopAudioVisualizer.qml index dc30b1543..a462df86c 100644 --- a/Modules/DesktopWidgets/Widgets/DesktopAudioVisualizer.qml +++ b/Modules/DesktopWidgets/Widgets/DesktopAudioVisualizer.qml @@ -25,7 +25,7 @@ DraggableDesktopWidget { readonly property bool shouldShow: visualizerType !== "" && visualizerType !== "none" && (!hideWhenIdle || MediaService.isPlaying) readonly property bool isHidden: !shouldShow - readonly property bool shouldRegisterSpectrum: shouldShow && MediaService.isPlaying + readonly property bool shouldRegisterSpectrum: shouldShow // Keep widget visible in edit mode so users can move/configure it visible: !root.isHidden || DesktopWidgetRegistry.editMode @@ -66,7 +66,7 @@ DraggableDesktopWidget { id: visualizerLoader anchors.fill: parent anchors.margins: root.showBackground ? Math.round(Style.marginXS * root.widgetScale) : 0 - active: root.shouldRegisterSpectrum + active: root.shouldShow asynchronous: true sourceComponent: { diff --git a/Modules/DesktopWidgets/Widgets/DesktopMediaPlayer.qml b/Modules/DesktopWidgets/Widgets/DesktopMediaPlayer.qml index 81ba80816..52b5cbbf7 100644 --- a/Modules/DesktopWidgets/Widgets/DesktopMediaPlayer.qml +++ b/Modules/DesktopWidgets/Widgets/DesktopMediaPlayer.qml @@ -34,7 +34,7 @@ DraggableDesktopWidget { // SpectrumService registration for visualizer readonly property string spectrumComponentId: "desktopmediaplayer:" + (root.screen ? root.screen.name : "unknown") - readonly property bool needsSpectrum: root.shouldShowVisualizer && !root.isHidden && root.isPlaying + readonly property bool needsSpectrum: root.shouldShowVisualizer && !root.isHidden onNeedsSpectrumChanged: { if (root.needsSpectrum) { diff --git a/Modules/LockScreen/LockScreen.qml b/Modules/LockScreen/LockScreen.qml index eb6851005..88698b58f 100644 --- a/Modules/LockScreen/LockScreen.qml +++ b/Modules/LockScreen/LockScreen.qml @@ -17,7 +17,7 @@ Loader { active: false // Track if the visualizer should be shown (lockscreen active + media playing + non-compact mode) - readonly property bool needsSpectrum: root.active && !Settings.data.general.compactLockScreen && Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none" && MediaService.isPlaying + readonly property bool needsSpectrum: root.active && !Settings.data.general.compactLockScreen && Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none" onActiveChanged: { if (root.active && root.needsSpectrum) { diff --git a/Modules/LockScreen/LockScreenPanel.qml b/Modules/LockScreen/LockScreenPanel.qml index 03c4e3e1d..ddd0678c4 100644 --- a/Modules/LockScreen/LockScreenPanel.qml +++ b/Modules/LockScreen/LockScreenPanel.qml @@ -264,7 +264,7 @@ Item { Loader { anchors.fill: parent anchors.margins: 4 - active: Settings.data.audio.visualizerType === "linear" && MediaService.isPlaying + active: Settings.data.audio.visualizerType === "linear" z: 0 sourceComponent: NLinearSpectrum { anchors.fill: parent @@ -278,7 +278,7 @@ Item { Loader { anchors.fill: parent anchors.margins: 4 - active: Settings.data.audio.visualizerType === "mirrored" && MediaService.isPlaying + active: Settings.data.audio.visualizerType === "mirrored" z: 0 sourceComponent: NMirroredSpectrum { anchors.fill: parent @@ -292,7 +292,7 @@ Item { Loader { anchors.fill: parent anchors.margins: 4 - active: Settings.data.audio.visualizerType === "wave" && MediaService.isPlaying + active: Settings.data.audio.visualizerType === "wave" z: 0 sourceComponent: NWaveSpectrum { anchors.fill: parent diff --git a/Modules/Panels/Media/MediaPlayerPanel.qml b/Modules/Panels/Media/MediaPlayerPanel.qml index 721ba7b5f..081c43dd5 100644 --- a/Modules/Panels/Media/MediaPlayerPanel.qml +++ b/Modules/Panels/Media/MediaPlayerPanel.qml @@ -50,7 +50,7 @@ SmartPanel { readonly property bool isSideBySide: root.compactMode && root.showAlbumArt - readonly property bool needsSpectrum: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && root.isPanelOpen && MediaService.isPlaying + readonly property bool needsSpectrum: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && root.isPanelOpen onNeedsSpectrumChanged: { if (root.needsSpectrum) {