Don't create presets that don't have any usable sounds

This commit is contained in:
Chris Robinson 2014-01-04 03:20:17 -08:00
parent 2dd87946fd
commit 4834f56779

View File

@ -1185,10 +1185,6 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context)
if(sfont.phdr[i+1].mZoneIdx == sfont.phdr[i].mZoneIdx) if(sfont.phdr[i+1].mZoneIdx == sfont.phdr[i].mZoneIdx)
continue; continue;
presets[presets_size] = NewPreset(context);
presets[presets_size]->Preset = sfont.phdr[i].mPreset;
presets[presets_size]->Bank = sfont.phdr[i].mBank;
GenModList_Construct(&gzone); GenModList_Construct(&gzone);
zone = sfont.pbag + sfont.phdr[i].mZoneIdx; zone = sfont.pbag + sfont.phdr[i].mZoneIdx;
zone_end = sfont.pbag + sfont.phdr[i+1].mZoneIdx; zone_end = sfont.pbag + sfont.phdr[i+1].mZoneIdx;
@ -1252,13 +1248,16 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context)
{ {
ALsizei j; ALsizei j;
presets[presets_size] = NewPreset(context);
presets[presets_size]->Preset = sfont.phdr[i].mPreset;
presets[presets_size]->Bank = sfont.phdr[i].mBank;
for(j = 0;j < sounds_size;j++) for(j = 0;j < sounds_size;j++)
IncrementRef(&sounds[j]->ref); IncrementRef(&sounds[j]->ref);
sounds = ExchangePtr((XchgPtr*)&presets[presets_size]->Sounds, sounds); sounds = ExchangePtr((XchgPtr*)&presets[presets_size]->Sounds, sounds);
ExchangeInt(&presets[presets_size]->NumSounds, sounds_size); ExchangeInt(&presets[presets_size]->NumSounds, sounds_size);
presets_size++;
} }
presets_size++;
free(sounds); free(sounds);
GenModList_Destruct(&gzone); GenModList_Destruct(&gzone);