shared/bap: Merge PAC records of the same type/codec
Luiz Augusto von Dentz
maintainerRFC 1/1 shared/bap: Merge PAC records of the same type/codec
From: Luiz Augusto von Dentz <[email protected]>
This attempts to merge PAC records which contain the same type and codec to simplify the matching with client endpoints so all capabilities and metadata are match at once instead of for each PAC record.
--- src/shared/bap.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
src/shared/bap.c +61 -0
@@ -284,6 +284,12 @@ static void *iov_add_mem(struct iovec *iov, size_t len, const void *d)return data; } +static void *iov_append (struct iovec *iov,size_t len,const void *d) +{ + iov->iov_base =realloc (iov->iov_base, iov->iov_len + len); +return iov_add_mem (iov, len, d); +} +static void iov_free (void *data) {struct iovec *iov = data;
@@ -2319,6 +2325,52 @@ static struct bt_ascs *bap_get_ascs(struct bt_bap *bap)return bap->rdb->ascs; } +static bool match_codec (const void *data,const void *user_data) +{ +const struct bt_bap_pac *pac = data; +const struct bt_bap_codec *codec = user_data; + +return bap_codec_equal (&pac->codec, codec); +} + +static struct bt_bap_pac *bap_pac_find (struct bt_bap_db *bdb,uint8_t type, +struct bt_bap_codec *codec) +{ +switch (type) { +case BT_BAP_SOURCE : +return queue_find (bdb->sources, match_codec, codec); +case BT_BAP_SINK : +return queue_find (bdb->sinks, match_codec, codec); + } + +return NULL ; +} + +static void *ltv_merge (struct iovec *data,struct iovec *cont) +{ +uint8_t delimiter =0 ; + +iov_append (data,sizeof (delimiter), &delimiter); + +return iov_append (data, cont->iov_len, cont->iov_base); +} + +static void bap_pac_merge (struct bt_bap_pac *pac,struct iovec *data, +struct iovec *metadata) +{ +/* Merge data into existing record */ +if (pac->data) +ltv_merge (pac->data, data); +else + pac->data =iov_dup (data,1 ); + +/* Merge metadata into existing record */ +if (pac->metadata) +ltv_merge (pac->metadata, metadata); +else + pac->metadata =iov_dup (metadata,1 ); +} + static struct bt_bap_pac *bap_pac_new(struct bt_bap_db *bdb, const char *name, uint8_t type, struct bt_bap_codec *codec,
@@ -2328,6 +2380,15 @@ static struct bt_bap_pac *bap_pac_new(struct bt_bap_db *bdb, const char *name, {struct bt_bap_pac *pac; +if (!qos) { +/* Check if there is already a PAC record for the codec */ + pac =bap_pac_find (bdb, type, codec); +if (pac) { +bap_pac_merge (pac, data, metadata); +return pac; + } + } + pac = new0(struct bt_bap_pac, 1); pac->bdb = bdb; pac->name = name ?strdup (name) :NULL ;
Signature · 1 line
2.37.3
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=687658
---Test result---
Test Summary:
CheckPatch PASS 1.50 seconds GitLint PASS 0.94 seconds Prep - Setup ELL PASS 28.28 seconds Build - Prep PASS 0.83 seconds Build - Configure PASS 9.25 seconds Build - Make PASS 1029.51 seconds Make Check PASS 11.98 seconds Make Check w/Valgrind PASS 302.50 seconds Make Distcheck PASS 253.24 seconds Build w/ext ELL - Configure PASS 9.64 seconds Build w/ext ELL - Make PASS 89.76 seconds Incremental Build w/ patches PASS 107.48 seconds Scan Build PASS 577.60 seconds
---
Regards,
Linux Bluetooth