diff --git a/changelog/next.md b/changelog/next.md index 66f87c1..583a2f4 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -36,7 +36,6 @@ set shell id. - Fixed volume control breaking with pipewire pro audio mode. - Fixed volume control breaking with bluez streams and potentially others. -- Fixed volume control breaking for devices without route definitions. - Fixed escape sequence handling in desktop entries. - Fixed volumes not initializing if a pipewire device was already loaded before its node. - Fixed hyprland active toplevel not resetting after window closes. diff --git a/src/core/scanenv.cpp b/src/core/scanenv.cpp index 047f472..b8c514c 100644 --- a/src/core/scanenv.cpp +++ b/src/core/scanenv.cpp @@ -1,7 +1,6 @@ #include "scanenv.hpp" #include -#include #include "build.hpp" @@ -20,12 +19,4 @@ bool PreprocEnv::hasVersion(int major, int minor, const QStringList& features) { return QS_VERSION_MAJOR == major && QS_VERSION_MINOR == minor; } -QString PreprocEnv::env(const QString& variable) { - return qEnvironmentVariable(variable.toStdString().c_str()); -} - -bool PreprocEnv::isEnvSet(const QString& variable) { - return qEnvironmentVariableIsSet(variable.toStdString().c_str()); -} - } // namespace qs::scan::env diff --git a/src/core/scanenv.hpp b/src/core/scanenv.hpp index c1c6814..0abde2e 100644 --- a/src/core/scanenv.hpp +++ b/src/core/scanenv.hpp @@ -12,9 +12,6 @@ class PreprocEnv: public QObject { public: Q_INVOKABLE static bool hasVersion(int major, int minor, const QStringList& features = QStringList()); - - Q_INVOKABLE static QString env(const QString& variable); - Q_INVOKABLE static bool isEnvSet(const QString& variable); }; } // namespace qs::scan::env diff --git a/src/services/pipewire/device.cpp b/src/services/pipewire/device.cpp index 61079a1..e3bc967 100644 --- a/src/services/pipewire/device.cpp +++ b/src/services/pipewire/device.cpp @@ -141,10 +141,6 @@ bool PwDevice::tryLoadVolumeProps(qint32 routeDevice, PwVolumeProps& volumeProps return true; } -bool PwDevice::hasRouteDevice(qint32 routeDevice) const { - return this->routeDeviceIndexes.contains(routeDevice); -} - void PwDevice::polled() { // It is far more likely that the list content has not come in yet than it having no entries, // and there isn't a way to check in the case that there *aren't* actually any entries. diff --git a/src/services/pipewire/device.hpp b/src/services/pipewire/device.hpp index cd61709..22af699 100644 --- a/src/services/pipewire/device.hpp +++ b/src/services/pipewire/device.hpp @@ -12,15 +12,13 @@ #include #include "core.hpp" +#include "node.hpp" #include "registry.hpp" namespace qs::service::pipewire { class PwDevice; -// Forward declare to avoid circular dependency with node.hpp -struct PwVolumeProps; - class PwDevice: public PwBindable { Q_OBJECT; @@ -35,7 +33,6 @@ public: [[nodiscard]] bool waitingForDevice() const; [[nodiscard]] bool tryLoadVolumeProps(qint32 routeDevice, PwVolumeProps& volumeProps); - [[nodiscard]] bool hasRouteDevice(qint32 routeDevice) const; signals: void deviceReady(); diff --git a/src/services/pipewire/node.cpp b/src/services/pipewire/node.cpp index 075a7ec..b6f0529 100644 --- a/src/services/pipewire/node.cpp +++ b/src/services/pipewire/node.cpp @@ -429,10 +429,6 @@ void PwNodeBoundAudio::setMuted(bool muted) { } float PwNodeBoundAudio::averageVolume() const { - if (this->mVolumes.isEmpty()) { - return 0.0f; - } - float total = 0; for (auto volume: this->mVolumes) { @@ -576,28 +572,22 @@ PwVolumeProps PwVolumeProps::parseSpaPod(const spa_pod* param) { const auto* muteProp = spa_pod_find_prop(param, nullptr, SPA_PROP_mute); const auto* volumeStepProp = spa_pod_find_prop(param, nullptr, SPA_PROP_volumeStep); - if (volumesProp) { - const auto* volumes = reinterpret_cast(&volumesProp->value); - spa_pod* iter = nullptr; - SPA_POD_ARRAY_FOREACH(volumes, iter) { - // Cubing behavior found in MPD source, and appears to corrospond to everyone else's measurements correctly. - auto linear = *reinterpret_cast(iter); - auto visual = std::cbrt(linear); - props.volumes.push_back(visual); - } + const auto* volumes = reinterpret_cast(&volumesProp->value); + const auto* channels = reinterpret_cast(&channelsProp->value); + + spa_pod* iter = nullptr; + SPA_POD_ARRAY_FOREACH(volumes, iter) { + // Cubing behavior found in MPD source, and appears to corrospond to everyone else's measurements correctly. + auto linear = *reinterpret_cast(iter); + auto visual = std::cbrt(linear); + props.volumes.push_back(visual); } - if (channelsProp) { - const auto* channels = reinterpret_cast(&channelsProp->value); - spa_pod* iter = nullptr; - SPA_POD_ARRAY_FOREACH(channels, iter) { - props.channels.push_back(*reinterpret_cast(iter)); - } + SPA_POD_ARRAY_FOREACH(channels, iter) { + props.channels.push_back(*reinterpret_cast(iter)); } - if (muteProp) { - spa_pod_get_bool(&muteProp->value, &props.mute); - } + spa_pod_get_bool(&muteProp->value, &props.mute); if (volumeStepProp) { spa_pod_get_float(&volumeStepProp->value, &props.volumeStep); diff --git a/src/services/pipewire/node.hpp b/src/services/pipewire/node.hpp index efc819c..fdec72d 100644 --- a/src/services/pipewire/node.hpp +++ b/src/services/pipewire/node.hpp @@ -15,7 +15,6 @@ #include #include "core.hpp" -#include "device.hpp" #include "registry.hpp" namespace qs::service::pipewire { @@ -250,9 +249,7 @@ public: bool proAudio = false; [[nodiscard]] bool shouldUseDevice() const { - if (!this->device || this->proAudio || this->routeDevice == -1) return false; - // Only use device control if the device actually has route indexes for this routeDevice - return this->device->hasRouteDevice(this->routeDevice); + return this->device && !this->proAudio && this->routeDevice != -1; } signals: