mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-23 06:59:58 -05:00
bluez5: simplify ltv parsing
This commit is contained in:
parent
ff6db3e08e
commit
2010a525d3
2 changed files with 36 additions and 22 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue