From 2746898e9ad1d357e10df44f406a286f86c169a2 Mon Sep 17 00:00:00 2001 From: hackerman-kl Date: Sun, 15 Mar 2026 10:22:48 +0100 Subject: [PATCH] milan-avb: rework mrp join/begin: * join/begin mrp protocol for attributes of mvrp and msrp within stream_activate. * Creation of the attribute done on stream creation during es_buidler --- src/modules/module-avb/aecp-aem-state.h | 11 ++- src/modules/module-avb/es-builder.c | 1 + src/modules/module-avb/msrp.c | 93 +++++++++++++++---------- src/modules/module-avb/msrp.h | 2 +- src/modules/module-avb/mvrp.c | 42 ++++++----- src/modules/module-avb/mvrp.h | 4 +- src/modules/module-avb/stream.c | 90 ++++++++++++++---------- src/tools/meson.build | 4 ++ src/tools/pw-avb-virtual.c | 3 +- test/meson.build | 4 ++ test/test-avb-utils.h | 6 +- test/test-avb.c | 60 ++++++++++------ 12 files changed, 199 insertions(+), 121 deletions(-) diff --git a/src/modules/module-avb/aecp-aem-state.h b/src/modules/module-avb/aecp-aem-state.h index 58d299767..cac9dcc91 100644 --- a/src/modules/module-avb/aecp-aem-state.h +++ b/src/modules/module-avb/aecp-aem-state.h @@ -81,7 +81,10 @@ struct aecp_aem_lock_state { struct aecp_aem_avb_interface_state { struct avb_aem_desc_avb_interface desc; - struct avb_msrp_attribute *domain_attr; + + struct avb_msrp_attribute domain_attr; + + struct avb_mvrp_attribute vlan_attr; }; @@ -130,7 +133,10 @@ struct aecp_aem_stream_input_counters { struct stream_common { struct stream stream; - struct avb_msrp_attribute *stream_attr; + + struct avb_msrp_attribute lstream_attr; + struct avb_msrp_attribute tastream_attr; + struct avb_msrp_attribute tfstream_attr; }; struct aecp_aem_stream_input_state { @@ -138,6 +144,7 @@ struct aecp_aem_stream_input_state { struct aecp_aem_stream_input_counters counters; struct stream_common common; + struct avb_mvrp_attribute mvrp_attr; }; struct stream_input_saved_binding_param { diff --git a/src/modules/module-avb/es-builder.c b/src/modules/module-avb/es-builder.c index a02b53ef4..3ba76163d 100644 --- a/src/modules/module-avb/es-builder.c +++ b/src/modules/module-avb/es-builder.c @@ -83,6 +83,7 @@ static struct descriptor *es_buidler_desc_stream_general_prepare(struct server * pstream_input = desc->ptr; stream = &pstream_input->common.stream; direction = SPA_DIRECTION_INPUT; + break; case AVB_AEM_DESC_STREAM_OUTPUT: struct aecp_aem_stream_output_state *pstream_output; diff --git a/src/modules/module-avb/msrp.c b/src/modules/module-avb/msrp.c index 611ddd537..2de4f07e9 100644 --- a/src/modules/module-avb/msrp.c +++ b/src/modules/module-avb/msrp.c @@ -16,7 +16,7 @@ static const uint8_t msrp_mac[6] = AVB_MSRP_MAC; struct attr { - struct avb_msrp_attribute attr; + struct avb_msrp_attribute *attr; struct msrp *msrp; struct spa_hook listener; struct spa_list link; @@ -53,8 +53,17 @@ static void debug_msrp_talker(const struct avb_packet_msrp_talker *t) static void notify_talker(struct msrp *msrp, uint64_t now, struct attr *attr, uint8_t notify) { - pw_log_info("> notify talker: %s", avb_mrp_notify_name(notify)); - debug_msrp_talker(&attr->attr.attr.talker); + pw_log_info("> notify talker advertise: %s", avb_mrp_notify_name(notify)); + if (msrp->server->avb_mode == AVB_MODE_MILAN_V12) { + } +} + +static void notify_talker_failed(struct msrp *msrp, uint64_t now, struct attr *attr, uint8_t notify) +{ + pw_log_info("> notify talker failed: %s", avb_mrp_notify_name(notify)); + + if (msrp->server->avb_mode == AVB_MODE_MILAN_V12) { + } } static int process_talker(struct msrp *msrp, uint64_t now, uint8_t attr_type, @@ -63,10 +72,10 @@ static int process_talker(struct msrp *msrp, uint64_t now, uint8_t attr_type, const struct avb_packet_msrp_talker *t = m; struct attr *a; spa_list_for_each(a, &msrp->attributes, link) - if (a->attr.type == attr_type && - a->attr.attr.talker.stream_id == t->stream_id) { - a->attr.attr.talker = *t; - avb_mrp_attribute_rx_event(a->attr.mrp, now, event); + if (a->attr->type == attr_type && + a->attr->attr.talker.stream_id == t->stream_id) { + a->attr->attr.talker = *t; + avb_mrp_attribute_rx_event(a->attr->mrp, now, event); } return 0; } @@ -88,10 +97,10 @@ static int encode_talker(struct msrp *msrp, struct attr *a, void *m) AVB_MRP_VECTOR_SET_NUM_VALUES(v, 1); t = (struct avb_packet_msrp_talker *)v->first_value; - *t = a->attr.attr.talker; + *t = a->attr->attr.talker; ev = SPA_PTROFF(t, sizeof(*t), uint8_t); - *ev = (a->attr.mrp->pending_send - 1) * 6 * 6; + *ev = (a->attr->mrp->pending_send - 1) * 6 * 6; f = SPA_PTROFF(ev, sizeof(*ev), struct avb_packet_mrp_footer); f->end_mark = 0; @@ -118,9 +127,9 @@ static int process_talker_fail(struct msrp *msrp, uint64_t now, uint8_t attr_typ debug_msrp_talker_fail(t); spa_list_for_each(a, &msrp->attributes, link) - if (a->attr.type == attr_type && - a->attr.attr.talker_fail.talker.stream_id == t->talker.stream_id) - avb_mrp_attribute_rx_event(a->attr.mrp, now, event); + if (a->attr->type == attr_type && + a->attr->attr.talker_fail.talker.stream_id == t->talker.stream_id) + avb_mrp_attribute_rx_event(a->attr->mrp, now, event); return 0; } @@ -135,7 +144,8 @@ static void debug_msrp_listener(const struct avb_packet_msrp_listener *l, uint8_ static void notify_listener(struct msrp *msrp, uint64_t now, struct attr *attr, uint8_t notify) { pw_log_info("> notify listener: %s", avb_mrp_notify_name(notify)); - debug_msrp_listener(&attr->attr.attr.listener, attr->attr.param); + debug_msrp_listener(&attr->attr->attr.listener, attr->attr->param); + } static int process_listener(struct msrp *msrp, uint64_t now, uint8_t attr_type, @@ -144,9 +154,9 @@ static int process_listener(struct msrp *msrp, uint64_t now, uint8_t attr_type, const struct avb_packet_msrp_listener *l = m; struct attr *a; spa_list_for_each(a, &msrp->attributes, link) - if (a->attr.type == attr_type && - a->attr.attr.listener.stream_id == l->stream_id) - avb_mrp_attribute_rx_event(a->attr.mrp, now, event); + if (a->attr->type == attr_type && + a->attr->attr.listener.stream_id == l->stream_id) + avb_mrp_attribute_rx_event(a->attr->mrp, now, event); return 0; } static int encode_listener(struct msrp *msrp, struct attr *a, void *m) @@ -167,13 +177,13 @@ static int encode_listener(struct msrp *msrp, struct attr *a, void *m) AVB_MRP_VECTOR_SET_NUM_VALUES(v, 1); l = (struct avb_packet_msrp_listener *)v->first_value; - *l = a->attr.attr.listener; + *l = a->attr->attr.listener; ev = SPA_PTROFF(l, sizeof(*l), uint8_t); - *ev = (a->attr.mrp->pending_send - 1) * 6 * 6; + *ev = (a->attr->mrp->pending_send - 1) * 6 * 6; ev = SPA_PTROFF(ev, sizeof(*ev), uint8_t); - *ev = a->attr.param * 4 * 4 * 4; + *ev = a->attr->param * 4 * 4 * 4; f = SPA_PTROFF(ev, sizeof(*ev), struct avb_packet_mrp_footer); f->end_mark = 0; @@ -192,7 +202,7 @@ static void debug_msrp_domain(const struct avb_packet_msrp_domain *d) static void notify_domain(struct msrp *msrp, uint64_t now, struct attr *attr, uint8_t notify) { pw_log_info("> notify domain: %s", avb_mrp_notify_name(notify)); - debug_msrp_domain(&attr->attr.attr.domain); + debug_msrp_domain(&attr->attr->attr.domain); } static int process_domain(struct msrp *msrp, uint64_t now, uint8_t attr_type, @@ -200,8 +210,8 @@ static int process_domain(struct msrp *msrp, uint64_t now, uint8_t attr_type, { struct attr *a; spa_list_for_each(a, &msrp->attributes, link) - if (a->attr.type == attr_type) - avb_mrp_attribute_rx_event(a->attr.mrp, now, event); + if (a->attr->type == attr_type) + avb_mrp_attribute_rx_event(a->attr->mrp, now, event); return 0; } @@ -223,10 +233,10 @@ static int encode_domain(struct msrp *msrp, struct attr *a, void *m) AVB_MRP_VECTOR_SET_NUM_VALUES(v, 1); d = (struct avb_packet_msrp_domain *)v->first_value; - *d = a->attr.attr.domain; + *d = a->attr->attr.domain; ev = SPA_PTROFF(d, sizeof(*d), uint8_t); - *ev = (a->attr.mrp->pending_send - 1) * 36; + *ev = (a->attr->mrp->pending_send - 1) * 36; f = SPA_PTROFF(ev, sizeof(*ev), struct avb_packet_mrp_footer); f->end_mark = 0; @@ -242,7 +252,7 @@ static const struct { void (*notify) (struct msrp *msrp, uint64_t now, struct attr *attr, uint8_t notify); } dispatch[] = { [AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE] = { "talker", process_talker, encode_talker, notify_talker, }, - [AVB_MSRP_ATTRIBUTE_TYPE_TALKER_FAILED] = { "talker-fail", process_talker_fail, NULL, NULL }, + [AVB_MSRP_ATTRIBUTE_TYPE_TALKER_FAILED] = { "talker-fail", process_talker_fail, NULL, notify_talker_failed, }, [AVB_MSRP_ATTRIBUTE_TYPE_LISTENER] = { "listener", process_listener, encode_listener, notify_listener }, [AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN] = { "domain", process_domain, encode_domain, notify_domain, }, }; @@ -265,8 +275,8 @@ static int msrp_attr_event(void *data, uint64_t now, uint8_t attribute_type, uin struct msrp *msrp = data; struct attr *a; spa_list_for_each(a, &msrp->attributes, link) - if (a->attr.type == attribute_type) - avb_mrp_attribute_update_state(a->attr.mrp, now, event); + if (a->attr->type == attribute_type) + avb_mrp_attribute_update_state(a->attr->mrp, now, event); return 0; } @@ -332,8 +342,9 @@ static void msrp_notify(void *data, uint64_t now, uint8_t notify) { struct attr *a = data; struct msrp *msrp = a->msrp; - if (dispatch[a->attr.type].notify) - dispatch[a->attr.type].notify(msrp, now, a, notify); + + if (dispatch[a->attr->type].notify) + dispatch[a->attr->type].notify(msrp, now, a, notify); } static const struct avb_mrp_attribute_events mrp_attr_events = { @@ -341,7 +352,7 @@ static const struct avb_mrp_attribute_events mrp_attr_events = { .notify = msrp_notify, }; -struct avb_msrp_attribute *avb_msrp_attribute_new(struct avb_msrp *m, +int avb_msrp_attribute_new(struct avb_msrp *m, struct avb_msrp_attribute *msrp_attr, uint8_t type) { struct msrp *msrp = (struct msrp*)m; @@ -349,16 +360,21 @@ struct avb_msrp_attribute *avb_msrp_attribute_new(struct avb_msrp *m, struct attr *a; attr = avb_mrp_attribute_new(msrp->server->mrp, sizeof(struct attr)); + if (!attr) { + pw_log_error("MSRP attribute allocation failed"); + return -1; + } a = attr->user_data; a->msrp = msrp; - a->attr.mrp = attr; - a->attr.type = type; + a->attr = msrp_attr; + a->attr->mrp = attr; + a->attr->type = type; attr->name = "MSRP"; spa_list_append(&msrp->attributes, &a->link); avb_mrp_attribute_add_listener(attr, &a->listener, &mrp_attr_events, a); - return &a->attr; + return 0; } static void msrp_event(void *data, uint64_t now, uint8_t event) @@ -375,15 +391,15 @@ static void msrp_event(void *data, uint64_t now, uint8_t event) p->version = AVB_MRP_PROTOCOL_VERSION; spa_list_for_each(a, &msrp->attributes, link) { - if (!a->attr.mrp->pending_send) + if (!a->attr->mrp->pending_send) continue; - if (dispatch[a->attr.type].encode == NULL) + if (dispatch[a->attr->type].encode == NULL) continue; - pw_log_debug("send %s %s", dispatch[a->attr.type].name, - avb_mrp_send_name(a->attr.mrp->pending_send)); + pw_log_debug("send %s %s", dispatch[a->attr->type].name, + avb_mrp_send_name(a->attr->mrp->pending_send)); - len = dispatch[a->attr.type].encode(msrp, a, msg); + len = dispatch[a->attr->type].encode(msrp, a, msg); if (len < 0) break; @@ -404,6 +420,7 @@ static const struct avb_mrp_events mrp_events = { .event = msrp_event, }; + struct avb_msrp *avb_msrp_register(struct server *server) { struct msrp *msrp; diff --git a/src/modules/module-avb/msrp.h b/src/modules/module-avb/msrp.h index 932fb9b40..5313bce2c 100644 --- a/src/modules/module-avb/msrp.h +++ b/src/modules/module-avb/msrp.h @@ -106,7 +106,7 @@ struct avb_msrp_attribute { struct avb_msrp; -struct avb_msrp_attribute *avb_msrp_attribute_new(struct avb_msrp *msrp, +int avb_msrp_attribute_new(struct avb_msrp *m, struct avb_msrp_attribute *attr, uint8_t type); struct avb_msrp *avb_msrp_register(struct server *server); diff --git a/src/modules/module-avb/mvrp.c b/src/modules/module-avb/mvrp.c index e2e501a9e..e9343767a 100644 --- a/src/modules/module-avb/mvrp.c +++ b/src/modules/module-avb/mvrp.c @@ -13,7 +13,7 @@ static const uint8_t mvrp_mac[6] = AVB_MVRP_MAC; struct attr { - struct avb_mvrp_attribute attr; + struct avb_mvrp_attribute *attr; struct spa_hook listener; struct spa_list link; struct mvrp *mvrp; @@ -47,8 +47,8 @@ static int mvrp_attr_event(void *data, uint64_t now, uint8_t attribute_type, uin struct mvrp *mvrp = data; struct attr *a; spa_list_for_each(a, &mvrp->attributes, link) - if (a->attr.type == attribute_type) - avb_mrp_attribute_rx_event(a->attr.mrp, now, event); + if (a->attr->type == attribute_type) + avb_mrp_attribute_rx_event(a->attr->mrp, now, event); return 0; } @@ -81,10 +81,10 @@ static int encode_vid(struct mvrp *mvrp, struct attr *a, void *m) AVB_MRP_VECTOR_SET_NUM_VALUES(v, 1); d = (struct avb_packet_mvrp_vid *)v->first_value; - *d = a->attr.attr.vid; + *d = a->attr->attr.vid; ev = SPA_PTROFF(d, sizeof(*d), uint8_t); - *ev = (a->attr.mrp->pending_send - 1) * 36; + *ev = (a->attr->mrp->pending_send - 1) * 36; f = SPA_PTROFF(ev, sizeof(*ev), struct avb_packet_mrp_footer); f->end_mark = 0; @@ -95,7 +95,7 @@ static int encode_vid(struct mvrp *mvrp, struct attr *a, void *m) static void notify_vid(struct mvrp *mvrp, uint64_t now, struct attr *attr, uint8_t notify) { pw_log_info("> notify vid: %s", avb_mrp_notify_name(notify)); - debug_vid(&attr->attr.attr.vid); + debug_vid(&attr->attr->attr.vid); } static const struct { @@ -171,8 +171,9 @@ static void mvrp_notify(void *data, uint64_t now, uint8_t notify) { struct attr *a = data; struct mvrp *mvrp = a->mvrp; - if (dispatch[a->attr.type].notify) - dispatch[a->attr.type].notify(mvrp, now, a, notify); + + if (dispatch[a->attr->type].notify) + dispatch[a->attr->type].notify(mvrp, now, a, notify); } static const struct avb_mrp_attribute_events mrp_attr_events = { @@ -180,23 +181,28 @@ static const struct avb_mrp_attribute_events mrp_attr_events = { .notify = mvrp_notify, }; -struct avb_mvrp_attribute *avb_mvrp_attribute_new(struct avb_mvrp *m, - uint8_t type) +int avb_mvrp_attribute_new(struct avb_mvrp *m, + struct avb_mvrp_attribute *mvrp_attr, uint8_t type) { struct mvrp *mvrp = (struct mvrp*)m; struct avb_mrp_attribute *attr; struct attr *a; attr = avb_mrp_attribute_new(mvrp->server->mrp, sizeof(struct attr)); + if (!attr) { + pw_log_error("MVRP attribute allocation failed"); + return -1; + } a = attr->user_data; - a->attr.mrp = attr; - a->attr.type = type; + a->attr = mvrp_attr; + a->attr->mrp = attr; + a->attr->type = type; attr->name = "MVRP"; spa_list_append(&mvrp->attributes, &a->link); avb_mrp_attribute_add_listener(attr, &a->listener, &mrp_attr_events, a); - return &a->attr; + return 0; } static void mvrp_event(void *data, uint64_t now, uint8_t event) @@ -213,15 +219,15 @@ static void mvrp_event(void *data, uint64_t now, uint8_t event) p->version = AVB_MRP_PROTOCOL_VERSION; spa_list_for_each(a, &mvrp->attributes, link) { - if (!a->attr.mrp->pending_send) + if (!a->attr->mrp->pending_send) continue; - if (dispatch[a->attr.type].encode == NULL) + if (dispatch[a->attr->type].encode == NULL) continue; - pw_log_debug("send %s %s", dispatch[a->attr.type].name, - avb_mrp_send_name(a->attr.mrp->pending_send)); + pw_log_debug("send %s %s", dispatch[a->attr->type].name, + avb_mrp_send_name(a->attr->mrp->pending_send)); - len = dispatch[a->attr.type].encode(mvrp, a, msg); + len = dispatch[a->attr->type].encode(mvrp, a, msg); if (len < 0) break; diff --git a/src/modules/module-avb/mvrp.h b/src/modules/module-avb/mvrp.h index cc6ea964e..57f83a367 100644 --- a/src/modules/module-avb/mvrp.h +++ b/src/modules/module-avb/mvrp.h @@ -34,8 +34,8 @@ struct avb_mvrp_attribute { } attr; }; -struct avb_mvrp_attribute *avb_mvrp_attribute_new(struct avb_mvrp *mvrp, - uint8_t type); +int avb_mvrp_attribute_new(struct avb_mvrp *mvrp, + struct avb_mvrp_attribute *attr, uint8_t type); struct avb_mvrp *avb_mvrp_register(struct server *server); diff --git a/src/modules/module-avb/stream.c b/src/modules/module-avb/stream.c index 0d77076ac..5191c3bfb 100644 --- a/src/modules/module-avb/stream.c +++ b/src/modules/module-avb/stream.c @@ -240,18 +240,13 @@ static const struct pw_stream_events sink_stream_events = { struct stream *server_create_stream(struct server *server, struct stream *stream, enum spa_direction direction, uint16_t index) { + struct stream_common *common = (struct stream_common *)stream; uint32_t n_params; const struct spa_pod *params[1]; uint8_t buffer[1024]; struct spa_pod_builder b; int res; - struct stream_common *common; - struct avb_msrp_attribute *stream_attr; - - - common = SPA_CONTAINER_OF(stream, struct stream_common, stream); - stream->server = server; stream->direction = direction; stream->prio = AVB_MSRP_PRIORITY_DEFAULT; @@ -324,29 +319,38 @@ struct stream *server_create_stream(struct server *server, struct stream *stream setup_pdu(stream); setup_msg(stream); - if (direction == SPA_DIRECTION_INPUT) { - stream_attr = avb_msrp_attribute_new(server->msrp, - AVB_MSRP_ATTRIBUTE_TYPE_LISTENER); - } else { - - stream_attr = avb_msrp_attribute_new(server->msrp, - AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); - - stream_attr->attr.talker.vlan_id = htons(stream->vlan_id); - - stream_attr->attr.talker.tspec_max_frame_size = - htons(32 + stream->frames_per_pdu * stream->stride); - - stream_attr->attr.talker.tspec_max_interval_frames = - htons(AVB_MSRP_TSPEC_MAX_INTERVAL_FRAMES_DEFAULT); - - stream_attr->attr.talker.priority = stream->prio; - stream_attr->attr.talker.rank = AVB_MSRP_RANK_DEFAULT; - stream_attr->attr.talker.accumulated_latency = htonl(95); + res = avb_msrp_attribute_new(server->msrp, &common->lstream_attr, + AVB_MSRP_ATTRIBUTE_TYPE_LISTENER); + if (res) { + goto error_free; } + res = avb_msrp_attribute_new(server->msrp, &common->tastream_attr, + AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); + if (res) { + goto error_free; + } - common->stream_attr = stream_attr; + res = avb_msrp_attribute_new(server->msrp, &common->tfstream_attr, + AVB_MSRP_ATTRIBUTE_TYPE_TALKER_FAILED); + if (res) { + goto error_free; + } + + if (stream->direction == SPA_DIRECTION_OUTPUT) { + struct avb_msrp_attribute *ta = &common->tastream_attr; + + ta->attr.talker.vlan_id = htons(stream->vlan_id); + ta->attr.talker.tspec_max_frame_size = + htons(32 + stream->frames_per_pdu * stream->stride); + + ta->attr.talker.tspec_max_interval_frames = + htons(AVB_MSRP_TSPEC_MAX_INTERVAL_FRAMES_DEFAULT); + + ta->attr.talker.priority = stream->prio; + ta->attr.talker.rank = AVB_MSRP_RANK_DEFAULT; + ta->attr.talker.accumulated_latency = htonl(95); + } spa_list_append(&server->streams, &stream->link); @@ -355,7 +359,7 @@ error_free_stream: pw_stream_destroy(stream->stream); errno = -res; error_free: - free(stream); + free(stream->buffer_data); return NULL; } @@ -364,7 +368,9 @@ void stream_destroy(struct stream *stream) struct stream_common *common; common = SPA_CONTAINER_OF(stream, struct stream_common, stream); - avb_mrp_attribute_destroy(common->stream_attr->mrp); + avb_mrp_attribute_destroy(common->lstream_attr.mrp); + avb_mrp_attribute_destroy(common->tastream_attr.mrp); + avb_mrp_attribute_destroy(common->tfstream_attr.mrp); } static int setup_socket(struct stream *stream) @@ -454,23 +460,31 @@ int stream_activate(struct stream *stream, uint16_t index, uint64_t now) } if (stream->direction == SPA_DIRECTION_INPUT) { - common->stream_attr->attr.listener.stream_id = htobe64(stream->peer_id); - common->stream_attr->param = AVB_MSRP_LISTENER_PARAM_READY; - avb_mrp_attribute_begin(common->stream_attr->mrp, now); - avb_mrp_attribute_join(common->stream_attr->mrp, now, true); + struct aecp_aem_stream_input_state *input_stream; + input_stream = SPA_CONTAINER_OF(common, struct aecp_aem_stream_input_state, common); + + common->lstream_attr.attr.listener.stream_id = htobe64(stream->peer_id); + common->lstream_attr.param = AVB_MSRP_LISTENER_PARAM_READY; + avb_mrp_attribute_begin(common->lstream_attr.mrp, now); + avb_mrp_attribute_join(common->lstream_attr.mrp, now, true); + + input_stream->mvrp_attr.attr.vid.vlan = htons(stream->vlan_id); + avb_mrp_attribute_begin(input_stream->mvrp_attr.mrp, now); + avb_mrp_attribute_join(input_stream->mvrp_attr.mrp, now, true); + } else { if ((res = avb_maap_get_address(server->maap, stream->addr, index)) < 0) return res; - common->stream_attr->attr.talker.stream_id = htobe64(stream->id); - memcpy(common->stream_attr->attr.talker.dest_addr, stream->addr, 6); + common->tastream_attr.attr.talker.stream_id = htobe64(stream->id); + memcpy(common->tastream_attr.attr.talker.dest_addr, stream->addr, 6); stream->sock_addr.sll_halen = ETH_ALEN; memcpy(&stream->sock_addr.sll_addr, stream->addr, ETH_ALEN); memcpy(h->dest, stream->addr, 6); memcpy(h->src, server->mac_addr, 6); - avb_mrp_attribute_begin(common->stream_attr->mrp, now); - avb_mrp_attribute_join(common->stream_attr->mrp, now, true); + avb_mrp_attribute_begin(common->tastream_attr.mrp, now); + avb_mrp_attribute_join(common->tastream_attr.mrp, now, true); } pw_stream_set_active(stream->stream, true); @@ -493,7 +507,9 @@ int stream_deactivate(struct stream *stream, uint64_t now) avb_mrp_attribute_leave(stream->vlan_attr->mrp, now); #endif // - avb_mrp_attribute_leave(common->stream_attr->mrp, now); + avb_mrp_attribute_leave(common->lstream_attr.mrp, now); + avb_mrp_attribute_leave(common->tastream_attr.mrp, now); + avb_mrp_attribute_leave(common->tfstream_attr.mrp, now); return 0; } diff --git a/src/tools/meson.build b/src/tools/meson.build index a9a112aa0..0d2d726bf 100644 --- a/src/tools/meson.build +++ b/src/tools/meson.build @@ -115,6 +115,9 @@ if build_avb_virtual '../modules/module-avb/avb.c', '../modules/module-avb/adp.c', '../modules/module-avb/acmp.c', + '../modules/module-avb/acmp-cmds-resps/acmp-common.c', + '../modules/module-avb/acmp-cmds-resps/acmp-legacy-avb.c', + '../modules/module-avb/acmp-cmds-resps/acmp-milan-v12.c', '../modules/module-avb/aecp.c', '../modules/module-avb/aecp-aem.c', '../modules/module-avb/aecp-aem-cmds-resps/cmd-available.c', @@ -127,6 +130,7 @@ if build_avb_virtual '../modules/module-avb/aecp-aem-cmds-resps/cmd-get-set-stream-format.c', '../modules/module-avb/aecp-aem-cmds-resps/cmd-lock-entity.c', '../modules/module-avb/aecp-aem-cmds-resps/cmd-get-set-configuration.c', + '../modules/module-avb/aecp-aem-cmds-resps/cmd-get-dynamic-info.c', '../modules/module-avb/aecp-aem-cmds-resps/reply-unsol-helpers.c', '../modules/module-avb/es-builder.c', '../modules/module-avb/avdecc.c', diff --git a/src/tools/pw-avb-virtual.c b/src/tools/pw-avb-virtual.c index 6b123949e..1cf3b6ab5 100644 --- a/src/tools/pw-avb-virtual.c +++ b/src/tools/pw-avb-virtual.c @@ -112,7 +112,8 @@ static struct server *create_virtual_server(struct data *data) avb_adp_register(server); avb_acmp_register(server); - server->domain_attr = avb_msrp_attribute_new(server->msrp, + server->domain_attr = calloc(1, sizeof(*server->domain_attr)); + avb_msrp_attribute_new(server->msrp, server->domain_attr, AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN); server->domain_attr->attr.domain.sr_class_id = AVB_MSRP_CLASS_ID_DEFAULT; server->domain_attr->attr.domain.sr_class_priority = AVB_MSRP_PRIORITY_DEFAULT; diff --git a/test/meson.build b/test/meson.build index de67ca70b..0a89db81a 100644 --- a/test/meson.build +++ b/test/meson.build @@ -170,6 +170,9 @@ if build_avb_virtual '../src/modules/module-avb/avb.c', '../src/modules/module-avb/adp.c', '../src/modules/module-avb/acmp.c', + '../src/modules/module-avb/acmp-cmds-resps/acmp-common.c', + '../src/modules/module-avb/acmp-cmds-resps/acmp-legacy-avb.c', + '../src/modules/module-avb/acmp-cmds-resps/acmp-milan-v12.c', '../src/modules/module-avb/aecp.c', '../src/modules/module-avb/aecp-aem.c', '../src/modules/module-avb/aecp-aem-cmds-resps/cmd-available.c', @@ -182,6 +185,7 @@ if build_avb_virtual '../src/modules/module-avb/aecp-aem-cmds-resps/cmd-get-set-stream-format.c', '../src/modules/module-avb/aecp-aem-cmds-resps/cmd-lock-entity.c', '../src/modules/module-avb/aecp-aem-cmds-resps/cmd-get-set-configuration.c', + '../src/modules/module-avb/aecp-aem-cmds-resps/cmd-get-dynamic-info.c', '../src/modules/module-avb/aecp-aem-cmds-resps/reply-unsol-helpers.c', '../src/modules/module-avb/es-builder.c', '../src/modules/module-avb/avdecc.c', diff --git a/test/test-avb-utils.h b/test/test-avb-utils.h index d4552f985..3268b7c4e 100644 --- a/test/test-avb-utils.h +++ b/test/test-avb-utils.h @@ -68,7 +68,8 @@ static inline struct server *avb_test_server_new(struct impl *impl) avb_adp_register(server); avb_acmp_register(server); - server->domain_attr = avb_msrp_attribute_new(server->msrp, + server->domain_attr = calloc(1, sizeof(*server->domain_attr)); + avb_msrp_attribute_new(server->msrp, server->domain_attr, AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN); server->domain_attr->attr.domain.sr_class_id = AVB_MSRP_CLASS_ID_DEFAULT; server->domain_attr->attr.domain.sr_class_priority = AVB_MSRP_PRIORITY_DEFAULT; @@ -313,7 +314,8 @@ static inline struct server *avb_test_server_new_milan(struct impl *impl) avb_adp_register(server); avb_acmp_register(server); - server->domain_attr = avb_msrp_attribute_new(server->msrp, + server->domain_attr = calloc(1, sizeof(*server->domain_attr)); + avb_msrp_attribute_new(server->msrp, server->domain_attr, AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN); server->domain_attr->attr.domain.sr_class_id = AVB_MSRP_CLASS_ID_DEFAULT; server->domain_attr->attr.domain.sr_class_priority = AVB_MSRP_PRIORITY_DEFAULT; diff --git a/test/test-avb.c b/test/test-avb.c index ac1966a68..26ff337fc 100644 --- a/test/test-avb.c +++ b/test/test-avb.c @@ -217,7 +217,8 @@ PWTEST(avb_mrp_attribute_lifecycle) pwtest_ptr_notnull(server); /* Create an MSRP talker attribute */ - attr = avb_msrp_attribute_new(server->msrp, + attr = calloc(1, sizeof(*attr)); + avb_msrp_attribute_new(server->msrp, attr, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); pwtest_ptr_notnull(attr); pwtest_ptr_notnull(attr->mrp); @@ -271,7 +272,8 @@ PWTEST(avb_milan_server_create) avb_adp_register(server); avb_acmp_register(server); - server->domain_attr = avb_msrp_attribute_new(server->msrp, + server->domain_attr = calloc(1, sizeof(*server->domain_attr)); + avb_msrp_attribute_new(server->msrp, server->domain_attr, AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN); server->domain_attr->attr.domain.sr_class_id = AVB_MSRP_CLASS_ID_DEFAULT; server->domain_attr->attr.domain.sr_class_priority = AVB_MSRP_PRIORITY_DEFAULT; @@ -323,7 +325,8 @@ PWTEST(avb_mrp_begin_join_new_tx) pwtest_ptr_notnull(server); /* Create a talker attribute */ - attr = avb_msrp_attribute_new(server->msrp, + attr = calloc(1, sizeof(*attr)); + avb_msrp_attribute_new(server->msrp, attr, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); pwtest_ptr_notnull(attr); @@ -364,7 +367,8 @@ PWTEST(avb_mrp_join_leave_cycle) server = avb_test_server_new(impl); pwtest_ptr_notnull(server); - attr = avb_msrp_attribute_new(server->msrp, + attr = calloc(1, sizeof(*attr)); + avb_msrp_attribute_new(server->msrp, attr, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); pwtest_ptr_notnull(attr); @@ -440,7 +444,8 @@ PWTEST(avb_mrp_rx_new_notification) /* Register a global MRP listener to track notifications */ avb_mrp_add_listener(server->mrp, &listener, &test_mrp_events, &tracker); - attr = avb_msrp_attribute_new(server->msrp, + attr = calloc(1, sizeof(*attr)); + avb_msrp_attribute_new(server->msrp, attr, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); pwtest_ptr_notnull(attr); @@ -486,7 +491,8 @@ PWTEST(avb_mrp_registrar_leave_timer) avb_mrp_add_listener(server->mrp, &listener, &test_mrp_events, &tracker); - attr = avb_msrp_attribute_new(server->msrp, + attr = calloc(1, sizeof(*attr)); + avb_msrp_attribute_new(server->msrp, attr, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); avb_mrp_attribute_begin(attr->mrp, 0); avb_mrp_attribute_join(attr->mrp, 0, true); @@ -527,9 +533,11 @@ PWTEST(avb_mrp_multiple_attributes) server = avb_test_server_new(impl); pwtest_ptr_notnull(server); - attr1 = avb_msrp_attribute_new(server->msrp, + attr1 = calloc(1, sizeof(*attr1)); + avb_msrp_attribute_new(server->msrp, attr1, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); - attr2 = avb_msrp_attribute_new(server->msrp, + attr2 = calloc(1, sizeof(*attr2)); + avb_msrp_attribute_new(server->msrp, attr2, AVB_MSRP_ATTRIBUTE_TYPE_LISTENER); pwtest_ptr_notnull(attr1); pwtest_ptr_notnull(attr2); @@ -570,22 +578,26 @@ PWTEST(avb_msrp_attribute_types) pwtest_ptr_notnull(server); /* Create all four MSRP attribute types */ - talker = avb_msrp_attribute_new(server->msrp, + talker = calloc(1, sizeof(*talker)); + avb_msrp_attribute_new(server->msrp, talker, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); pwtest_ptr_notnull(talker); pwtest_int_eq(talker->type, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); - talker_fail = avb_msrp_attribute_new(server->msrp, + talker_fail = calloc(1, sizeof(*talker_fail)); + avb_msrp_attribute_new(server->msrp, talker_fail, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_FAILED); pwtest_ptr_notnull(talker_fail); pwtest_int_eq(talker_fail->type, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_FAILED); - listener_attr = avb_msrp_attribute_new(server->msrp, + listener_attr = calloc(1, sizeof(*listener_attr)); + avb_msrp_attribute_new(server->msrp, listener_attr, AVB_MSRP_ATTRIBUTE_TYPE_LISTENER); pwtest_ptr_notnull(listener_attr); pwtest_int_eq(listener_attr->type, AVB_MSRP_ATTRIBUTE_TYPE_LISTENER); - domain = avb_msrp_attribute_new(server->msrp, + domain = calloc(1, sizeof(*domain)); + avb_msrp_attribute_new(server->msrp, domain, AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN); pwtest_ptr_notnull(domain); pwtest_int_eq(domain->type, AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN); @@ -638,7 +650,8 @@ PWTEST(avb_msrp_domain_transmit) /* The test server already has a domain_attr, but create another * to test independent domain attribute behavior */ - domain = avb_msrp_attribute_new(server->msrp, + domain = calloc(1, sizeof(*domain)); + avb_msrp_attribute_new(server->msrp, domain, AVB_MSRP_ATTRIBUTE_TYPE_DOMAIN); domain->attr.domain.sr_class_id = 7; domain->attr.domain.sr_class_priority = 2; @@ -675,7 +688,8 @@ PWTEST(avb_msrp_talker_transmit) server = avb_test_server_new(impl); pwtest_ptr_notnull(server); - talker = avb_msrp_attribute_new(server->msrp, + talker = calloc(1, sizeof(*talker)); + avb_msrp_attribute_new(server->msrp, talker, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); pwtest_ptr_notnull(talker); @@ -1012,7 +1026,8 @@ PWTEST(avb_msrp_talker_failed_notify) server = avb_test_server_new(impl); pwtest_ptr_notnull(server); - talker_fail = avb_msrp_attribute_new(server->msrp, + talker_fail = calloc(1, sizeof(*talker_fail)); + avb_msrp_attribute_new(server->msrp, talker_fail, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_FAILED); pwtest_ptr_notnull(talker_fail); @@ -2584,7 +2599,8 @@ PWTEST(avb_mrp_leave_all_timer) avb_mrp_add_listener(server->mrp, &listener, &test_mrp_events, &tracker); /* Create and join an attribute */ - attr = avb_msrp_attribute_new(server->msrp, + attr = calloc(1, sizeof(*attr)); + avb_msrp_attribute_new(server->msrp, attr, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); pwtest_ptr_notnull(attr); @@ -2630,7 +2646,8 @@ PWTEST(avb_mrp_periodic_timer) server = avb_test_server_new(impl); pwtest_ptr_notnull(server); - attr = avb_msrp_attribute_new(server->msrp, + attr = calloc(1, sizeof(*attr)); + avb_msrp_attribute_new(server->msrp, attr, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_ADVERTISE); avb_mrp_attribute_begin(attr->mrp, 0); avb_mrp_attribute_join(attr->mrp, 0, true); @@ -2674,7 +2691,8 @@ PWTEST(avb_msrp_talker_failed_process) /* Create a talker-failed attribute that matches the stream_id * we'll send in the MSRP packet. This ensures process_talker_fail() * finds a matching attribute and calls avb_mrp_attribute_rx_event(). */ - talker_fail = avb_msrp_attribute_new(server->msrp, + talker_fail = calloc(1, sizeof(*talker_fail)); + avb_msrp_attribute_new(server->msrp, talker_fail, AVB_MSRP_ATTRIBUTE_TYPE_TALKER_FAILED); pwtest_ptr_notnull(talker_fail); @@ -2780,7 +2798,8 @@ PWTEST(avb_mvrp_attribute_lifecycle) server = avb_test_server_new(impl); pwtest_ptr_notnull(server); - vid = avb_mvrp_attribute_new(server->mvrp, + vid = calloc(1, sizeof(*vid)); + avb_mvrp_attribute_new(server->mvrp, vid, AVB_MVRP_ATTRIBUTE_TYPE_VID); pwtest_ptr_notnull(vid); pwtest_int_eq(vid->type, AVB_MVRP_ATTRIBUTE_TYPE_VID); @@ -2816,7 +2835,8 @@ PWTEST(avb_mvrp_vid_transmit) server = avb_test_server_new(impl); pwtest_ptr_notnull(server); - vid = avb_mvrp_attribute_new(server->mvrp, + vid = calloc(1, sizeof(*vid)); + avb_mvrp_attribute_new(server->mvrp, vid, AVB_MVRP_ATTRIBUTE_TYPE_VID); pwtest_ptr_notnull(vid);