mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-27 18:30:56 +00:00
Merge pull request #8192 from unknownbrackets/atrac-sas
Fix issues in Sol Trigger with atrac/sas
This commit is contained in:
commit
9462bf3ba7
@ -562,6 +562,7 @@ static Atrac *getAtrac(int atracID) {
|
||||
// Read in any changes from the game to the context.
|
||||
// TODO: Might be better to just always track in RAM.
|
||||
atrac->bufferState = atrac->atracContext->info.state;
|
||||
atrac->loopNum = atrac->atracContext->info.loopNum;
|
||||
}
|
||||
|
||||
return atrac;
|
||||
@ -1858,6 +1859,9 @@ static u32 sceAtracSetLoopNum(int atracID, int loopNum) {
|
||||
atrac->loopStartSample = atrac->firstSampleoffset + atrac->firstOffsetExtra();
|
||||
atrac->loopEndSample = atrac->endSample + atrac->firstSampleoffset + atrac->firstOffsetExtra();
|
||||
}
|
||||
if (atrac->atracContext.IsValid()) {
|
||||
_AtracGenerateContext(atrac, atrac->atracContext);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -2121,7 +2125,7 @@ void _AtracGenerateContext(Atrac *atrac, SceAtracId *context) {
|
||||
context->info.dataOff = atrac->dataOff;
|
||||
context->info.endSample = atrac->endSample + atrac->firstSampleoffset + atrac->firstOffsetExtra();
|
||||
context->info.dataEnd = atrac->first.filesize;
|
||||
context->info.curOff = atrac->getFileOffsetBySample(atrac->currentSample);
|
||||
context->info.curOff = atrac->first.fileoffset;
|
||||
context->info.decodePos = atrac->getDecodePosBySample(atrac->currentSample);
|
||||
context->info.streamDataByte = atrac->first.size - atrac->dataOff;
|
||||
|
||||
|
@ -182,49 +182,55 @@ void VagDecoder::DoState(PointerWrap &p) {
|
||||
}
|
||||
|
||||
int SasAtrac3::setContext(u32 context) {
|
||||
contextAddr = context;
|
||||
atracID = _AtracGetIDByContext(context);
|
||||
if (!sampleQueue)
|
||||
sampleQueue = new BufferQueue();
|
||||
sampleQueue->clear();
|
||||
contextAddr_ = context;
|
||||
atracID_ = _AtracGetIDByContext(context);
|
||||
if (!sampleQueue_)
|
||||
sampleQueue_ = new BufferQueue();
|
||||
sampleQueue_->clear();
|
||||
end_ = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SasAtrac3::getNextSamples(s16* outbuf, int wantedSamples) {
|
||||
if (atracID < 0)
|
||||
return -1;
|
||||
void SasAtrac3::getNextSamples(s16 *outbuf, int wantedSamples) {
|
||||
if (atracID_ < 0) {
|
||||
end_ = true;
|
||||
return;
|
||||
}
|
||||
u32 finish = 0;
|
||||
int wantedbytes = wantedSamples * sizeof(s16);
|
||||
while (!finish && sampleQueue->getQueueSize() < wantedbytes) {
|
||||
while (!finish && sampleQueue_->getQueueSize() < wantedbytes) {
|
||||
u32 numSamples = 0;
|
||||
int remains = 0;
|
||||
static s16 buf[0x800];
|
||||
_AtracDecodeData(atracID, (u8*)buf, 0, &numSamples, &finish, &remains);
|
||||
_AtracDecodeData(atracID_, (u8*)buf, 0, &numSamples, &finish, &remains);
|
||||
if (numSamples > 0)
|
||||
sampleQueue->push((u8*)buf, numSamples * sizeof(s16));
|
||||
sampleQueue_->push((u8*)buf, numSamples * sizeof(s16));
|
||||
else
|
||||
finish = 1;
|
||||
}
|
||||
sampleQueue->pop_front((u8*)outbuf, wantedbytes);
|
||||
return finish;
|
||||
sampleQueue_->pop_front((u8*)outbuf, wantedbytes);
|
||||
end_ = finish == 1;
|
||||
}
|
||||
|
||||
int SasAtrac3::addStreamData(u32 bufPtr, u32 addbytes) {
|
||||
if (atracID > 0) {
|
||||
_AtracAddStreamData(atracID, bufPtr, addbytes);
|
||||
if (atracID_ > 0) {
|
||||
_AtracAddStreamData(atracID_, bufPtr, addbytes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SasAtrac3::DoState(PointerWrap &p) {
|
||||
auto s = p.Section("SasAtrac3", 1);
|
||||
auto s = p.Section("SasAtrac3", 1, 2);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
p.Do(contextAddr);
|
||||
p.Do(atracID);
|
||||
if (p.mode == p.MODE_READ && atracID >= 0 && !sampleQueue) {
|
||||
sampleQueue = new BufferQueue();
|
||||
p.Do(contextAddr_);
|
||||
p.Do(atracID_);
|
||||
if (p.mode == p.MODE_READ && atracID_ >= 0 && !sampleQueue_) {
|
||||
sampleQueue_ = new BufferQueue();
|
||||
}
|
||||
if (s >= 2) {
|
||||
p.Do(end_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,15 +442,7 @@ void SasVoice::ReadSamples(s16 *output, int numSamples) {
|
||||
}
|
||||
break;
|
||||
case VOICETYPE_ATRAC3:
|
||||
{
|
||||
int ret = atrac3.getNextSamples(output, numSamples);
|
||||
if (ret) {
|
||||
// Hit atrac3 voice end
|
||||
playing = false;
|
||||
on = false; // ??
|
||||
envelope.End();
|
||||
}
|
||||
}
|
||||
atrac3.getNextSamples(output, numSamples);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@ -463,8 +461,7 @@ bool SasVoice::HaveSamplesEnded() const {
|
||||
return pcmIndex >= pcmSize;
|
||||
|
||||
case VOICETYPE_ATRAC3:
|
||||
// TODO: Is it here, or before the samples are processed?
|
||||
return false;
|
||||
return atrac3.End();
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -128,17 +128,21 @@ private:
|
||||
|
||||
class SasAtrac3 {
|
||||
public:
|
||||
SasAtrac3() : contextAddr(0), atracID(-1), sampleQueue(0) {}
|
||||
~SasAtrac3() { if (sampleQueue) delete sampleQueue; }
|
||||
SasAtrac3() : contextAddr_(0), atracID_(-1), sampleQueue_(0), end_(false) {}
|
||||
~SasAtrac3() { if (sampleQueue_) delete sampleQueue_; }
|
||||
int setContext(u32 context);
|
||||
int getNextSamples(s16* outbuf, int wantedSamples);
|
||||
void getNextSamples(s16 *outbuf, int wantedSamples);
|
||||
int addStreamData(u32 bufPtr, u32 addbytes);
|
||||
void DoState(PointerWrap &p);
|
||||
bool End() const {
|
||||
return end_;
|
||||
}
|
||||
|
||||
private:
|
||||
u32 contextAddr;
|
||||
int atracID;
|
||||
BufferQueue *sampleQueue;
|
||||
u32 contextAddr_;
|
||||
int atracID_;
|
||||
BufferQueue *sampleQueue_;
|
||||
bool end_;
|
||||
};
|
||||
|
||||
class ADSREnvelope {
|
||||
|
@ -127,7 +127,7 @@ static const SasReverbData presets[10] = {
|
||||
{
|
||||
"Echo (almost infinite)",
|
||||
0x18040,
|
||||
0x0001,0x0001,0x7FFF,0x7FFF,0x0000,0x0000,0x0000,(int16_t)0x8100,
|
||||
0x0001,0x0001,0x7FFF,0x7FFF,0x0000,0x0000,0x0000,(int16_t)0xC080,
|
||||
0x0000,0x0000,0x1FFF,0x0FFF,0x1005,0x0005,0x0000,0x0000,
|
||||
0x1005,0x0005,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
|
||||
0x0000,0x0000,0x1004,0x1002,0x0004,0x0002, //(int16_t)0x8000,(int16_t)0x8000,
|
||||
|
Loading…
Reference in New Issue
Block a user