mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05:00
spa/buffer: rename SPA_MEMBER to SPA_PTROFF
SPA_MEMBER is misleading, all we're doing here is pointer+offset and a type-casting the result. Rename to SPA_PTROFF which is more expressive (and has the same number of characters so we don't need to re-indent).
This commit is contained in:
parent
e598d0a422
commit
2405f0942b
92 changed files with 248 additions and 227 deletions
|
|
@ -132,8 +132,19 @@ struct spa_fraction {
|
|||
x; \
|
||||
})
|
||||
|
||||
#define SPA_MEMBER(b,o,t) ((t*)((uint8_t*)(b) + (int)(o)))
|
||||
#define SPA_MEMBER_ALIGN(b,o,a,t) SPA_PTR_ALIGN(SPA_MEMBER(b,o,t),a,t)
|
||||
/**
|
||||
* Return the address (buffer + offset) as pointer of \a type
|
||||
*/
|
||||
#define SPA_PTROFF(ptr_,offset_,type_) ((type_*)((uint8_t*)(ptr_) + (int)(offset_)))
|
||||
#define SPA_PTROFF_ALIGN(ptr_,offset_,alignment_,type_) \
|
||||
SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)
|
||||
|
||||
|
||||
/**
|
||||
* Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead
|
||||
*/
|
||||
#define SPA_MEMBER(b,o,t) SPA_PTROFF(b,o,t)
|
||||
#define SPA_MEMBER_ALIGN(b,o,a,t) SPA_PTROFF_ALIGN(b,o,a,t)
|
||||
|
||||
#define SPA_CONTAINER_OF(p,t,m) (t*)((uint8_t*)p - offsetof (t,m))
|
||||
|
||||
|
|
|
|||
|
|
@ -100,9 +100,9 @@ spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf,
|
|||
uint32_t offset, void *data, uint32_t len)
|
||||
{
|
||||
uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0;
|
||||
spa_memcpy(data, SPA_MEMBER(buffer, offset, void), l0);
|
||||
spa_memcpy(data, SPA_PTROFF(buffer, offset, void), l0);
|
||||
if (SPA_UNLIKELY(l1 > 0))
|
||||
spa_memcpy(SPA_MEMBER(data, l0, void), buffer, l1);
|
||||
spa_memcpy(SPA_PTROFF(data, l0, void), buffer, l1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -150,9 +150,9 @@ spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf,
|
|||
uint32_t offset, const void *data, uint32_t len)
|
||||
{
|
||||
uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0;
|
||||
spa_memcpy(SPA_MEMBER(buffer, offset, void), data, l0);
|
||||
spa_memcpy(SPA_PTROFF(buffer, offset, void), data, l0);
|
||||
if (SPA_UNLIKELY(l1 > 0))
|
||||
spa_memcpy(buffer, SPA_MEMBER(data, l0, void), l1);
|
||||
spa_memcpy(buffer, SPA_PTROFF(data, l0, void), l1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue