From 4ab432a81952b5ef608775522d27ad9709b97307 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 10 Feb 2006 12:05:33 +0000 Subject: Fix some new alignment bugs in the tagstruct handling. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@477 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/tagstruct.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/polyp/tagstruct.c b/polyp/tagstruct.c index 64f00e4d..676f67de 100644 --- a/polyp/tagstruct.c +++ b/polyp/tagstruct.c @@ -203,6 +203,7 @@ void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map) { void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume) { unsigned i; + pa_volume_t vol; assert(t); extend(t, 2 + cvolume->channels * sizeof(pa_volume_t)); @@ -211,7 +212,8 @@ void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume) { t->data[t->length++] = cvolume->channels; for (i = 0; i < cvolume->channels; i ++) { - *(pa_volume_t*) (t->data + t->length) = htonl(cvolume->values[i]); + vol = htonl(cvolume->values[i]); + memcpy(t->data + t->length, &vol, sizeof(pa_volume_t)); t->length += sizeof(pa_volume_t); } } @@ -433,6 +435,7 @@ int pa_tagstruct_get_channel_map(pa_tagstruct *t, pa_channel_map *map) { int pa_tagstruct_get_cvolume(pa_tagstruct *t, pa_cvolume *cvolume) { unsigned i; + pa_volume_t vol; assert(t); assert(cvolume); @@ -449,8 +452,10 @@ int pa_tagstruct_get_cvolume(pa_tagstruct *t, pa_cvolume *cvolume) { if (t->rindex+2+cvolume->channels*sizeof(pa_volume_t) > t->length) return -1; - for (i = 0; i < cvolume->channels; i ++) - cvolume->values[i] = (pa_volume_t) ntohl(*((pa_volume_t*) (t->data + t->rindex + 2)+i)); + for (i = 0; i < cvolume->channels; i ++) { + memcpy(&vol, t->data + t->rindex + 2 + i * sizeof(pa_volume_t), sizeof(pa_volume_t)); + cvolume->values[i] = (pa_volume_t) ntohl(vol); + } if (!pa_cvolume_valid(cvolume)) return -1; -- cgit