summaryrefslogtreecommitdiff
path: root/spa/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'spa/plugins')
-rw-r--r--spa/plugins/audioconvert/channelmix.c34
-rw-r--r--spa/plugins/audioconvert/fmtconvert.c34
-rw-r--r--spa/plugins/audioconvert/merger.c34
-rw-r--r--spa/plugins/audioconvert/resample.c34
-rw-r--r--spa/plugins/audioconvert/splitter.c34
-rw-r--r--spa/plugins/audiomixer/audiomixer.c33
-rw-r--r--spa/plugins/audiotestsrc/audiotestsrc.c34
-rw-r--r--spa/plugins/bluez5/a2dp-sink.c9
-rw-r--r--spa/plugins/videotestsrc/videotestsrc.c33
-rw-r--r--spa/plugins/volume/volume.c38
10 files changed, 59 insertions, 258 deletions
diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c
index 3b689a91..50419167 100644
--- a/spa/plugins/audioconvert/channelmix.c
+++ b/spa/plugins/audioconvert/channelmix.c
@@ -335,32 +335,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
- struct port *port = GET_PORT(this, direction, port_id);
-
- if (!port->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", port->format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_layout, "I", port->format.info.raw.layout,
- ":", SPA_FORMAT_AUDIO_rate, "i", port->format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", port->format.info.raw.channels);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -412,8 +386,12 @@ impl_node_port_enum_params(struct spa_node *node,
break;
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, &param, &b)) <= 0)
- return res;
+ if (!port->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &port->format.info.raw);
break;
case SPA_PARAM_Buffers:
diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c
index c124bb00..fb401913 100644
--- a/spa/plugins/audioconvert/fmtconvert.c
+++ b/spa/plugins/audioconvert/fmtconvert.c
@@ -465,32 +465,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
- struct port *port = GET_PORT(this, direction, port_id);
-
- if (!port->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", port->format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_layout, "I", port->format.info.raw.layout,
- ":", SPA_FORMAT_AUDIO_rate, "i", port->format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", port->format.info.raw.channels);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -543,8 +517,12 @@ impl_node_port_enum_params(struct spa_node *node,
break;
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, &param, &b)) <= 0)
- return res;
+ if (!port->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &port->format.info.raw);
break;
case SPA_PARAM_Buffers:
diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c
index 266b306c..4f20ad13 100644
--- a/spa/plugins/audioconvert/merger.c
+++ b/spa/plugins/audioconvert/merger.c
@@ -360,32 +360,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
- struct port *port = GET_PORT(this, direction, port_id);
-
- if (!port->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", port->format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_layout, "I", port->format.info.raw.layout,
- ":", SPA_FORMAT_AUDIO_rate, "i", port->format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", port->format.info.raw.channels);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -436,8 +410,12 @@ impl_node_port_enum_params(struct spa_node *node,
return res;
break;
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, &param, &b)) <= 0)
- return res;
+ if (!port->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &port->format.info.raw);
break;
case SPA_PARAM_Buffers:
if (!port->have_format)
diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c
index 6dc2fd13..e21644ec 100644
--- a/spa/plugins/audioconvert/resample.c
+++ b/spa/plugins/audioconvert/resample.c
@@ -309,32 +309,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
- struct port *port = GET_PORT(this, direction, port_id);
-
- if (!port->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", port->format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_layout, "I", port->format.info.raw.layout,
- ":", SPA_FORMAT_AUDIO_rate, "i", port->format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", port->format.info.raw.channels);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -385,8 +359,12 @@ impl_node_port_enum_params(struct spa_node *node,
return res;
break;
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, &param, &b)) <= 0)
- return res;
+ if (!port->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &port->format.info.raw);
break;
case SPA_PARAM_Buffers:
{
diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c
index 5d4b0456..4730c602 100644
--- a/spa/plugins/audioconvert/splitter.c
+++ b/spa/plugins/audioconvert/splitter.c
@@ -360,32 +360,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
- struct port *port = GET_PORT(this, direction, port_id);
-
- if (!port->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", port->format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_layout, "I", port->format.info.raw.layout,
- ":", SPA_FORMAT_AUDIO_rate, "i", port->format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", port->format.info.raw.channels);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -437,8 +411,12 @@ impl_node_port_enum_params(struct spa_node *node,
return res;
break;
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, &param, &b)) <= 0)
- return res;
+ if (!port->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &port->format.info.raw);
break;
case SPA_PARAM_Buffers:
if (!port->have_format)
diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c
index d82989c3..bcbfd711 100644
--- a/spa/plugins/audiomixer/audiomixer.c
+++ b/spa/plugins/audiomixer/audiomixer.c
@@ -353,31 +353,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
- struct port *port = GET_PORT(this, direction, port_id);
-
- if (!port->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", this->format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_rate, "i", this->format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", this->format.info.raw.channels);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -427,8 +402,12 @@ impl_node_port_enum_params(struct spa_node *node,
return res;
break;
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, &param, &b)) <= 0)
- return res;
+ if (!port->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &this->format.info.raw);
break;
case SPA_PARAM_Buffers:
if (!port->have_format)
diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c
index 62137f0e..f59d7192 100644
--- a/spa/plugins/audiotestsrc/audiotestsrc.c
+++ b/spa/plugins/audiotestsrc/audiotestsrc.c
@@ -534,6 +534,7 @@ port_enum_formats(struct impl *this,
SPA_AUDIO_FORMAT_S32,
SPA_AUDIO_FORMAT_F32,
SPA_AUDIO_FORMAT_F64),
+ ":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_INTERLEAVED,
":", SPA_FORMAT_AUDIO_rate, "iru", 44100,
SPA_POD_PROP_MIN_MAX(1, INT32_MAX),
":", SPA_FORMAT_AUDIO_channels, "iru", 2,
@@ -546,30 +547,6 @@ port_enum_formats(struct impl *this,
}
static int
-port_get_format(struct impl *this,
- enum spa_direction direction,
- uint32_t port_id,
- uint32_t *index,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- if (!this->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", this->current_format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_rate, "i", this->current_format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", this->current_format.info.raw.channels);
-
- return 1;
-}
-
-static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t *index,
@@ -614,9 +591,14 @@ impl_node_port_enum_params(struct spa_node *node,
if ((res = port_enum_formats(this, direction, port_id, index, &param, &b)) <= 0)
return res;
break;
+
case SPA_PARAM_Format:
- if ((res = port_get_format(this, direction, port_id, index, &param, &b)) <= 0)
- return res;
+ if (!this->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &this->current_format.info.raw);
break;
case SPA_PARAM_Buffers:
diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c
index ecfcd5d3..b0ad5a9d 100644
--- a/spa/plugins/bluez5/a2dp-sink.c
+++ b/spa/plugins/bluez5/a2dp-sink.c
@@ -984,14 +984,7 @@ impl_node_port_enum_params(struct spa_node *node,
if (*index > 0)
return 0;
- param = spa_pod_builder_object(&b,
- SPA_TYPE_OBJECT_Format, id,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", this->current_format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_layout, "I", this->current_format.info.raw.layout,
- ":", SPA_FORMAT_AUDIO_rate, "i", this->current_format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", this->current_format.info.raw.channels);
+ param = spa_format_audio_raw_build(&b, id, &this->current_format.info.raw);
break;
case SPA_PARAM_Buffers:
diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c
index af6b6dd6..97f89298 100644
--- a/spa/plugins/videotestsrc/videotestsrc.c
+++ b/spa/plugins/videotestsrc/videotestsrc.c
@@ -482,31 +482,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- const struct spa_pod *filter,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
-
- if (!this->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_video,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_VIDEO_format, "I", this->current_format.info.raw.format,
- ":", SPA_FORMAT_VIDEO_size, "R", &this->current_format.info.raw.size,
- ":", SPA_FORMAT_VIDEO_framerate, "F", &this->current_format.info.raw.framerate);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -553,8 +528,12 @@ impl_node_port_enum_params(struct spa_node *node,
break;
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, filter, &param, &b)) <= 0)
- return res;
+ if (!this->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_video_raw_build(builder, id, &this->current_format.info.raw);
break;
case SPA_PARAM_Buffers:
diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c
index 1de770af..9b308a35 100644
--- a/spa/plugins/volume/volume.c
+++ b/spa/plugins/volume/volume.c
@@ -344,34 +344,6 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
-static int port_get_format(struct spa_node *node,
- enum spa_direction direction, uint32_t port_id,
- uint32_t *index,
- const struct spa_pod *filter,
- struct spa_pod **param,
- struct spa_pod_builder *builder)
-{
- struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
- struct port *port;
-
- port = GET_PORT(this, direction, port_id);
-
- if (!port->have_format)
- return -EIO;
- if (*index > 0)
- return 0;
-
- *param = spa_pod_builder_object(builder,
- SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
- "I", SPA_MEDIA_TYPE_audio,
- "I", SPA_MEDIA_SUBTYPE_raw,
- ":", SPA_FORMAT_AUDIO_format, "I", this->current_format.info.raw.format,
- ":", SPA_FORMAT_AUDIO_rate, "i", this->current_format.info.raw.rate,
- ":", SPA_FORMAT_AUDIO_channels, "i", this->current_format.info.raw.channels);
-
- return 1;
-}
-
static int
impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
@@ -420,10 +392,16 @@ impl_node_port_enum_params(struct spa_node *node,
if ((res = port_enum_formats(node, direction, port_id, index, filter, &param, &b)) <= 0)
return res;
break;
+
case SPA_PARAM_Format:
- if ((res = port_get_format(node, direction, port_id, index, filter, &param, &b)) <= 0)
- return res;
+ if (!port->have_format)
+ return -EIO;
+ if (*index > 0)
+ return 0;
+
+ param = spa_format_audio_raw_build(&b, id, &this->current_format.info.raw);
break;
+
case SPA_PARAM_Buffers:
if (!port->have_format)
return -EIO;