mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
channelmix: improve control parsing
This commit is contained in:
parent
1352c7555e
commit
699bed4a1f
4 changed files with 36 additions and 17 deletions
|
|
@ -59,19 +59,14 @@ static inline void spa_pod_iter_advance(struct spa_pod_iter *iter, struct spa_po
|
||||||
iter->offset += SPA_ROUND_UP_N(SPA_POD_SIZE(current), 8);
|
iter->offset += SPA_ROUND_UP_N(SPA_POD_SIZE(current), 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool spa_pod_is_inside(const void *pod, uint32_t size, const struct spa_pod *iter)
|
static inline bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)
|
||||||
{
|
{
|
||||||
return iter < SPA_MEMBER(pod, size, struct spa_pod);
|
return iter < SPA_MEMBER(pod, size, void);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool spa_pod_control_is_inside(const void *pod, uint32_t size, const struct spa_pod_control *iter)
|
static inline void *spa_pod_next(const void *iter)
|
||||||
{
|
{
|
||||||
return iter < SPA_MEMBER(pod, size, struct spa_pod_control);
|
return SPA_MEMBER(iter, SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), void);
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct spa_pod *spa_pod_next(const struct spa_pod *iter)
|
|
||||||
{
|
|
||||||
return SPA_MEMBER(iter, SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), struct spa_pod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_control *iter)
|
static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_control *iter)
|
||||||
|
|
@ -90,7 +85,7 @@ static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_
|
||||||
(iter) = spa_pod_next(iter))
|
(iter) = spa_pod_next(iter))
|
||||||
|
|
||||||
#define SPA_POD_CONTENTS_FOREACH(pod, offset, iter) \
|
#define SPA_POD_CONTENTS_FOREACH(pod, offset, iter) \
|
||||||
SPA_POD_FOREACH(SPA_MEMBER((pod), (offset), struct spa_pod),SPA_POD_SIZE (pod)-(offset),iter)
|
SPA_POD_FOREACH(SPA_MEMBER((pod), (offset), void),SPA_POD_SIZE (pod)-(offset),iter)
|
||||||
|
|
||||||
#define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter) \
|
#define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter) \
|
||||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_object_body), struct spa_pod); \
|
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_object_body), struct spa_pod); \
|
||||||
|
|
@ -102,7 +97,7 @@ static inline struct spa_pod_control *spa_pod_control_next(const struct spa_pod_
|
||||||
|
|
||||||
#define SPA_POD_SEQUENCE_BODY_FOREACH(body, size, iter) \
|
#define SPA_POD_SEQUENCE_BODY_FOREACH(body, size, iter) \
|
||||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_sequence_body), struct spa_pod_control); \
|
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_sequence_body), struct spa_pod_control); \
|
||||||
spa_pod_control_is_inside(body, size, iter); \
|
spa_pod_is_inside(body, size, iter); \
|
||||||
(iter) = spa_pod_control_next(iter))
|
(iter) = spa_pod_control_next(iter))
|
||||||
|
|
||||||
#define SPA_POD_SEQUENCE_FOREACH(seq, iter) \
|
#define SPA_POD_SEQUENCE_FOREACH(seq, iter) \
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,9 @@ struct spa_pod_bitmap {
|
||||||
/* array of uint8_t follows with the bitmap */
|
/* array of uint8_t follows with the bitmap */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SPA_POD_ARRAY_TYPE(arr) ((arr)->body.child.type)
|
||||||
|
#define SPA_POD_ARRAY_N_VALUES(arr) (((arr)->pod.size - sizeof(struct spa_pod_array_body)) / (arr)->body.child.size)
|
||||||
|
|
||||||
struct spa_pod_array_body {
|
struct spa_pod_array_body {
|
||||||
struct spa_pod child;
|
struct spa_pod child;
|
||||||
/* array with elements of child.size follows */
|
/* array with elements of child.size follows */
|
||||||
|
|
|
||||||
|
|
@ -707,15 +707,27 @@ static int process_control(struct impl *this, struct port *port, struct spa_pod_
|
||||||
{
|
{
|
||||||
struct props *p = &this->props;
|
struct props *p = &this->props;
|
||||||
float volume = p->volume;
|
float volume = p->volume;
|
||||||
|
struct spa_pod *pod;
|
||||||
|
struct spa_pod_object *obj = (struct spa_pod_object *) &c->value;
|
||||||
|
|
||||||
spa_pod_object_parse(&c->value,
|
SPA_POD_OBJECT_FOREACH(obj, pod) {
|
||||||
":", SPA_PROP_volume, "?f", &volume,
|
struct spa_pod_prop *prop = (struct spa_pod_prop *)pod;
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (volume != p->volume) {
|
switch (prop->body.key) {
|
||||||
p->volume = volume;
|
case SPA_PROP_volume:
|
||||||
setup_matrix(this, &GET_IN_PORT(this, 0)->format, &GET_OUT_PORT(this, 0)->format);
|
volume = SPA_POD_VALUE(struct spa_pod_float, &prop->body.value);
|
||||||
|
if (volume != p->volume) {
|
||||||
|
p->volume = volume;
|
||||||
|
setup_matrix(this,
|
||||||
|
&GET_IN_PORT(this, 0)->format,
|
||||||
|
&GET_OUT_PORT(this, 0)->format);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -326,6 +326,15 @@ int main(int argc, char *argv[])
|
||||||
* "framerate": ( "Fru", (25, 1), ( (0,1), (MAX, 1)) )
|
* "framerate": ( "Fru", (25, 1), ( (0,1), (MAX, 1)) )
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
|
*
|
||||||
|
* { "Type" : "Format", "Id" : 0,
|
||||||
|
* "mediaType": "video",
|
||||||
|
* "mediaSubtype": "raw",
|
||||||
|
* "videoFormat": [ "enum", "I420", "YUY2" ],
|
||||||
|
* "videoSize": [ "range", [320,242], [1,1], [MAX,MAX] ],
|
||||||
|
* "videoFramerate": [ "range", [25,1], [0,1], [MAX,1] ]
|
||||||
|
* }
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
fmt = spa_pod_builder_add(&b,
|
fmt = spa_pod_builder_add(&b,
|
||||||
"{", SPA_TYPE_OBJECT_Format, 0,
|
"{", SPA_TYPE_OBJECT_Format, 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue