mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
audio: remove layout from audio
Make special format types for planar and interleaved instead of having a field. Add enum for audio channel positions Add some default audio channel layouts Place the channel layout in the audio format when possible alsa: place audio channel positions in format Add sse optimized channel mixing for some common cases Remove name from port info, it's not mandatory and in the properties Add direction to port info
This commit is contained in:
parent
fb3379e587
commit
5196f7f053
38 changed files with 981 additions and 369 deletions
|
|
@ -115,7 +115,6 @@ int main(int argc, char *argv[])
|
|||
params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat,
|
||||
&SPA_AUDIO_INFO_RAW_INIT(
|
||||
.format = SPA_AUDIO_FORMAT_F32,
|
||||
.layout = SPA_AUDIO_LAYOUT_INTERLEAVED,
|
||||
.channels = DEFAULT_CHANNELS,
|
||||
.rate = DEFAULT_RATE ));
|
||||
|
||||
|
|
|
|||
|
|
@ -179,14 +179,12 @@ static int port_enum_formats(struct spa_node *node,
|
|||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
||||
SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(3,
|
||||
SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(5,
|
||||
SPA_AUDIO_FORMAT_S16,
|
||||
SPA_AUDIO_FORMAT_S16P,
|
||||
SPA_AUDIO_FORMAT_S16,
|
||||
SPA_AUDIO_FORMAT_F32P,
|
||||
SPA_AUDIO_FORMAT_F32),
|
||||
SPA_FORMAT_AUDIO_layout, &SPA_POD_CHOICE_ENUM_Id(3,
|
||||
SPA_AUDIO_LAYOUT_INTERLEAVED,
|
||||
SPA_AUDIO_LAYOUT_INTERLEAVED,
|
||||
SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
|
||||
SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
|
||||
SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
|
||||
0);
|
||||
|
|
|
|||
|
|
@ -190,8 +190,8 @@ static void node_proxy_destroy(void *data)
|
|||
if (n->info)
|
||||
pw_node_info_free(n->info);
|
||||
if (n->session) {
|
||||
n->session = NULL;
|
||||
spa_list_remove(&n->session_link);
|
||||
n->session = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +276,11 @@ handle_node(struct impl *impl, uint32_t id, uint32_t parent_id,
|
|||
sess->need_dsp = need_dsp;
|
||||
sess->enabled = true;
|
||||
sess->node = node;
|
||||
if ((str = spa_dict_lookup(props, "node.plugged")) != NULL)
|
||||
sess->plugged = pw_properties_parse_uint64(str);
|
||||
else
|
||||
sess->plugged = SPA_TIMESPEC_TO_TIME(&impl->now);
|
||||
|
||||
spa_list_init(&sess->node_list);
|
||||
spa_list_append(&impl->session_list, &sess->l);
|
||||
|
||||
|
|
@ -397,8 +402,6 @@ registry_global(void *data,uint32_t id, uint32_t parent_id,
|
|||
{
|
||||
struct impl *impl = data;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &impl->now);
|
||||
|
||||
pw_log_debug(NAME " %p: new global '%d'", impl, id);
|
||||
|
||||
switch (type) {
|
||||
|
|
@ -699,7 +702,6 @@ static void dsp_node_event_info(void *object, struct pw_node_info *info)
|
|||
s->dsp = dsp;
|
||||
spa_hook_remove(&s->listener);
|
||||
|
||||
dsp->session = s;
|
||||
dsp->direction = s->direction;
|
||||
dsp->type = NODE_TYPE_DSP;
|
||||
}
|
||||
|
|
@ -727,7 +729,7 @@ static void rescan_session(struct impl *impl, struct session *sess)
|
|||
props = pw_properties_new_dict(node->info->props);
|
||||
pw_properties_setf(props, "audio-dsp.direction", "%d", sess->direction);
|
||||
pw_properties_setf(props, "audio-dsp.channels", "%d", node->format.channels);
|
||||
pw_properties_setf(props, "audio-dsp.channelmask", "%"PRIu64, node->format.channel_mask);
|
||||
pw_properties_setf(props, "audio-dsp.channelmask", "%d", 0);
|
||||
pw_properties_setf(props, "audio-dsp.rate", "%d", node->format.rate);
|
||||
pw_properties_setf(props, "audio-dsp.maxbuffer", "%ld", MAX_QUANTUM_SIZE * sizeof(float));
|
||||
|
||||
|
|
@ -749,6 +751,8 @@ static void do_rescan(struct impl *impl)
|
|||
struct session *sess;
|
||||
struct node *node;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &impl->now);
|
||||
|
||||
spa_list_for_each(sess, &impl->session_list, l)
|
||||
rescan_session(impl, sess);
|
||||
spa_list_for_each(node, &impl->node_list, l)
|
||||
|
|
|
|||
|
|
@ -454,6 +454,7 @@ handle_audio_fields (ConvertData *d)
|
|||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
|
||||
#if 0
|
||||
value = gst_structure_get_value (d->cs, "layout");
|
||||
if (value) {
|
||||
const char *v;
|
||||
|
|
@ -478,6 +479,7 @@ handle_audio_fields (ConvertData *d)
|
|||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
#endif
|
||||
value = gst_structure_get_value (d->cs, "rate");
|
||||
if (value) {
|
||||
int v;
|
||||
|
|
|
|||
|
|
@ -896,6 +896,9 @@ static void client_node_initialized(void *data)
|
|||
spa_debug_type_find_name(spa_type_media_subtype, media_subtype));
|
||||
|
||||
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debug_format(2, NULL, format);
|
||||
|
||||
if (!exclusive &&
|
||||
media_type == SPA_MEDIA_TYPE_audio &&
|
||||
media_subtype == SPA_MEDIA_SUBTYPE_raw) {
|
||||
|
|
|
|||
|
|
@ -646,7 +646,6 @@ static int collect_audio_format(void *data, uint32_t id,
|
|||
|
||||
if (info.channels > d->channels) {
|
||||
d->channels = info.channels;
|
||||
d->channelmask = info.channel_mask;
|
||||
d->rate = info.rate;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,8 @@ static const struct pw_port_implementation port_implementation = {
|
|||
|
||||
static const char *chmap_names[] =
|
||||
{
|
||||
"FL",
|
||||
"MONO", /**< mono */
|
||||
"FL", /**< front left */
|
||||
"FR", /**< front right */
|
||||
"RL", /**< rear left */
|
||||
"RR", /**< rear right */
|
||||
|
|
@ -242,6 +243,8 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
|
|||
pw_properties_set(pr, "node.session", str);
|
||||
|
||||
pw_properties_setf(pr, "node.format.rate", "%d", sample_rate);
|
||||
pw_properties_setf(pr, "node.format.channels", "%d", channels);
|
||||
pw_properties_setf(pr, "node.format.channelmask", "%"PRIu64, channelmask);
|
||||
|
||||
node = pw_spa_node_load(core, NULL, NULL,
|
||||
"audioconvert/libspa-audioconvert",
|
||||
|
|
@ -293,6 +296,7 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
|
|||
alias,
|
||||
direction == PW_DIRECTION_INPUT ? "in" : "out",
|
||||
channel_name);
|
||||
pw_properties_setf(props, "port.channel", "%s", channel_name);
|
||||
|
||||
port = pw_port_new(direction,
|
||||
i,
|
||||
|
|
|
|||
|
|
@ -331,8 +331,7 @@ static int port_enum_formats(struct spa_node *node,
|
|||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
||||
SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
|
||||
SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
|
||||
SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32P),
|
||||
SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
|
||||
SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(1),
|
||||
0);
|
||||
|
|
@ -550,7 +549,7 @@ static int port_set_format(struct spa_node *node,
|
|||
if (memcmp(&info, &this->format, sizeof(struct spa_audio_info)))
|
||||
return -EINVAL;
|
||||
} else {
|
||||
if (info.info.raw.format != SPA_AUDIO_FORMAT_F32)
|
||||
if (info.info.raw.format != SPA_AUDIO_FORMAT_F32P)
|
||||
return -EINVAL;
|
||||
|
||||
this->stride = sizeof(float);
|
||||
|
|
|
|||
|
|
@ -777,8 +777,8 @@ static void port_marshal_info(void *object, struct pw_port_info *info)
|
|||
spa_pod_builder_add(b,
|
||||
"[",
|
||||
"i", info->id,
|
||||
"i", info->direction,
|
||||
"l", info->change_mask,
|
||||
"s", info->name,
|
||||
"i", n_items, NULL);
|
||||
|
||||
for (i = 0; i < n_items; i++) {
|
||||
|
|
@ -803,8 +803,8 @@ static int port_demarshal_info(void *object, void *data, size_t size)
|
|||
if (spa_pod_parser_get(&prs,
|
||||
"["
|
||||
"i", &info.id,
|
||||
"i", &info.direction,
|
||||
"l", &info.change_mask,
|
||||
"s", &info.name,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -242,13 +242,9 @@ struct pw_port_info *pw_port_info_update(struct pw_port_info *info,
|
|||
return NULL;
|
||||
}
|
||||
info->id = update->id;
|
||||
info->direction = update->direction;
|
||||
info->change_mask = update->change_mask;
|
||||
|
||||
if (update->change_mask & PW_PORT_CHANGE_MASK_NAME) {
|
||||
if (info->name)
|
||||
free((void *) info->name);
|
||||
info->name = update->name ? strdup(update->name) : NULL;
|
||||
}
|
||||
if (update->change_mask & PW_PORT_CHANGE_MASK_PROPS) {
|
||||
if (info->props)
|
||||
pw_spa_dict_destroy(info->props);
|
||||
|
|
@ -260,8 +256,6 @@ struct pw_port_info *pw_port_info_update(struct pw_port_info *info,
|
|||
void pw_port_info_free(struct pw_port_info *info)
|
||||
{
|
||||
|
||||
if (info->name)
|
||||
free((void *) info->name);
|
||||
if (info->props)
|
||||
pw_spa_dict_destroy(info->props);
|
||||
free(info);
|
||||
|
|
|
|||
|
|
@ -167,11 +167,10 @@ pw_node_info_free(struct pw_node_info *info);
|
|||
|
||||
struct pw_port_info {
|
||||
uint32_t id; /**< id of the global */
|
||||
#define PW_PORT_CHANGE_MASK_NAME (1 << 0)
|
||||
#define PW_PORT_CHANGE_MASK_PROPS (1 << 1)
|
||||
#define PW_PORT_CHANGE_MASK_ENUM_PARAMS (1 << 2)
|
||||
enum pw_direction direction; /**< port direction */
|
||||
#define PW_PORT_CHANGE_MASK_PROPS (1 << 0)
|
||||
#define PW_PORT_CHANGE_MASK_ENUM_PARAMS (1 << 1)
|
||||
uint64_t change_mask; /**< bitfield of changed fields since last call */
|
||||
const char *name; /**< name the port, suitable for display */
|
||||
struct spa_dict *props; /**< the properties of the port */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -889,8 +889,8 @@ uint32_t pw_node_get_free_port_id(struct pw_node *node, enum pw_direction direct
|
|||
n_ports = node->info.n_output_ports;
|
||||
portmap = &node->output_port_map;
|
||||
}
|
||||
pw_log_debug("node %p: direction %d %u %u",
|
||||
node, direction, n_ports, max_ports);
|
||||
pw_log_debug("node %p: direction %s n_ports:%u max_ports:%u",
|
||||
node, pw_direction_as_string(direction), n_ports, max_ports);
|
||||
|
||||
if (n_ports >= max_ports)
|
||||
goto no_mem;
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ struct pw_port *pw_port_new(enum pw_direction direction,
|
|||
if (user_data_size > 0)
|
||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||
|
||||
this->info.direction = direction;
|
||||
this->info.props = &this->properties->dict;
|
||||
|
||||
spa_list_init(&this->links);
|
||||
|
|
|
|||
|
|
@ -555,9 +555,8 @@ static void info_port(struct proxy_data *pd)
|
|||
struct pw_port_info *info = pd->info;
|
||||
|
||||
info_global(pd);
|
||||
fprintf(stdout, "%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name);
|
||||
print_properties(info->props, MARK_CHANGE(1), true);
|
||||
fprintf(stdout, "%c\tenum_params\n", MARK_CHANGE(2));
|
||||
print_properties(info->props, MARK_CHANGE(0), true);
|
||||
fprintf(stdout, "%c\tenum_params\n", MARK_CHANGE(1));
|
||||
info->change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -289,8 +289,8 @@ static void print_port(struct proxy_data *data)
|
|||
printf("\ttype: %s (version %d)\n", PW_TYPE_INTERFACE__Port, data->version);
|
||||
if (print_all) {
|
||||
int i;
|
||||
printf("%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name);
|
||||
printf("%c\tparams:\n", MARK_CHANGE(2));
|
||||
printf(" \tdirection: \"%s\"\n", pw_direction_as_string(info->direction));
|
||||
printf("%c\tparams:\n", MARK_CHANGE(1));
|
||||
for (i = 0; i < data->n_params; i++) {
|
||||
if (spa_pod_is_object_type(data->params[i], SPA_TYPE_OBJECT_Format))
|
||||
spa_debug_format(12, NULL, data->params[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue