diff options
-rw-r--r-- | audio/a2dp.c | 3 | ||||
-rw-r--r-- | audio/device.c | 2 | ||||
-rw-r--r-- | audio/device.h | 13 | ||||
-rw-r--r-- | audio/gateway.c | 2 | ||||
-rw-r--r-- | audio/gateway.h | 4 | ||||
-rw-r--r-- | audio/headset.c | 61 | ||||
-rw-r--r-- | audio/headset.h | 32 | ||||
-rw-r--r-- | audio/manager.c | 6 | ||||
-rw-r--r-- | audio/manager.h | 1 | ||||
-rw-r--r-- | audio/sink.c | 28 | ||||
-rw-r--r-- | audio/sink.h | 19 | ||||
-rw-r--r-- | audio/unix.c | 1 |
12 files changed, 87 insertions, 85 deletions
diff --git a/audio/a2dp.c b/audio/a2dp.c index 1f34fc24..03cb8868 100644 --- a/audio/a2dp.c +++ b/audio/a2dp.c @@ -35,6 +35,7 @@ #include "logging.h" #include "manager.h" +#include "device.h" #include "avdtp.h" #include "sink.h" #include "a2dp.h" @@ -72,7 +73,7 @@ static gboolean setconf_ind(struct avdtp *session, return FALSE; } - sink_new_stream(session, stream, dev); + sink_new_stream(dev, session, stream); return TRUE; } diff --git a/audio/device.c b/audio/device.c index 18e494c1..54d4bb6f 100644 --- a/audio/device.c +++ b/audio/device.c @@ -43,6 +43,8 @@ #include "logging.h" #include "textfile.h" +#include "headset.h" +#include "sink.h" #include "device.h" static DBusHandlerResult device_get_address(DBusConnection *conn, diff --git a/audio/device.h b/audio/device.h index d7608741..5782dd99 100644 --- a/audio/device.h +++ b/audio/device.h @@ -20,12 +20,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ +#ifndef __AUDIO_DEVICE_H__ +#define __AUDIO_DEVICE_H__ #include <bluetooth/bluetooth.h> +#include <dbus/dbus.h> +#include <glib.h> -#include "headset.h" -#include "gateway.h" -#include "sink.h" +#include "ipc.h" #define AUDIO_DEVICE_INTERFACE "org.bluez.audio.Device" @@ -53,6 +55,9 @@ struct source; struct control; struct target; +struct sink; +struct headset; +struct gateway; struct device { DBusConnection *conn; @@ -82,3 +87,5 @@ int device_get_config(struct device *dev, int sock, struct ipc_packet *req, void device_set_state(struct device *dev, uint8_t state); uint8_t device_get_state(struct device *dev); + +#endif diff --git a/audio/gateway.c b/audio/gateway.c index 2f4ab59e..d91a2225 100644 --- a/audio/gateway.c +++ b/audio/gateway.c @@ -24,3 +24,5 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif + +#include "gateway.h" diff --git a/audio/gateway.h b/audio/gateway.h index 8794ac99..7fddb33c 100644 --- a/audio/gateway.h +++ b/audio/gateway.h @@ -21,9 +21,9 @@ * */ -#define AUDIO_GATEWAY_INTERFACE "org.bluez.audio.Gateway" +#include "device.h" -struct gateway; +#define AUDIO_GATEWAY_INTERFACE "org.bluez.audio.Gateway" int gateway_init(DBusConnection *conn, gboolean disable_hfp, gboolean sco_hci); diff --git a/audio/headset.c b/audio/headset.c index 9c91c925..3a01dbb1 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -51,9 +51,11 @@ #include "dbus.h" #include "dbus-helper.h" #include "logging.h" +#include "device.h" #include "manager.h" #include "error.h" #include "unix.h" +#include "headset.h" #define RING_INTERVAL 3000 @@ -1291,9 +1293,9 @@ static void headset_set_channel(struct headset *headset, sdp_record_t *record) error("Unable to get RFCOMM channel from Headset record"); } -void headset_update(void *device, sdp_record_t *record, uint16_t svc) +void headset_update(struct device *dev, sdp_record_t *record, uint16_t svc) { - struct headset *headset = ((struct device *) device)->headset; + struct headset *headset = dev->headset; switch (svc) { case HANDSFREE_SVCLASS_ID: @@ -1329,10 +1331,9 @@ void headset_update(void *device, sdp_record_t *record, uint16_t svc) headset_set_channel(headset, record); } -struct headset *headset_init(void *device, sdp_record_t *record, - uint16_t svc) +struct headset *headset_init(struct device *dev, sdp_record_t *record, + uint16_t svc) { - struct device *dev = (struct device *) device; struct headset *hs; hs = g_new0(struct headset, 1); @@ -1371,9 +1372,8 @@ register_iface: return hs; } -void headset_free(void *device) +void headset_free(struct device *dev) { - struct device *dev = device; struct headset *hs = dev->headset; if (hs->sco) { @@ -1390,10 +1390,10 @@ void headset_free(void *device) dev->headset = NULL; } -int headset_get_config(void *device, int sock, struct ipc_packet *pkt, +int headset_get_config(struct device *dev, int sock, struct ipc_packet *pkt, int pkt_len, struct ipc_data_cfg **cfg, int *fd) { - struct headset *hs = ((struct device *) device)->headset; + struct headset *hs = dev->headset; int err = EINVAL; struct pending_connect *c; @@ -1406,9 +1406,9 @@ int headset_get_config(void *device, int sock, struct ipc_packet *pkt, memcpy(c->pkt, pkt, pkt_len); if (hs->rfcomm == NULL) - err = rfcomm_connect(device, c); + err = rfcomm_connect(dev, c); else if (hs->sco == NULL) - err = sco_connect(device, c); + err = sco_connect(dev, c); else goto error; @@ -1436,32 +1436,31 @@ error: return -err; } -headset_type_t headset_get_type(void *device) +headset_type_t headset_get_type(struct device *dev) { - struct headset *hs = ((struct device *) device)->headset; + struct headset *hs = dev->headset; return hs->type; } -void headset_set_type(void *device, headset_type_t type) +void headset_set_type(struct device *dev, headset_type_t type) { - struct headset *hs = ((struct device *) device)->headset; + struct headset *hs = dev->headset; hs->type = type; } -int headset_connect_rfcomm(void *device, int sock) +int headset_connect_rfcomm(struct device *dev, int sock) { - struct headset *hs = ((struct device *) device)->headset; + struct headset *hs = dev->headset; hs->rfcomm = g_io_channel_unix_new(sock); return hs->rfcomm ? 0 : -EINVAL; } -int headset_close_rfcomm(void *device) +int headset_close_rfcomm(struct device *dev) { - struct device *dev = (struct device *) device; struct headset *hs = dev->headset; if (hs->ring_timer) { @@ -1480,9 +1479,8 @@ int headset_close_rfcomm(void *device) return 0; } -void headset_set_state(void *device, headset_state_t state) +void headset_set_state(struct device *dev, headset_state_t state) { - struct device *dev = (struct device *) device; struct headset *hs = dev->headset; char str[13]; @@ -1491,8 +1489,8 @@ void headset_set_state(void *device, headset_state_t state) switch(state) { case HEADSET_STATE_DISCONNECTED: - close_sco(device); - headset_close_rfcomm(device); + close_sco(dev); + headset_close_rfcomm(dev); dbus_connection_emit_signal(dev->conn, dev->path, AUDIO_HEADSET_INTERFACE, "Disconnected", @@ -1504,7 +1502,7 @@ void headset_set_state(void *device, headset_state_t state) if (hs->state < state) { g_io_add_watch(hs->rfcomm, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - (GIOFunc) rfcomm_io_cb, device); + (GIOFunc) rfcomm_io_cb, dev); dbus_connection_emit_signal(dev->conn, dev->path, AUDIO_HEADSET_INTERFACE, @@ -1512,7 +1510,7 @@ void headset_set_state(void *device, headset_state_t state) DBUS_TYPE_INVALID); } else { - close_sco(device); + close_sco(dev); dbus_connection_emit_signal(dev->conn, dev->path, AUDIO_HEADSET_INTERFACE, "Stopped", @@ -1523,7 +1521,7 @@ void headset_set_state(void *device, headset_state_t state) break; case HEADSET_STATE_PLAYING: g_io_add_watch(hs->sco, G_IO_ERR | G_IO_HUP | G_IO_NVAL, - (GIOFunc) sco_cb, device); + (GIOFunc) sco_cb, dev); dbus_connection_emit_signal(dev->conn, dev->path, AUDIO_HEADSET_INTERFACE, @@ -1548,23 +1546,22 @@ void headset_set_state(void *device, headset_state_t state) hs->state = state; } -headset_state_t headset_get_state(void *device) +headset_state_t headset_get_state(struct device *dev) { - struct headset *hs = ((struct device *) device)->headset; + struct headset *hs = dev->headset; return hs->state; } -int headset_get_channel(void *device) +int headset_get_channel(struct device *dev) { - struct headset *hs = ((struct device *) device)->headset; + struct headset *hs = dev->headset; return hs->rfcomm_ch; } -gboolean headset_is_active(void *device) +gboolean headset_is_active(struct device *dev) { - struct device *dev = device; struct headset *hs = dev->headset; if (hs->state != HEADSET_STATE_DISCONNECTED) diff --git a/audio/headset.h b/audio/headset.h index db1fef65..ec57f1d8 100644 --- a/audio/headset.h +++ b/audio/headset.h @@ -20,15 +20,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ -#ifndef __AUDIO_HEADSET_H__ -#define __AUDIO_HEADSET_H__ - #include <bluetooth/sdp.h> #include <bluetooth/sdp_lib.h> #include <dbus/dbus.h> #include "ipc.h" +#include "device.h" #define AUDIO_HEADSET_INTERFACE "org.bluez.audio.Headset" @@ -55,29 +53,25 @@ typedef enum { SVC_HANDSFREE } headset_type_t; -struct headset; - -struct headset *headset_init(void *device, sdp_record_t *record, +struct headset *headset_init(struct device *dev, sdp_record_t *record, uint16_t svc); -void headset_free(void *device); +void headset_free(struct device *dev); -void headset_update(void *device, sdp_record_t *record, uint16_t svc); +void headset_update(struct device *dev, sdp_record_t *record, uint16_t svc); -int headset_get_config(void *device, int sock, struct ipc_packet *pkt, +int headset_get_config(struct device *dev, int sock, struct ipc_packet *pkt, int pkt_len, struct ipc_data_cfg **rsp, int *fd); -headset_type_t headset_get_type(void *device); -void headset_set_type(void *device, headset_type_t type); - -int headset_connect_rfcomm(void *device, int sock); -int headset_close_rfcomm(void *device); +headset_type_t headset_get_type(struct device *dev); +void headset_set_type(struct device *dev, headset_type_t type); -headset_state_t headset_get_state(void *device); -void headset_set_state(void *device, headset_state_t state); +int headset_connect_rfcomm(struct device *dev, int sock); +int headset_close_rfcomm(struct device *dev); -int headset_get_channel(void *device); +headset_state_t headset_get_state(struct device *dev); +void headset_set_state(struct device *dev, headset_state_t state); -gboolean headset_is_active(void *device); +int headset_get_channel(struct device *dev); -#endif +gboolean headset_is_active(struct device *dev); diff --git a/audio/manager.c b/audio/manager.c index e3c5a564..dd0907f6 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -50,10 +50,14 @@ #include "dbus-helper.h" #include "logging.h" #include "textfile.h" -#include "manager.h" +#include "device.h" #include "error.h" #include "a2dp.h" #include "avdtp.h" +#include "headset.h" +#include "gateway.h" +#include "sink.h" +#include "manager.h" typedef enum { HEADSET = 1 << 0, diff --git a/audio/manager.h b/audio/manager.h index 0bfcad85..993c1057 100644 --- a/audio/manager.h +++ b/audio/manager.h @@ -21,6 +21,7 @@ * */ +#include <bluetooth/sdp.h> #include <dbus/dbus.h> #include "device.h" diff --git a/audio/sink.c b/audio/sink.c index be762e39..08a862cf 100644 --- a/audio/sink.c +++ b/audio/sink.c @@ -39,6 +39,7 @@ #include "a2dp.h" #include "error.h" #include "unix.h" +#include "sink.h" struct pending_connect { DBusMessage *msg; @@ -328,10 +329,8 @@ static DBusSignalVTable sink_signals[] = { { NULL, NULL } }; -struct sink *sink_init(void *device) +struct sink *sink_init(struct device *dev) { - struct device *dev = device; - if (!dbus_connection_register_interface(dev->conn, dev->path, AUDIO_SINK_INTERFACE, sink_methods, @@ -341,9 +340,8 @@ struct sink *sink_init(void *device) return g_new0(struct sink, 1); } -void sink_free(void *device) +void sink_free(struct device *dev) { - struct device *dev = device; struct sink *sink = dev->sink; if (sink->session) @@ -356,10 +354,9 @@ void sink_free(void *device) dev->sink = NULL; } -int sink_get_config(void *device, int sock, struct ipc_packet *req, +int sink_get_config(struct device *dev, int sock, struct ipc_packet *req, int pkt_len, struct ipc_data_cfg **rsp, int *fd) { - struct device *dev = device; struct sink *sink = dev->sink; int err = EINVAL; struct pending_connect *c = NULL; @@ -377,7 +374,7 @@ int sink_get_config(void *device, int sock, struct ipc_packet *req, sink->c = c; if (sink->state == AVDTP_STATE_IDLE) - err = avdtp_discover(sink->session, discovery_complete, device); + err = avdtp_discover(sink->session, discovery_complete, dev); else if (sink->state < AVDTP_STATE_STREAMING) err = avdtp_start(sink->session, sink->stream); else @@ -400,9 +397,8 @@ error: return -err; } -gboolean sink_is_active(void *device) +gboolean sink_is_active(struct device *dev) { - struct device *dev = device; struct sink *sink = dev->sink; if (sink->session) @@ -411,9 +407,8 @@ gboolean sink_is_active(void *device) return FALSE; } -void sink_set_state(void *device, avdtp_state_t state) +void sink_set_state(struct device *dev, avdtp_state_t state) { - struct device *dev = device; struct sink *sink = dev->sink; int err = 0; @@ -455,18 +450,17 @@ failed: error("%s: Error changing states", dev->path); } -avdtp_state_t sink_get_state(void *device) +avdtp_state_t sink_get_state(struct device *dev) { - struct device *dev = device; struct sink *sink = dev->sink; return sink->state; } -gboolean sink_new_stream(struct avdtp *session, struct avdtp_stream *stream, - void *dev) +gboolean sink_new_stream(struct device *dev, struct avdtp *session, + struct avdtp_stream *stream) { - struct sink *sink = ((struct device *) (dev))->sink; + struct sink *sink = dev->sink; if (sink->stream) return FALSE; diff --git a/audio/sink.h b/audio/sink.h index 45745a19..4cb5d0c3 100644 --- a/audio/sink.h +++ b/audio/sink.h @@ -23,17 +23,16 @@ #include "ipc.h" #include "avdtp.h" +#include "device.h" #define AUDIO_SINK_INTERFACE "org.bluez.audio.Sink" -struct sink; - -struct sink *sink_init(void *device); -void sink_free(void *device); -int sink_get_config(void *device, int sock, struct ipc_packet *req, +struct sink *sink_init(struct device *dev); +void sink_free(struct device *dev); +int sink_get_config(struct device *dev, int sock, struct ipc_packet *req, int pkt_len, struct ipc_data_cfg **rsp, int *fd); -gboolean sink_is_active(void *device); -void sink_set_state(void *device, avdtp_state_t state); -avdtp_state_t sink_get_state(void *device); -gboolean sink_new_stream(struct avdtp *session, struct avdtp_stream *stream, - void *dev); +gboolean sink_is_active(struct device *dev); +void sink_set_state(struct device *dev, avdtp_state_t state); +avdtp_state_t sink_get_state(struct device *dev); +gboolean sink_new_stream(struct device *dev, struct avdtp *session, + struct avdtp_stream *stream); diff --git a/audio/unix.c b/audio/unix.c index 355a7403..8a65df8e 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -37,6 +37,7 @@ #include "logging.h" #include "dbus.h" +#include "device.h" #include "manager.h" #include "ipc.h" #include "unix.h" |