mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
treewide: remove some obsolete channel checks
The spa_audio_info can not be parsed with too many channels so there is always enough space for the positions.
This commit is contained in:
parent
78219471ff
commit
aa0272f6f3
8 changed files with 50 additions and 64 deletions
|
|
@ -491,7 +491,7 @@ static void get_default_bitrates(const struct media_codec *codec, bool bidi, int
|
|||
|
||||
static int get_mapping(const struct media_codec *codec, const a2dp_opus_05_direction_t *conf,
|
||||
bool use_surround_encoder, uint8_t *streams_ret, uint8_t *coupled_streams_ret,
|
||||
const uint8_t **surround_mapping, uint32_t *positions, uint32_t max_positions)
|
||||
const uint8_t **surround_mapping, uint32_t *positions)
|
||||
{
|
||||
const uint32_t channels = conf->channels;
|
||||
const uint32_t location = OPUS_05_GET_LOCATION(*conf);
|
||||
|
|
@ -539,12 +539,11 @@ static int get_mapping(const struct media_codec *codec, const a2dp_opus_05_direc
|
|||
|
||||
if (location & loc.mask) {
|
||||
uint32_t idx = permutation ? permutation[j] : j;
|
||||
if (idx < max_positions)
|
||||
positions[idx] = loc.position;
|
||||
positions[idx] = loc.position;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for (i = SPA_AUDIO_CHANNEL_START_Aux; j < channels && j < max_positions; ++i, ++j)
|
||||
for (i = SPA_AUDIO_CHANNEL_START_Aux; j < channels; ++i, ++j)
|
||||
positions[j] = i;
|
||||
}
|
||||
|
||||
|
|
@ -779,7 +778,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
|||
|
||||
dir = !is_duplex_codec(codec) ? &conf.main : &conf.bidi;
|
||||
|
||||
if (get_mapping(codec, dir, surround_encoder, NULL, NULL, NULL, position, MAX_CHANNELS) < 0)
|
||||
if (get_mapping(codec, dir, surround_encoder, NULL, NULL, NULL, position) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
spa_pod_builder_push_object(b, &f[0], SPA_TYPE_OBJECT_Format, id);
|
||||
|
|
@ -832,9 +831,9 @@ static int codec_validate_config(const struct media_codec *codec, uint32_t flags
|
|||
|
||||
info->info.raw.channels = dir1->channels;
|
||||
if (get_mapping(codec, dir1, surround_encoder, NULL, NULL, NULL,
|
||||
info->info.raw.position, SPA_N_ELEMENTS(info->info.raw.position)) < 0)
|
||||
info->info.raw.position) < 0)
|
||||
return -EINVAL;
|
||||
if (get_mapping(codec, dir2, surround_encoder, NULL, NULL, NULL, NULL, 0) < 0)
|
||||
if (get_mapping(codec, dir2, surround_encoder, NULL, NULL, NULL, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
|
|
@ -925,7 +924,7 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags,
|
|||
if ((res = codec_validate_config(codec, flags, config, config_len, &config_info)) < 0)
|
||||
goto error;
|
||||
if ((res = get_mapping(codec, dir, surround_encoder, &this->streams, &this->coupled_streams,
|
||||
&enc_mapping, NULL, 0)) < 0)
|
||||
&enc_mapping, NULL)) < 0)
|
||||
goto error;
|
||||
if (config_info.info.raw.channels != info->info.raw.channels) {
|
||||
res = -EINVAL;
|
||||
|
|
|
|||
|
|
@ -452,8 +452,7 @@ static int node_offload_set_active(struct node *node, bool active)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void get_channels(struct spa_bt_transport *t, bool a2dp_duplex, uint32_t *n_channels, uint32_t *channels,
|
||||
uint32_t max_channels)
|
||||
static void get_channels(struct spa_bt_transport *t, bool a2dp_duplex, uint32_t *n_channels, uint32_t *channels)
|
||||
{
|
||||
const struct media_codec *codec;
|
||||
struct spa_audio_info info = { 0 };
|
||||
|
|
@ -689,7 +688,7 @@ static void emit_node(struct impl *this, struct spa_bt_transport *t,
|
|||
this->nodes[id].active = true;
|
||||
this->nodes[id].offload_acquired = false;
|
||||
this->nodes[id].a2dp_duplex = a2dp_duplex;
|
||||
get_channels(t, a2dp_duplex, &this->nodes[id].n_channels, this->nodes[id].channels, MAX_CHANNELS);
|
||||
get_channels(t, a2dp_duplex, &this->nodes[id].n_channels, this->nodes[id].channels);
|
||||
if (this->nodes[id].transport)
|
||||
spa_hook_remove(&this->nodes[id].transport_listener);
|
||||
this->nodes[id].transport = t;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue