Parallelize SF2 loading (#812)

The loading of SF2 samples can be parallelized as well, at least for bigger soundfonts like the Stgiga 4GB monster.

The following test is performed with hot-caches:

`time src/fluidsynth -i -a alsa Stgiga\'s\ HiDef\ Soundfont\ \(2019-05-25\).sf2`

Serial version:
```
real    0m15,460s
user    0m14,163s
sys     0m1,192s
```

Parallelized version proposed by this PR:
```
real    0m5,851s
user    0m14,089s
sys     0m1,194s
```
This commit is contained in:
Tom M 2021-03-17 19:41:33 +01:00 committed by GitHub
parent ea5ebe4813
commit c32faa7b17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -421,6 +421,8 @@ int fluid_defsfont_load_all_sampledata(fluid_defsfont_t *defsfont, SFData *sfdat
}
}
else
{
#pragma omp task firstprivate(sample, defsfont) default(none)
{
/* Data pointers of SF2 samples point to large sample data block loaded above */
sample->data = defsfont->sampledata;
@ -429,6 +431,7 @@ int fluid_defsfont_load_all_sampledata(fluid_defsfont_t *defsfont, SFData *sfdat
fluid_voice_optimize_sample(sample);
}
}
}
return sample_parsing_result;
}

View file

@ -147,7 +147,7 @@ struct _fluid_sample_t
{
char name[21]; /**< Sample name */
/* The following for sample pointers store the original pointers from the Soundfont
/* The following four sample pointers store the original pointers from the Soundfont
* file. They are never changed after loading and are used to re-create the
* actual sample pointers after a sample has been unloaded and loaded again. The
* actual sample pointers get modified during loading for SF3 (compressed) samples