Don't use SPA_AUDIO_MAX_CHANNELS directly

Make a MAX_CHANNELS define and use that one in code. This makes it
easier to change the constant later.
This commit is contained in:
Wim Taymans 2025-10-20 15:33:17 +02:00
parent eb096bfb62
commit 13b8c23767
30 changed files with 136 additions and 108 deletions

View file

@ -38,6 +38,7 @@
extern struct spa_i18n *acp_i18n;
#define MAX_POLL 16
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define DEFAULT_DEVICE "hw:0"
#define DEFAULT_AUTO_PROFILE true
@ -156,7 +157,7 @@ static int emit_node(struct impl *this, struct acp_device *dev)
uint32_t n_items, i;
char device_name[128], path[210], channels[16], ch[12], routes[16];
char card_index[16], card_name[64], *p;
char positions[SPA_AUDIO_MAX_CHANNELS * 12];
char positions[MAX_CHANNELS * 12];
char codecs[512];
struct spa_device_object_info info;
struct acp_card *card = this->card;
@ -673,8 +674,8 @@ static int apply_device_props(struct impl *this, struct acp_device *dev, struct
struct spa_pod_prop *prop;
struct spa_pod_object *obj = (struct spa_pod_object *) props;
int changed = 0;
float volumes[SPA_AUDIO_MAX_CHANNELS];
uint32_t channels[SPA_AUDIO_MAX_CHANNELS];
float volumes[MAX_CHANNELS];
uint32_t channels[MAX_CHANNELS];
uint32_t n_volumes = 0;
if (!spa_pod_is_object_type(props, SPA_TYPE_OBJECT_Props))

View file

@ -163,10 +163,10 @@ static int alsa_set_param(struct state *state, const char *k, const char *s)
int fmt_change = 0;
if (spa_streq(k, SPA_KEY_AUDIO_CHANNELS)) {
state->default_channels = atoi(s);
if (state->default_channels > SPA_AUDIO_MAX_CHANNELS) {
if (state->default_channels > MAX_CHANNELS) {
spa_log_warn(state->log, "%p: %s: %s > %d, clamping",
state, k, s, SPA_AUDIO_MAX_CHANNELS);
state->default_channels = SPA_AUDIO_MAX_CHANNELS;
state, k, s, MAX_CHANNELS);
state->default_channels = MAX_CHANNELS;
}
fmt_change++;
} else if (spa_streq(k, SPA_KEY_AUDIO_RATE)) {
@ -1584,8 +1584,8 @@ static int add_channels(struct state *state, bool all, uint32_t index, uint32_t
spa_log_debug(state->log, "channels (%d %d) default:%d all:%d",
min, max, state->default_channels, all);
min = SPA_MIN(min, SPA_AUDIO_MAX_CHANNELS);
max = SPA_MIN(max, SPA_AUDIO_MAX_CHANNELS);
min = SPA_MIN(min, MAX_CHANNELS);
max = SPA_MIN(max, MAX_CHANNELS);
if (state->default_channels != 0 && !all) {
if (min > state->default_channels ||

View file

@ -36,6 +36,7 @@ extern "C" {
#endif
#define MAX_RATES 16
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define DEFAULT_PERIOD 1024u
#define DEFAULT_RATE 48000u
@ -72,7 +73,7 @@ struct buffer {
struct channel_map {
uint32_t channels;
uint32_t pos[SPA_AUDIO_MAX_CHANNELS];
uint32_t pos[MAX_CHANNELS];
};
struct card {

View file

@ -47,10 +47,11 @@ SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.audioconvert");
#define DEFAULT_RATE 48000
#define DEFAULT_CHANNELS 2
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define MAX_ALIGN FMT_OPS_MAX_ALIGN
#define MAX_BUFFERS 32
#define MAX_DATAS SPA_AUDIO_MAX_CHANNELS
#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
#define MAX_DATAS MAX_CHANNELS
#define MAX_PORTS (MAX_CHANNELS+1)
#define MAX_STAGES 64
#define MAX_GRAPH 9 /* 8 active + 1 replacement slot */
@ -62,7 +63,7 @@ SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.audioconvert");
struct volumes {
bool mute;
uint32_t n_volumes;
float volumes[SPA_AUDIO_MAX_CHANNELS];
float volumes[MAX_CHANNELS];
};
static void init_volumes(struct volumes *vol)
@ -70,7 +71,7 @@ static void init_volumes(struct volumes *vol)
uint32_t i;
vol->mute = DEFAULT_MUTE;
vol->n_volumes = 0;
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
vol->volumes[i] = DEFAULT_VOLUME;
}
@ -91,7 +92,7 @@ struct props {
float max_volume;
float prev_volume;
uint32_t n_channels;
uint32_t channel_map[SPA_AUDIO_MAX_CHANNELS];
uint32_t channel_map[MAX_CHANNELS];
struct volumes channel;
struct volumes soft;
struct volumes monitor;
@ -112,7 +113,7 @@ static void props_reset(struct props *props)
props->min_volume = DEFAULT_MIN_VOLUME;
props->max_volume = DEFAULT_MAX_VOLUME;
props->n_channels = 0;
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
props->channel_map[i] = SPA_AUDIO_CHANNEL_UNKNOWN;
init_volumes(&props->channel);
init_volumes(&props->soft);
@ -241,9 +242,9 @@ struct filter_graph {
struct spa_filter_graph *graph;
struct spa_hook listener;
uint32_t n_inputs;
uint32_t inputs_position[SPA_AUDIO_MAX_CHANNELS];
uint32_t inputs_position[MAX_CHANNELS];
uint32_t n_outputs;
uint32_t outputs_position[SPA_AUDIO_MAX_CHANNELS];
uint32_t outputs_position[MAX_CHANNELS];
uint32_t latency;
bool removing;
bool setup;
@ -1966,7 +1967,7 @@ static int node_set_param_port_config(struct impl *this, uint32_t flags,
return -EINVAL;
if (info.info.raw.channels == 0 ||
info.info.raw.channels > SPA_AUDIO_MAX_CHANNELS)
info.info.raw.channels > MAX_CHANNELS)
return -EINVAL;
infop = &info;
@ -2153,7 +2154,7 @@ static void set_volume(struct impl *this)
{
struct volumes *vol;
uint32_t i;
float volumes[SPA_AUDIO_MAX_CHANNELS];
float volumes[MAX_CHANNELS];
struct dir *dir = &this->dir[this->direction];
spa_log_debug(this->log, "%p set volume %f have_format:%d", this, this->props.volume, dir->have_format);
@ -2671,7 +2672,7 @@ static int port_param_enum_formats(struct impl *impl, struct port *port, uint32_
}
spa_pod_builder_add(b,
SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(
DEFAULT_CHANNELS, 1, SPA_AUDIO_MAX_CHANNELS),
DEFAULT_CHANNELS, 1, MAX_CHANNELS),
0);
*param = spa_pod_builder_pop(b, &f[0]);
}
@ -3064,7 +3065,7 @@ static int port_set_format(void *object,
if (info.info.raw.format == 0 ||
(!this->props.resample_disabled && info.info.raw.rate == 0) ||
info.info.raw.channels == 0 ||
info.info.raw.channels > SPA_AUDIO_MAX_CHANNELS) {
info.info.raw.channels > MAX_CHANNELS) {
spa_log_error(this->log, "invalid format:%d rate:%d channels:%d",
info.info.raw.format, info.info.raw.rate,
info.info.raw.channels);

View file

@ -142,29 +142,29 @@ static uint32_t mask_to_ch(struct channelmix *mix, uint64_t mask)
}
static void distribute_mix(struct channelmix *mix,
float matrix[SPA_AUDIO_MAX_CHANNELS][SPA_AUDIO_MAX_CHANNELS],
float matrix[MAX_CHANNELS][MAX_CHANNELS],
uint64_t mask)
{
uint32_t i, ch = mask_to_ch(mix, mask);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
matrix[i][ch]= 1.0f;
}
static void average_mix(struct channelmix *mix,
float matrix[SPA_AUDIO_MAX_CHANNELS][SPA_AUDIO_MAX_CHANNELS],
float matrix[MAX_CHANNELS][MAX_CHANNELS],
uint64_t mask)
{
uint32_t i, ch = mask_to_ch(mix, mask);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
matrix[ch][i]= 1.0f;
}
static void pair_mix(float matrix[SPA_AUDIO_MAX_CHANNELS][SPA_AUDIO_MAX_CHANNELS])
static void pair_mix(float matrix[MAX_CHANNELS][MAX_CHANNELS])
{
uint32_t i;
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
matrix[i][i]= 1.0f;
}
static bool match_mix(struct channelmix *mix,
float matrix[SPA_AUDIO_MAX_CHANNELS][SPA_AUDIO_MAX_CHANNELS],
float matrix[MAX_CHANNELS][MAX_CHANNELS],
uint64_t src_mask, uint64_t dst_mask)
{
bool matched = false;
@ -181,7 +181,7 @@ static bool match_mix(struct channelmix *mix,
static int make_matrix(struct channelmix *mix)
{
float matrix[SPA_AUDIO_MAX_CHANNELS][SPA_AUDIO_MAX_CHANNELS] = {{ 0.0f }};
float matrix[MAX_CHANNELS][MAX_CHANNELS] = {{ 0.0f }};
uint64_t src_mask = mix->src_mask, src_paired;
uint64_t dst_mask = mix->dst_mask, dst_paired;
uint32_t src_chan = mix->src_chan;
@ -293,7 +293,7 @@ static int make_matrix(struct channelmix *mix)
keep &= ~STEREO;
} else if (dst_mask & _MASK(MONO)){
spa_log_info(mix->log, "assign FC to MONO (%f)", 1.0f);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
matrix[i][_CH(FC)]= 1.0f;
normalize = true;
} else {
@ -313,7 +313,7 @@ static int make_matrix(struct channelmix *mix)
keep &= ~FRONT;
} else if ((dst_mask & _MASK(MONO))){
spa_log_info(mix->log, "assign STEREO to MONO (%f)", 1.0f);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++) {
for (i = 0; i < MAX_CHANNELS; i++) {
matrix[i][_CH(FL)]= 1.0f;
matrix[i][_CH(FR)]= 1.0f;
}
@ -352,7 +352,7 @@ static int make_matrix(struct channelmix *mix)
_MATRIX(FC,RC) += slev * SQRT1_2;
} else if (dst_mask & _MASK(MONO)){
spa_log_info(mix->log, "assign RC to MONO (%f)", 1.0f);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
matrix[i][_CH(RC)]= 1.0f;
normalize = true;
} else {
@ -398,7 +398,7 @@ static int make_matrix(struct channelmix *mix)
_MATRIX(FC,RR)+= slev * SQRT1_2;
} else if (dst_mask & _MASK(MONO)){
spa_log_info(mix->log, "assign RL+RR to MONO (%f)", 1.0f);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++) {
for (i = 0; i < MAX_CHANNELS; i++) {
matrix[i][_CH(RL)]= 1.0f;
matrix[i][_CH(RR)]= 1.0f;
}
@ -450,7 +450,7 @@ static int make_matrix(struct channelmix *mix)
_MATRIX(FC,SR) += slev * SQRT1_2;
} else if (dst_mask & _MASK(MONO)){
spa_log_info(mix->log, "assign SL+SR to MONO (%f)", 1.0f);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++) {
for (i = 0; i < MAX_CHANNELS; i++) {
matrix[i][_CH(SL)]= 1.0f;
matrix[i][_CH(SR)]= 1.0f;
}
@ -471,7 +471,7 @@ static int make_matrix(struct channelmix *mix)
_MATRIX(FC,FRC)+= SQRT1_2;
} else if (dst_mask & _MASK(MONO)){
spa_log_info(mix->log, "assign FLC+FRC to MONO (%f)", 1.0f);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++) {
for (i = 0; i < MAX_CHANNELS; i++) {
matrix[i][_CH(FLC)]= 1.0f;
matrix[i][_CH(FRC)]= 1.0f;
}
@ -492,7 +492,7 @@ static int make_matrix(struct channelmix *mix)
_MATRIX(FR,LFE) += llev * SQRT1_2;
} else if ((dst_mask & _MASK(MONO))){
spa_log_info(mix->log, "assign LFE to MONO (%f)", 1.0f);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
for (i = 0; i < MAX_CHANNELS; i++)
matrix[i][_CH(LFE)]= 1.0f;
normalize = true;
} else {
@ -690,7 +690,7 @@ done:
static void impl_channelmix_set_volume(struct channelmix *mix, float volume, bool mute,
uint32_t n_channel_volumes, float *channel_volumes)
{
float volumes[SPA_AUDIO_MAX_CHANNELS];
float volumes[MAX_CHANNELS];
float vol = mute ? 0.0f : volume, t;
uint32_t i, j;
uint32_t src_chan = mix->src_chan;
@ -760,8 +760,8 @@ int channelmix_init(struct channelmix *mix)
{
const struct channelmix_info *info;
if (mix->src_chan > SPA_AUDIO_MAX_CHANNELS ||
mix->dst_chan > SPA_AUDIO_MAX_CHANNELS)
if (mix->src_chan > MAX_CHANNELS ||
mix->dst_chan > MAX_CHANNELS)
return -EINVAL;
info = find_channelmix_info(mix->src_chan, mix->src_mask, mix->dst_chan, mix->dst_mask,

View file

@ -24,6 +24,7 @@
#define BUFFER_SIZE 4096
#define MAX_TAPS 255u
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define CHANNELMIX_OPS_MAX_ALIGN 16
@ -50,8 +51,8 @@ struct channelmix {
#define CHANNELMIX_FLAG_EQUAL (1<<2) /**< all values are equal */
#define CHANNELMIX_FLAG_COPY (1<<3) /**< 1 on diagonal, can be nxm */
uint32_t flags;
float matrix_orig[SPA_AUDIO_MAX_CHANNELS][SPA_AUDIO_MAX_CHANNELS];
float matrix[SPA_AUDIO_MAX_CHANNELS][SPA_AUDIO_MAX_CHANNELS];
float matrix_orig[MAX_CHANNELS][MAX_CHANNELS];
float matrix[MAX_CHANNELS][MAX_CHANNELS];
float freq; /* sample frequency */
float lfe_cutoff; /* in Hz, 0 is disabled */
@ -59,7 +60,7 @@ struct channelmix {
float rear_delay; /* in ms, 0 is disabled */
float widen; /* stereo widen. 0 is disabled */
uint32_t hilbert_taps; /* to phase shift, 0 disabled */
struct lr4 lr4[SPA_AUDIO_MAX_CHANNELS];
struct lr4 lr4[MAX_CHANNELS];
float buffer_mem[2 * BUFFER_SIZE*2 + CHANNELMIX_OPS_MAX_ALIGN/4];
float *buffer[2];

View file

@ -25,7 +25,8 @@ SPA_LOG_IMPL(logger);
extern const struct spa_handle_factory test_source_factory;
#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define MAX_PORTS (MAX_CHANNELS+1)
struct context {
struct spa_handle *convert_handle;

View file

@ -109,6 +109,7 @@ static inline char *format_streamid(char *str, size_t size, const uint64_t strea
return str;
}
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define MAX_BUFFERS 32
struct buffer {
@ -127,7 +128,7 @@ struct buffer {
struct channel_map {
uint32_t channels;
uint32_t pos[SPA_AUDIO_MAX_CHANNELS];
uint32_t pos[MAX_CHANNELS];
};
struct port {

View file

@ -58,6 +58,8 @@ static struct spa_log *log;
#define BITRATE_DUPLEX_BIDI 160000
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define OPUS_05_MAX_BYTES (15 * 1024)
struct props {
@ -313,14 +315,14 @@ static void parse_settings(struct props *props, const struct spa_dict *settings)
return;
if (spa_atou32(spa_dict_lookup(settings, "bluez5.a2dp.opus.pro.channels"), &v, 0))
props->channels = SPA_CLAMP(v, 1u, SPA_AUDIO_MAX_CHANNELS);
props->channels = SPA_CLAMP(v, 1u, MAX_CHANNELS);
if (spa_atou32(spa_dict_lookup(settings, "bluez5.a2dp.opus.pro.max-bitrate"), &v, 0))
props->max_bitrate = SPA_MAX(v, (uint32_t)BITRATE_MIN);
if (spa_atou32(spa_dict_lookup(settings, "bluez5.a2dp.opus.pro.coupled-streams"), &v, 0))
props->coupled_streams = SPA_CLAMP(v, 0u, props->channels / 2);
if (spa_atou32(spa_dict_lookup(settings, "bluez5.a2dp.opus.pro.bidi.channels"), &v, 0))
props->bidi_channels = SPA_CLAMP(v, 0u, SPA_AUDIO_MAX_CHANNELS);
props->bidi_channels = SPA_CLAMP(v, 0u, MAX_CHANNELS);
if (spa_atou32(spa_dict_lookup(settings, "bluez5.a2dp.opus.pro.bidi.max-bitrate"), &v, 0))
props->bidi_max_bitrate = SPA_MAX(v, (uint32_t)BITRATE_MIN);
if (spa_atou32(spa_dict_lookup(settings, "bluez5.a2dp.opus.pro.bidi.coupled-streams"), &v, 0))
@ -503,7 +505,7 @@ static int get_mapping(const struct media_codec *codec, const a2dp_opus_05_direc
const uint8_t *permutation = NULL;
size_t i, j;
if (channels > SPA_AUDIO_MAX_CHANNELS)
if (channels > MAX_CHANNELS)
return -EINVAL;
if (2 * coupled_streams > channels)
return -EINVAL;
@ -561,7 +563,7 @@ static int codec_fill_caps(const struct media_codec *codec, uint32_t flags,
a2dp_opus_05_t a2dp_opus_05 = {
.info = codec->vendor,
.main = {
.channels = SPA_MIN(255u, SPA_AUDIO_MAX_CHANNELS),
.channels = SPA_MIN(255u, MAX_CHANNELS),
.frame_duration = (OPUS_05_FRAME_DURATION_25 |
OPUS_05_FRAME_DURATION_50 |
OPUS_05_FRAME_DURATION_100 |
@ -571,7 +573,7 @@ static int codec_fill_caps(const struct media_codec *codec, uint32_t flags,
OPUS_05_INIT_BITRATE(0)
},
.bidi = {
.channels = SPA_MIN(255u, SPA_AUDIO_MAX_CHANNELS),
.channels = SPA_MIN(255u, MAX_CHANNELS),
.frame_duration = (OPUS_05_FRAME_DURATION_25 |
OPUS_05_FRAME_DURATION_50 |
OPUS_05_FRAME_DURATION_100 |
@ -771,7 +773,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
a2dp_opus_05_t conf;
a2dp_opus_05_direction_t *dir;
struct spa_pod_frame f[1];
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
uint32_t position[MAX_CHANNELS];
if (caps_size < sizeof(conf))
return -EINVAL;

View file

@ -6850,7 +6850,7 @@ static void parse_bap_locations(struct spa_bt_monitor *this, const struct spa_di
const char *key, uint32_t *value)
{
const char *str;
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
uint32_t position[MAX_CHANNELS];
uint32_t n_channels;
uint32_t locations;
unsigned int i, j;

View file

@ -38,7 +38,7 @@ SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.bluez5.device");
#undef SPA_LOG_TOPIC_DEFAULT
#define SPA_LOG_TOPIC_DEFAULT &log_topic
#define MAX_NODES (2*SPA_AUDIO_MAX_CHANNELS)
#define MAX_NODES (2*MAX_CHANNELS)
#define DEVICE_ID_SOURCE 0
#define DEVICE_ID_SINK 1
@ -99,9 +99,9 @@ struct node {
unsigned int offload_acquired:1;
uint32_t n_channels;
int64_t latency_offset;
uint32_t channels[SPA_AUDIO_MAX_CHANNELS];
float volumes[SPA_AUDIO_MAX_CHANNELS];
float soft_volumes[SPA_AUDIO_MAX_CHANNELS];
uint32_t channels[MAX_CHANNELS];
float volumes[MAX_CHANNELS];
float soft_volumes[MAX_CHANNELS];
};
struct dynamic_node
@ -129,8 +129,8 @@ struct device_set {
bool leader;
uint32_t sinks;
uint32_t sources;
struct device_set_member sink[SPA_AUDIO_MAX_CHANNELS];
struct device_set_member source[SPA_AUDIO_MAX_CHANNELS];
struct device_set_member sink[MAX_CHANNELS];
struct device_set_member source[MAX_CHANNELS];
};
struct impl {
@ -182,7 +182,7 @@ static void init_node(struct impl *this, struct node *node, uint32_t id)
spa_zero(*node);
node->id = id;
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++) {
for (i = 0; i < MAX_CHANNELS; i++) {
node->volumes[i] = 1.0f;
node->soft_volumes[i] = 1.0f;
}
@ -546,7 +546,7 @@ static void emit_device_set_node(struct impl *this, uint32_t id)
if (node->channels[k] == t->channels[j])
break;
}
if (k == node->n_channels && node->n_channels < SPA_AUDIO_MAX_CHANNELS)
if (k == node->n_channels && node->n_channels < MAX_CHANNELS)
node->channels[node->n_channels++] = t->channels[j];
}
}
@ -2946,8 +2946,8 @@ static int apply_device_props(struct impl *this, struct node *node, struct spa_p
struct spa_pod_prop *prop;
struct spa_pod_object *obj = (struct spa_pod_object *) props;
int changed = 0;
float volumes[SPA_AUDIO_MAX_CHANNELS];
uint32_t channels[SPA_AUDIO_MAX_CHANNELS];
float volumes[MAX_CHANNELS];
uint32_t channels[MAX_CHANNELS];
uint32_t n_volumes = 0, SPA_UNUSED n_channels = 0;
int64_t latency_offset = 0;

View file

@ -157,6 +157,8 @@ extern "C" {
#define SPA_BT_NO_BATTERY ((uint8_t)255)
#define MAX_CHANNELS (SPA_AUDIO_MAX_CHANNELS)
enum spa_bt_media_direction {
SPA_BT_MEDIA_SOURCE,
SPA_BT_MEDIA_SINK,
@ -678,7 +680,7 @@ struct spa_bt_transport {
struct spa_list bap_transport_linked;
uint32_t n_channels;
uint32_t channels[SPA_AUDIO_MAX_CHANNELS];
uint32_t channels[MAX_CHANNELS];
struct spa_bt_transport_volume volumes[SPA_BT_VOLUME_ID_TERM];

View file

@ -2139,7 +2139,7 @@ static int port_set_format(struct impl *this, struct port *port,
if (info.info.raw.rate == 0 ||
info.info.raw.channels == 0 ||
info.info.raw.channels > SPA_AUDIO_MAX_CHANNELS)
info.info.raw.channels > MAX_CHANNELS)
return -EINVAL;
if (this->transport && this->transport->iso_io) {

View file

@ -1439,7 +1439,7 @@ static int port_set_format(struct impl *this, struct port *port,
if (info.info.raw.rate == 0 ||
info.info.raw.channels == 0 ||
info.info.raw.channels > SPA_AUDIO_MAX_CHANNELS)
info.info.raw.channels > MAX_CHANNELS)
return -EINVAL;
port->frame_size = info.info.raw.channels;

View file

@ -39,6 +39,7 @@
SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.filter-graph");
#define MAX_HNDL 64
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
#define DEFAULT_RATE 48000
@ -154,15 +155,15 @@ struct graph_hndl {
struct volume {
bool mute;
uint32_t n_volumes;
float volumes[SPA_AUDIO_MAX_CHANNELS];
float volumes[MAX_CHANNELS];
uint32_t n_ports;
struct port *ports[SPA_AUDIO_MAX_CHANNELS];
float min[SPA_AUDIO_MAX_CHANNELS];
float max[SPA_AUDIO_MAX_CHANNELS];
struct port *ports[MAX_CHANNELS];
float min[MAX_CHANNELS];
float max[MAX_CHANNELS];
#define SCALE_LINEAR 0
#define SCALE_CUBIC 1
int scale[SPA_AUDIO_MAX_CHANNELS];
int scale[MAX_CHANNELS];
};
struct graph {
@ -194,9 +195,9 @@ struct graph {
uint32_t n_inputs;
uint32_t n_outputs;
uint32_t inputs_position[SPA_AUDIO_MAX_CHANNELS];
uint32_t inputs_position[MAX_CHANNELS];
uint32_t n_inputs_position;
uint32_t outputs_position[SPA_AUDIO_MAX_CHANNELS];
uint32_t outputs_position[MAX_CHANNELS];
uint32_t n_outputs_position;
float min_latency;
@ -256,8 +257,8 @@ static void emit_filter_graph_info(struct impl *impl, bool full)
char n_inputs[64], n_outputs[64], latency[64];
struct spa_dict_item items[6];
struct spa_dict dict = SPA_DICT(items, 0);
char in_pos[SPA_AUDIO_MAX_CHANNELS * 8];
char out_pos[SPA_AUDIO_MAX_CHANNELS * 8];
char in_pos[MAX_CHANNELS * 8];
char out_pos[MAX_CHANNELS * 8];
snprintf(n_inputs, sizeof(n_inputs), "%d", impl->graph.n_inputs);
snprintf(n_outputs, sizeof(n_outputs), "%d", impl->graph.n_outputs);
@ -745,7 +746,7 @@ static int impl_set_props(void *object, enum spa_direction direction, const stru
case SPA_PROP_channelVolumes:
{
uint32_t i, n_vols;
float vols[SPA_AUDIO_MAX_CHANNELS];
float vols[MAX_CHANNELS];
if ((n_vols = spa_pod_copy_array(&prop->value, SPA_TYPE_Float, vols,
SPA_AUDIO_MAX_CHANNELS)) > 0) {
@ -772,7 +773,7 @@ static int impl_set_props(void *object, enum spa_direction direction, const stru
}
}
if (do_volume && vol->n_ports != 0) {
float soft_vols[SPA_AUDIO_MAX_CHANNELS];
float soft_vols[MAX_CHANNELS];
uint32_t i;
for (i = 0; i < vol->n_volumes; i++)
@ -1264,7 +1265,7 @@ static int parse_volume(struct graph *graph, struct spa_json *json, enum spa_dir
spa_log_error(impl->log, "unknown control port %s", control);
return -ENOENT;
}
if (vol->n_ports >= SPA_AUDIO_MAX_CHANNELS) {
if (vol->n_ports >= MAX_CHANNELS) {
spa_log_error(impl->log, "too many volume controls");
return -ENOSPC;
}

View file

@ -35,12 +35,13 @@
SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.null-audio-sink");
#define DEFAULT_CLOCK_NAME "clock.system.monotonic"
#define MAX_CHANNELS SPA_AUDIO_MAX_CHANNELS
struct props {
uint32_t format;
uint32_t channels;
uint32_t rate;
uint32_t pos[SPA_AUDIO_MAX_CHANNELS];
uint32_t pos[MAX_CHANNELS];
char clock_name[64];
unsigned int debug:1;
unsigned int driver:1;