mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: remove some obsolete functions
The spa_audio_info array now always holds enough positions for all channels and we don't need to wrap around.
This commit is contained in:
parent
6d74eee874
commit
78219471ff
12 changed files with 34 additions and 64 deletions
|
|
@ -28,35 +28,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPA_API_AUDIO_RAW_UTILS uint32_t
|
|
||||||
spa_format_audio_raw_get_position(const struct spa_audio_info_raw *info, uint32_t idx)
|
|
||||||
{
|
|
||||||
uint32_t pos, max_position = SPA_N_ELEMENTS(info->position);
|
|
||||||
if (idx < max_position) {
|
|
||||||
pos = info->position[idx];
|
|
||||||
} else {
|
|
||||||
pos = info->position[idx % max_position];
|
|
||||||
if (SPA_AUDIO_CHANNEL_IS_AUX(pos))
|
|
||||||
pos += (idx / max_position) * max_position;
|
|
||||||
}
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
SPA_API_AUDIO_RAW_UTILS void
|
|
||||||
spa_format_audio_raw_set_position(struct spa_audio_info_raw *info, uint32_t idx, uint32_t position)
|
|
||||||
{
|
|
||||||
if (idx < SPA_N_ELEMENTS(info->position))
|
|
||||||
info->position[idx] = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
SPA_API_AUDIO_RAW_UTILS uint32_t
|
|
||||||
spa_format_audio_raw_copy_positions(const struct spa_audio_info_raw *info, uint32_t *position, uint32_t max_position)
|
|
||||||
{
|
|
||||||
uint32_t i, n_pos = SPA_MIN(info->channels, max_position);
|
|
||||||
for (i = 0; i < n_pos; i++)
|
|
||||||
position[i] = spa_format_audio_raw_get_position(info, i);
|
|
||||||
return n_pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
SPA_API_AUDIO_RAW_UTILS int
|
SPA_API_AUDIO_RAW_UTILS int
|
||||||
spa_format_audio_raw_ext_parse(const struct spa_pod *format, struct spa_audio_info_raw *info, size_t size)
|
spa_format_audio_raw_ext_parse(const struct spa_pod *format, struct spa_audio_info_raw *info, size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1897,7 +1897,7 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m
|
||||||
this->dir[SPA_DIRECTION_OUTPUT].n_ports = dir->n_ports + 1;
|
this->dir[SPA_DIRECTION_OUTPUT].n_ports = dir->n_ports + 1;
|
||||||
|
|
||||||
for (i = 0; i < dir->n_ports; i++) {
|
for (i = 0; i < dir->n_ports; i++) {
|
||||||
uint32_t pos = spa_format_audio_raw_get_position(&info->info.raw, i);
|
uint32_t pos = info->info.raw.position[i];
|
||||||
init_port(this, direction, i, pos, true, false, false);
|
init_port(this, direction, i, pos, true, false, false);
|
||||||
if (this->monitor && direction == SPA_DIRECTION_INPUT)
|
if (this->monitor && direction == SPA_DIRECTION_INPUT)
|
||||||
init_port(this, SPA_DIRECTION_OUTPUT, i+1,
|
init_port(this, SPA_DIRECTION_OUTPUT, i+1,
|
||||||
|
|
@ -2067,8 +2067,8 @@ static int setup_in_convert(struct impl *this)
|
||||||
uint32_t pi, pj;
|
uint32_t pi, pj;
|
||||||
char b1[8], b2[8];
|
char b1[8], b2[8];
|
||||||
|
|
||||||
pi = spa_format_audio_raw_get_position(&src_info.info.raw, i);
|
pi = src_info.info.raw.position[i];
|
||||||
pj = spa_format_audio_raw_get_position(&dst_info.info.raw, j);
|
pj = dst_info.info.raw.position[j];
|
||||||
if (pi != pj)
|
if (pi != pj)
|
||||||
continue;
|
continue;
|
||||||
in->remap[i] = j;
|
in->remap[i] = j;
|
||||||
|
|
@ -2078,7 +2078,7 @@ static int setup_in_convert(struct impl *this)
|
||||||
i, in->remap[i], j,
|
i, in->remap[i], j,
|
||||||
spa_type_audio_channel_make_short_name(pi, b1, 8, "UNK"),
|
spa_type_audio_channel_make_short_name(pi, b1, 8, "UNK"),
|
||||||
spa_type_audio_channel_make_short_name(pj, b2, 8, "UNK"));
|
spa_type_audio_channel_make_short_name(pj, b2, 8, "UNK"));
|
||||||
spa_format_audio_raw_set_position(&dst_info.info.raw, j, -1);
|
dst_info.info.raw.position[j] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2126,7 +2126,7 @@ static int remap_volumes(struct impl *this, const struct spa_audio_info *info)
|
||||||
|
|
||||||
for (i = 0; i < p->n_channels; i++) {
|
for (i = 0; i < p->n_channels; i++) {
|
||||||
for (j = i; j < target; j++) {
|
for (j = i; j < target; j++) {
|
||||||
uint32_t pj = spa_format_audio_raw_get_position(&info->info.raw, j);
|
uint32_t pj = info->info.raw.position[j];
|
||||||
spa_log_debug(this->log, "%d %d: %d <-> %d", i, j,
|
spa_log_debug(this->log, "%d %d: %d <-> %d", i, j,
|
||||||
p->channel_map[i], pj);
|
p->channel_map[i], pj);
|
||||||
if (p->channel_map[i] != pj)
|
if (p->channel_map[i] != pj)
|
||||||
|
|
@ -2142,7 +2142,7 @@ static int remap_volumes(struct impl *this, const struct spa_audio_info *info)
|
||||||
}
|
}
|
||||||
p->n_channels = target;
|
p->n_channels = target;
|
||||||
for (i = 0; i < p->n_channels; i++)
|
for (i = 0; i < p->n_channels; i++)
|
||||||
p->channel_map[i] = spa_format_audio_raw_get_position(&info->info.raw, i);
|
p->channel_map[i] = info->info.raw.position[i];
|
||||||
|
|
||||||
if (target == 0)
|
if (target == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2216,7 +2216,7 @@ static int setup_channelmix(struct impl *this, uint32_t channels, uint32_t *posi
|
||||||
src_mask |= 1ULL << (p < 64 ? p : 0);
|
src_mask |= 1ULL << (p < 64 ? p : 0);
|
||||||
}
|
}
|
||||||
for (i = 0, dst_mask = 0; i < dst_chan; i++) {
|
for (i = 0, dst_mask = 0; i < dst_chan; i++) {
|
||||||
p = spa_format_audio_raw_get_position(&out->format.info.raw, i);
|
p = out->format.info.raw.position[i];
|
||||||
dst_mask |= 1ULL << (p < 64 ? p : 0);
|
dst_mask |= 1ULL << (p < 64 ? p : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2361,8 +2361,8 @@ static int setup_out_convert(struct impl *this)
|
||||||
uint32_t pi, pj;
|
uint32_t pi, pj;
|
||||||
char b1[8], b2[8];
|
char b1[8], b2[8];
|
||||||
|
|
||||||
pi = spa_format_audio_raw_get_position(&src_info.info.raw, i);
|
pi = src_info.info.raw.position[i];
|
||||||
pj = spa_format_audio_raw_get_position(&dst_info.info.raw, j);
|
pj = dst_info.info.raw.position[j];
|
||||||
if (pi != pj)
|
if (pi != pj)
|
||||||
continue;
|
continue;
|
||||||
out->remap[i] = j;
|
out->remap[i] = j;
|
||||||
|
|
@ -2374,7 +2374,7 @@ static int setup_out_convert(struct impl *this)
|
||||||
spa_type_audio_channel_make_short_name(pi, b1, 8, "UNK"),
|
spa_type_audio_channel_make_short_name(pi, b1, 8, "UNK"),
|
||||||
spa_type_audio_channel_make_short_name(pj, b2, 8, "UNK"));
|
spa_type_audio_channel_make_short_name(pj, b2, 8, "UNK"));
|
||||||
|
|
||||||
spa_format_audio_raw_set_position(&dst_info.info.raw, j, -1);
|
dst_info.info.raw.position[j] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5038,9 +5038,13 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn,
|
||||||
spa_log_error(monitor->log, "invalid transport configuration");
|
spa_log_error(monitor->log, "invalid transport configuration");
|
||||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
|
if (info.info.raw.channels > MAX_CHANNELS) {
|
||||||
|
spa_log_error(monitor->log, "too many channels in transport");
|
||||||
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
|
}
|
||||||
transport->n_channels = info.info.raw.channels;
|
transport->n_channels = info.info.raw.channels;
|
||||||
spa_format_audio_raw_copy_positions(&info.info.raw,
|
memcpy(transport->channels, info.info.raw.position,
|
||||||
transport->channels, SPA_N_ELEMENTS(transport->channels));
|
transport->n_channels * sizeof(uint32_t));
|
||||||
} else {
|
} else {
|
||||||
transport->n_channels = 2;
|
transport->n_channels = 2;
|
||||||
transport->channels[0] = SPA_AUDIO_CHANNEL_FL;
|
transport->channels[0] = SPA_AUDIO_CHANNEL_FL;
|
||||||
|
|
|
||||||
|
|
@ -475,7 +475,10 @@ static void get_channels(struct spa_bt_transport *t, bool a2dp_duplex, uint32_t
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*n_channels = spa_format_audio_raw_copy_positions(&info.info.raw, channels, max_channels);
|
*n_channels = info.info.raw.channels;
|
||||||
|
memcpy(channels, info.info.raw.position,
|
||||||
|
info.info.raw.channels * sizeof(uint32_t));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_channel_name(uint32_t channel)
|
static const char *get_channel_name(uint32_t channel)
|
||||||
|
|
|
||||||
|
|
@ -883,8 +883,8 @@ static int create_stream(struct stream_info *info)
|
||||||
s->remap[i] = i;
|
s->remap[i] = i;
|
||||||
for (j = 0; j < tmp_info.channels; j++) {
|
for (j = 0; j < tmp_info.channels; j++) {
|
||||||
uint32_t pj, pi;
|
uint32_t pj, pi;
|
||||||
pj = spa_format_audio_raw_get_position(&tmp_info, j);
|
pj = tmp_info.position[j];
|
||||||
pi = spa_format_audio_raw_get_position(&remap_info, i);
|
pi = remap_info.position[i];
|
||||||
if (pj == pi) {
|
if (pj == pi) {
|
||||||
s->remap[i] = j;
|
s->remap[i] = j;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -525,8 +525,7 @@ static void make_stream_ports(struct stream *s)
|
||||||
|
|
||||||
if (i < s->info.channels) {
|
if (i < s->info.channels) {
|
||||||
str = spa_type_audio_channel_make_short_name(
|
str = spa_type_audio_channel_make_short_name(
|
||||||
spa_format_audio_raw_get_position(&s->info, i),
|
s->info.position[i], pos, sizeof(pos), NULL);
|
||||||
pos, sizeof(pos), NULL);
|
|
||||||
if (str)
|
if (str)
|
||||||
snprintf(name, sizeof(name), "%s_%s", prefix, str);
|
snprintf(name, sizeof(name), "%s_%s", prefix, str);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,7 @@ static void param_format_changed(struct impl *impl, const struct spa_pod *param,
|
||||||
(impl->info.channels != 0 &&
|
(impl->info.channels != 0 &&
|
||||||
(impl->info.channels != info.channels ||
|
(impl->info.channels != info.channels ||
|
||||||
memcmp(impl->info.position, info.position,
|
memcmp(impl->info.position, info.position,
|
||||||
SPA_MIN(info.channels, SPA_N_ELEMENTS(info.position)) * sizeof(uint32_t)) != 0))) {
|
info.channels * sizeof(uint32_t)) != 0))) {
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b;
|
struct spa_pod_builder b;
|
||||||
const struct spa_pod *params[1];
|
const struct spa_pod *params[1];
|
||||||
|
|
|
||||||
|
|
@ -442,8 +442,7 @@ static void make_stream_ports(struct stream *s)
|
||||||
|
|
||||||
if (i < s->info.channels) {
|
if (i < s->info.channels) {
|
||||||
str = spa_type_audio_channel_make_short_name(
|
str = spa_type_audio_channel_make_short_name(
|
||||||
spa_format_audio_raw_get_position(&s->info, i),
|
s->info.position[i], name, sizeof(name), "UNK");
|
||||||
name, sizeof(name), "UNK");
|
|
||||||
props = pw_properties_new(
|
props = pw_properties_new(
|
||||||
PW_KEY_FORMAT_DSP, "32 bit float mono audio",
|
PW_KEY_FORMAT_DSP, "32 bit float mono audio",
|
||||||
PW_KEY_AUDIO_CHANNEL, str,
|
PW_KEY_AUDIO_CHANNEL, str,
|
||||||
|
|
@ -866,8 +865,7 @@ static int handle_follower_setup(struct impl *impl, struct nj2_session_params *p
|
||||||
if ((uint32_t)peer->params.send_audio_channels != impl->sink.info.channels) {
|
if ((uint32_t)peer->params.send_audio_channels != impl->sink.info.channels) {
|
||||||
impl->sink.info.channels = peer->params.send_audio_channels;
|
impl->sink.info.channels = peer->params.send_audio_channels;
|
||||||
for (i = 0; i < impl->sink.info.channels; i++)
|
for (i = 0; i < impl->sink.info.channels; i++)
|
||||||
spa_format_audio_raw_set_position(&impl->sink.info, i,
|
impl->sink.info.position[i] = SPA_AUDIO_CHANNEL_AUX0 + i;
|
||||||
SPA_AUDIO_CHANNEL_AUX0 + i);
|
|
||||||
}
|
}
|
||||||
impl->source.n_ports = peer->params.recv_audio_channels + peer->params.recv_midi_channels;
|
impl->source.n_ports = peer->params.recv_audio_channels + peer->params.recv_midi_channels;
|
||||||
if (impl->source.n_ports > MAX_PORTS) {
|
if (impl->source.n_ports > MAX_PORTS) {
|
||||||
|
|
@ -878,8 +876,7 @@ static int handle_follower_setup(struct impl *impl, struct nj2_session_params *p
|
||||||
if ((uint32_t)peer->params.recv_audio_channels != impl->source.info.channels) {
|
if ((uint32_t)peer->params.recv_audio_channels != impl->source.info.channels) {
|
||||||
impl->source.info.channels = peer->params.recv_audio_channels;
|
impl->source.info.channels = peer->params.recv_audio_channels;
|
||||||
for (i = 0; i < impl->source.info.channels; i++)
|
for (i = 0; i < impl->source.info.channels; i++)
|
||||||
spa_format_audio_raw_set_position(&impl->source.info, i,
|
impl->source.info.position[i] = SPA_AUDIO_CHANNEL_AUX0 + i;
|
||||||
SPA_AUDIO_CHANNEL_AUX0 + i);
|
|
||||||
}
|
}
|
||||||
impl->samplerate = peer->params.sample_rate;
|
impl->samplerate = peer->params.sample_rate;
|
||||||
impl->period_size = peer->params.period_size;
|
impl->period_size = peer->params.period_size;
|
||||||
|
|
|
||||||
|
|
@ -602,8 +602,7 @@ static void make_stream_ports(struct stream *s)
|
||||||
|
|
||||||
if (i < s->info.channels) {
|
if (i < s->info.channels) {
|
||||||
str = spa_type_audio_channel_make_short_name(
|
str = spa_type_audio_channel_make_short_name(
|
||||||
spa_format_audio_raw_get_position(&s->info, i),
|
s->info.position[i], name, sizeof(name), "UNK");
|
||||||
name, sizeof(name), "UNK");
|
|
||||||
props = pw_properties_new(
|
props = pw_properties_new(
|
||||||
PW_KEY_FORMAT_DSP, "32 bit float mono audio",
|
PW_KEY_FORMAT_DSP, "32 bit float mono audio",
|
||||||
PW_KEY_AUDIO_CHANNEL, str,
|
PW_KEY_AUDIO_CHANNEL, str,
|
||||||
|
|
@ -1031,16 +1030,14 @@ static int handle_follower_available(struct impl *impl, struct nj2_session_param
|
||||||
if ((uint32_t)peer->params.recv_audio_channels != follower->source.info.channels) {
|
if ((uint32_t)peer->params.recv_audio_channels != follower->source.info.channels) {
|
||||||
follower->source.info.channels = peer->params.recv_audio_channels;
|
follower->source.info.channels = peer->params.recv_audio_channels;
|
||||||
for (i = 0; i < follower->source.info.channels; i++)
|
for (i = 0; i < follower->source.info.channels; i++)
|
||||||
spa_format_audio_raw_set_position(&follower->source.info, i,
|
follower->source.info.position[i] = SPA_AUDIO_CHANNEL_AUX0 + i;
|
||||||
SPA_AUDIO_CHANNEL_AUX0 + i);
|
|
||||||
}
|
}
|
||||||
follower->sink.n_ports = peer->params.send_audio_channels + peer->params.send_midi_channels;
|
follower->sink.n_ports = peer->params.send_audio_channels + peer->params.send_midi_channels;
|
||||||
follower->sink.info.rate = peer->params.sample_rate;
|
follower->sink.info.rate = peer->params.sample_rate;
|
||||||
if ((uint32_t)peer->params.send_audio_channels != follower->sink.info.channels) {
|
if ((uint32_t)peer->params.send_audio_channels != follower->sink.info.channels) {
|
||||||
follower->sink.info.channels = peer->params.send_audio_channels;
|
follower->sink.info.channels = peer->params.send_audio_channels;
|
||||||
for (i = 0; i < follower->sink.info.channels; i++)
|
for (i = 0; i < follower->sink.info.channels; i++)
|
||||||
spa_format_audio_raw_set_position(&follower->sink.info, i,
|
follower->sink.info.position[i] = SPA_AUDIO_CHANNEL_AUX0 + i;
|
||||||
SPA_AUDIO_CHANNEL_AUX0 + i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (follower->source.n_ports > MAX_PORTS || follower->sink.n_ports > MAX_PORTS) {
|
if (follower->source.n_ports > MAX_PORTS || follower->sink.n_ports > MAX_PORTS) {
|
||||||
|
|
|
||||||
|
|
@ -585,7 +585,7 @@ int format_parse_param(const struct spa_pod *param, bool collect,
|
||||||
if (info.info.raw.channels) {
|
if (info.info.raw.channels) {
|
||||||
map->channels = SPA_MIN(info.info.raw.channels, CHANNELS_MAX);
|
map->channels = SPA_MIN(info.info.raw.channels, CHANNELS_MAX);
|
||||||
for (i = 0; i < map->channels; i++)
|
for (i = 0; i < map->channels; i++)
|
||||||
map->map[i] = spa_format_audio_raw_get_position(&info.info.raw, i);
|
map->map[i] = info.info.raw.position[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ int module_args_to_audioinfo_keys(struct impl *impl, struct pw_properties *props
|
||||||
} else {
|
} else {
|
||||||
/* FIXME add more mappings */
|
/* FIXME add more mappings */
|
||||||
for (i = 0; i < info->channels; i++)
|
for (i = 0; i < info->channels; i++)
|
||||||
spa_format_audio_raw_set_position(info, i, SPA_AUDIO_CHANNEL_UNKNOWN);
|
info->position[i] = SPA_AUDIO_CHANNEL_UNKNOWN;
|
||||||
}
|
}
|
||||||
if (info->position[0] == SPA_AUDIO_CHANNEL_UNKNOWN)
|
if (info->position[0] == SPA_AUDIO_CHANNEL_UNKNOWN)
|
||||||
info->flags |= SPA_AUDIO_FLAG_UNPOSITIONED;
|
info->flags |= SPA_AUDIO_FLAG_UNPOSITIONED;
|
||||||
|
|
@ -290,8 +290,7 @@ void audioinfo_to_properties(struct spa_audio_info_raw *info, struct pw_properti
|
||||||
p = s = alloca(info->channels * 8);
|
p = s = alloca(info->channels * 8);
|
||||||
for (i = 0; i < info->channels; i++)
|
for (i = 0; i < info->channels; i++)
|
||||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ", ",
|
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ", ",
|
||||||
channel_id2name(spa_format_audio_raw_get_position(info, i),
|
channel_id2name(info->position[i], pos, sizeof(pos)));
|
||||||
pos, sizeof(pos)));
|
|
||||||
pw_properties_setf(props, SPA_KEY_AUDIO_POSITION, "[ %s ]", s);
|
pw_properties_setf(props, SPA_KEY_AUDIO_POSITION, "[ %s ]", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -755,7 +755,7 @@ static int create_pulse_stream(struct impl *impl)
|
||||||
map.channels = impl->info.channels;
|
map.channels = impl->info.channels;
|
||||||
for (i = 0; i < map.channels; i++)
|
for (i = 0; i < map.channels; i++)
|
||||||
map.map[i] = (pa_channel_position_t)channel_id2pa(
|
map.map[i] = (pa_channel_position_t)channel_id2pa(
|
||||||
spa_format_audio_raw_get_position(&impl->info, i), &aux);
|
impl->info.position[i], &aux);
|
||||||
|
|
||||||
snprintf(stream_name, sizeof(stream_name), _("Tunnel for %s@%s"),
|
snprintf(stream_name, sizeof(stream_name), _("Tunnel for %s@%s"),
|
||||||
pw_get_user_name(), pw_get_host_name());
|
pw_get_user_name(), pw_get_host_name());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue