mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-29 15:14:31 +08:00
Add watch for RFCOMM disconnect to HFP HF role
This commit is contained in:
parent
3163523575
commit
b15f606312
@ -192,9 +192,26 @@ static void sco_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
|
||||
(GIOFunc) sco_io_cb, dev);
|
||||
}
|
||||
|
||||
static gboolean rfcomm_disconnect_cb(GIOChannel *chan, GIOCondition cond,
|
||||
struct audio_device *dev)
|
||||
{
|
||||
struct gateway *gw = dev->gateway;
|
||||
|
||||
if (cond & G_IO_NVAL)
|
||||
return FALSE;
|
||||
|
||||
g_io_channel_shutdown(gw->rfcomm, TRUE, NULL);
|
||||
g_io_channel_unref(gw->rfcomm);
|
||||
gw->rfcomm = NULL;
|
||||
change_state(dev, GATEWAY_STATE_DISCONNECTED);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void newconnection_reply(DBusPendingCall *call, void *data)
|
||||
{
|
||||
struct audio_device *dev = data;
|
||||
struct gateway *gw = dev->gateway;
|
||||
DBusMessage *reply = dbus_pending_call_steal_reply(call);
|
||||
DBusError derr;
|
||||
|
||||
@ -206,6 +223,8 @@ static void newconnection_reply(DBusPendingCall *call, void *data)
|
||||
dbus_error_init(&derr);
|
||||
if (!dbus_set_error_from_message(&derr, reply)) {
|
||||
DBG("Agent reply: file descriptor passed successfully");
|
||||
g_io_add_watch(gw->rfcomm, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
|
||||
(GIOFunc) rfcomm_disconnect_cb, dev);
|
||||
change_state(dev, GATEWAY_STATE_CONNECTED);
|
||||
goto done;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user