]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aseqdump: Refactor UMP SysEx dump
authorTakashi Iwai <tiwai@suse.de>
Thu, 27 Jun 2024 11:24:11 +0000 (13:24 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 27 Jun 2024 11:24:11 +0000 (13:24 +0200)
A slightly better version.  The extraction of a SysEx byte from a UMP
packet is more complicated than wished, in anyway.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
seq/aseqdump/aseqdump.c

index e1aea4cd4de63baf71b196e382b072504f2282df..b8137112d8368c5e39726a0894eeea55e47c824a 100644 (file)
@@ -668,9 +668,16 @@ static void dump_ump_system_event(const unsigned int *ump)
        }
 }
 
+static unsigned char ump_sysex7_data(const unsigned int *ump,
+                                    unsigned int offset)
+{
+       offset += 2;
+       return (ump[offset / 4] >> ((3 - (offset & 3)) * 8)) & 0xff;
+}
+
 static void dump_ump_sysex_event(const unsigned int *ump)
 {
-       int i, offset, length;
+       int i, length;
 
        printf("Group %2d, ", group_number(snd_ump_msg_group(ump)));
        switch (snd_ump_sysex_msg_status(ump)) {
@@ -693,18 +700,8 @@ static void dump_ump_sysex_event(const unsigned int *ump)
 
        length = snd_ump_sysex_msg_length(ump);
        printf(" length %d ", length);
-       offset = 24;
-       for (i = 0; i < length; i++) {
-               if (i)
-                       printf(":");
-               printf("%02x", (*ump >> (32 - offset)) & 0x7f);
-               if (offset < 32) {
-                       offset += 8;
-               } else {
-                       ump++;
-                       offset = 8;
-               }
-       }
+       for (i = 0; i < length; i++)
+               printf("%s%02x", i ? ":" : "", ump_sysex7_data(ump, i));
        printf("\n");
 }