summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2006-02-10 12:05:33 +0000
committerPierre Ossman <ossman@cendio.se>2006-02-10 12:05:33 +0000
commit4ab432a81952b5ef608775522d27ad9709b97307 (patch)
tree8e9f5f3f59047beb5f95efbc1bc336632db20162
parent8d91ffe4b42d460efff32c36edc51ee01f3af442 (diff)
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
-rw-r--r--polyp/tagstruct.c11
1 files 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;