fix more possible crashes when deleting ins

and added a fatal error if implementation is missing
This commit is contained in:
tildearrow 2023-01-19 00:37:37 -05:00
parent bb4dc21603
commit c1e26ee749
34 changed files with 111 additions and 10 deletions

View file

@ -18,6 +18,7 @@
*/ */
#include "../dispatch.h" #include "../dispatch.h"
#include "../../ta-log.h"
void DivDispatch::acquire(short** buf, size_t len) { void DivDispatch::acquire(short** buf, size_t len) {
} }
@ -121,7 +122,8 @@ void DivDispatch::notifyWaveChange(int ins) {
} }
void DivDispatch::notifyInsDeletion(void* ins) { void DivDispatch::notifyInsDeletion(void* ins) {
logE("notifyInsDeletion NOT implemented!");
abort();
} }
void DivDispatch::notifyPlaybackStop() { void DivDispatch::notifyPlaybackStop() {

View file

@ -800,6 +800,12 @@ void DivPlatformArcade::notifyInsChange(int ins) {
} }
} }
void DivPlatformArcade::notifyInsDeletion(void* ins) {
for (int i=0; i<8; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
void* DivPlatformArcade::getChanState(int ch) { void* DivPlatformArcade::getChanState(int ch) {
return &chan[ch]; return &chan[ch];
} }

View file

@ -76,6 +76,7 @@ class DivPlatformArcade: public DivPlatformOPM {
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
DivMacroInt* getChanMacroInt(int ch); DivMacroInt* getChanMacroInt(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
void setFlags(const DivConfig& flags); void setFlags(const DivConfig& flags);
int getOutputCount(); int getOutputCount();
void setYMFM(bool use); void setYMFM(bool use);

View file

@ -131,6 +131,10 @@ int DivPlatformDummy::dispatch(DivCommand c) {
return 1; return 1;
} }
void DivPlatformDummy::notifyInsDeletion(void* ins) {
// nothing
}
void DivPlatformDummy::reset() { void DivPlatformDummy::reset() {
for (int i=0; i<chans; i++) { for (int i=0; i<chans; i++) {
chan[i]=DivPlatformDummy::Channel(); chan[i]=DivPlatformDummy::Channel();

View file

@ -40,6 +40,7 @@ class DivPlatformDummy: public DivDispatch {
void acquire(short** buf, size_t len); void acquire(short** buf, size_t len);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
int dispatch(DivCommand c); int dispatch(DivCommand c);
void notifyInsDeletion(void* ins);
void* getChanState(int chan); void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan); DivDispatchOscBuffer* getOscBuffer(int chan);
void reset(); void reset();

View file

@ -118,7 +118,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
void toggleRegisterDump(bool enable); void toggleRegisterDump(bool enable);
void setFlags(const DivConfig& flags); void setFlags(const DivConfig& flags);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins); virtual void notifyInsDeletion(void* ins);
void setSoftPCM(bool value); void setSoftPCM(bool value);
int getPortaFloor(int ch); int getPortaFloor(int ch);
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);

View file

@ -746,6 +746,13 @@ void DivPlatformGenesisExt::notifyInsChange(int ins) {
} }
} }
void DivPlatformGenesisExt::notifyInsDeletion(void* ins) {
DivPlatformGenesis::notifyInsDeletion(ins);
for (int i=0; i<4; i++) {
opChan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
int DivPlatformGenesisExt::getPortaFloor(int ch) { int DivPlatformGenesisExt::getPortaFloor(int ch) {
return (ch>8)?12:0; return (ch>8)?12:0;
} }

View file

@ -41,6 +41,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch); bool keyOffAffectsPorta(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
int getPortaFloor(int ch); int getPortaFloor(int ch);
void setCSMChannel(unsigned char ch); void setCSMChannel(unsigned char ch);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View file

@ -353,6 +353,9 @@ void DivPlatformMSM6258::notifyInsChange(int ins) {
} }
void DivPlatformMSM6258::notifyInsDeletion(void* ins) { void DivPlatformMSM6258::notifyInsDeletion(void* ins) {
for (int i=0; i<1; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
void DivPlatformMSM6258::setFlags(const DivConfig& flags) { void DivPlatformMSM6258::setFlags(const DivConfig& flags) {

View file

@ -326,6 +326,9 @@ void DivPlatformMSM6295::notifyInsChange(int ins) {
} }
void DivPlatformMSM6295::notifyInsDeletion(void* ins) { void DivPlatformMSM6295::notifyInsDeletion(void* ins) {
for (int i=0; i<4; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
const void* DivPlatformMSM6295::getSampleMem(int index) { const void* DivPlatformMSM6295::getSampleMem(int index) {

View file

@ -1640,6 +1640,9 @@ void DivPlatformOPL::notifyInsChange(int ins) {
} }
void DivPlatformOPL::notifyInsDeletion(void* ins) { void DivPlatformOPL::notifyInsDeletion(void* ins) {
for (int i=0; i<totalChans; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
void DivPlatformOPL::poke(unsigned int addr, unsigned short val) { void DivPlatformOPL::poke(unsigned int addr, unsigned short val) {

View file

@ -940,6 +940,9 @@ void DivPlatformOPLL::notifyInsChange(int ins) {
} }
void DivPlatformOPLL::notifyInsDeletion(void* ins) { void DivPlatformOPLL::notifyInsDeletion(void* ins) {
for (int i=0; i<11; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
void DivPlatformOPLL::poke(unsigned int addr, unsigned short val) { void DivPlatformOPLL::poke(unsigned int addr, unsigned short val) {

View file

@ -606,7 +606,7 @@ void DivPlatformQSound::forceIns() {
for (int i=0; i<19; i++) { for (int i=0; i<19; i++) {
chan[i].insChanged=true; chan[i].insChanged=true;
chan[i].freqChanged=true; chan[i].freqChanged=true;
chan[i].sample=-1; //chan[i].sample=-1;
} }
} }
@ -645,7 +645,7 @@ bool DivPlatformQSound::keyOffAffectsArp(int ch) {
} }
void DivPlatformQSound::notifyInsChange(int ins) { void DivPlatformQSound::notifyInsChange(int ins) {
for (int i=0; i<4; i++) { for (int i=0; i<19; i++) {
if (chan[i].ins==ins) { if (chan[i].ins==ins) {
chan[i].insChanged=true; chan[i].insChanged=true;
} }
@ -657,7 +657,7 @@ void DivPlatformQSound::notifyWaveChange(int wave) {
} }
void DivPlatformQSound::notifyInsDeletion(void* ins) { void DivPlatformQSound::notifyInsDeletion(void* ins) {
for (int i=0; i<4; i++) { for (int i=0; i<19; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins); chan[i].std.notifyInsDeletion((DivInstrument*)ins);
} }
} }

View file

@ -406,6 +406,12 @@ void DivPlatformSegaPCM::notifyInsChange(int ins) {
} }
} }
void DivPlatformSegaPCM::notifyInsDeletion(void* ins) {
for (int i=0; i<16; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
void* DivPlatformSegaPCM::getChanState(int ch) { void* DivPlatformSegaPCM::getChanState(int ch) {
return &chan[ch]; return &chan[ch];
} }

View file

@ -89,6 +89,7 @@ class DivPlatformSegaPCM: public DivDispatch {
void tick(bool sysTick=true); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
void renderSamples(int chipID); void renderSamples(int chipID);
void setFlags(const DivConfig& flags); void setFlags(const DivConfig& flags);
int getOutputCount(); int getOutputCount();

View file

@ -873,6 +873,12 @@ void DivPlatformTX81Z::notifyInsChange(int ins) {
} }
} }
void DivPlatformTX81Z::notifyInsDeletion(void* ins) {
for (int i=0; i<8; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
void* DivPlatformTX81Z::getChanState(int ch) { void* DivPlatformTX81Z::getChanState(int ch) {
return &chan[ch]; return &chan[ch];
} }

View file

@ -72,6 +72,7 @@ class DivPlatformTX81Z: public DivPlatformOPM {
void tick(bool sysTick=true); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
void setFlags(const DivConfig& flags); void setFlags(const DivConfig& flags);
int getOutputCount(); int getOutputCount();
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);

View file

@ -411,7 +411,7 @@ int DivPlatformVERA::getOutputCount() {
} }
void DivPlatformVERA::notifyInsDeletion(void* ins) { void DivPlatformVERA::notifyInsDeletion(void* ins) {
for (int i=0; i<2; i++) { for (int i=0; i<17; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins); chan[i].std.notifyInsDeletion((DivInstrument*)ins);
} }
} }

View file

@ -986,6 +986,9 @@ void DivPlatformYM2203::notifyInsChange(int ins) {
void DivPlatformYM2203::notifyInsDeletion(void* ins) { void DivPlatformYM2203::notifyInsDeletion(void* ins) {
ay->notifyInsDeletion(ins); ay->notifyInsDeletion(ins);
for (int i=0; i<3; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
void DivPlatformYM2203::setSkipRegisterWrites(bool value) { void DivPlatformYM2203::setSkipRegisterWrites(bool value) {

View file

@ -73,7 +73,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
int getOutputCount(); int getOutputCount();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins); virtual void notifyInsDeletion(void* ins);
void setSkipRegisterWrites(bool val); void setSkipRegisterWrites(bool val);
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist); void poke(std::vector<DivRegWrite>& wlist);

View file

@ -641,6 +641,13 @@ void DivPlatformYM2203Ext::notifyInsChange(int ins) {
} }
} }
void DivPlatformYM2203Ext::notifyInsDeletion(void* ins) {
DivPlatformYM2203::notifyInsDeletion(ins);
for (int i=0; i<4; i++) {
opChan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
int DivPlatformYM2203Ext::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) { int DivPlatformYM2203Ext::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) {
DivPlatformYM2203::init(parent,channels,sugRate,flags); DivPlatformYM2203::init(parent,channels,sugRate,flags);
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {

View file

@ -39,6 +39,7 @@ class DivPlatformYM2203Ext: public DivPlatformYM2203 {
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
~DivPlatformYM2203Ext(); ~DivPlatformYM2203Ext();

View file

@ -1458,6 +1458,12 @@ void DivPlatformYM2608::notifyInsChange(int ins) {
void DivPlatformYM2608::notifyInsDeletion(void* ins) { void DivPlatformYM2608::notifyInsDeletion(void* ins) {
ay->notifyInsDeletion(ins); ay->notifyInsDeletion(ins);
for (int i=0; i<psgChanOffs; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
for (int i=adpcmAChanOffs; i<chanNum; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
void DivPlatformYM2608::setSkipRegisterWrites(bool value) { void DivPlatformYM2608::setSkipRegisterWrites(bool value) {

View file

@ -88,7 +88,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
int getOutputCount(); int getOutputCount();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins); virtual void notifyInsDeletion(void* ins);
void setSkipRegisterWrites(bool val); void setSkipRegisterWrites(bool val);
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist); void poke(std::vector<DivRegWrite>& wlist);

View file

@ -679,6 +679,13 @@ void DivPlatformYM2608Ext::notifyInsChange(int ins) {
} }
} }
void DivPlatformYM2608Ext::notifyInsDeletion(void* ins) {
DivPlatformYM2608::notifyInsDeletion(ins);
for (int i=0; i<4; i++) {
opChan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
int DivPlatformYM2608Ext::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) { int DivPlatformYM2608Ext::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) {
DivPlatformYM2608::init(parent,channels,sugRate,flags); DivPlatformYM2608::init(parent,channels,sugRate,flags);
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {

View file

@ -39,6 +39,7 @@ class DivPlatformYM2608Ext: public DivPlatformYM2608 {
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
~DivPlatformYM2608Ext(); ~DivPlatformYM2608Ext();

View file

@ -1406,6 +1406,12 @@ void DivPlatformYM2610::notifyInsChange(int ins) {
void DivPlatformYM2610::notifyInsDeletion(void* ins) { void DivPlatformYM2610::notifyInsDeletion(void* ins) {
ay->notifyInsDeletion(ins); ay->notifyInsDeletion(ins);
for (int i=0; i<psgChanOffs; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
for (int i=adpcmAChanOffs; i<chanNum; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
void DivPlatformYM2610::setSkipRegisterWrites(bool value) { void DivPlatformYM2610::setSkipRegisterWrites(bool value) {

View file

@ -56,7 +56,7 @@ class DivPlatformYM2610: public DivPlatformYM2610Base {
int getOutputCount(); int getOutputCount();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins); virtual void notifyInsDeletion(void* ins);
void setSkipRegisterWrites(bool val); void setSkipRegisterWrites(bool val);
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist); void poke(std::vector<DivRegWrite>& wlist);

View file

@ -1477,6 +1477,12 @@ void DivPlatformYM2610B::notifyInsChange(int ins) {
void DivPlatformYM2610B::notifyInsDeletion(void* ins) { void DivPlatformYM2610B::notifyInsDeletion(void* ins) {
ay->notifyInsDeletion(ins); ay->notifyInsDeletion(ins);
for (int i=0; i<psgChanOffs; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
for (int i=adpcmAChanOffs; i<chanNum; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
} }
void DivPlatformYM2610B::setSkipRegisterWrites(bool value) { void DivPlatformYM2610B::setSkipRegisterWrites(bool value) {

View file

@ -52,7 +52,7 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base {
int getOutputCount(); int getOutputCount();
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins); virtual void notifyInsDeletion(void* ins);
void setSkipRegisterWrites(bool val); void setSkipRegisterWrites(bool val);
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist); void poke(std::vector<DivRegWrite>& wlist);

View file

@ -670,6 +670,13 @@ void DivPlatformYM2610BExt::notifyInsChange(int ins) {
} }
} }
void DivPlatformYM2610BExt::notifyInsDeletion(void* ins) {
DivPlatformYM2610B::notifyInsDeletion(ins);
for (int i=0; i<4; i++) {
opChan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
int DivPlatformYM2610BExt::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) { int DivPlatformYM2610BExt::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) {
DivPlatformYM2610B::init(parent,channels,sugRate,flags); DivPlatformYM2610B::init(parent,channels,sugRate,flags);
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {

View file

@ -39,6 +39,7 @@ class DivPlatformYM2610BExt: public DivPlatformYM2610B {
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
~DivPlatformYM2610BExt(); ~DivPlatformYM2610BExt();

View file

@ -670,6 +670,13 @@ void DivPlatformYM2610Ext::notifyInsChange(int ins) {
} }
} }
void DivPlatformYM2610Ext::notifyInsDeletion(void* ins) {
DivPlatformYM2610::notifyInsDeletion(ins);
for (int i=0; i<4; i++) {
opChan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
int DivPlatformYM2610Ext::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) { int DivPlatformYM2610Ext::init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) {
DivPlatformYM2610::init(parent,channels,sugRate,flags); DivPlatformYM2610::init(parent,channels,sugRate,flags);
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {

View file

@ -39,6 +39,7 @@ class DivPlatformYM2610Ext: public DivPlatformYM2610 {
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
~DivPlatformYM2610Ext(); ~DivPlatformYM2610Ext();