diff options
author | Wim Taymans <wtaymans@redhat.com> | 2017-11-13 12:30:48 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2017-11-13 12:30:48 +0100 |
commit | cd5e697e9f68d0756a4db6790a3ba781d340e246 (patch) | |
tree | e5c62d88a48062576e6f6d9cd9f38f9738cb7600 | |
parent | 737b4280772a00d532f27d03cf369b70c53365a1 (diff) |
builder: make methods to save and restore state
-rw-r--r-- | spa/include/spa/pod/builder.h | 66 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-sink.c | 13 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-source.c | 12 | ||||
-rw-r--r-- | spa/plugins/audiomixer/audiomixer.c | 6 | ||||
-rw-r--r-- | spa/plugins/audiotestsrc/audiotestsrc.c | 12 | ||||
-rw-r--r-- | spa/plugins/ffmpeg/ffmpeg-dec.c | 6 | ||||
-rw-r--r-- | spa/plugins/ffmpeg/ffmpeg-enc.c | 6 | ||||
-rw-r--r-- | spa/plugins/test/fakesink.c | 12 | ||||
-rw-r--r-- | spa/plugins/test/fakesrc.c | 12 | ||||
-rw-r--r-- | spa/plugins/v4l2/v4l2-source.c | 12 | ||||
-rw-r--r-- | spa/plugins/videotestsrc/videotestsrc.c | 12 | ||||
-rw-r--r-- | spa/plugins/volume/volume.c | 12 | ||||
-rw-r--r-- | spa/tests/test-graph.c | 2 | ||||
-rw-r--r-- | spa/tests/test-mixer.c | 2 | ||||
-rw-r--r-- | spa/tests/test-ringbuffer.c | 2 | ||||
-rw-r--r-- | src/gst/gstpipewireformat.c | 6 | ||||
-rw-r--r-- | src/modules/module-client-node/client-node.c | 13 | ||||
-rw-r--r-- | src/modules/module-jack/jack-node.c | 6 | ||||
-rw-r--r-- | src/modules/module-protocol-native/connection.c | 14 | ||||
-rw-r--r-- | src/pipewire/link.c | 2 |
20 files changed, 118 insertions, 110 deletions
diff --git a/spa/include/spa/pod/builder.h b/spa/include/spa/pod/builder.h index c8b65fd7..6cee1682 100644 --- a/spa/include/spa/pod/builder.h +++ b/spa/include/spa/pod/builder.h @@ -33,30 +33,40 @@ struct spa_pod_frame { uint32_t ref; }; +struct spa_pod_builder_state { + uint32_t offset; + bool in_array; + bool first; + int depth; +}; + struct spa_pod_builder { void *data; uint32_t size; - uint32_t offset; uint32_t (*write) (struct spa_pod_builder *builder, const void *data, uint32_t size); void * (*deref) (struct spa_pod_builder *builder, uint32_t ref); - void (*reset) (struct spa_pod_builder *builder, uint32_t offset); - bool in_array; - bool first; - int depth; + void (*reset) (struct spa_pod_builder *builder, struct spa_pod_builder_state *state); + + struct spa_pod_builder_state state; struct spa_pod_frame frame[SPA_POD_MAX_DEPTH]; }; #define SPA_POD_BUILDER_INIT(buffer,size) { buffer, size, } static inline void -spa_pod_builder_reset(struct spa_pod_builder *builder, uint32_t offset) +spa_pod_builder_get_state(struct spa_pod_builder *builder, struct spa_pod_builder_state *state) +{ + *state = builder->state; +} + +static inline void +spa_pod_builder_reset(struct spa_pod_builder *builder, struct spa_pod_builder_state *state) { if (builder->reset) - builder->reset(builder, offset); - builder->offset = offset; - builder->depth = 0; - builder->in_array = builder->first = false; + builder->reset(builder, state); + else + builder->state = *state; } static inline void spa_pod_builder_init(struct spa_pod_builder *builder, void *data, uint32_t size) @@ -84,11 +94,11 @@ spa_pod_builder_push(struct spa_pod_builder *builder, const struct spa_pod *pod, uint32_t ref) { - struct spa_pod_frame *frame = &builder->frame[builder->depth++]; + struct spa_pod_frame *frame = &builder->frame[builder->state.depth++]; frame->pod = *pod; frame->ref = ref; - builder->in_array = builder->first = (pod->type == SPA_POD_TYPE_ARRAY || - pod->type == SPA_POD_TYPE_PROP); + builder->state.in_array = builder->state.first = + (pod->type == SPA_POD_TYPE_ARRAY || pod->type == SPA_POD_TYPE_PROP); return ref; } @@ -101,16 +111,16 @@ spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t if (builder->write) { ref = builder->write(builder, data, size); } else { - ref = builder->offset; + ref = builder->state.offset; if (ref + size > builder->size) ref = -1; else memcpy(builder->data + ref, data, size); } - builder->offset += size; + builder->state.offset += size; - for (i = 0; i < builder->depth; i++) + for (i = 0; i < builder->state.depth; i++) builder->frame[i].pod.size += size; return ref; @@ -137,14 +147,14 @@ static inline void *spa_pod_builder_pop(struct spa_pod_builder *builder) struct spa_pod_frame *frame, *top; struct spa_pod *pod; - frame = &builder->frame[--builder->depth]; + frame = &builder->frame[--builder->state.depth]; if ((pod = spa_pod_builder_deref(builder, frame->ref)) != NULL) *pod = frame->pod; - top = builder->depth > 0 ? &builder->frame[builder->depth-1] : NULL; - builder->in_array = (top && (top->pod.type == SPA_POD_TYPE_ARRAY || - top->pod.type == SPA_POD_TYPE_PROP)); - spa_pod_builder_pad(builder, builder->offset); + top = builder->state.depth > 0 ? &builder->frame[builder->state.depth-1] : NULL; + builder->state.in_array = (top && + (top->pod.type == SPA_POD_TYPE_ARRAY || top->pod.type == SPA_POD_TYPE_PROP)); + spa_pod_builder_pad(builder, builder->state.offset); return pod; } @@ -155,16 +165,16 @@ spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod const void *data; uint32_t size, ref; - if (builder->in_array && !builder->first) { + if (builder->state.in_array && !builder->state.first) { data = SPA_POD_BODY_CONST(p); size = SPA_POD_BODY_SIZE(p); } else { data = p; size = SPA_POD_SIZE(p); - builder->first = false; + builder->state.first = false; } ref = spa_pod_builder_raw(builder, data, size); - if (!builder->in_array) + if (!builder->state.in_array) spa_pod_builder_pad(builder, size); return ref; } @@ -235,7 +245,7 @@ spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, u ref = -1; if (spa_pod_builder_raw(builder, "", 1) == -1) ref = -1; - spa_pod_builder_pad(builder, builder->offset); + spa_pod_builder_pad(builder, builder->state.offset); return ref; } @@ -543,8 +553,8 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, } case ']': case ')': case '>': spa_pod_builder_pop(builder); - if (builder->depth > 0 && - builder->frame[builder->depth-1].pod.type == SPA_POD_TYPE_PROP) + if (builder->state.depth > 0 && + builder->frame[builder->state.depth-1].pod.type == SPA_POD_TYPE_PROP) spa_pod_builder_pop(builder); break; case ' ': case '\n': case '\t': case '\r': @@ -558,7 +568,7 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, } format++; } - return spa_pod_builder_deref(builder, builder->frame[builder->depth].ref); + return spa_pod_builder_deref(builder, builder->frame[builder->state.depth].ref); } static inline void *spa_pod_builder_add(struct spa_pod_builder *builder, const char *format, ...) diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index b49ccd66..86f5caf7 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -51,7 +51,7 @@ static int impl_node_enum_params(struct spa_node *node, struct state *this; struct type *t; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(index != NULL, -EINVAL); @@ -60,7 +60,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct state, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -92,7 +92,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -281,7 +281,7 @@ impl_node_port_enum_params(struct spa_node *node, struct state *this; struct type *t; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(index != NULL, -EINVAL); @@ -292,8 +292,7 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); - offset = builder->offset; - + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -375,7 +374,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index b90795f9..9ce819b0 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -50,7 +50,7 @@ static int impl_node_enum_params(struct spa_node *node, struct state *this; struct type *t; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(index != NULL, -EINVAL); @@ -59,7 +59,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct state, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -89,7 +89,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -330,7 +330,7 @@ impl_node_port_enum_params(struct spa_node *node, struct state *this; struct type *t; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; int res; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -342,7 +342,7 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -398,7 +398,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index f3f74476..c11f0af7 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -387,7 +387,7 @@ impl_node_port_enum_params(struct spa_node *node, struct type *t; struct port *port; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; int res; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -401,7 +401,7 @@ impl_node_port_enum_params(struct spa_node *node, port = GET_PORT(this, direction, port_id); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -471,7 +471,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 9eb11ef4..ff3eaee1 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -174,7 +174,7 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -184,7 +184,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -217,7 +217,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -577,7 +577,7 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; int res; @@ -590,7 +590,7 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -660,7 +660,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index d4687d15..76942422 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -275,11 +275,11 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct type *t = &this->type; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; int res; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -305,7 +305,7 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index db37fbac..4fdfa050 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -271,11 +271,11 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct type *t = &this->type; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; int res; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -301,7 +301,7 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index 690b1a99..70f914cb 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -135,7 +135,7 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -144,7 +144,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -168,7 +168,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -468,7 +468,7 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; int res; @@ -481,7 +481,7 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -533,7 +533,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index 0c4d8721..d32a5fce 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -141,7 +141,7 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -151,7 +151,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -179,7 +179,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -483,7 +483,7 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; int res; @@ -496,7 +496,7 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -548,7 +548,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index d494c9ad..e3de22f7 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -176,7 +176,7 @@ static int impl_node_enum_params(struct spa_node *node, struct impl *this; struct type *t; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(index != NULL, -EINVAL); @@ -185,7 +185,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -212,7 +212,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -520,7 +520,7 @@ static int impl_node_port_enum_params(struct spa_node *node, struct port *port; struct type *t; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; int res; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -534,7 +534,7 @@ static int impl_node_port_enum_params(struct spa_node *node, port = &this->out_ports[port_id]; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -587,7 +587,7 @@ static int impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index 0e32f3b3..a0d8038e 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -158,8 +158,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; struct spa_pod *param; + struct spa_pod_builder_state state; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(builder != NULL, -EINVAL); @@ -167,7 +167,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -196,7 +196,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -522,7 +522,7 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; int res; @@ -535,7 +535,7 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -595,7 +595,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index faf97523..7b9badac 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -145,7 +145,7 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -155,7 +155,7 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -182,7 +182,7 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; @@ -392,7 +392,7 @@ impl_node_port_enum_params(struct spa_node *node, struct impl *this; struct type *t; struct port *port; - uint32_t offset; + struct spa_pod_builder_state state; struct spa_pod *param; int res; @@ -407,7 +407,7 @@ impl_node_port_enum_params(struct spa_node *node, port = GET_PORT(this, direction, port_id); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idList) { @@ -463,7 +463,7 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) goto next; diff --git a/spa/tests/test-graph.c b/spa/tests/test-graph.c index bd834fbd..43873f6a 100644 --- a/spa/tests/test-graph.c +++ b/spa/tests/test-graph.c @@ -384,7 +384,7 @@ static int negotiate_formats(struct data *data) ":", data->type.format_audio.rate, "i", 44100, ":", data->type.format_audio.channels, "i", 2); - ref = b.offset; + ref = b.state.offset; spa_debug_pod(&filter->pod, 0); diff --git a/spa/tests/test-mixer.c b/spa/tests/test-mixer.c index 0dff3da2..f59dfc76 100644 --- a/spa/tests/test-mixer.c +++ b/spa/tests/test-mixer.c @@ -468,7 +468,7 @@ static int negotiate_formats(struct data *data) ":", data->type.format_audio.rate, "i", 44100, ":", data->type.format_audio.channels, "i", 2); - ref = b.offset; + ref = b.state.offset; if ((res = spa_node_port_enum_params(data->sink, diff --git a/spa/tests/test-ringbuffer.c b/spa/tests/test-ringbuffer.c index 122472b3..de09f455 100644 --- a/spa/tests/test-ringbuffer.c +++ b/spa/tests/test-ringbuffer.c @@ -333,7 +333,7 @@ static int negotiate_formats(struct data *data) ":", data->type.format_audio.rate, "i", 44100, ":", data->type.format_audio.channels, "i", 2); - ref = b.offset; + ref = b.state.offset; if ((res = spa_node_port_enum_params(data->sink, SPA_DIRECTION_INPUT, 0, diff --git a/src/gst/gstpipewireformat.c b/src/gst/gstpipewireformat.c index 9717a5e4..9e4c86f1 100644 --- a/src/gst/gstpipewireformat.c +++ b/src/gst/gstpipewireformat.c @@ -531,10 +531,10 @@ handle_audio_fields (ConvertData *d) static uint32_t write_pod (struct spa_pod_builder *b, const void *data, uint32_t size) { - uint32_t ref = b->offset; + uint32_t ref = b->state.offset; - if (b->size <= b->offset) { - b->size = SPA_ROUND_UP_N (b->offset + size, 512); + if (b->size <= ref) { + b->size = SPA_ROUND_UP_N (ref + size, 512); b->data = realloc (b->data, b->size); if (b->data == NULL) return -1; diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 021ce5ba..6d9ec0d0 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -156,7 +156,7 @@ static int spa_proxy_node_enum_params(struct spa_node *node, struct spa_pod_builder *builder) { struct proxy *this; - uint32_t offset; + struct spa_pod_builder_state state; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(index != NULL, -EINVAL); @@ -164,7 +164,7 @@ static int spa_proxy_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct proxy, node); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); while (true) { struct spa_pod_object *param; @@ -180,7 +180,7 @@ static int spa_proxy_node_enum_params(struct spa_node *node, if (spa_pod_filter(builder, ¶m->pod, &filter->pod) == 0) break; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); } return 1; } @@ -456,7 +456,7 @@ spa_proxy_node_port_enum_params(struct spa_node *node, { struct proxy *this; struct proxy_port *port; - uint32_t offset; + struct spa_pod_builder_state state; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(index != NULL, -EINVAL); @@ -468,7 +468,8 @@ spa_proxy_node_port_enum_params(struct spa_node *node, port = GET_PORT(this, direction, port_id); - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); + while (true) { struct spa_pod_object *param; @@ -483,7 +484,7 @@ spa_proxy_node_port_enum_params(struct spa_node *node, if (spa_pod_filter(builder, ¶m->pod, &filter->pod) == 0) break; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); } return 1; } diff --git a/src/modules/module-jack/jack-node.c b/src/modules/module-jack/jack-node.c index 22112325..d3d00def 100644 --- a/src/modules/module-jack/jack-node.c +++ b/src/modules/module-jack/jack-node.c @@ -447,10 +447,10 @@ static int port_enum_params(struct spa_node *node, struct node_data *nd = SPA_CONTAINER_OF(node, struct node_data, node_impl); struct type *t = &nd->type; struct spa_pod *param; - uint32_t offset; + struct spa_pod_builder_state state; int res; - offset = builder->offset; + spa_pod_builder_get_state(builder, &state); next: if (id == t->param.idEnumFormat) { @@ -466,7 +466,7 @@ static int port_enum_params(struct spa_node *node, (*index)++; - spa_pod_builder_reset(builder, offset); + spa_pod_builder_reset(builder, &state); if ((res = spa_pod_filter(builder, param, (struct spa_pod*)filter)) < 0) goto next; diff --git a/src/modules/module-protocol-native/connection.c b/src/modules/module-protocol-native/connection.c index f3063acc..7b92eb1a 100644 --- a/src/modules/module-protocol-native/connection.c +++ b/src/modules/module-protocol-native/connection.c @@ -348,12 +348,10 @@ static inline void *begin_write(struct pw_protocol_native_connection *conn, uint static uint32_t write_pod(struct spa_pod_builder *b, const void *data, uint32_t size) { struct impl *impl = SPA_CONTAINER_OF(b, struct impl, builder); - uint32_t ref = b->offset; + uint32_t ref = b->state.offset; - ref = b->offset; - - if (b->size <= b->offset) { - b->size = SPA_ROUND_UP_N(b->offset + size, 4096); + if (b->size <= ref) { + b->size = SPA_ROUND_UP_N(ref + size, 4096); b->data = begin_write(&impl->this, b->size); } memcpy(b->data + ref, data, size); @@ -385,7 +383,7 @@ pw_protocol_native_connection_begin_resource(struct pw_protocol_native_connectio impl->dest_id = resource->id; impl->opcode = opcode; - impl->builder = (struct spa_pod_builder) { NULL, 0, 0, write_pod }; + impl->builder = (struct spa_pod_builder) { NULL, 0, write_pod }; return &impl->builder; } @@ -414,7 +412,7 @@ pw_protocol_native_connection_begin_proxy(struct pw_protocol_native_connection * impl->dest_id = proxy->id; impl->opcode = opcode; - impl->builder = (struct spa_pod_builder) { NULL, 0, 0, write_pod }; + impl->builder = (struct spa_pod_builder) { NULL, 0, write_pod }; return &impl->builder; } @@ -424,7 +422,7 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn, struct spa_pod_builder *builder) { struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this); - uint32_t *p, size = builder->offset; + uint32_t *p, size = builder->state.offset; struct buffer *buf = &impl->out; if ((p = connection_ensure_size(conn, buf, 8 + size)) == NULL) diff --git a/src/pipewire/link.c b/src/pipewire/link.c index a4c71850..f075ad22 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -422,7 +422,7 @@ param_filter(struct pw_link *this, for (oidx = 0;;) { uint32_t offset; - offset = result->offset; + offset = result->state.offset; pw_log_debug("oparam %d %d", oidx, offset); if (spa_node_port_enum_params(out_port->node->node, out_port->direction, |