From b1f7df52e3f97d69e49a0fd4247b04f594a1938a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 15 Mar 2017 17:09:28 +0100 Subject: [PATCH] format: use padding attribute --- spa/include/spa/format-builder.h | 4 ++-- spa/include/spa/format.h | 8 +++----- spa/tests/test-props.c | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/spa/include/spa/format-builder.h b/spa/include/spa/format-builder.h index 748f9e49f..651b69afb 100644 --- a/spa/include/spa/format-builder.h +++ b/spa/include/spa/format-builder.h @@ -37,8 +37,8 @@ spa_pod_builder_push_format (SpaPODBuilder *builder, { const SpaFormat p = { { sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT }, { { 0, 0 }, - { { sizeof (uint32_t), SPA_POD_TYPE_INT }, media_type }, 0, - { { sizeof (uint32_t), SPA_POD_TYPE_INT }, media_subtype }, 0 } }; + { { sizeof (uint32_t), SPA_POD_TYPE_INT }, media_type }, + { { sizeof (uint32_t), SPA_POD_TYPE_INT }, media_subtype } } }; return spa_pod_builder_push (builder, frame, &p.pod, spa_pod_builder_raw (builder, &p, sizeof(p))); } diff --git a/spa/include/spa/format.h b/spa/include/spa/format.h index 659c94880..e2d3f0fbc 100644 --- a/spa/include/spa/format.h +++ b/spa/include/spa/format.h @@ -91,10 +91,8 @@ typedef enum { typedef struct { SpaPODObjectBody obj_body; - SpaPODInt media_type; - uint32_t pad1; - SpaPODInt media_subtype; - uint32_t pad2; + SpaPODInt media_type SPA_ALIGNED (8); + SpaPODInt media_subtype SPA_ALIGNED (8); /* contents follow, series of SpaPODProp */ } SpaFormatBody; @@ -120,7 +118,7 @@ struct _SpaFormat { static inline SpaPODProp * spa_format_find_prop (const SpaFormat *format, uint32_t key) { - return spa_pod_contents_find_prop (&format->pod, sizeof (SpaFormat), key); + return spa_pod_contents_find_prop (&format->pod, SPA_ROUND_UP_N (sizeof (SpaFormat), 8), key); } static inline SpaResult diff --git a/spa/tests/test-props.c b/spa/tests/test-props.c index 23df751b8..50f0bcb10 100644 --- a/spa/tests/test-props.c +++ b/spa/tests/test-props.c @@ -88,8 +88,8 @@ static const struct _test_format { } test_format = { { { sizeof (test_format.props) + sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT }, { { 0, 0 }, - { { sizeof (uint32_t), SPA_POD_TYPE_INT }, SPA_MEDIA_TYPE_VIDEO }, 0, - { { sizeof (uint32_t), SPA_POD_TYPE_INT }, SPA_MEDIA_SUBTYPE_RAW }, 0 }, + { { sizeof (uint32_t), SPA_POD_TYPE_INT }, SPA_MEDIA_TYPE_VIDEO }, + { { sizeof (uint32_t), SPA_POD_TYPE_INT }, SPA_MEDIA_SUBTYPE_RAW } }, }, { { { sizeof (test_format.props.format_vals) + sizeof (SpaPODPropBody), SPA_POD_TYPE_PROP } ,