From 68a550a41976b3ff05313da19bce2999ee3ad5a8 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 5 Mar 2025 18:57:17 -0500 Subject: [PATCH] update the acquireDirect API size_t offset is no more - it is always 0 --- src/engine/dispatch.h | 3 +-- src/engine/dispatchContainer.cpp | 6 +++--- src/engine/engine.h | 2 +- src/engine/platform/abstract.cpp | 2 +- src/engine/platform/amiga.cpp | 10 +++------- src/engine/platform/amiga.h | 2 +- src/engine/platform/esfm.cpp | 9 +++------ src/engine/platform/esfm.h | 2 +- src/engine/platform/ga20.cpp | 4 ++-- src/engine/platform/ga20.h | 2 +- src/engine/platform/pce.cpp | 4 ++-- src/engine/platform/pce.h | 2 +- src/engine/platform/pcspkr.cpp | 20 +++++++++----------- src/engine/platform/pcspkr.h | 6 +++--- src/engine/playback.cpp | 4 ++-- 15 files changed, 34 insertions(+), 44 deletions(-) diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index 14aea9a9e..64f9515da 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -653,10 +653,9 @@ class DivDispatch { /** * fill a buffer with sound data (direct access to blip_buf). * @param bb pointers to blip_buf instances. - * @param the offset to the first sample (use this when calling blip_add_delta). * @param len the amount of samples to fill. */ - virtual void acquireDirect(blip_buffer_t** bb, size_t off, size_t len); + virtual void acquireDirect(blip_buffer_t** bb, size_t len); /** * post-process a rendered sound buffer. diff --git a/src/engine/dispatchContainer.cpp b/src/engine/dispatchContainer.cpp index 80ab61927..018c9e4e4 100644 --- a/src/engine/dispatchContainer.cpp +++ b/src/engine/dispatchContainer.cpp @@ -152,11 +152,11 @@ void DivDispatchContainer::grow(size_t size) { } \ if (mustClear) clear(); \ -void DivDispatchContainer::acquire(size_t offset, size_t count) { +void DivDispatchContainer::acquire(size_t count) { CHECK_MISSING_BUFS; if (dispatch->hasAcquireDirect()) { - dispatch->acquireDirect(bb,offset,count); + dispatch->acquireDirect(bb,count); } else { for (int i=0; i=outs) { @@ -165,7 +165,7 @@ void DivDispatchContainer::acquire(size_t offset, size_t count) { if (bbIn[i]==NULL) { bbInMapped[i]=NULL; } else { - bbInMapped[i]=&bbIn[i][offset]; + bbInMapped[i]=bbIn[i]; } } } diff --git a/src/engine/engine.h b/src/engine/engine.h index 966cff058..0c7b94d43 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -261,7 +261,7 @@ struct DivDispatchContainer { void setRates(double gotRate); void setQuality(bool lowQual, bool dcHiPass); void grow(size_t size); - void acquire(size_t offset, size_t count); + void acquire(size_t count); void flush(size_t offset, size_t count); void fillBuf(size_t runtotal, size_t offset, size_t size); void clear(); diff --git a/src/engine/platform/abstract.cpp b/src/engine/platform/abstract.cpp index 9cce8881e..a5ae25676 100644 --- a/src/engine/platform/abstract.cpp +++ b/src/engine/platform/abstract.cpp @@ -23,7 +23,7 @@ void DivDispatch::acquire(short** buf, size_t len) { } -void DivDispatch::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) { +void DivDispatch::acquireDirect(blip_buffer_t** bb, size_t len) { } void DivDispatch::fillStream(std::vector& stream, int sRate, size_t len) { diff --git a/src/engine/platform/amiga.cpp b/src/engine/platform/amiga.cpp index 8bd8e7507..cfe2e912d 100644 --- a/src/engine/platform/amiga.cpp +++ b/src/engine/platform/amiga.cpp @@ -82,14 +82,13 @@ const char** DivPlatformAmiga::getRegisterSheet() { void DivPlatformAmiga::acquire(short** buf, size_t len) { } -void DivPlatformAmiga::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) { +void DivPlatformAmiga::acquireDirect(blip_buffer_t** bb, size_t len) { thread_local int outL, outR, output; for (int i=0; i<4; i++) { oscBuf[i]->begin(len); } - size_t pos=off; int runCount=1; for (size_t h=0; h0) { - pos+=runCount-1; h+=runCount-1; } else { runCount=1; @@ -234,15 +232,13 @@ void DivPlatformAmiga::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) } if (outL!=oldOut[0]) { - blip_add_delta(bb[0],pos,outL-oldOut[0]); + blip_add_delta(bb[0],h,outL-oldOut[0]); oldOut[0]=outL; } if (outR!=oldOut[1]) { - blip_add_delta(bb[1],pos,outR-oldOut[1]); + blip_add_delta(bb[1],h,outR-oldOut[1]); oldOut[1]=outR; } - - pos++; } for (int i=0; i<4; i++) { diff --git a/src/engine/platform/amiga.h b/src/engine/platform/amiga.h index 3ab340705..0c660b2fd 100644 --- a/src/engine/platform/amiga.h +++ b/src/engine/platform/amiga.h @@ -139,7 +139,7 @@ class DivPlatformAmiga: public DivDispatch { public: void acquire(short** buf, size_t len); - void acquireDirect(blip_buffer_t** bb, size_t off, size_t len); + void acquireDirect(blip_buffer_t** bb, size_t len); void postProcess(short* buf, int outIndex, size_t len, int sampleRate); int dispatch(DivCommand c); void* getChanState(int chan); diff --git a/src/engine/platform/esfm.cpp b/src/engine/platform/esfm.cpp index d05ebd188..6412a4859 100644 --- a/src/engine/platform/esfm.cpp +++ b/src/engine/platform/esfm.cpp @@ -66,13 +66,12 @@ void DivPlatformESFM::acquire(short** buf, size_t len) { } } -void DivPlatformESFM::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) { +void DivPlatformESFM::acquireDirect(blip_buffer_t** bb, size_t len) { thread_local short o[2]; unsigned int sharedNeedlePos=oscBuf[0]->needle; for (int i=0; i<18; i++) { oscBuf[i]->begin(len); } - size_t pos=off; for (size_t h=0; hrateMul; if (o[0]!=oldOut[0]) { - blip_add_delta(bb[0],pos,oldOut[0]-o[0]); + blip_add_delta(bb[0],h,oldOut[0]-o[0]); oldOut[0]=o[0]; } if (o[1]!=oldOut[1]) { - blip_add_delta(bb[1],pos,oldOut[1]-o[1]); + blip_add_delta(bb[1],h,oldOut[1]-o[1]); oldOut[1]=o[1]; } - - pos++; } for (int i=0; i<18; i++) { oscBuf[i]->end(len); diff --git a/src/engine/platform/esfm.h b/src/engine/platform/esfm.h index df7fcc068..fc0aaf8e8 100644 --- a/src/engine/platform/esfm.h +++ b/src/engine/platform/esfm.h @@ -181,7 +181,7 @@ class DivPlatformESFM: public DivDispatch { public: void acquire(short** buf, size_t len); - void acquireDirect(blip_buffer_t** bb, size_t off, size_t len); + void acquireDirect(blip_buffer_t** bb, size_t len); int dispatch(DivCommand c); void* getChanState(int chan); DivMacroInt* getChanMacroInt(int ch); diff --git a/src/engine/platform/ga20.cpp b/src/engine/platform/ga20.cpp index f300f59dd..30196b5a4 100644 --- a/src/engine/platform/ga20.cpp +++ b/src/engine/platform/ga20.cpp @@ -77,7 +77,7 @@ void DivPlatformGA20::acquire(short** buf, size_t len) { } } -void DivPlatformGA20::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) { +void DivPlatformGA20::acquireDirect(blip_buffer_t** bb, size_t len) { thread_local short ga20Buf[4]; for (int i=0; i<4; i++) { @@ -109,7 +109,7 @@ void DivPlatformGA20::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) h+=advance; const int out=(signed int)(ga20Buf[0]+ga20Buf[1]+ga20Buf[2]+ga20Buf[3])>>2; if (out!=oldOut) { - blip_add_delta(bb[0],off+h,out-oldOut); + blip_add_delta(bb[0],h,out-oldOut); oldOut=out; } for (int i=0; i<4; i++) { diff --git a/src/engine/platform/ga20.h b/src/engine/platform/ga20.h index 2ff1dc2e9..167af3e5e 100644 --- a/src/engine/platform/ga20.h +++ b/src/engine/platform/ga20.h @@ -74,7 +74,7 @@ class DivPlatformGA20: public DivDispatch, public iremga20_intf { void chWrite(unsigned char ch, unsigned int addr, unsigned char val); public: virtual u8 read_byte(u32 address) override; - virtual void acquireDirect(blip_buffer_t** bb, size_t off, size_t len) override; + virtual void acquireDirect(blip_buffer_t** bb, size_t len) override; virtual void acquire(short** buf, size_t len) override; virtual int dispatch(DivCommand c) override; virtual void* getChanState(int chan) override; diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index 5b0adc266..3897d56bb 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -57,7 +57,7 @@ const char** DivPlatformPCE::getRegisterSheet() { void DivPlatformPCE::acquire(short** buf, size_t len) { } -void DivPlatformPCE::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) { +void DivPlatformPCE::acquireDirect(blip_buffer_t** bb, size_t len) { for (int i=0; i<6; i++) { oscBuf[i]->begin(len); pce->channel[i].oscBuf=oscBuf[i]; @@ -66,7 +66,7 @@ void DivPlatformPCE::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) { pce->bb[0]=bb[0]; pce->bb[1]=bb[1]; - size_t pos=off; + size_t pos=0; pce->ResetTS(pos); while (!writes.empty()) { diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index 4840c665e..4dfd321d8 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -79,7 +79,7 @@ class DivPlatformPCE: public DivDispatch { friend void putDispatchChan(void*,int,int); public: void acquire(short** buf, size_t len); - void acquireDirect(blip_buffer_t** bb, size_t off, size_t len); + void acquireDirect(blip_buffer_t** bb, size_t len); int dispatch(DivCommand c); void* getChanState(int chan); DivMacroInt* getChanMacroInt(int ch); diff --git a/src/engine/platform/pcspkr.cpp b/src/engine/platform/pcspkr.cpp index e49f8f72d..355fbf966 100644 --- a/src/engine/platform/pcspkr.cpp +++ b/src/engine/platform/pcspkr.cpp @@ -192,7 +192,7 @@ const char** DivPlatformPCSpeaker::getRegisterSheet() { return regCheatSheetPCSpeaker; } -void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t off, size_t len) { +void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t len) { int out=0; int freq1=freq+1; int timeToNextToggle=0; @@ -210,12 +210,11 @@ void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t off, size_t timeToNextToggle=pos; } out=(posToggle && !isMuted[0])?32767:0; - blip_add_delta(bb[0],off,out-oldOut); + blip_add_delta(bb[0],0,out-oldOut); oscBuf->putSample(0,out); oldOut=out; if (freq>=1) { - size_t boff=off; - size_t oscOff=0; + size_t boff=0; size_t i=len; while (true) { if ((int)iputSample(oscOff,out); + oscBuf->putSample(boff,out); oldOut=out; } } } else { out=0; - blip_add_delta(bb[0],off,out-oldOut); + blip_add_delta(bb[0],0,out-oldOut); oscBuf->putSample(0,out); oldOut=out; } @@ -333,7 +331,7 @@ void DivPlatformPCSpeaker::beepFreq(int freq, int delay) { realOutCond.notify_one(); } -void DivPlatformPCSpeaker::acquire_real(blip_buffer_t** bb, size_t off, size_t len) { +void DivPlatformPCSpeaker::acquire_real(blip_buffer_t** bb, size_t len) { //int out=0; if (lastOn!=on || lastFreq!=freq) { lastOn=on; @@ -372,13 +370,13 @@ void DivPlatformPCSpeaker::acquire(short** buf, size_t len) { } } -void DivPlatformPCSpeaker::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) { +void DivPlatformPCSpeaker::acquireDirect(blip_buffer_t** bb, size_t len) { switch (speakerType) { case 0: - acquire_unfilt(bb,off,len); + acquire_unfilt(bb,len); break; case 3: - acquire_real(bb,off,len); + acquire_real(bb,len); break; } } diff --git a/src/engine/platform/pcspkr.h b/src/engine/platform/pcspkr.h index 8d7b1c546..d9fe04da8 100644 --- a/src/engine/platform/pcspkr.h +++ b/src/engine/platform/pcspkr.h @@ -67,14 +67,14 @@ class DivPlatformPCSpeaker: public DivDispatch { void beepFreq(int freq, int delay=0); - void acquire_unfilt(blip_buffer_t** bb, size_t off, size_t len); + void acquire_unfilt(blip_buffer_t** bb, size_t len); void acquire_cone(short** buf, size_t len); void acquire_piezo(short** buf, size_t len); - void acquire_real(blip_buffer_t** bb, size_t off, size_t len); + void acquire_real(blip_buffer_t** bb, size_t len); public: void pcSpeakerThread(); - void acquireDirect(blip_buffer_t** bb, size_t off, size_t len); + void acquireDirect(blip_buffer_t** bb, size_t len); void acquire(short** buf, size_t len); int dispatch(DivCommand c); void* getChanState(int chan); diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index c58075c25..649d314f0 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -2510,7 +2510,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi logD("growing dispatch %p bbIn to %d",(void*)dc,total+256); dc->grow(total+256); } - dc->acquire(0,total); + dc->acquire(total); dc->fillBuf(total,dc->runPos,dc->cycles); dc->runPos+=dc->cycles; },&disCont[i]); @@ -2544,7 +2544,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi logD("growing dispatch %p bbIn to %d",(void*)dc,total+256); dc->grow(total+256); } - dc->acquire(0,total); + dc->acquire(total); dc->fillBuf(total,dc->runPos,dc->cycles); },&disCont[i]); }