mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-04 06:46:24 -04:00
Use real size to determine if we have room for the message
This commit is contained in:
parent
c5e5a6c788
commit
2f36f4009a
1 changed files with 21 additions and 23 deletions
|
|
@ -1189,7 +1189,6 @@ static const struct spa_dict_item module_props[] = {
|
|||
|
||||
#define DEFAULT_RATE 48000
|
||||
#define DEFAULT_FEEDBACK_BUFFER_SIZE 49152
|
||||
#define DEFAULT_FEEDBACK_MAX_MESSAGE_SIZE 4096;
|
||||
|
||||
struct impl {
|
||||
struct pw_context *context;
|
||||
|
|
@ -1225,7 +1224,6 @@ struct impl {
|
|||
|
||||
struct spa_ringbuffer feedback_ringbuffer;
|
||||
uint32_t feedback_ringbuffer_size;
|
||||
uint32_t feedback_ringbuffer_max_message_size;
|
||||
void *feedback_ringbuffer_data;
|
||||
|
||||
struct spa_audio_info_raw info;
|
||||
|
|
@ -2066,30 +2064,25 @@ static void graph_props_changed(void *object, enum spa_direction direction)
|
|||
uint32_t index;
|
||||
const uint32_t available = impl->feedback_ringbuffer_size
|
||||
- spa_ringbuffer_get_write_index(&impl->feedback_ringbuffer, &index);
|
||||
if (available >= impl->feedback_ringbuffer_max_message_size) {
|
||||
const uint64_t pod_length = SPA_POD_SIZE(params[0]);
|
||||
const uint64_t full_length = pod_length + sizeof(uint64_t);
|
||||
if (available >= full_length) {
|
||||
fprintf(stdout, "writing to buffer\n");
|
||||
const uint64_t pod_length = SPA_POD_SIZE(params[0]);
|
||||
const uint64_t full_length = pod_length + sizeof(uint64_t);
|
||||
if (full_length > impl->feedback_ringbuffer_max_message_size) {
|
||||
fprintf(stdout, "feedback ringbuffer full\n");
|
||||
pw_log_warn("feedback ringbuffer message too large");
|
||||
} else {
|
||||
fprintf(stdout, "writing data, pod length: %lu\nindex: %u\n",
|
||||
pod_length, index);
|
||||
fprintf(stdout, "writing data, pod length: %lu\nindex: %u\n",
|
||||
pod_length, index);
|
||||
|
||||
spa_ringbuffer_write_data(&impl->feedback_ringbuffer,
|
||||
impl->feedback_ringbuffer_data, impl->feedback_ringbuffer_size,
|
||||
index % impl->feedback_ringbuffer_size, &pod_length,
|
||||
sizeof(uint64_t));
|
||||
spa_ringbuffer_write_data(&impl->feedback_ringbuffer,
|
||||
impl->feedback_ringbuffer_data, impl->feedback_ringbuffer_size,
|
||||
index % impl->feedback_ringbuffer_size, &pod_length,
|
||||
sizeof(uint64_t));
|
||||
|
||||
spa_ringbuffer_write_data(&impl->feedback_ringbuffer,
|
||||
impl->feedback_ringbuffer_data, impl->feedback_ringbuffer_size,
|
||||
(index + sizeof(uint64_t)) % impl->feedback_ringbuffer_size, params[0],
|
||||
SPA_POD_SIZE(params[0]));
|
||||
spa_ringbuffer_write_data(&impl->feedback_ringbuffer,
|
||||
impl->feedback_ringbuffer_data, impl->feedback_ringbuffer_size,
|
||||
(index + sizeof(uint64_t)) % impl->feedback_ringbuffer_size, params[0],
|
||||
SPA_POD_SIZE(params[0]));
|
||||
|
||||
spa_ringbuffer_write_update(&impl->feedback_ringbuffer,
|
||||
index + sizeof(uint64_t) + SPA_POD_SIZE(params[0]));
|
||||
}
|
||||
spa_ringbuffer_write_update(&impl->feedback_ringbuffer,
|
||||
index + sizeof(uint64_t) + SPA_POD_SIZE(params[0]));
|
||||
} else {
|
||||
fprintf(stdout, "not enough space in ringbuffer\n");
|
||||
}
|
||||
|
|
@ -2320,6 +2313,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
if (pw_properties_get(impl->playback_props, PW_KEY_MEDIA_NAME) == NULL)
|
||||
pw_properties_setf(impl->playback_props, PW_KEY_MEDIA_NAME, "%s output",
|
||||
pw_properties_get(impl->playback_props, PW_KEY_NODE_DESCRIPTION));
|
||||
if (pw_properties_get(impl->control_props, PW_KEY_MEDIA_NAME) == NULL)
|
||||
pw_properties_setf(impl->control_props, PW_KEY_MEDIA_NAME, "%s control",
|
||||
pw_properties_get(impl->control_props, PW_KEY_NODE_DESCRIPTION));
|
||||
if (pw_properties_get(impl->feedback_props, PW_KEY_MEDIA_NAME) == NULL)
|
||||
pw_properties_setf(impl->feedback_props, PW_KEY_MEDIA_NAME, "%s feedback",
|
||||
pw_properties_get(impl->feedback_props, PW_KEY_NODE_DESCRIPTION));
|
||||
|
||||
p = pw_context_get_properties(impl->context);
|
||||
pw_properties_set(props, "clock.quantum-limit",
|
||||
|
|
@ -2374,7 +2373,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
spa_ringbuffer_init(&impl->feedback_ringbuffer);
|
||||
impl->feedback_ringbuffer_data = malloc(DEFAULT_FEEDBACK_BUFFER_SIZE);
|
||||
impl->feedback_ringbuffer_size = DEFAULT_FEEDBACK_BUFFER_SIZE;
|
||||
impl->feedback_ringbuffer_max_message_size = DEFAULT_FEEDBACK_MAX_MESSAGE_SIZE;
|
||||
}
|
||||
|
||||
setup_streams(impl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue