mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-05 06:46:28 -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_RATE 48000
|
||||||
#define DEFAULT_FEEDBACK_BUFFER_SIZE 49152
|
#define DEFAULT_FEEDBACK_BUFFER_SIZE 49152
|
||||||
#define DEFAULT_FEEDBACK_MAX_MESSAGE_SIZE 4096;
|
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_context *context;
|
struct pw_context *context;
|
||||||
|
|
@ -1225,7 +1224,6 @@ struct impl {
|
||||||
|
|
||||||
struct spa_ringbuffer feedback_ringbuffer;
|
struct spa_ringbuffer feedback_ringbuffer;
|
||||||
uint32_t feedback_ringbuffer_size;
|
uint32_t feedback_ringbuffer_size;
|
||||||
uint32_t feedback_ringbuffer_max_message_size;
|
|
||||||
void *feedback_ringbuffer_data;
|
void *feedback_ringbuffer_data;
|
||||||
|
|
||||||
struct spa_audio_info_raw info;
|
struct spa_audio_info_raw info;
|
||||||
|
|
@ -2066,14 +2064,10 @@ static void graph_props_changed(void *object, enum spa_direction direction)
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
const uint32_t available = impl->feedback_ringbuffer_size
|
const uint32_t available = impl->feedback_ringbuffer_size
|
||||||
- spa_ringbuffer_get_write_index(&impl->feedback_ringbuffer, &index);
|
- spa_ringbuffer_get_write_index(&impl->feedback_ringbuffer, &index);
|
||||||
if (available >= impl->feedback_ringbuffer_max_message_size) {
|
|
||||||
fprintf(stdout, "writing to buffer\n");
|
|
||||||
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 (full_length > impl->feedback_ringbuffer_max_message_size) {
|
if (available >= full_length) {
|
||||||
fprintf(stdout, "feedback ringbuffer full\n");
|
fprintf(stdout, "writing to buffer\n");
|
||||||
pw_log_warn("feedback ringbuffer message too large");
|
|
||||||
} else {
|
|
||||||
fprintf(stdout, "writing data, pod length: %lu\nindex: %u\n",
|
fprintf(stdout, "writing data, pod length: %lu\nindex: %u\n",
|
||||||
pod_length, index);
|
pod_length, index);
|
||||||
|
|
||||||
|
|
@ -2089,7 +2083,6 @@ 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\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)
|
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_setf(impl->playback_props, PW_KEY_MEDIA_NAME, "%s output",
|
||||||
pw_properties_get(impl->playback_props, PW_KEY_NODE_DESCRIPTION));
|
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);
|
p = pw_context_get_properties(impl->context);
|
||||||
pw_properties_set(props, "clock.quantum-limit",
|
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);
|
spa_ringbuffer_init(&impl->feedback_ringbuffer);
|
||||||
impl->feedback_ringbuffer_data = malloc(DEFAULT_FEEDBACK_BUFFER_SIZE);
|
impl->feedback_ringbuffer_data = malloc(DEFAULT_FEEDBACK_BUFFER_SIZE);
|
||||||
impl->feedback_ringbuffer_size = 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);
|
setup_streams(impl);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue