[polypaudio-commits] r477 - /trunk/polyp/tagstruct.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Feb 10 04:05:34 PST 2006


Author: ossman
Date: Fri Feb 10 13:05:33 2006
New Revision: 477

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=477&root=polypaudio&view=rev
Log:
Fix some new alignment bugs in the tagstruct handling.

Modified:
    trunk/polyp/tagstruct.c

Modified: trunk/polyp/tagstruct.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/polyp/tagstruct.c?rev=477&root=polypaudio&r1=476&r2=477&view=diff
==============================================================================
--- trunk/polyp/tagstruct.c (original)
+++ trunk/polyp/tagstruct.c Fri Feb 10 13:05:33 2006
@@ -203,6 +203,7 @@
 
 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 @@
     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_cvolume(pa_tagstruct *t, pa_cvolume *cvolume) {
     unsigned i;
+    pa_volume_t vol;
     
     assert(t);
     assert(cvolume);
@@ -449,8 +452,10 @@
     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;




More information about the pulseaudio-commits mailing list