Skip to content

Commit 11d6d67

Browse files
committed
services/pipewire: add peak detection
1 parent 5d8354a commit 11d6d67

7 files changed

Lines changed: 513 additions & 1 deletion

File tree

changelog/next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set shell id.
1919
- Added minimized, maximized, and fullscreen properties to FloatingWindow.
2020
- Added the ability to handle move and resize events to FloatingWindow.
2121
- Pipewire service now reconnects if pipewire dies or a protocol error occurs.
22+
- Added pipewire audio peak detection.
2223

2324
## Other Changes
2425

src/services/pipewire/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pkg_check_modules(pipewire REQUIRED IMPORTED_TARGET libpipewire-0.3)
33

44
qt_add_library(quickshell-service-pipewire STATIC
55
qml.cpp
6+
peak.cpp
67
core.cpp
78
connection.cpp
89
registry.cpp

src/services/pipewire/module.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name = "Quickshell.Services.Pipewire"
22
description = "Pipewire API"
33
headers = [
44
"qml.hpp",
5+
"peak.hpp",
56
"link.hpp",
67
"node.hpp",
78
]

src/services/pipewire/node.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <qlogging.h>
1212
#include <qloggingcategory.h>
1313
#include <qobject.h>
14-
#include <qstringliteral.h>
14+
#include <qstring.h>
1515
#include <qtmetamacros.h>
1616
#include <qtypes.h>
1717
#include <spa/node/keys.h>
@@ -90,6 +90,8 @@ QString PwAudioChannel::toString(Enum value) {
9090

9191
QString PwNodeType::toString(PwNodeType::Flags type) {
9292
switch (type) {
93+
// qstringliteral apparently not imported...
94+
// NOLINTBEGIN
9395
case PwNodeType::VideoSource: return QStringLiteral("VideoSource");
9496
case PwNodeType::VideoSink: return QStringLiteral("VideoSink");
9597
case PwNodeType::AudioSource: return QStringLiteral("AudioSource");
@@ -99,6 +101,7 @@ QString PwNodeType::toString(PwNodeType::Flags type) {
99101
case PwNodeType::AudioInStream: return QStringLiteral("AudioInStream");
100102
case PwNodeType::Untracked: return QStringLiteral("Untracked");
101103
default: return QStringLiteral("Invalid");
104+
// NOLINTEND
102105
}
103106
}
104107

@@ -161,6 +164,18 @@ void PwNode::initProps(const spa_dict* props) {
161164
this->nick = nodeNick;
162165
}
163166

167+
if (const auto* serial = spa_dict_lookup(props, PW_KEY_OBJECT_SERIAL)) {
168+
auto ok = false;
169+
auto value = QString::fromUtf8(serial).toULongLong(&ok);
170+
if (!ok) {
171+
qCWarning(logNode) << this
172+
<< "has an object.serial property but the value is not valid. Value:"
173+
<< serial;
174+
} else {
175+
this->objectSerial = value;
176+
}
177+
}
178+
164179
if (const auto* deviceId = spa_dict_lookup(props, PW_KEY_DEVICE_ID)) {
165180
auto ok = false;
166181
auto id = QString::fromUtf8(deviceId).toInt(&ok);

src/services/pipewire/node.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ class PwNodeBoundAudio
199199
[[nodiscard]] QVector<float> volumes() const;
200200
void setVolumes(const QVector<float>& volumes);
201201

202+
[[nodiscard]] QVector<float> server() const;
203+
202204
signals:
203205
void volumesChanged();
204206
void channelsChanged();
@@ -233,6 +235,7 @@ class PwNode: public PwBindable<pw_node, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE
233235
QString description;
234236
QString nick;
235237
QMap<QString, QString> properties;
238+
quint64 objectSerial = 0;
236239

237240
PwNodeType::Flags type = PwNodeType::Untracked;
238241

0 commit comments

Comments
 (0)