mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
netjack2: remove hardcoded buffer size
This commit is contained in:
parent
01857b616c
commit
4bb3e292c5
3 changed files with 14 additions and 5 deletions
|
|
@ -199,6 +199,7 @@ struct impl {
|
|||
int dscp;
|
||||
int mtu;
|
||||
uint32_t latency;
|
||||
uint32_t quantum_limit;
|
||||
|
||||
struct pw_impl_module *module;
|
||||
struct spa_hook module_listener;
|
||||
|
|
@ -868,6 +869,7 @@ static int handle_follower_setup(struct impl *impl, struct nj2_session_params *p
|
|||
peer->other_stream = 's';
|
||||
peer->send_volume = &impl->sink.volume;
|
||||
peer->recv_volume = &impl->source.volume;
|
||||
peer->quantum_limit = impl->quantum_limit;
|
||||
netjack2_init(peer);
|
||||
|
||||
int bufsize = NETWORK_MAX_LATENCY * (peer->params.mtu +
|
||||
|
|
@ -1238,6 +1240,9 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->props = props;
|
||||
data_loop = pw_context_get_data_loop(context);
|
||||
impl->data_loop = pw_data_loop_get_loop(data_loop);
|
||||
impl->quantum_limit = pw_properties_get_uint32(
|
||||
pw_context_get_properties(context),
|
||||
"default.clock.quantum-limit", 8192u);
|
||||
|
||||
impl->sink.props = pw_properties_new(NULL, NULL);
|
||||
impl->source.props = pw_properties_new(NULL, NULL);
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ struct impl {
|
|||
uint32_t samplerate;
|
||||
uint32_t encoding;
|
||||
uint32_t kbps;
|
||||
uint32_t quantum_limit;
|
||||
|
||||
struct pw_impl_module *module;
|
||||
struct spa_hook module_listener;
|
||||
|
|
@ -1011,6 +1012,7 @@ static int handle_follower_available(struct impl *impl, struct nj2_session_param
|
|||
peer->other_stream = 'r';
|
||||
peer->send_volume = &follower->sink.volume;
|
||||
peer->recv_volume = &follower->source.volume;
|
||||
peer->quantum_limit = impl->quantum_limit;
|
||||
netjack2_init(peer);
|
||||
|
||||
int bufsize = NETWORK_MAX_LATENCY * (peer->params.mtu +
|
||||
|
|
@ -1279,6 +1281,9 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->props = props;
|
||||
data_loop = pw_context_get_data_loop(context);
|
||||
impl->data_loop = pw_data_loop_get_loop(data_loop);
|
||||
impl->quantum_limit = pw_properties_get_uint32(
|
||||
pw_context_get_properties(context),
|
||||
"default.clock.quantum-limit", 8192u);
|
||||
|
||||
impl->sink_props = pw_properties_new(NULL, NULL);
|
||||
impl->source_props = pw_properties_new(NULL, NULL);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
#include <opus/opus_custom.h>
|
||||
#endif
|
||||
|
||||
#define MAX_BUFFER_FRAMES 8192
|
||||
|
||||
struct volume {
|
||||
bool mute;
|
||||
uint32_t n_volumes;
|
||||
|
|
@ -117,6 +115,7 @@ struct netjack2_peer {
|
|||
void *midi_data;
|
||||
uint32_t midi_size;
|
||||
|
||||
uint32_t quantum_limit;
|
||||
float *empty;
|
||||
void *encoded_data;
|
||||
uint32_t encoded_size;
|
||||
|
|
@ -134,7 +133,7 @@ static int netjack2_init(struct netjack2_peer *peer)
|
|||
{
|
||||
int res = 0;
|
||||
|
||||
peer->empty = calloc(MAX_BUFFER_FRAMES, sizeof(float));
|
||||
peer->empty = calloc(peer->quantum_limit, sizeof(float));
|
||||
|
||||
peer->midi_size = peer->params.period_size * sizeof(float) *
|
||||
SPA_MAX(peer->params.send_midi_channels, peer->params.recv_midi_channels);
|
||||
|
|
@ -252,7 +251,7 @@ static void midi_to_netjack2(struct netjack2_peer *peer,
|
|||
uint32_t free_size;
|
||||
|
||||
buf->magic = MIDI_BUFFER_MAGIC;
|
||||
buf->buffer_size = MAX_BUFFER_FRAMES * sizeof(float);
|
||||
buf->buffer_size = peer->quantum_limit * sizeof(float);
|
||||
buf->nframes = n_samples;
|
||||
buf->write_pos = 0;
|
||||
buf->event_count = 0;
|
||||
|
|
@ -805,7 +804,7 @@ static int netjack2_recv_float(struct netjack2_peer *peer, struct nj2_packet_hea
|
|||
return 0;
|
||||
|
||||
sub_cycle = ntohl(header->sub_cycle);
|
||||
if (sub_cycle * sub_period_size > MAX_BUFFER_FRAMES)
|
||||
if (sub_cycle * sub_period_size > peer->quantum_limit)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < active_ports; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue