]> git.alsa-project.org Git - alsa-tools.git/commitdiff
hdspmixer: Handle channel count in old (v1.0.23) preset file format
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>
Fri, 8 Apr 2011 17:58:36 +0000 (19:58 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 14 Apr 2011 10:00:52 +0000 (12:00 +0200)
When reading a preset file, v1.0.23 only used 26 channels instead of 64.
Reading 64 channels from a 26 channel file won't work, hence set it
depending on the file format version.

Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
hdspmixer/src/HDSPMixerWindow.cxx

index d6d28e399bcb3efe60c914bf27cce48aaca473ee..fb417214f5accc818016e4640f44cb2f2312a3bb 100644 (file)
@@ -488,6 +488,7 @@ void HDSPMixerWindow::load()
     char buffer[sizeof(header)];
     bool ondisk_v1 = false;
     int pan_array_size = 14; /* old (pre 1.0.24) HDSP_MAX_DEST */
+    int channels_per_card = 26; /* old (pre 1.0.24) HDSP_MAX_CHANNELS */
 
     if (fread(&buffer, sizeof(char), sizeof(buffer), file) != sizeof(buffer)) {
             goto load_error;
@@ -496,6 +497,7 @@ void HDSPMixerWindow::load()
         /* new ondisk format found */
         ondisk_v1 = true;
         pan_array_size = HDSP_MAX_DEST;
+        channels_per_card = HDSP_MAX_CHANNELS;
     } else {
         /* old format, rewind to the start and simply read all data */
         rewind(file);
@@ -504,7 +506,7 @@ void HDSPMixerWindow::load()
     for (int speed = 0; speed < 3; ++speed) {
        for (int card = 0; card < MAX_CARDS; ++card) {
            for (int preset = 0; preset < 8; ++preset) {
-               for (int channel = 0; channel < HDSP_MAX_CHANNELS; ++channel) {
+               for (int channel = 0; channel < channels_per_card; ++channel) {
                    /* inputs pans and volumes */
                    if (fread((void *)&(inputs->strips[channel]->data[card][speed][preset]->pan_pos[0]), sizeof(int), pan_array_size, file) != pan_array_size) {
                        goto load_error;