bluez5: simplify ltv parsing

This commit is contained in:
Pauli Virtanen 2025-10-12 02:15:34 +03:00 committed by Wim Taymans
parent ff6db3e08e
commit 2010a525d3
2 changed files with 36 additions and 22 deletions

View file

@ -15,6 +15,7 @@
#include <spa/pod/pod.h>
#include <spa/pod/builder.h>
#include <spa/support/log.h>
#include <spa/debug/log.h>
#include "a2dp-codec-caps.h"
#include "bap-codec-caps.h"
@ -287,4 +288,24 @@ void ltv_writer_uint16(struct ltv_writer *w, uint8_t type, uint16_t value);
void ltv_writer_uint32(struct ltv_writer *w, uint8_t type, uint32_t value);
int ltv_writer_end(struct ltv_writer *w);
static inline const struct ltv *ltv_next(const void **data, size_t *size)
{
const struct ltv *ltv;
if (*size == 0) {
*data = NULL;
return NULL;
}
if (*size < sizeof(struct ltv))
return NULL;
ltv = *data;
if (ltv->len >= *size)
return NULL;
*data = SPA_PTROFF(*data, ltv->len + 1, void);
*size -= ltv->len + 1;
return ltv;
}
#endif