mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-14 05:34:06 -04:00
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:
parent
eb096bfb62
commit
13b8c23767
30 changed files with 136 additions and 108 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue