add some constants for max samples

This commit is contained in:
Wim Taymans 2019-10-24 12:35:00 +02:00
parent 605a0a6f97
commit 2fa97daa24
8 changed files with 31 additions and 22 deletions

View file

@ -42,8 +42,8 @@
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0) #define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0)
static const char default_device[] = "hw:0"; static const char default_device[] = "hw:0";
static const uint32_t default_min_latency = 16; static const uint32_t default_min_latency = MIN_LATENCY;
static const uint32_t default_max_latency = 1024; static const uint32_t default_max_latency = MAX_LATENCY;
static void reset_props(struct props *props) static void reset_props(struct props *props)
{ {

View file

@ -42,8 +42,8 @@
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0) #define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
static const char default_device[] = "hw:0"; static const char default_device[] = "hw:0";
static const uint32_t default_min_latency = 64; static const uint32_t default_min_latency = MIN_LATENCY;
static const uint32_t default_max_latency = 1024; static const uint32_t default_max_latency = MAX_LATENCY;
static void reset_props(struct props *props) static void reset_props(struct props *props)
{ {

View file

@ -44,6 +44,9 @@ extern "C" {
#include <spa/param/param.h> #include <spa/param/param.h>
#include <spa/param/audio/format-utils.h> #include <spa/param/audio/format-utils.h>
#define MIN_LATENCY 16
#define MAX_LATENCY 1024
#define DEFAULT_RATE 48000u #define DEFAULT_RATE 48000u
#define DEFAULT_CHANNELS 2u #define DEFAULT_CHANNELS 2u

View file

@ -45,6 +45,7 @@
#define DEFAULT_RATE 44100 #define DEFAULT_RATE 44100
#define DEFAULT_CHANNELS 2 #define DEFAULT_CHANNELS 2
#define MAX_SAMPLES 1024
#define MAX_BUFFERS 32 #define MAX_BUFFERS 32
#define MAX_DATAS 32 #define MAX_DATAS 32
@ -569,7 +570,7 @@ impl_node_port_enum_params(void *object, int seq,
size = other->size / other->stride; size = other->size / other->stride;
} else { } else {
buffers = 1; buffers = 1;
size = port->format.info.raw.rate * 1024 / DEFAULT_RATE; size = MAX_SAMPLES;
} }
param = spa_pod_builder_add_object(&b, param = spa_pod_builder_add_object(&b,
@ -579,7 +580,7 @@ impl_node_port_enum_params(void *object, int seq,
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int( SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
size * port->stride, size * port->stride,
16 * port->stride, 16 * port->stride,
INT32_MAX / port->stride), INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride), SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16)); SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
break; break;

View file

@ -47,7 +47,9 @@
#define DEFAULT_RATE 48000 #define DEFAULT_RATE 48000
#define DEFAULT_CHANNELS 2 #define DEFAULT_CHANNELS 2
#define MAX_SAMPLES 1024
#define MAX_BUFFERS 64 #define MAX_BUFFERS 64
#define MAX_ALIGN 16
#define MAX_DATAS 32 #define MAX_DATAS 32
#define MAX_PORTS 128 #define MAX_PORTS 128
@ -473,9 +475,9 @@ impl_node_port_enum_params(void *object, int seq,
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS), SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks), SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int( SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
2048 * port->stride, MAX_SAMPLES * 2 * port->stride,
16 * port->stride, 16 * port->stride,
INT32_MAX / port->stride), INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride), SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16)); SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
} }
@ -698,7 +700,7 @@ impl_node_port_use_buffers(void *object,
this, j, i); this, j, i);
return -EINVAL; return -EINVAL;
} }
if (!SPA_IS_ALIGNED(d[j].data, 16)) { if (!SPA_IS_ALIGNED(d[j].data, MAX_ALIGN)) {
spa_log_warn(this->log, NAME " %p: memory %d on buffer %d not aligned", spa_log_warn(this->log, NAME " %p: memory %d on buffer %d not aligned",
this, j, i); this, j, i);
} }

View file

@ -48,7 +48,8 @@
#define DEFAULT_RATE 48000 #define DEFAULT_RATE 48000
#define DEFAULT_CHANNELS 2 #define DEFAULT_CHANNELS 2
#define MAX_SAMPLES 2048 #define MAX_SAMPLES 1024
#define MAX_ALIGN 16
#define MAX_BUFFERS 64 #define MAX_BUFFERS 64
#define MAX_DATAS 32 #define MAX_DATAS 32
#define MAX_PORTS 128 #define MAX_PORTS 128
@ -110,7 +111,7 @@ struct impl {
unsigned int monitor:1; unsigned int monitor:1;
unsigned int have_profile:1; unsigned int have_profile:1;
float empty[MAX_SAMPLES + 15]; float empty[MAX_SAMPLES*2 + MAX_ALIGN];
}; };
#define CHECK_IN_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) < this->port_count) #define CHECK_IN_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) < this->port_count)
@ -490,7 +491,7 @@ impl_node_port_enum_params(void *object, int seq,
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS), SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks), SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int( SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
1024 * port->stride, MAX_SAMPLES * port->stride,
16 * port->stride, 16 * port->stride,
MAX_SAMPLES * port->stride), MAX_SAMPLES * port->stride),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride), SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
@ -793,7 +794,7 @@ impl_node_port_use_buffers(void *object,
this, j, i, d[j].type, d[j].data); this, j, i, d[j].type, d[j].data);
return -EINVAL; return -EINVAL;
} }
if (!SPA_IS_ALIGNED(d[j].data, 16)) { if (!SPA_IS_ALIGNED(d[j].data, MAX_ALIGN)) {
spa_log_warn(this->log, NAME " %p: memory %d on buffer %d not aligned", spa_log_warn(this->log, NAME " %p: memory %d on buffer %d not aligned",
this, j, i); this, j, i);
} }
@ -962,7 +963,7 @@ static int impl_node_process(void *object)
struct port *inport = GET_IN_PORT(this, i); struct port *inport = GET_IN_PORT(this, i);
if (get_in_buffer(this, inport, &sbuf) < 0) { if (get_in_buffer(this, inport, &sbuf) < 0) {
src_datas[n_src_datas++] = SPA_PTR_ALIGN(this->empty, 16, void); src_datas[n_src_datas++] = SPA_PTR_ALIGN(this->empty, MAX_ALIGN, void);
continue; continue;
} }

