diff options
author | Luiz Augusto von Dentz <luiz.dentz@indt.org.br> | 2008-07-30 17:57:50 -0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@indt.org.br> | 2008-07-30 17:57:50 -0300 |
commit | d0c561820ca05cafc8a7d20e3250953b48aa5214 (patch) | |
tree | f653006e6617f4f89c9bc60d4451df323bf1a08c | |
parent | 990b22de8763ca1b23a6c2911dcd3ca30592ac3f (diff) |
Remove use of g_dbus_unregister_all_interfaces.
-rw-r--r-- | audio/control.c | 40 | ||||
-rw-r--r-- | audio/control.h | 2 | ||||
-rw-r--r-- | audio/device.c | 18 | ||||
-rw-r--r-- | audio/headset.c | 64 | ||||
-rw-r--r-- | audio/headset.h | 2 | ||||
-rw-r--r-- | audio/sink.c | 46 | ||||
-rw-r--r-- | audio/sink.h | 2 |
7 files changed, 110 insertions, 64 deletions
diff --git a/audio/control.c b/audio/control.c index 02fb8cd1..2a5e5e23 100644 --- a/audio/control.c +++ b/audio/control.c @@ -915,12 +915,39 @@ static GDBusSignalTable control_signals[] = { { NULL, NULL } }; +static void control_free(struct audio_device *dev) +{ + struct control *control = dev->control; + + if (control->session) + avctp_unref(control->session); + + g_free(control); + dev->control = NULL; +} + +static void path_unregister(void *data) +{ + struct audio_device *dev = data; + + info("Unregistered interface %s on path %s", + AUDIO_CONTROL_INTERFACE, dev->path); + + control_free(dev); +} + +void control_unregister(struct audio_device *dev) +{ + g_dbus_unregister_interface(dev->conn, dev->path, + AUDIO_CONTROL_INTERFACE); +} + struct control *control_init(struct audio_device *dev) { if (!g_dbus_register_interface(dev->conn, dev->path, AUDIO_CONTROL_INTERFACE, control_methods, control_signals, NULL, - dev, NULL)) + dev, path_unregister)) return NULL; info("Registered interface %s on path %s", @@ -929,17 +956,6 @@ struct control *control_init(struct audio_device *dev) return g_new0(struct control, 1); } -void control_free(struct audio_device *dev) -{ - struct control *control = dev->control; - - if (control->session) - avctp_unref(control->session); - - g_free(control); - dev->control = NULL; -} - gboolean control_is_active(struct audio_device *dev) { struct control *control = dev->control; diff --git a/audio/control.h b/audio/control.h index bbb5128c..4ebcb9a3 100644 --- a/audio/control.h +++ b/audio/control.h @@ -31,5 +31,5 @@ gboolean avrcp_connect(struct audio_device *dev); void avrcp_disconnect(struct audio_device *dev); struct control *control_init(struct audio_device *dev); -void control_free(struct audio_device *dev); +void control_unregister(struct audio_device *dev); gboolean control_is_active(struct audio_device *dev); diff --git a/audio/device.c b/audio/device.c index 19ce3b41..b5ba61a2 100644 --- a/audio/device.c +++ b/audio/device.c @@ -56,15 +56,6 @@ static void device_free(struct audio_device *dev) { - if (dev->headset) - headset_free(dev); - - if (dev->sink) - sink_free(dev); - - if (dev->control) - control_free(dev); - if (dev->conn) dbus_connection_unref(dev->conn); @@ -119,7 +110,14 @@ gboolean device_is_connected(struct audio_device *dev, const char *interface) void device_unregister(struct audio_device *device) { - g_dbus_unregister_all_interfaces(device->conn, device->path); + if (device->headset) + headset_unregister(device); + + if (device->sink) + sink_unregister(device); + + if (device->control) + control_unregister(device); device_free(device); } diff --git a/audio/headset.c b/audio/headset.c index 7faab78c..61b1745f 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -1456,6 +1456,45 @@ void headset_update(struct audio_device *dev, sdp_record_t *record, uint16_t svc headset_set_channel(headset, record, svc); } +static void headset_free(struct audio_device *dev) +{ + struct headset *hs = dev->headset; + + if (hs->dc_timer) { + g_source_remove(hs->dc_timer); + hs->dc_timer = 0; + } + + if (hs->sco) { + g_io_channel_close(hs->sco); + g_io_channel_unref(hs->sco); + } + + if (hs->rfcomm) { + g_io_channel_close(hs->rfcomm); + g_io_channel_unref(hs->rfcomm); + } + + g_free(hs); + dev->headset = NULL; +} + +static void path_unregister(void *data) +{ + struct audio_device *dev = data; + + info("Unregistered interface %s on path %s", + AUDIO_HEADSET_INTERFACE, dev->path); + + headset_free(dev); +} + +void headset_unregister(struct audio_device *dev) +{ + g_dbus_unregister_interface(dev->conn, dev->path, + AUDIO_HEADSET_INTERFACE); +} + struct headset *headset_init(struct audio_device *dev, sdp_record_t *record, uint16_t svc) { @@ -1493,7 +1532,7 @@ register_iface: if (!g_dbus_register_interface(dev->conn, dev->path, AUDIO_HEADSET_INTERFACE, headset_methods, headset_signals, NULL, - dev, NULL)) { + dev, path_unregister)) { g_free(hs); return NULL; } @@ -1614,29 +1653,6 @@ uint32_t headset_config_init(GKeyFile *config) return ag_features; } -void headset_free(struct audio_device *dev) -{ - struct headset *hs = dev->headset; - - if (hs->dc_timer) { - g_source_remove(hs->dc_timer); - hs->dc_timer = 0; - } - - if (hs->sco) { - g_io_channel_close(hs->sco); - g_io_channel_unref(hs->sco); - } - - if (hs->rfcomm) { - g_io_channel_close(hs->rfcomm); - g_io_channel_unref(hs->rfcomm); - } - - g_free(hs); - dev->headset = NULL; -} - static gboolean hs_dc_timeout(struct audio_device *dev) { headset_set_state(dev, HEADSET_STATE_DISCONNECTED); diff --git a/audio/headset.h b/audio/headset.h index b61a1015..4c928e54 100644 --- a/audio/headset.h +++ b/audio/headset.h @@ -45,7 +45,7 @@ typedef void (*headset_stream_cb_t) (struct audio_device *dev, void *user_data); struct headset *headset_init(struct audio_device *dev, sdp_record_t *record, uint16_t svc); -void headset_free(struct audio_device *dev); +void headset_unregister(struct audio_device *dev); uint32_t headset_config_init(GKeyFile *config); diff --git a/audio/sink.c b/audio/sink.c index 0aa14542..f3b7c55f 100644 --- a/audio/sink.c +++ b/audio/sink.c @@ -494,21 +494,7 @@ static GDBusSignalTable sink_signals[] = { { NULL, NULL } }; -struct sink *sink_init(struct audio_device *dev) -{ - if (!g_dbus_register_interface(dev->conn, dev->path, - AUDIO_SINK_INTERFACE, - sink_methods, sink_signals, NULL, - dev, NULL)) - return NULL; - - info("Registered interface %s on path %s", - AUDIO_SINK_INTERFACE, dev->path); - - return g_new0(struct sink, 1); -} - -void sink_free(struct audio_device *dev) +static void sink_free(struct audio_device *dev) { struct sink *sink = dev->sink; @@ -529,6 +515,36 @@ void sink_free(struct audio_device *dev) dev->sink = NULL; } +static void path_unregister(void *data) +{ + struct audio_device *dev = data; + + info("Unregistered interface %s on path %s", + AUDIO_SINK_INTERFACE, dev->path); + + sink_free(dev); +} + +void sink_unregister(struct audio_device *dev) +{ + g_dbus_unregister_interface(dev->conn, dev->path, + AUDIO_SINK_INTERFACE); +} + +struct sink *sink_init(struct audio_device *dev) +{ + if (!g_dbus_register_interface(dev->conn, dev->path, + AUDIO_SINK_INTERFACE, + sink_methods, sink_signals, NULL, + dev, path_unregister)) + return NULL; + + info("Registered interface %s on path %s", + AUDIO_SINK_INTERFACE, dev->path); + + return g_new0(struct sink, 1); +} + gboolean sink_is_active(struct audio_device *dev) { struct sink *sink = dev->sink; diff --git a/audio/sink.h b/audio/sink.h index 5e4b6aaa..b067e19c 100644 --- a/audio/sink.h +++ b/audio/sink.h @@ -25,7 +25,7 @@ #define AUDIO_SINK_INTERFACE "org.bluez.audio.Sink" struct sink *sink_init(struct audio_device *dev); -void sink_free(struct audio_device *dev); +void sink_unregister(struct audio_device *dev); gboolean sink_is_active(struct audio_device *dev); avdtp_state_t sink_get_state(struct audio_device *dev); gboolean sink_new_stream(struct audio_device *dev, struct avdtp *session, |