Really really fix NDSP wavebuf scheduling, this time for real

This commit is contained in:
fincs 2015-10-24 01:47:23 +02:00
parent 28f73801cc
commit b3e6a64596
2 changed files with 23 additions and 19 deletions

View File

@ -360,31 +360,35 @@ void ndspiReadChnState(void)
if (chn->syncCount == st->syncCount) if (chn->syncCount == st->syncCount)
{ {
u16 seqId = st->curSeqId; u16 seqId = st->curSeqId;
LightLock_Lock(&chn->lock);
ndspWaveBuf* wb = chn->waveBuf;
chn->samplePos = ndspiRotateVal(st->samplePos); chn->samplePos = ndspiRotateVal(st->samplePos);
chn->waveBufSeqPos = seqId; chn->waveBufSeqPos = seqId;
if ((st->flags & 0xFF00) && wb) if (st->flags & 0xFF00)
{ {
while (wb->sequence_id != seqId) LightLock_Lock(&chn->lock);
ndspWaveBuf* wb = chn->waveBuf;
if (wb)
{ {
chn->wavBufCount--; if (chn->wavBufCount)
bool shouldBreak = seqId == 0 && (wb->sequence_id == st->lastSeqId || st->lastSeqId == 0); {
wb->status = NDSP_WBUF_DONE; while (wb->sequence_id != seqId)
wb = wb->next; {
if (!wb || shouldBreak || chn->wavBufCount == 0) chn->wavBufCount--;
break; bool shouldBreak = seqId == 0 && (wb->sequence_id == st->lastSeqId || st->lastSeqId == 0);
wb->status = NDSP_WBUF_DONE;
wb = wb->next;
if (!wb || shouldBreak || chn->wavBufCount == 0)
break;
}
if (wb && wb->status != NDSP_WBUF_DONE)
wb->status = NDSP_WBUF_PLAYING;
}
if (seqId == 0)
chn->wavBufCount = 0;
chn->waveBuf = wb;
} }
if (wb && wb->status != NDSP_WBUF_DONE) LightLock_Unlock(&chn->lock);
wb->status = NDSP_WBUF_PLAYING;
if (seqId == 0)
chn->wavBufCount = 0;
chn->waveBuf = wb;
} }
LightLock_Unlock(&chn->lock);
} }
chn->playing = (st->flags & 0xFF) ? true : false; chn->playing = (st->flags & 0xFF) ? true : false;
} }

View File

@ -461,7 +461,7 @@ Result ndspInit(void)
ndspiInitChn(); ndspiInitChn();
rc = initCfgu(); rc = initCfgu();
if (rc) if (rc==0)
{ {
u8 outMode; u8 outMode;
CFGU_GetConfigInfoBlk2(sizeof(outMode), 0x70001, &outMode); CFGU_GetConfigInfoBlk2(sizeof(outMode), 0x70001, &outMode);