Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions linux/media/mediacontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ void MediaController::followMediaChanges() {
bool MediaController::isActiveOutputDeviceAirPods() {
QString defaultSink = m_pulseAudio->getDefaultSink();
LOG_DEBUG("Default sink: " << defaultSink);
return defaultSink.contains(connectedDeviceMacAddress);
LOG_DEBUG("Default macAddress: " << connectedDeviceMacAddress);
QString macForPulseWire = connectedDeviceMacAddress;
macForPulseWire.replace("_",":");
LOG_DEBUG("macAddress formated for PulseWire/PipeWire: " << macForPulseWire);
return defaultSink.contains(macForPulseWire, Qt::CaseInsensitive);
}

void MediaController::handleConversationalAwareness(const QByteArray &data) {
Expand Down Expand Up @@ -154,7 +158,7 @@ bool MediaController::isA2dpProfileAvailable() {
return false;
}

return m_pulseAudio->isProfileAvailable(m_deviceOutputName, "a2dp-sink-sbc_xq") ||
return m_pulseAudio->isProfileAvailable(m_deviceOutputName, "a2dp-sink-sbc_xq") ||
m_pulseAudio->isProfileAvailable(m_deviceOutputName, "a2dp-sink-sbc") ||
m_pulseAudio->isProfileAvailable(m_deviceOutputName, "a2dp-sink");
}
Expand All @@ -164,7 +168,7 @@ QString MediaController::getPreferredA2dpProfile() {
return QString();
}

if (!m_cachedA2dpProfile.isEmpty() &&
if (!m_cachedA2dpProfile.isEmpty() &&
m_pulseAudio->isProfileAvailable(m_deviceOutputName, m_cachedA2dpProfile)) {
return m_cachedA2dpProfile;
}
Expand Down Expand Up @@ -234,7 +238,7 @@ void MediaController::removeAudioOutputDevice() {
LOG_WARN("Connected device MAC address or output name is empty, cannot remove audio output device");
return;
}

LOG_INFO("Removing AirPods as audio output device");
if (!m_pulseAudio->setCardProfile(m_deviceOutputName, "off")) {
LOG_ERROR("Failed to remove AirPods as audio output device");
Expand Down Expand Up @@ -416,4 +420,4 @@ QString MediaController::getAudioDeviceName()
LOG_ERROR("No matching Bluetooth card found for MAC address: " << connectedDeviceMacAddress);
}
return cardName;
}
}