service/pipewire: don't use configured default devices

These don't appear to be intended for use by applications, only the
non configured ones.

This fixes the default device being unset on many computers and the
device being lost on actions like headphone unplug which replace it.
This commit is contained in:
outfoxxed 2024-09-17 23:04:06 -07:00
parent bd8978375b
commit 931aca5392
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 4 additions and 25 deletions

View file

@ -70,22 +70,11 @@ void PwDefaultsMetadata::onMetadataUpdate(
) {
if (subject != 0) return;
// non "configured" sinks and sources have lower priority as wireplumber seems to only change
// the "configured" ones.
bool sink = false;
if (strcmp(key, "default.configured.audio.sink") == 0) {
sink = true;
this->sinkConfigured = true;
} else if ((!this->sinkConfigured && strcmp(key, "default.audio.sink") == 0)) {
sink = true;
}
if (sink) {
if (strcmp(key, "default.audio.sink") == 0) {
this->defaultSinkHolder.setObject(metadata);
auto newSink = PwDefaultsMetadata::parseNameSpaJson(value);
qCInfo(logMeta) << "Got default sink" << newSink << "configured:" << this->sinkConfigured;
qCInfo(logMeta) << "Got default sink" << newSink;
if (newSink == this->mDefaultSink) return;
this->mDefaultSink = newSink;
@ -93,19 +82,11 @@ void PwDefaultsMetadata::onMetadataUpdate(
return;
}
bool source = false;
if (strcmp(key, "default.configured.audio.source") == 0) {
source = true;
this->sourceConfigured = true;
} else if ((!this->sourceConfigured && strcmp(key, "default.audio.source") == 0)) {
source = true;
}
if (source) {
if (strcmp(key, "default.audio.source") == 0) {
this->defaultSourceHolder.setObject(metadata);
auto newSource = PwDefaultsMetadata::parseNameSpaJson(value);
qCInfo(logMeta) << "Got default source" << newSource << "configured:" << this->sourceConfigured;
qCInfo(logMeta) << "Got default source" << newSource;
if (newSource == this->mDefaultSource) return;
this->mDefaultSource = newSource;

View file

@ -55,9 +55,7 @@ private:
PwBindableRef<PwMetadata> defaultSinkHolder;
PwBindableRef<PwMetadata> defaultSourceHolder;
bool sinkConfigured = false;
QString mDefaultSink;
bool sourceConfigured = false;
QString mDefaultSource;
};