1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

cava: optimize CPU burn

related #631
This commit is contained in:
bbedward
2026-07-14 14:16:05 -04:00
parent 1973526c4e
commit 2c5a1a2804
4 changed files with 31 additions and 13 deletions
@@ -8,7 +8,7 @@ Item {
readonly property MprisPlayer activePlayer: MprisController.activePlayer
readonly property bool isPlaying: activePlayer !== null && activePlayer.playbackState === MprisPlaybackState.Playing
readonly property bool live: visible && isPlaying
readonly property bool live: visible && (Window.window?.visible ?? false) && isPlaying
width: 20
height: Theme.iconSize
@@ -1477,12 +1477,16 @@ Item {
anchors.verticalCenter: parent.verticalCenter
Item {
id: lockVisualizer
width: 20
height: Theme.iconSize
anchors.verticalCenter: parent.verticalCenter
readonly property bool live: visible && (Window.window?.visible ?? false) && MprisController.activePlayer?.playbackState === MprisPlaybackState.Playing
Loader {
active: MprisController.activePlayer?.playbackState === MprisPlaybackState.Playing
active: lockVisualizer.live
sourceComponent: Component {
Ref {
@@ -1492,7 +1496,7 @@ Item {
}
Timer {
running: !CavaService.cavaAvailable && MprisController.activePlayer?.playbackState === MprisPlaybackState.Playing
running: !CavaService.cavaAvailable && lockVisualizer.live
interval: 256
repeat: true
onTriggered: {
+13 -7
View File
@@ -39,6 +39,7 @@ framerate=25
bars=6
autosens=0
sensitivity=30
sleep_timer=3
lower_cutoff_freq=50
higher_cutoff_freq=12000
@@ -67,13 +68,18 @@ exec cava -p ${root._confPath} < /dev/null`]
stdout: SplitParser {
splitMarker: "\n"
onRead: data => {
if (root.refCount > 0 && data.length > 0) {
const parts = data.split(";");
if (parts.length >= 6) {
const points = [parseInt(parts[0], 10), parseInt(parts[1], 10), parseInt(parts[2], 10), parseInt(parts[3], 10), parseInt(parts[4], 10), parseInt(parts[5], 10)];
root.values = points;
}
}
if (root.refCount <= 0 || data.length === 0)
return;
const parts = data.split(";");
if (parts.length < 6)
return;
const points = [parseInt(parts[0], 10), parseInt(parts[1], 10), parseInt(parts[2], 10), parseInt(parts[3], 10), parseInt(parts[4], 10), parseInt(parts[5], 10)];
if (points.every((v, i) => v === root.values[i]))
return;
root.values = points;
}
}
}
+11 -3
View File
@@ -45,7 +45,8 @@ Item {
readonly property real blobMorphBoost: 1.7
readonly property real blobSpinSpeed: 0.03
readonly property bool blobActive: CavaService.cavaAvailable && activePlayer?.playbackState === MprisPlaybackState.Playing && showAnimation && albumArtStatus === Image.Ready
readonly property bool onScreen: visible && (Window.window?.visible ?? false)
readonly property bool blobActive: CavaService.cavaAvailable && onScreen && activePlayer?.playbackState === MprisPlaybackState.Playing && showAnimation && albumArtStatus === Image.Ready
property var smoothedBands: [0, 0, 0, 0, 0, 0]
property var slowBands: [0, 0, 0, 0, 0, 0]
property var bandTargets: [0, 0, 0, 0, 0, 0]
@@ -165,7 +166,7 @@ Item {
}
Loader {
active: activePlayer?.playbackState === MprisPlaybackState.Playing && showAnimation
active: root.onScreen && activePlayer?.playbackState === MprisPlaybackState.Playing && showAnimation
sourceComponent: Component {
Ref {
service: CavaService
@@ -183,7 +184,14 @@ Item {
FrameAnimation {
running: blobEffect.visible
onTriggered: root.stepBlob(Math.min(frameTime, 0.05))
property real pending: 0
onTriggered: {
pending += frameTime;
if (pending < 0.03)
return;
root.stepBlob(Math.min(pending, 0.05));
pending = 0;
}
}
ShaderEffect {