mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
bluez5: backend-native: hangup held/active calls respectively only if they exist
On some phones (at least), sending AT+CHLD=0 while there is no held call returns an error. Make sure we don't do this to avoid returning an error on D-Bus when in fact hangup_all actually succeeds.
This commit is contained in:
parent
a2fc92ee69
commit
37fb79b9b8
1 changed files with 27 additions and 5 deletions
|
|
@ -1620,12 +1620,32 @@ static void hfp_hf_hangup_all(void *data, enum spa_bt_telephony_error *err)
|
||||||
{
|
{
|
||||||
struct rfcomm *rfcomm = data;
|
struct rfcomm *rfcomm = data;
|
||||||
struct impl *backend = rfcomm->backend;
|
struct impl *backend = rfcomm->backend;
|
||||||
|
struct spa_bt_telephony_call *call;
|
||||||
|
bool found_active = false;
|
||||||
|
bool found_held = false;
|
||||||
char reply[20];
|
char reply[20];
|
||||||
|
|
||||||
|
spa_list_for_each(call, &rfcomm->telephony_ag->call_list, link) {
|
||||||
|
switch (call->state) {
|
||||||
|
case CALL_STATE_ACTIVE:
|
||||||
|
case CALL_STATE_DIALING:
|
||||||
|
case CALL_STATE_ALERTING:
|
||||||
|
case CALL_STATE_INCOMING:
|
||||||
|
found_active = true;
|
||||||
|
break;
|
||||||
|
case CALL_STATE_HELD:
|
||||||
|
case CALL_STATE_WAITING:
|
||||||
|
found_held = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*err = BT_TELEPHONY_ERROR_NONE;
|
*err = BT_TELEPHONY_ERROR_NONE;
|
||||||
|
|
||||||
/* Hangup held calls */
|
/* Hangup held calls */
|
||||||
if (rfcomm->chld_supported) {
|
if (found_held) {
|
||||||
rfcomm_send_cmd(rfcomm, "AT+CHLD=0");
|
rfcomm_send_cmd(rfcomm, "AT+CHLD=0");
|
||||||
if (!hfp_hf_wait_for_reply(rfcomm, reply, sizeof(reply)) || !spa_strstartswith(reply, "OK")) {
|
if (!hfp_hf_wait_for_reply(rfcomm, reply, sizeof(reply)) || !spa_strstartswith(reply, "OK")) {
|
||||||
spa_log_info(backend->log, "Failed to hangup held calls");
|
spa_log_info(backend->log, "Failed to hangup held calls");
|
||||||
|
|
@ -1634,12 +1654,14 @@ static void hfp_hf_hangup_all(void *data, enum spa_bt_telephony_error *err)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hangup active calls */
|
/* Hangup active calls */
|
||||||
|
if (found_active) {
|
||||||
rfcomm_send_cmd(rfcomm, "AT+CHUP");
|
rfcomm_send_cmd(rfcomm, "AT+CHUP");
|
||||||
if (!hfp_hf_wait_for_reply(rfcomm, reply, sizeof(reply)) || !spa_strstartswith(reply, "OK")) {
|
if (!hfp_hf_wait_for_reply(rfcomm, reply, sizeof(reply)) || !spa_strstartswith(reply, "OK")) {
|
||||||
spa_log_info(backend->log, "Failed to hangup active calls");
|
spa_log_info(backend->log, "Failed to hangup active calls");
|
||||||
*err = BT_TELEPHONY_ERROR_FAILED;
|
*err = BT_TELEPHONY_ERROR_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void hfp_hf_create_multiparty(void *data, enum spa_bt_telephony_error *err)
|
static void hfp_hf_create_multiparty(void *data, enum spa_bt_telephony_error *err)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue