bluetooth: add QDSP6 internal BT-SCO audio routing, fix A2DP/HSP-HFP profile handling, and add in-call Bluetooth route
This commit is contained in:
1 parent
02ce3ab1f4
commit
b2ade2dc42
70 files changed
+1182
-97
No files matched your search
@@ -447,9 +447,25 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
bool ringMuted = false;
|
||||
bool micMuted = false;
|
||||
bool speakerOn = false;
|
||||
bool btAudioOn = false;
|
||||
int callVolumePct = 85;
|
||||
int selectedRow = 0;
|
||||
|
||||
auto hasBtAudioCard = []() -> bool {
|
||||
FILE* fp = ::popen("pactl list short cards 2>/dev/null", "r");
|
||||
if (!fp) return false;
|
||||
char line[256];
|
||||
bool found = false;
|
||||
while (std::fgets(line, sizeof(line), fp)) {
|
||||
if (std::strstr(line, "bluez_card.") != nullptr) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
::pclose(fp);
|
||||
return found;
|
||||
};
|
||||
|
||||
int64_t callStartMs = 0;
|
||||
int64_t endedAtMs = 0;
|
||||
int lastFinalDurationSec = 0;
|
||||
@@ -497,8 +513,17 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
alsa.setInteger("ADC1 Volume", mute ? 0 : 8);
|
||||
alsa.setInteger("ADC3 Volume", mute ? 0 : 8);
|
||||
alsa.setInteger("TX1 Digital Volume", mute ? 0 : 88);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", !mute);
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", !mute);
|
||||
if (btAudioOn) {
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer INT_BT_SCO_TX", !mute);
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", !mute);
|
||||
} else {
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer INT_BT_SCO_TX", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", !mute);
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", !mute);
|
||||
}
|
||||
runAsyncCmd(mute ? "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1 >/dev/null 2>&1"
|
||||
: "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0 >/dev/null 2>&1");
|
||||
statusNotice = mute ? "Microphone muted" : "Microphone unmuted";
|
||||
@@ -510,15 +535,64 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
activeSimSlot == 3 || activeSimSlot == 4;
|
||||
};
|
||||
|
||||
auto setSpeakerRoute = [&](bool toSpeaker) {
|
||||
speakerOn = toSpeaker;
|
||||
auto setSpeakerRoute = [&](bool toSpeaker, bool toBt = false) {
|
||||
speakerOn = toBt ? false : toSpeaker;
|
||||
btAudioOn = toBt;
|
||||
bool jackPlugged = (readIntFile("/tmp/sxmo_jack_plugged", 0) == 1);
|
||||
long hwVol = pctToHwVol(callVolumePct, toSpeaker, !toSpeaker && jackPlugged);
|
||||
long hwVol = pctToHwVol(callVolumePct, speakerOn, !speakerOn && jackPlugged);
|
||||
bool voip = isVoipCallId(callId);
|
||||
auto setOutDevFile = [](const char* devName) {
|
||||
std::ofstream out("/tmp/sxmo_audio_out_device", std::ios::trunc);
|
||||
if (out.is_open()) out << devName << "\n";
|
||||
};
|
||||
|
||||
if (toBt) {
|
||||
alsa.setBoolean("SPK DAC Switch", false);
|
||||
alsa.setEnum("EAR_S", 0);
|
||||
alsa.setEnum("HPHL", 0);
|
||||
alsa.setEnum("HPHR", 0);
|
||||
alsa.setEnum("RX1 MIX1 INP1", 0);
|
||||
alsa.setEnum("RX2 MIX1 INP1", 0);
|
||||
alsa.setEnum("RX3 MIX1 INP1", 0);
|
||||
alsa.setInteger("RX1 Digital Volume", 0);
|
||||
alsa.setInteger("RX2 Digital Volume", 0);
|
||||
alsa.setInteger("RX3 Digital Volume", 0);
|
||||
if (!voip) {
|
||||
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
|
||||
alsa.setBoolean("INT_BT_SCO_RX Voice Mixer VoiceMMode1", true);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer INT_BT_SCO_TX", !micMuted);
|
||||
} else {
|
||||
alsa.setBoolean("PRI_MI2S_RX Audio Mixer MultiMedia1", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", false);
|
||||
alsa.setBoolean("INT_BT_SCO_RX Audio Mixer MultiMedia1", true);
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", !micMuted);
|
||||
}
|
||||
setOutDevFile("Bluetooth");
|
||||
statusNotice = "Audio routed to Bluetooth";
|
||||
runAsyncCmd(
|
||||
"bt_card=$(pactl list short cards 2>/dev/null | awk '$2 ~ /^bluez_card\\./ { print $2; exit }'); "
|
||||
"if [ -n \"$bt_card\" ]; then "
|
||||
" pactl set-card-profile \"$bt_card\" headset-head-unit-cvsd >/dev/null 2>&1 || "
|
||||
" pactl set-card-profile \"$bt_card\" headset-head-unit >/dev/null 2>&1 || "
|
||||
" pactl set-card-profile \"$bt_card\" headset-head-unit-msbc >/dev/null 2>&1 || true; "
|
||||
"fi; "
|
||||
"sxmo_audio.sh device set Bluetooth >/dev/null 2>&1; "
|
||||
"sxmo_audio.sh device setinput Bluetooth >/dev/null 2>&1; "
|
||||
"PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" "
|
||||
"sxmo_hook_statusbar.sh volume >/dev/null 2>&1");
|
||||
statusNoticeUntilMs = nowMs() + 2000;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!voip) {
|
||||
alsa.setBoolean("INT_BT_SCO_RX Voice Mixer VoiceMMode1", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer INT_BT_SCO_TX", false);
|
||||
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", true);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", !micMuted);
|
||||
} else {
|
||||
alsa.setBoolean("INT_BT_SCO_RX Audio Mixer MultiMedia1", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", false);
|
||||
alsa.setBoolean("PRI_MI2S_RX Audio Mixer MultiMedia1", true);
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", !micMuted);
|
||||
}
|
||||
@@ -528,10 +602,6 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
alsa.setInteger("ADC1 Volume", 8);
|
||||
alsa.setInteger("TX1 Digital Volume", 88);
|
||||
}
|
||||
auto setOutDevFile = [](const char* devName) {
|
||||
std::ofstream out("/tmp/sxmo_audio_out_device", std::ios::trunc);
|
||||
if (out.is_open()) out << devName << "\n";
|
||||
};
|
||||
if (toSpeaker) {
|
||||
alsa.setEnum("EAR_S", 0);
|
||||
alsa.setEnum("HPHL", 0);
|
||||
@@ -585,18 +655,34 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
statusNoticeUntilMs = nowMs() + 2000;
|
||||
};
|
||||
|
||||
auto cycleAudioRoute = [&]() {
|
||||
if (hasBtAudioCard()) {
|
||||
if (btAudioOn) {
|
||||
setSpeakerRoute(true, false);
|
||||
} else if (speakerOn) {
|
||||
setSpeakerRoute(false, false);
|
||||
} else {
|
||||
setSpeakerRoute(false, true);
|
||||
}
|
||||
} else {
|
||||
setSpeakerRoute(!speakerOn, false);
|
||||
}
|
||||
};
|
||||
|
||||
auto adjustVolume = [&](int deltaPct) {
|
||||
callVolumePct = std::clamp(callVolumePct + deltaPct, 5, 100);
|
||||
writeIntFile("/tmp/sxmo_call_vol", callVolumePct);
|
||||
bool jackPlugged = (readIntFile("/tmp/sxmo_jack_plugged", 0) == 1);
|
||||
if (speakerOn) {
|
||||
alsa.setInteger("RX3 Digital Volume", pctToHwVol(callVolumePct, true, false));
|
||||
} else if (jackPlugged) {
|
||||
long hw = pctToHwVol(callVolumePct, false, true);
|
||||
alsa.setInteger("RX1 Digital Volume", hw);
|
||||
alsa.setInteger("RX2 Digital Volume", hw);
|
||||
} else {
|
||||
alsa.setInteger("RX1 Digital Volume", pctToHwVol(callVolumePct, false, false));
|
||||
if (!btAudioOn) {
|
||||
if (speakerOn) {
|
||||
alsa.setInteger("RX3 Digital Volume", pctToHwVol(callVolumePct, true, false));
|
||||
} else if (jackPlugged) {
|
||||
long hw = pctToHwVol(callVolumePct, false, true);
|
||||
alsa.setInteger("RX1 Digital Volume", hw);
|
||||
alsa.setInteger("RX2 Digital Volume", hw);
|
||||
} else {
|
||||
alsa.setInteger("RX1 Digital Volume", pctToHwVol(callVolumePct, false, false));
|
||||
}
|
||||
}
|
||||
char cmd[128];
|
||||
std::snprintf(cmd, sizeof(cmd),
|
||||
@@ -606,7 +692,13 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
};
|
||||
|
||||
auto finishRecordingFile = [&]() {
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", !micMuted);
|
||||
if (btAudioOn) {
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", !micMuted);
|
||||
} else {
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", !micMuted);
|
||||
}
|
||||
finalizeWavHeader(recordFilePath);
|
||||
struct stat st {};
|
||||
if (!recordFilePath.empty() && ::stat(recordFilePath.c_str(), &st) == 0 &&
|
||||
@@ -686,7 +778,13 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
alsa.setInteger("ADC1 Volume", 8);
|
||||
alsa.setInteger("TX1 Digital Volume", 88);
|
||||
}
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", true);
|
||||
if (btAudioOn) {
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", true);
|
||||
} else {
|
||||
alsa.setBoolean("MultiMedia2 Mixer INT_BT_SCO_TX", false);
|
||||
alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", true);
|
||||
}
|
||||
|
||||
pid_t pid = ::fork();
|
||||
if (pid < 0) {
|
||||
@@ -1037,9 +1135,12 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
"[2] Record", std::max(72, kWinWidth - vw - 44));
|
||||
drawPango(layoutMain, icCol, kWinWidth - vw - 8, ry, rowH, valStr);
|
||||
} else if (i == 2) {
|
||||
bool jackPlugged = (readIntFile("/tmp/sxmo_jack_plugged", 0) == 1);
|
||||
const char* ic = speakerOn ? kIconSpeaker : kIconEarpiece;
|
||||
XftColor* icCol = speakerOn ? &colYellow : &colBlue;
|
||||
std::string valStr = speakerOn ? "SPEAKER" : "EARPIECE";
|
||||
XftColor* icCol = btAudioOn ? &colGreen : (speakerOn ? &colYellow : &colBlue);
|
||||
std::string valStr = btAudioOn ? "BLUETOOTH"
|
||||
: (speakerOn ? "SPEAKER"
|
||||
: (jackPlugged ? "HEADPHONES" : "EARPIECE"));
|
||||
int vw = pangoWidth(layoutMain, valStr);
|
||||
drawPango(layoutIcon, icCol, 10, ry, rowH, ic);
|
||||
drawPango(layoutMain, isSel ? &colWhite : &colLight, 34, ry, rowH,
|
||||
@@ -1261,7 +1362,7 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
selectedRow = 0;
|
||||
writeActiveStateFiles();
|
||||
stopRingingJobs();
|
||||
setSpeakerRoute(false);
|
||||
setSpeakerRoute(false, hasBtAudioCard());
|
||||
render();
|
||||
|
||||
if (cid.rfind("sip:", 0) == 0) {
|
||||
@@ -1310,6 +1411,9 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
ringMuted = false;
|
||||
writeActiveStateFiles();
|
||||
stopRingingJobs();
|
||||
btAudioOn = false;
|
||||
alsa.setBoolean("INT_BT_SCO_RX Voice Mixer VoiceMMode1", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer INT_BT_SCO_TX", false);
|
||||
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
|
||||
alsa.setEnum("EAR_S", 0);
|
||||
@@ -1319,22 +1423,12 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
alsa.setBoolean("SPK DAC Switch", true);
|
||||
int spkPct = readIntFile(getHomeDirPath() + "/.config/sxmo/speaker_vol", 85);
|
||||
alsa.setInteger("RX3 Digital Volume", pctToHwVol(spkPct, true, false));
|
||||
{
|
||||
bool jackPlugged = (readIntFile("/tmp/sxmo_jack_plugged", 0) == 1);
|
||||
std::ofstream out("/tmp/sxmo_audio_out_device", std::ios::trunc);
|
||||
if (out.is_open()) out << (jackPlugged ? "Headphones" : "Speaker") << "\n";
|
||||
}
|
||||
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
|
||||
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; "
|
||||
"sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1; "
|
||||
"if [ \"$(cat /tmp/sxmo_jack_plugged 2>/dev/null)\" = \"1\" ]; then "
|
||||
" sxmo_audio.sh out set Headphones >/dev/null 2>&1; "
|
||||
"else "
|
||||
" sxmo_audio.sh out set Speaker >/dev/null 2>&1; "
|
||||
"fi");
|
||||
"sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1");
|
||||
render();
|
||||
};
|
||||
|
||||
@@ -1615,13 +1709,14 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
if (foundState == "active" && callState != CallState::Active) {
|
||||
if (callState != CallState::Outgoing) {
|
||||
speakerOn = false;
|
||||
btAudioOn = hasBtAudioCard();
|
||||
}
|
||||
callState = CallState::Active;
|
||||
callStartMs = nowMs();
|
||||
ringMuted = false;
|
||||
writeActiveStateFiles();
|
||||
stopRingingJobs();
|
||||
setSpeakerRoute(speakerOn);
|
||||
setSpeakerRoute(speakerOn, btAudioOn);
|
||||
render();
|
||||
} else if (foundState == "ringing-in" && callState == CallState::Idle) {
|
||||
callState = CallState::Incoming;
|
||||
@@ -1820,10 +1915,11 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
callStartMs = nowMs();
|
||||
ringMuted = false;
|
||||
speakerOn = false;
|
||||
btAudioOn = hasBtAudioCard();
|
||||
dtmfMode = false;
|
||||
dtmfSent.clear();
|
||||
selectedRow = 0;
|
||||
setSpeakerRoute(false);
|
||||
setSpeakerRoute(false, btAudioOn);
|
||||
statusNotice.clear();
|
||||
statusNoticeUntilMs = 0;
|
||||
writeActiveStateFiles();
|
||||
@@ -1840,11 +1936,12 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
callStartMs = nowMs();
|
||||
if (!wasOutgoing) {
|
||||
speakerOn = false;
|
||||
btAudioOn = hasBtAudioCard();
|
||||
}
|
||||
}
|
||||
ringMuted = false;
|
||||
selectedRow = 0;
|
||||
setSpeakerRoute(speakerOn);
|
||||
setSpeakerRoute(speakerOn, btAudioOn);
|
||||
statusNotice.clear();
|
||||
statusNoticeUntilMs = 0;
|
||||
writeActiveStateFiles();
|
||||
@@ -2045,7 +2142,7 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
selectedRow = 1;
|
||||
render();
|
||||
} else if (dialCh == '3') {
|
||||
setSpeakerRoute(!speakerOn);
|
||||
cycleAudioRoute();
|
||||
selectedRow = 2;
|
||||
render();
|
||||
} else if (dialCh == '0') {
|
||||
@@ -2120,7 +2217,7 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
} else if (selectedRow == 1) {
|
||||
toggleRecording();
|
||||
} else if (selectedRow == 2) {
|
||||
setSpeakerRoute(!speakerOn);
|
||||
cycleAudioRoute();
|
||||
} else if (selectedRow == 3) {
|
||||
adjustVolume(callVolumePct >= 95 ? -50 : +10);
|
||||
}
|
||||
|
||||
@@ -443,7 +443,24 @@ std::vector<BtDeviceEntry> queryBtDevices() {
|
||||
connectedMacs);
|
||||
|
||||
std::string paRaw = runCaptureCmd(
|
||||
"pactl list sinks short 2>/dev/null; pactl list sources short 2>/dev/null");
|
||||
"pactl list sinks short 2>/dev/null; pactl list sources short 2>/dev/null; "
|
||||
"pactl list cards 2>/dev/null");
|
||||
|
||||
std::unordered_map<std::string, std::string> cardActiveProfile;
|
||||
{
|
||||
std::istringstream pss(paRaw);
|
||||
std::string pline;
|
||||
std::string curCard;
|
||||
while (std::getline(pss, pline)) {
|
||||
std::string t = trimStr(pline);
|
||||
if (t.rfind("Name: bluez_card.", 0) == 0) {
|
||||
curCard = trimStr(t.substr(6));
|
||||
} else if (!curCard.empty() && t.rfind("Active Profile:", 0) == 0) {
|
||||
cardActiveProfile[curCard] = trimStr(t.substr(15));
|
||||
curCard.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string allRaw = runCaptureCmd("timeout 2 bluetoothctl devices 2>/dev/null");
|
||||
std::istringstream ss(allRaw);
|
||||
@@ -553,7 +570,14 @@ std::vector<BtDeviceEntry> queryBtDevices() {
|
||||
infoLow.find("icon: audio-") != std::string::npos) {
|
||||
d.kind = BtDevKind::Audio;
|
||||
if (d.connected) {
|
||||
if (hasPaSrc) {
|
||||
std::string activeProf = toLowerStr(cardActiveProfile["bluez_card." + macU]);
|
||||
if (activeProf.rfind("headset-head-unit", 0) == 0 ||
|
||||
activeProf.find("hfp") != std::string::npos ||
|
||||
activeProf.find("hsp") != std::string::npos) {
|
||||
d.profileLabel = "HSP/HFP";
|
||||
} else if (activeProf.rfind("a2dp", 0) == 0) {
|
||||
d.profileLabel = "A2DP";
|
||||
} else if (hasPaSrc) {
|
||||
d.profileLabel = "HSP/HFP";
|
||||
} else if (hasPaSink) {
|
||||
d.profileLabel = "A2DP";
|
||||
@@ -1537,7 +1561,8 @@ int runNetworksApp(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
if (isConn && targetBt.kind == BtDevKind::Audio) {
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
runCaptureCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
refreshCurrentTab(false);
|
||||
}
|
||||
setBanner(isConn ? ("Connected: " + targetBt.name) : "Connect failed");
|
||||
} else if (act == 1) {
|
||||
@@ -1545,6 +1570,10 @@ int runNetworksApp(int argc, char** argv) {
|
||||
render();
|
||||
runCaptureCmd("timeout 4 bluetoothctl disconnect " + shellQuote(targetBt.mac) +
|
||||
" >/dev/null 2>&1", &rc);
|
||||
if (targetBt.kind == BtDevKind::Audio) {
|
||||
runAsyncCmd("sxmo_audio.sh device setinput Mic1 >/dev/null 2>&1; "
|
||||
"sxmo_audio.sh device set Speaker >/dev/null 2>&1");
|
||||
}
|
||||
refreshCurrentTab(false);
|
||||
setBanner("Disconnected " + targetBt.name);
|
||||
} else if (act == 2) {
|
||||
@@ -1563,7 +1592,8 @@ int runNetworksApp(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
if (isPairedOrConn && targetBt.kind == BtDevKind::Audio) {
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
runCaptureCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
refreshCurrentTab(false);
|
||||
}
|
||||
setBanner(isPairedOrConn ? ("Paired & connected: " + targetBt.name)
|
||||
: ("Pairing failed: " + targetBt.name));
|
||||
@@ -1579,19 +1609,37 @@ int runNetworksApp(int argc, char** argv) {
|
||||
render();
|
||||
if (wantHfp) {
|
||||
runCaptureCmd("pactl set-card-profile " + shellQuote(card) +
|
||||
" headset-head-unit-cvsd >/dev/null 2>&1 || "
|
||||
"pactl set-card-profile " + shellQuote(card) +
|
||||
" headset-head-unit >/dev/null 2>&1 || "
|
||||
"pactl set-card-profile " + shellQuote(card) +
|
||||
" headset-head-unit-msbc >/dev/null 2>&1 || "
|
||||
"pactl set-card-profile " + shellQuote(card) +
|
||||
" headset-head-unit-cvsd >/dev/null 2>&1", &rc);
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1; "
|
||||
"sxmo_audio.sh device setinput Bluetooth >/dev/null 2>&1");
|
||||
" headset-head-unit-msbc >/dev/null 2>&1", &rc);
|
||||
runCaptureCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1; "
|
||||
"sxmo_audio.sh device setinput Bluetooth >/dev/null 2>&1");
|
||||
} else {
|
||||
runCaptureCmd("pactl set-card-profile " + shellQuote(card) +
|
||||
" a2dp-sink >/dev/null 2>&1", &rc);
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
std::string a2dpCmd =
|
||||
"if ! pactl set-card-profile " + shellQuote(card) +
|
||||
" a2dp-sink >/dev/null 2>&1; then "
|
||||
" prof=$(pactl list cards 2>/dev/null | awk -v c=" +
|
||||
shellQuote(card) +
|
||||
" '$1==\"Name:\"{in_c=($2==c);in_p=0} "
|
||||
"in_c&&$1==\"Profiles:\"{in_p=1;next} "
|
||||
"in_c&&in_p&&/^[[:space:]]*Active Profile:/{in_p=0} "
|
||||
"in_c&&in_p&&$1~/^a2dp-sink/&&$0!~/available: no/{sub(/:$/,\"\",$1);print $1;exit}'); "
|
||||
" [ -n \"$prof\" ] && pactl set-card-profile " + shellQuote(card) +
|
||||
" \"$prof\" >/dev/null 2>&1; "
|
||||
"fi";
|
||||
runCaptureCmd(a2dpCmd, &rc);
|
||||
runCaptureCmd("sxmo_audio.sh device setinput Mic1 >/dev/null 2>&1; "
|
||||
"sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
}
|
||||
refreshCurrentTab(false);
|
||||
for (const auto& d : btList) {
|
||||
if (d.mac == targetBt.mac) {
|
||||
targetBt = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setBanner(rc == 0 ? (std::string("Audio profile: ") + (wantHfp ? "HSP/HFP" : "A2DP"))
|
||||
: "Profile switch unsupported by device");
|
||||
} else if (act == 4) {
|
||||
|
||||
Reference in new issue
Block a user