mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-02-10 19:52:24 +00:00
[Linux] Activate AirPods as output device when connecting
This commit is contained in:
committed by
Tim Gromeyer
parent
f75419748b
commit
c2db0afdf1
@@ -320,6 +320,7 @@ private slots:
|
|||||||
// Clear the device name and model
|
// Clear the device name and model
|
||||||
m_deviceName.clear();
|
m_deviceName.clear();
|
||||||
connectedDeviceMacAddress.clear();
|
connectedDeviceMacAddress.clear();
|
||||||
|
mediaController->setConnectedDeviceMacAddress(connectedDeviceMacAddress);
|
||||||
m_model = AirPodsModel::Unknown;
|
m_model = AirPodsModel::Unknown;
|
||||||
emit deviceNameChanged(m_deviceName);
|
emit deviceNameChanged(m_deviceName);
|
||||||
emit modelChanged();
|
emit modelChanged();
|
||||||
@@ -500,7 +501,6 @@ private slots:
|
|||||||
|
|
||||||
localSocket->connectToService(device.address(), QBluetoothUuid("74ec2172-0bad-4d01-8f77-997b2be0722a"));
|
localSocket->connectToService(device.address(), QBluetoothUuid("74ec2172-0bad-4d01-8f77-997b2be0722a"));
|
||||||
connectedDeviceMacAddress = device.address().toString().replace(":", "_");
|
connectedDeviceMacAddress = device.address().toString().replace(":", "_");
|
||||||
mediaController->setConnectedDeviceMacAddress(connectedDeviceMacAddress);
|
|
||||||
notifyAndroidDevice();
|
notifyAndroidDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,6 +600,11 @@ private slots:
|
|||||||
{
|
{
|
||||||
parseMetadata(data);
|
parseMetadata(data);
|
||||||
initiateMagicPairing();
|
initiateMagicPairing();
|
||||||
|
mediaController->setConnectedDeviceMacAddress(connectedDeviceMacAddress);
|
||||||
|
if (isLeftPodInEar() || isRightPodInEar()) // AirPods get added as output device only after this
|
||||||
|
{
|
||||||
|
mediaController->activateA2dpProfile();
|
||||||
|
}
|
||||||
emit airPodsStatusChanged();
|
emit airPodsStatusChanged();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -145,6 +145,11 @@ void MediaController::handleConversationalAwareness(const QByteArray &data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MediaController::activateA2dpProfile() {
|
void MediaController::activateA2dpProfile() {
|
||||||
|
if (connectedDeviceMacAddress.isEmpty()) {
|
||||||
|
LOG_WARN("Connected device MAC address is empty, cannot activate A2DP profile");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("Activating A2DP profile for AirPods");
|
LOG_INFO("Activating A2DP profile for AirPods");
|
||||||
int result = QProcess::execute(
|
int result = QProcess::execute(
|
||||||
"pactl", QStringList()
|
"pactl", QStringList()
|
||||||
@@ -156,6 +161,11 @@ void MediaController::activateA2dpProfile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MediaController::removeAudioOutputDevice() {
|
void MediaController::removeAudioOutputDevice() {
|
||||||
|
if (connectedDeviceMacAddress.isEmpty()) {
|
||||||
|
LOG_WARN("Connected device MAC address is empty, cannot remove audio output device");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("Removing AirPods as audio output device");
|
LOG_INFO("Removing AirPods as audio output device");
|
||||||
int result = QProcess::execute(
|
int result = QProcess::execute(
|
||||||
"pactl", QStringList()
|
"pactl", QStringList()
|
||||||
|
|||||||
Reference in New Issue
Block a user