mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
audio: don't use SPA_AUDIO_MAX_CHANNELS in some places
When we know the max size of the array, just use this instead of the SPA_AUDIO_MAX_CHANNELS constant.
This commit is contained in:
parent
c94aff8cae
commit
f453b1545d
14 changed files with 22 additions and 18 deletions
|
|
@ -200,7 +200,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
a2dp_aac_t conf;
|
a2dp_aac_t conf;
|
||||||
struct spa_pod_frame f[2];
|
struct spa_pod_frame f[2];
|
||||||
struct spa_pod_choice *choice;
|
struct spa_pod_choice *choice;
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[2];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
if (caps_size < sizeof(conf))
|
if (caps_size < sizeof(conf))
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
a2dp_aptx_t conf;
|
a2dp_aptx_t conf;
|
||||||
struct spa_pod_frame f[2];
|
struct spa_pod_frame f[2];
|
||||||
struct spa_pod_choice *choice;
|
struct spa_pod_choice *choice;
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[2];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
if (caps_size < sizeof(conf))
|
if (caps_size < sizeof(conf))
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
a2dp_faststream_t conf;
|
a2dp_faststream_t conf;
|
||||||
struct spa_pod_frame f[2];
|
struct spa_pod_frame f[2];
|
||||||
struct spa_pod_choice *choice;
|
struct spa_pod_choice *choice;
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[2];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
if (caps_size < sizeof(conf))
|
if (caps_size < sizeof(conf))
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
a2dp_lc3plus_hr_t conf;
|
a2dp_lc3plus_hr_t conf;
|
||||||
struct spa_pod_frame f[2];
|
struct spa_pod_frame f[2];
|
||||||
struct spa_pod_choice *choice;
|
struct spa_pod_choice *choice;
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[2];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
if (caps_size < sizeof(conf))
|
if (caps_size < sizeof(conf))
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
struct spa_pod_frame f[2];
|
struct spa_pod_frame f[2];
|
||||||
struct spa_pod_choice *choice;
|
struct spa_pod_choice *choice;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[2];
|
||||||
|
|
||||||
if (caps_size < sizeof(conf))
|
if (caps_size < sizeof(conf))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
{
|
{
|
||||||
a2dp_opus_g_t conf;
|
a2dp_opus_g_t conf;
|
||||||
struct spa_pod_frame f[1];
|
struct spa_pod_frame f[1];
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[2];
|
||||||
int channels;
|
int channels;
|
||||||
|
|
||||||
if (caps_size < sizeof(conf))
|
if (caps_size < sizeof(conf))
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
struct spa_pod_frame f[2];
|
struct spa_pod_frame f[2];
|
||||||
struct spa_pod_choice *choice;
|
struct spa_pod_choice *choice;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[2];
|
||||||
|
|
||||||
if (caps_size < sizeof(conf))
|
if (caps_size < sizeof(conf))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
||||||
|
|
@ -901,12 +901,12 @@ static int codec_caps_preference_cmp(const struct media_codec *codec, uint32_t f
|
||||||
return conf_cmp(&conf1, res1, &conf2, res2);
|
return conf_cmp(&conf1, res1, &conf2, res2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t channels_to_positions(uint32_t channels, uint32_t *position)
|
static uint8_t channels_to_positions(uint32_t channels, uint32_t *position, uint32_t max_position)
|
||||||
{
|
{
|
||||||
uint32_t n_channels = get_channel_count(channels);
|
uint32_t n_channels = get_channel_count(channels);
|
||||||
uint8_t n_positions = 0;
|
uint8_t n_positions = 0;
|
||||||
|
|
||||||
spa_assert(n_channels <= SPA_AUDIO_MAX_CHANNELS);
|
spa_assert(n_channels <= max_position);
|
||||||
|
|
||||||
if (channels == 0) {
|
if (channels == 0) {
|
||||||
position[0] = SPA_AUDIO_CHANNEL_MONO;
|
position[0] = SPA_AUDIO_CHANNEL_MONO;
|
||||||
|
|
@ -932,7 +932,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
bap_lc3_t conf;
|
bap_lc3_t conf;
|
||||||
struct spa_pod_frame f[2];
|
struct spa_pod_frame f[2];
|
||||||
struct spa_pod_choice *choice;
|
struct spa_pod_choice *choice;
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
uint32_t position[LC3_MAX_CHANNELS];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint8_t res;
|
uint8_t res;
|
||||||
|
|
||||||
|
|
@ -990,7 +990,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
res = channels_to_positions(conf.channels, position);
|
res = channels_to_positions(conf.channels, position, SPA_N_ELEMENTS(position));
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
spa_pod_builder_add(b,
|
spa_pod_builder_add(b,
|
||||||
|
|
@ -1044,7 +1044,8 @@ static int codec_validate_config(const struct media_codec *codec, uint32_t flags
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = channels_to_positions(conf.channels, info->info.raw.position);
|
res = channels_to_positions(conf.channels, info->info.raw.position,
|
||||||
|
SPA_N_ELEMENTS(info->info.raw.position));
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
info->info.raw.channels = res;
|
info->info.raw.channels = res;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
struct spa_pod_builder *b, struct spa_pod **param)
|
struct spa_pod_builder *b, struct spa_pod **param)
|
||||||
{
|
{
|
||||||
struct spa_pod_frame f[1];
|
struct spa_pod_frame f[1];
|
||||||
const uint32_t position[SPA_AUDIO_MAX_CHANNELS] = { SPA_AUDIO_CHANNEL_MONO };
|
const uint32_t position[1] = { SPA_AUDIO_CHANNEL_MONO };
|
||||||
const int channels = 1;
|
const int channels = 1;
|
||||||
|
|
||||||
spa_assert(caps == NULL && caps_size == 0);
|
spa_assert(caps == NULL && caps_size == 0);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
struct spa_pod_builder *b, struct spa_pod **param)
|
struct spa_pod_builder *b, struct spa_pod **param)
|
||||||
{
|
{
|
||||||
struct spa_pod_frame f[1];
|
struct spa_pod_frame f[1];
|
||||||
const uint32_t position[SPA_AUDIO_MAX_CHANNELS] = { SPA_AUDIO_CHANNEL_MONO };
|
const uint32_t position[1] = { SPA_AUDIO_CHANNEL_MONO };
|
||||||
const int channels = 1;
|
const int channels = 1;
|
||||||
|
|
||||||
spa_assert(caps == NULL && caps_size == 0);
|
spa_assert(caps == NULL && caps_size == 0);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
struct spa_pod_builder *b, struct spa_pod **param)
|
struct spa_pod_builder *b, struct spa_pod **param)
|
||||||
{
|
{
|
||||||
struct spa_pod_frame f[1];
|
struct spa_pod_frame f[1];
|
||||||
const uint32_t position[SPA_AUDIO_MAX_CHANNELS] = { SPA_AUDIO_CHANNEL_MONO };
|
const uint32_t position[1] = { SPA_AUDIO_CHANNEL_MONO };
|
||||||
const int channels = 1;
|
const int channels = 1;
|
||||||
|
|
||||||
spa_assert(caps == NULL && caps_size == 0);
|
spa_assert(caps == NULL && caps_size == 0);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
||||||
struct spa_pod_builder *b, struct spa_pod **param)
|
struct spa_pod_builder *b, struct spa_pod **param)
|
||||||
{
|
{
|
||||||
struct spa_pod_frame f[1];
|
struct spa_pod_frame f[1];
|
||||||
const uint32_t position[SPA_AUDIO_MAX_CHANNELS] = { SPA_AUDIO_CHANNEL_MONO };
|
const uint32_t position[1] = { SPA_AUDIO_CHANNEL_MONO };
|
||||||
const int channels = 1;
|
const int channels = 1;
|
||||||
|
|
||||||
spa_assert(caps == NULL && caps_size == 0);
|
spa_assert(caps == NULL && caps_size == 0);
|
||||||
|
|
|
||||||
|
|
@ -649,7 +649,7 @@ handle_video_fields (ConvertData *d)
|
||||||
static void
|
static void
|
||||||
set_default_channels (struct spa_pod_builder *b, uint32_t channels)
|
set_default_channels (struct spa_pod_builder *b, uint32_t channels)
|
||||||
{
|
{
|
||||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS] = {0};
|
uint32_t position[8] = {0};
|
||||||
gboolean ok = TRUE;
|
gboolean ok = TRUE;
|
||||||
|
|
||||||
switch (channels) {
|
switch (channels) {
|
||||||
|
|
|
||||||
|
|
@ -334,9 +334,12 @@ static void rtp_opus_deinit(struct impl *impl, enum spa_direction direction)
|
||||||
static int rtp_opus_init(struct impl *impl, enum spa_direction direction)
|
static int rtp_opus_init(struct impl *impl, enum spa_direction direction)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
unsigned char mapping[SPA_AUDIO_MAX_CHANNELS];
|
unsigned char mapping[255];
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
|
if (impl->info.info.opus.channels > 255)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (impl->psamples >= 2880)
|
if (impl->psamples >= 2880)
|
||||||
impl->psamples = 2880;
|
impl->psamples = 2880;
|
||||||
else if (impl->psamples >= 1920)
|
else if (impl->psamples >= 1920)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue