Add a method for getting the audio stream associated with a media transport. --- Notes: v2: make generic and split out to separate patch profiles/audio/transport.c | 18 ++++++++++++++++++ profiles/audio/transport.h | 1 + 2 files changed, 19 insertions(+) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 5e057e2a5..912f404e8 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -116,6 +116,8 @@ struct media_transport { guint id); void (*set_state) (struct media_transport *transport, transport_state_t state); + void *(*get_stream) + (struct media_transport *transport); GDestroyNotify destroy; void *data; }; @@ -1380,6 +1382,13 @@ static void bap_connecting(struct bt_bap_stream *stream, bool state, int fd, bap_update_links(transport); } +static void *get_stream_bap(struct media_transport *transport) +{ + struct bap_transport *bap = transport->data; + + return bap->stream; +} + static void free_bap(void *data) { struct bap_transport *bap = data; @@ -1415,6 +1424,7 @@ static int media_transport_init_bap(struct media_transport *transport, transport->suspend = suspend_bap; transport->cancel = cancel_bap; transport->set_state = set_state_bap; + transport->get_stream = get_stream_bap; transport->destroy = free_bap; return 0; @@ -1483,6 +1493,14 @@ const char *media_transport_get_path(struct media_transport *transport) return transport->path; } +void *media_transport_get_stream(struct media_transport *transport) +{ + if (transport->get_stream) + return transport->get_stream(transport); + + return NULL; +} + void media_transport_update_delay(struct media_transport *transport, uint16_t delay) { diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index 102fc3cf1..5ca9b8f9e 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -19,6 +19,7 @@ struct media_transport *media_transport_create(struct btd_device *device, void media_transport_destroy(struct media_transport *transport); const char *media_transport_get_path(struct media_transport *transport); +void *media_transport_get_stream(struct media_transport *transport); struct btd_device *media_transport_get_dev(struct media_transport *transport); int8_t media_transport_get_volume(struct media_transport *transport); void media_transport_update_delay(struct media_transport *transport, -- 2.39.1