View file

@ -47,6 +47,7 @@
#define DEFAULT_RATE 44100 #define DEFAULT_RATE 44100
#define DEFAULT_CHANNELS 2 #define DEFAULT_CHANNELS 2
#define MAX_SAMPLES 1024
#define MAX_BUFFERS 32 #define MAX_BUFFERS 32
struct impl; struct impl;
@ -425,7 +426,7 @@ impl_node_port_enum_params(void *object, int seq,
} }
else { else {
buffers = 1; buffers = 1;
size = 2048 * other->stride; size = MAX_SAMPLES * 2 * other->stride;
} }
param = spa_pod_builder_add_object(&b, param = spa_pod_builder_add_object(&b,
@ -755,7 +756,7 @@ static int impl_node_process(void *object)
if (this->io_position) { if (this->io_position) {
max = this->io_position->clock.duration; max = this->io_position->clock.duration;
} else { } else {
max = 1024; max = maxsize / sizeof(float);
} }
switch (this->mode) { switch (this->mode) {

View file

@ -49,7 +49,8 @@
#define DEFAULT_CHANNELS 2 #define DEFAULT_CHANNELS 2
#define DEFAULT_MASK (1LL << SPA_AUDIO_CHANNEL_FL) | (1LL << SPA_AUDIO_CHANNEL_FR) #define DEFAULT_MASK (1LL << SPA_AUDIO_CHANNEL_FL) | (1LL << SPA_AUDIO_CHANNEL_FR)
#define MAX_SAMPLES 2048 #define MAX_SAMPLES 1024
#define MAX_ALIGN 16
#define MAX_BUFFERS 64 #define MAX_BUFFERS 64
#define MAX_DATAS 32 #define MAX_DATAS 32
#define MAX_PORTS 128 #define MAX_PORTS 128
@ -112,7 +113,7 @@ struct impl {
bool have_profile; bool have_profile;
float empty[MAX_SAMPLES + 15]; float empty[MAX_SAMPLES*2 + MAX_ALIGN];
}; };
#define CHECK_OUT_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < this->port_count) #define CHECK_OUT_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < this->port_count)
@ -473,7 +474,7 @@ impl_node_port_enum_params(void *object, int seq,
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS), SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks), SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int( SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
1024 * port->stride, MAX_SAMPLES * port->stride,
16 * port->stride, 16 * port->stride,
MAX_SAMPLES * port->stride), MAX_SAMPLES * port->stride),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride), SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
@ -751,7 +752,7 @@ impl_node_port_use_buffers(void *object,
this, j, i, d[j].type, d[j].data); this, j, i, d[j].type, d[j].data);
return -EINVAL; return -EINVAL;
} }
if (!SPA_IS_ALIGNED(d[j].data, 16)) { if (!SPA_IS_ALIGNED(d[j].data, MAX_ALIGN)) {
spa_log_warn(this->log, NAME " %p: memory %d on buffer %d not aligned", spa_log_warn(this->log, NAME " %p: memory %d on buffer %d not aligned",
this, j, i); this, j, i);
} }
@ -878,7 +879,7 @@ static int impl_node_process(void *object)
outio->status = -EPIPE; outio->status = -EPIPE;
empty: empty:
spa_log_trace_fp(this->log, NAME" %p: %d skip output", this, i); spa_log_trace_fp(this->log, NAME" %p: %d skip output", this, i);
dst_datas[n_dst_datas++] = SPA_PTR_ALIGN(this->empty, 16, void); dst_datas[n_dst_datas++] = SPA_PTR_ALIGN(this->empty, MAX_ALIGN, void);
continue; continue;
} }
@ -902,7 +903,7 @@ static int impl_node_process(void *object)
} }
while (n_dst_datas < this->port_count) { while (n_dst_datas < this->port_count) {
spa_log_trace_fp(this->log, NAME" %p: %d fill output", this, n_dst_datas); spa_log_trace_fp(this->log, NAME" %p: %d fill output", this, n_dst_datas);
dst_datas[n_dst_datas++] = SPA_PTR_ALIGN(this->empty, 16, void); dst_datas[n_dst_datas++] = SPA_PTR_ALIGN(this->empty, MAX_ALIGN, void);
} }
spa_log_trace_fp(this->log, NAME " %p: n_src:%d n_dst:%d n_samples:%d max:%d stride:%d p:%d", this, spa_log_trace_fp(this->log, NAME " %p: n_src:%d n_dst:%d n_samples:%d max:%d stride:%d p:%d", this,