Each preset can have a different level meter setting (FS samples for OVR, release rate, minimum level and so on).
These settings were not saved/restore to/from the on-disk file. This patch adds the missing functionality.
Unfortunately, the current on-disk format is a 1:1 binary dump from memory without any header information. In other words, this commit will break backward compatibility with older hdspmixers, that is, new preset files cannot be read by older versions of hdspmixer. However, we can still read the old mix files and save them in the new format.
I hence bumped the version, so users know to re-create their files after upgrading to 1.11.
Bug discovered by Raphaƫl Doursenaud from ematech.fr.
Signed-off-by: Adrian Knoth adi@drcomp.erfurt.thur.de
diff --git a/hdspmixer/configure.in b/hdspmixer/configure.in index 1b43bc9..e47a97d 100644 --- a/hdspmixer/configure.in +++ b/hdspmixer/configure.in @@ -1,5 +1,5 @@ AC_INIT(src/hdspmixer.cxx) -AM_INIT_AUTOMAKE(hdspmixer, 1.10) +AM_INIT_AUTOMAKE(hdspmixer, 1.11)
AC_PROG_CXX AC_PROG_MAKE_SET diff --git a/hdspmixer/src/HDSPMixerWindow.cxx b/hdspmixer/src/HDSPMixerWindow.cxx index 364d727..960ec0f 100644 --- a/hdspmixer/src/HDSPMixerWindow.cxx +++ b/hdspmixer/src/HDSPMixerWindow.cxx @@ -25,6 +25,9 @@ #pragma implementation #include "HDSPMixerWindow.h"
+/* header used in .mix file */ +const char header[] = "HDSPMixer v1"; + static void readregisters_cb(void *arg) { int err; @@ -341,6 +344,13 @@ void HDSPMixerWindow::save() if (dirty) { inputs->buttons->presets->save_preset(current_preset+1); } + /* since hdspmixer 1.11, we also store the meter level settings. Indicate + * the new on-disk structure via a small header */ + if (fwrite((void *)&header, sizeof(char), sizeof(header), file) != + sizeof(header)) { + goto save_error; + } + for (int speed = 0; speed < 3; ++speed) { for (int card = 0; card < MAX_CARDS; ++card) { for (int preset = 0; preset < 8; ++preset) { @@ -414,6 +424,24 @@ void HDSPMixerWindow::save() if (fwrite((void *)&(data[card][speed][preset]->mute), sizeof(int), 1, file) != 1) { goto save_error; } + if (fwrite((void *)&(data[card][speed][preset]->last_destination), sizeof(int), 1, file) != 1) { + goto save_error; + } + if (fwrite((void *)&(data[card][speed][preset]->rmsplus3), sizeof(int), 1, file) != 1) { + goto save_error; + } + if (fwrite((void *)&(data[card][speed][preset]->numbers), sizeof(int), 1, file) != 1) { + goto save_error; + } + if (fwrite((void *)&(data[card][speed][preset]->over), sizeof(int), 1, file) != 1) { + goto save_error; + } + if (fwrite((void *)&(data[card][speed][preset]->level), sizeof(int), 1, file) != 1) { + goto save_error; + } + if (fwrite((void *)&(data[card][speed][preset]->rate), sizeof(int), 1, file) != 1) { + goto save_error; + } } } } @@ -437,6 +465,21 @@ void HDSPMixerWindow::load() inputs->buttons->presets->preset_change(1); return; } + + /* check for new ondisk format */ + char buffer[sizeof(header)]; + bool ondisk_v1 = false; + if (fread(&buffer, sizeof(char), sizeof(buffer), file) != sizeof(buffer)) { + goto load_error; + } + if (0 == strncmp(buffer, header, sizeof(buffer))) { + /* new ondisk format found */ + ondisk_v1 = true; + } else { + /* old format, rewind to the start and simply read all data */ + rewind(file); + } + for (int speed = 0; speed < 3; ++speed) { for (int card = 0; card < MAX_CARDS; ++card) { for (int preset = 0; preset < 8; ++preset) { @@ -510,6 +553,27 @@ void HDSPMixerWindow::load() if (fread((void *)&(data[card][speed][preset]->mute), sizeof(int), 1, file) != 1) { goto load_error; } + /* read additional meter settings only present in newer mix files */ + if (ondisk_v1) { + if (fread((void *)&(data[card][speed][preset]->last_destination), sizeof(int), 1, file) != 1) { + goto load_error; + } + if (fread((void *)&(data[card][speed][preset]->rmsplus3), sizeof(int), 1, file) != 1) { + goto load_error; + } + if (fread((void *)&(data[card][speed][preset]->numbers), sizeof(int), 1, file) != 1) { + goto load_error; + } + if (fread((void *)&(data[card][speed][preset]->over), sizeof(int), 1, file) != 1) { + goto load_error; + } + if (fread((void *)&(data[card][speed][preset]->level), sizeof(int), 1, file) != 1) { + goto load_error; + } + if (fread((void *)&(data[card][speed][preset]->rate), sizeof(int), 1, file) != 1) { + goto load_error; + } + } } } }