mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-27 21:37:37 -04:00
pulse: inline the message check
Inline the resize check and then call the resize function when necessary.
This commit is contained in:
parent
7ce0b0f339
commit
753ed37ec5
1 changed files with 12 additions and 7 deletions
|
|
@ -377,18 +377,12 @@ done:
|
|||
return res;
|
||||
}
|
||||
|
||||
static int ensure_size(struct message *m, uint32_t size)
|
||||
static int message_resize(struct message *m, uint32_t size)
|
||||
{
|
||||
uint64_t needed;
|
||||
uint32_t alloc, diff;
|
||||
void *data;
|
||||
|
||||
if (m->length > m->allocated)
|
||||
return -ENOMEM;
|
||||
|
||||
if (size <= m->allocated - m->length)
|
||||
return size;
|
||||
|
||||
needed = SPA_ROUND_UP_N(SPA_MAX((uint64_t)m->allocated + size, 4096u), 4096u);
|
||||
if (needed > UINT32_MAX)
|
||||
return -ENOMEM;
|
||||
|
|
@ -408,6 +402,17 @@ static int ensure_size(struct message *m, uint32_t size)
|
|||
return size;
|
||||
}
|
||||
|
||||
static inline int ensure_size(struct message *m, uint32_t size)
|
||||
{
|
||||
if (m->length > m->allocated)
|
||||
return -ENOMEM;
|
||||
|
||||
if (size <= m->allocated - m->length)
|
||||
return size;
|
||||
|
||||
return message_resize(m, size);
|
||||
}
|
||||
|
||||
static void write_8(struct message *m, uint8_t val)
|
||||
{
|
||||
if (ensure_size(m, 1) > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue