diff --git a/profiles/audio/device.h b/profiles/audio/device.h
index e24bdf9..9e0147e 100644
--- a/profiles/audio/device.h
+++ b/profiles/audio/device.h
*/
struct audio_device;
-struct source;
struct control;
struct dev_priv;
struct btd_device *btd_dev;
struct btd_service *sink;
- struct source *source;
+ struct btd_service *source;
struct control *control;
struct dev_priv *priv;
diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index be78818..9de5a02 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
return -1;
}
- audio_dev->source = source_init(audio_dev, service);
+ audio_dev->source = service;
- return 0;
+ return source_init(audio_dev, service);
}
static int a2dp_sink_probe(struct btd_service *service)
diff --git a/profiles/audio/source.c b/profiles/audio/source.c
index 73c3185..a80df2a 100644
--- a/profiles/audio/source.c
+++ b/profiles/audio/source.c
static void source_set_state(struct audio_device *dev, source_state_t new_state)
{
- struct source *source = dev->source;
+ struct source *source = btd_service_get_user_data(dev->source);
source_state_t old_state = source->state;
GSList *l;
avdtp_session_state_t old_state,
avdtp_session_state_t new_state)
{
- struct source *source = dev->source;
+ struct source *source = btd_service_get_user_data(dev->source);
switch (new_state) {
case AVDTP_SESSION_STATE_DISCONNECTED:
void *user_data)
{
struct audio_device *dev = user_data;
- struct source *source = dev->source;
+ struct source *source = btd_service_get_user_data(dev->source);
if (err)
return;
source->session = NULL;
}
-gboolean source_setup_stream(struct source *source, struct avdtp *session)
+gboolean source_setup_stream(struct btd_service *service,
+ struct avdtp *session)
{
+ struct source *source = btd_service_get_user_data(service);
+
if (source->connect_id > 0 || source->disconnect_id > 0)
return FALSE;
int source_connect(struct audio_device *dev)
{
- struct source *source = dev->source;
+ struct source *source = btd_service_get_user_data(dev->source);
if (!source->session)
source->session = avdtp_get(dev);
if (source->stream_state >= AVDTP_STATE_OPEN)
return -EALREADY;
- if (!source_setup_stream(source, NULL)) {
+ if (!source_setup_stream(source->service, NULL)) {
DBG("Failed to create a stream");
return -EIO;
}
static void source_free(struct audio_device *dev)
{
- struct source *source = dev->source;
+ struct source *source = btd_service_get_user_data(dev->source);
if (source->cb_id)
avdtp_stream_remove_cb(source->session, source->stream,
source_free(dev);
}
-struct source *source_init(struct audio_device *dev,
- struct btd_service *service)
+int source_init(struct audio_device *dev, struct btd_service *service)
{
struct source *source;
source->avdtp_callback_id = avdtp_add_state_cb(dev,
avdtp_state_callback);
- return source;
+ btd_service_set_user_data(service, source);
+
+ return 0;
}
gboolean source_new_stream(struct audio_device *dev, struct avdtp *session,
struct avdtp_stream *stream)
{
- struct source *source = dev->source;
+ struct source *source = btd_service_get_user_data(dev->source);
if (source->stream)
return FALSE;
int source_disconnect(struct audio_device *dev, gboolean shutdown)
{
- struct source *source = dev->source;
+ struct source *source = btd_service_get_user_data(dev->source);
if (!source->session)
return -ENOTCONN;
diff --git a/profiles/audio/source.h b/profiles/audio/source.h
index 8bd20a7..ac7ffbd 100644
--- a/profiles/audio/source.h
+++ b/profiles/audio/source.h
void *user_data);
gboolean source_remove_state_cb(unsigned int id);
-struct source *source_init(struct audio_device *dev,
- struct btd_service *service);
+int source_init(struct audio_device *dev, struct btd_service *service);
void source_unregister(struct audio_device *dev);
int source_connect(struct audio_device *dev);
gboolean source_new_stream(struct audio_device *dev, struct avdtp *session,
struct avdtp_stream *stream);
-gboolean source_setup_stream(struct source *source, struct avdtp *session);
+gboolean source_setup_stream(struct btd_service *service,
+ struct avdtp *session);
int source_disconnect(struct audio_device *dev, gboolean shutdown);