Fix free QSound ADPCM space calculation (#826)

This commit is contained in:
cam900 2023-01-14 04:10:33 +09:00 committed by GitHub
parent b4f3deeb18
commit ab532cca84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -707,11 +707,11 @@ const void* DivPlatformQSound::getSampleMem(int index) {
} }
size_t DivPlatformQSound::getSampleMemCapacity(int index) { size_t DivPlatformQSound::getSampleMemCapacity(int index) {
return (index == 0 || index == 1) ? 16777216 : 0; return index == 0 ? 16777216 : index == 1 ? (16777216 - sampleMemUsage) : 0;
} }
size_t DivPlatformQSound::getSampleMemUsage(int index) { size_t DivPlatformQSound::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : index == 1 ? sampleMemLenBS : 0; return index == 0 ? sampleMemLen : index == 1 ? (sampleMemLenBS - sampleMemUsage) : 0;
} }
bool DivPlatformQSound::isSampleLoaded(int index, int sample) { bool DivPlatformQSound::isSampleLoaded(int index, int sample) {
@ -766,6 +766,7 @@ void DivPlatformQSound::renderSamples(int sysID) {
sampleMemLen=memPos+256; sampleMemLen=memPos+256;
memPos=(memPos+0xffff)&0xff0000; memPos=(memPos+0xffff)&0xff0000;
sampleMemUsage=memPos;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
@ -818,6 +819,7 @@ int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, const DivCo
sampleMem=new unsigned char[getSampleMemCapacity()]; sampleMem=new unsigned char[getSampleMemCapacity()];
sampleMemLen=0; sampleMemLen=0;
sampleMemLenBS=0; sampleMemLenBS=0;
sampleMemUsage=0;
chip.rom_data=sampleMem; chip.rom_data=sampleMem;
chip.rom_mask=0xffffff; chip.rom_mask=0xffffff;
reset(); reset();

View file

@ -50,6 +50,7 @@ class DivPlatformQSound: public DivDispatch {
unsigned char* sampleMem; unsigned char* sampleMem;
size_t sampleMemLen; size_t sampleMemLen;
size_t sampleMemLenBS; size_t sampleMemLenBS;
size_t sampleMemUsage;
bool sampleLoaded[256]; bool sampleLoaded[256];
bool sampleLoadedBS[256]; bool sampleLoadedBS[256];
struct qsound_chip chip; struct qsound_chip chip;