Only add to ringbuffer if feedback stream is active

This commit is contained in:
Frank Krick 2025-08-28 18:41:30 -04:00
parent 2f36f4009a
commit 2f7d2a6668

View file

@ -2060,10 +2060,11 @@ static void graph_props_changed(void *object, enum spa_direction direction)
pw_stream_update_params(impl->capture, params, 1); pw_stream_update_params(impl->capture, params, 1);
if (impl->feedback_stream_active) {
fprintf(stdout, "graph props changed\n"); fprintf(stdout, "graph props changed\n");
uint32_t index; uint32_t index;
const uint32_t available = impl->feedback_ringbuffer_size int32_t write_index_return = spa_ringbuffer_get_write_index(&impl->feedback_ringbuffer, &index);
- spa_ringbuffer_get_write_index(&impl->feedback_ringbuffer, &index); const uint32_t available = impl->feedback_ringbuffer_size - write_index_return;
const uint64_t pod_length = SPA_POD_SIZE(params[0]); const uint64_t pod_length = SPA_POD_SIZE(params[0]);
const uint64_t full_length = pod_length + sizeof(uint64_t); const uint64_t full_length = pod_length + sizeof(uint64_t);
if (available >= full_length) { if (available >= full_length) {
@ -2084,7 +2085,8 @@ static void graph_props_changed(void *object, enum spa_direction direction)
spa_ringbuffer_write_update(&impl->feedback_ringbuffer, spa_ringbuffer_write_update(&impl->feedback_ringbuffer,
index + sizeof(uint64_t) + SPA_POD_SIZE(params[0])); index + sizeof(uint64_t) + SPA_POD_SIZE(params[0]));
} else { } else {
fprintf(stdout, "not enough space in ringbuffer\n"); fprintf(stdout, "not enough space in ringbuffer, available: %u, required: %lu, write index return: %i, buffer size: %u\n", available, full_length, write_index_return, impl->feedback_ringbuffer_size);
}
} }
spa_pod_dynamic_builder_clean(&b); spa_pod_dynamic_builder_clean(&b);