diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index c276c52..3516640 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
struct avctp_state_callback {
avctp_state_cb cb;
+ struct audio_device *dev;
void *user_data;
unsigned int id;
};
for (l = callbacks; l != NULL; l = l->next) {
struct avctp_state_callback *cb = l->data;
+
+ if (cb->dev && cb->dev != dev)
+ continue;
+
cb->cb(dev, old_state, new_state, cb->user_data);
}
func, user_data);
}
-unsigned int avctp_add_state_cb(avctp_state_cb cb, void *user_data)
+unsigned int avctp_add_state_cb(struct audio_device *dev, avctp_state_cb cb,
+ void *user_data)
{
struct avctp_state_callback *state_cb;
static unsigned int id = 0;
state_cb = g_new(struct avctp_state_callback, 1);
state_cb->cb = cb;
+ state_cb->dev = dev;
state_cb->user_data = user_data;
state_cb->id = ++id;
diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h
index 411b093..7d05572 100644
--- a/profiles/audio/avctp.h
+++ b/profiles/audio/avctp.h
uint8_t *operands, size_t operand_count,
void *user_data);
-unsigned int avctp_add_state_cb(avctp_state_cb cb, void *user_data);
+unsigned int avctp_add_state_cb(struct audio_device *dev, avctp_state_cb cb,
+ void *user_data);
gboolean avctp_remove_state_cb(unsigned int id);
int avctp_register(struct btd_adapter *adapter, gboolean master);
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index abb902a..6965fe2 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
servers = g_slist_append(servers, server);
if (!avctp_id)
- avctp_id = avctp_add_state_cb(state_changed, NULL);
+ avctp_id = avctp_add_state_cb(NULL, state_changed, NULL);
return 0;
}
diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index 18c8478..b50e890 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
#include "glib-helper.h"
#include "dbus-common.h"
-static unsigned int avctp_id = 0;
-
struct control {
struct avctp *session;
gboolean target;
+ unsigned int avctp_id;
};
static void state_changed(struct audio_device *dev, avctp_state_t old_state,
if (control->session)
avctp_disconnect(control->session);
+ avctp_remove_state_cb(control->avctp_id);
+
g_free(control);
dev->control = NULL;
}
control_update(control, uuids);
- if (!avctp_id)
- avctp_id = avctp_add_state_cb(state_changed, NULL);
+ control->avctp_id = avctp_add_state_cb(dev, state_changed, NULL);
return control;
}
diff --git a/profiles/audio/device.c b/profiles/audio/device.c
index 8d5e10f..bd62434 100644
--- a/profiles/audio/device.c
+++ b/profiles/audio/device.c
gboolean disconnecting;
unsigned int avdtp_callback_id;
+ unsigned int avctp_callback_id;
};
static unsigned int sink_callback_id = 0;
-static unsigned int avctp_callback_id = 0;
static void device_free(struct audio_device *dev)
{
priv->dc_id);
avdtp_remove_state_cb(priv->avdtp_callback_id);
+ avctp_remove_state_cb(priv->avctp_callback_id);
g_free(priv);
}
sink_callback_id = sink_add_state_cb(device_sink_cb, NULL);
dev->priv->avdtp_callback_id = avdtp_add_state_cb(dev, device_avdtp_cb);
-
- if (avctp_callback_id == 0)
- avctp_callback_id = avctp_add_state_cb(device_avctp_cb, NULL);
+ dev->priv->avctp_callback_id = avctp_add_state_cb(dev, device_avctp_cb,
+ NULL);
return dev;
}