3
* BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2006-2007 Nokia Corporation
6
* Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org>
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33
#include <sys/param.h>
34
#include <netinet/in.h>
36
#include <bluetooth/bluetooth.h>
37
#include <bluetooth/hci.h>
38
#include <bluetooth/hci_lib.h>
39
#include <bluetooth/sdp.h>
40
#include <bluetooth/sdp_lib.h>
43
#include <dbus/dbus.h>
57
static void device_free(struct audio_device *dev)
60
dbus_connection_unref(dev->conn);
66
struct audio_device *device_register(DBusConnection *conn,
67
const char *path, const bdaddr_t *src,
70
struct audio_device *dev;
75
dev = g_new0(struct audio_device, 1);
77
dev->path = g_strdup(path);
78
bacpy(&dev->dst, dst);
79
bacpy(&dev->src, src);
80
dev->conn = dbus_connection_ref(conn);
85
gboolean device_is_connected(struct audio_device *dev, const char *interface)
88
if ((dev->sink || dev->source) &&
89
avdtp_is_connected(&dev->src, &dev->dst))
92
if (dev->headset && headset_is_active(dev))
95
else if (!strcmp(interface, AUDIO_SINK_INTERFACE) && dev->sink &&
96
avdtp_is_connected(&dev->src, &dev->dst))
98
else if (!strcmp(interface, AUDIO_SOURCE_INTERFACE) && dev->source &&
99
avdtp_is_connected(&dev->src, &dev->dst))
101
else if (!strcmp(interface, AUDIO_HEADSET_INTERFACE) && dev->headset &&
102
headset_is_active(dev))
104
else if (!strcmp(interface, AUDIO_CONTROL_INTERFACE) && dev->headset &&
105
control_is_active(dev))
111
void device_unregister(struct audio_device *device)
114
headset_unregister(device);
117
sink_unregister(device);
120
control_unregister(device);