mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Meta: rework ringbuffer meta
ringbuffer: remove size and mask from the ringbuffer, we have that elsewhere in the user of the ringbuffer. Remove the buffer data offset and size fields and replace with a ringbuffer. We then have a ringbuffer in all buffer data, which simplifies things. We can now remove the ringbuffer metadata.
This commit is contained in:
parent
49d8f6792e
commit
2923b623b3
27 changed files with 199 additions and 374 deletions
|
|
@ -86,8 +86,8 @@ impl_log_logv(struct spa_log *log,
|
|||
uint64_t count = 1;
|
||||
|
||||
spa_ringbuffer_get_write_index(&impl->trace_rb, &index);
|
||||
spa_ringbuffer_write_data(&impl->trace_rb, impl->trace_data,
|
||||
index & impl->trace_rb.mask, location, size);
|
||||
spa_ringbuffer_write_data(&impl->trace_rb, impl->trace_data, TRACE_BUFFER,
|
||||
index & (TRACE_BUFFER - 1), location, size);
|
||||
spa_ringbuffer_write_update(&impl->trace_rb, index + size);
|
||||
|
||||
if (write(impl->source.fd, &count, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
|
|
@ -124,12 +124,12 @@ static void on_trace_event(struct spa_source *source)
|
|||
while ((avail = spa_ringbuffer_get_read_index(&impl->trace_rb, &index)) > 0) {
|
||||
uint32_t offset, first;
|
||||
|
||||
if (avail > impl->trace_rb.size) {
|
||||
index += avail - impl->trace_rb.size;
|
||||
avail = impl->trace_rb.size;
|
||||
if (avail > TRACE_BUFFER) {
|
||||
index += avail - TRACE_BUFFER;
|
||||
avail = TRACE_BUFFER;
|
||||
}
|
||||
offset = index & impl->trace_rb.mask;
|
||||
first = SPA_MIN(avail, impl->trace_rb.size - offset);
|
||||
offset = index & (TRACE_BUFFER - 1);
|
||||
first = SPA_MIN(avail, TRACE_BUFFER - offset);
|
||||
|
||||
fwrite(impl->trace_data + offset, first, 1, stderr);
|
||||
if (SPA_UNLIKELY(avail > first)) {
|
||||
|
|
@ -223,7 +223,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->have_source = true;
|
||||
}
|
||||
|
||||
spa_ringbuffer_init(&this->trace_rb, TRACE_BUFFER);
|
||||
spa_ringbuffer_init(&this->trace_rb);
|
||||
|
||||
spa_log_debug(&this->log, NAME " %p: initialized", this);
|
||||
|
||||
|
|
|
|||
|
|
@ -212,18 +212,18 @@ loop_invoke(struct spa_loop *loop,
|
|||
uint32_t idx, offset, l0;
|
||||
|
||||
filled = spa_ringbuffer_get_write_index(&impl->buffer, &idx);
|
||||
if (filled < 0 || filled > impl->buffer.size) {
|
||||
if (filled < 0 || filled > DATAS_SIZE) {
|
||||
spa_log_warn(impl->log, NAME " %p: queue xrun %d", impl, filled);
|
||||
return -EPIPE;
|
||||
}
|
||||
avail = impl->buffer.size - filled;
|
||||
avail = DATAS_SIZE - filled;
|
||||
if (avail < sizeof(struct invoke_item)) {
|
||||
spa_log_warn(impl->log, NAME " %p: queue full %d", impl, avail);
|
||||
return -EPIPE;
|
||||
}
|
||||
offset = idx & impl->buffer.mask;
|
||||
offset = idx & (DATAS_SIZE - 1);
|
||||
|
||||
l0 = impl->buffer.size - offset;
|
||||
l0 = DATAS_SIZE - offset;
|
||||
|
||||
item = SPA_MEMBER(impl->buffer_data, offset, struct invoke_item);
|
||||
item->func = func;
|
||||
|
|
@ -272,7 +272,7 @@ static void wakeup_func(void *data, uint64_t count)
|
|||
|
||||
while (spa_ringbuffer_get_read_index(&impl->buffer, &index) > 0) {
|
||||
struct invoke_item *item =
|
||||
SPA_MEMBER(impl->buffer_data, index & impl->buffer.mask, struct invoke_item);
|
||||
SPA_MEMBER(impl->buffer_data, index & (DATAS_SIZE - 1), struct invoke_item);
|
||||
item->res = item->func(&impl->loop, true, item->seq, item->size, item->data,
|
||||
item->user_data);
|
||||
spa_ringbuffer_read_update(&impl->buffer, index + item->item_size);
|
||||
|
|
@ -737,7 +737,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
spa_list_init(&impl->destroy_list);
|
||||
spa_hook_list_init(&impl->hooks_list);
|
||||
|
||||
spa_ringbuffer_init(&impl->buffer, DATAS_SIZE);
|
||||
spa_ringbuffer_init(&impl->buffer);
|
||||
|
||||
impl->wakeup = spa_loop_utils_add_event(&impl->utils, wakeup_func, impl);
|
||||
impl->ack_fd = eventfd(0, EFD_CLOEXEC);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue