+ work->rvb_addr = 0;
+ if (spu.rvb->StartAddr) {
+ if (spu_config.iUseReverb)
+ work->rvb_addr = spu.rvb->CurrAddr;
+
+ spu.rvb->CurrAddr += ns_to / 2;
+ while (spu.rvb->CurrAddr >= 0x40000)
+ spu.rvb->CurrAddr -= 0x40000 - spu.rvb->StartAddr;
+ }
+
+ worker->i_ready++;
+ thread_work_start();
+}
+
+static void do_channel_work(struct work_item *work)
+{
+ unsigned int mask;
+ int *SB, sinc, spos, sbpos;
+ int d, ch, ns_to;
+
+ ns_to = work->ns_to;
+
+ if (work->rvb_addr)
+ memset(RVB, 0, ns_to * sizeof(RVB[0]) * 2);
+
+ mask = work->channels_new;
+ for (ch = 0; mask != 0; ch++, mask >>= 1) {
+ if (mask & 1)
+ StartSoundSB(spu.SB + ch * SB_SIZE);
+ }
+
+ mask = work->channels_on;
+ for (ch = 0; mask != 0; ch++, mask >>= 1)
+ {
+ if (!(mask & 1)) continue;
+
+ d = work->ch[ch].ns_to;
+ spos = work->ch[ch].spos;
+ sbpos = work->ch[ch].sbpos;
+ sinc = work->ch[ch].sinc;
+
+ SB = spu.SB + ch * SB_SIZE;
+ if (work->ch[ch].bNewPitch)
+ SB[32] = 1; // reset interpolation
+
+ if (work->ch[ch].bNoise)
+ do_lsfr_samples(d, work->ctrl, &spu.dwNoiseCount, &spu.dwNoiseVal);
+ else if (work->ch[ch].bFMod == 2
+ || (work->ch[ch].bFMod == 0 && spu_config.iUseInterpolation == 0))
+ do_samples_noint(decode_block_work, work, ch, d, SB, sinc, &spos, &sbpos);
+ else if (work->ch[ch].bFMod == 0 && spu_config.iUseInterpolation == 1)
+ do_samples_simple(decode_block_work, work, ch, d, SB, sinc, &spos, &sbpos);
+ else
+ do_samples_default(decode_block_work, work, ch, d, SB, sinc, &spos, &sbpos);
+
+ d = MixADSR(&work->ch[ch].adsr, d);
+ if (d < ns_to) {
+ work->ch[ch].adsr.EnvelopeVol = 0;
+ memset(&ChanBuf[d], 0, (ns_to - d) * sizeof(ChanBuf[0]));