+ if (work->ch[ch].bFMod == 2) // fmod freq channel
+ memcpy(iFMod, &ChanBuf, ns_to * sizeof(iFMod[0]));
+ if (work->ch[ch].bRVBActive && work->rvb_addr)
+ mix_chan_rvb(work->SSumLR, ns_to,
+ work->ch[ch].vol_l, work->ch[ch].vol_r, RVB);
+ else
+ mix_chan(work->SSumLR, ns_to, work->ch[ch].vol_l, work->ch[ch].vol_r);
+ }
+
+ if (work->rvb_addr)
+ REVERBDo(work->SSumLR, RVB, ns_to, work->rvb_addr);
+}
+
+static void sync_worker_thread(int force)
+{
+ struct work_item *work;
+ int done, used_space;
+
+ // rvb offsets will change, thread may be using them
+ force |= spu.rvb->dirty && spu.rvb->StartAddr;
+
+ done = thread_get_i_done() - worker->i_reaped;
+ used_space = worker->i_ready - worker->i_reaped;
+
+ //printf("done: %d use: %d dsp: %u/%u\n", done, used_space,
+ // worker->boot_cnt, worker->i_done);
+
+ while ((force && used_space > 0) || used_space >= WORK_MAXCNT || done > 0) {
+ work = &worker->i[worker->i_reaped & WORK_I_MASK];
+ thread_work_wait_sync(work, force);
+
+ MixXA(work->SSumLR, RVB, work->ns_to, work->decode_pos);
+ do_samples_finish(work->SSumLR, work->ns_to,
+ work->channels_silent, work->decode_pos);
+
+ worker->i_reaped++;
+ done = thread_get_i_done() - worker->i_reaped;
+ used_space = worker->i_ready - worker->i_reaped;
+ }
+ if (force)
+ thread_sync_caches();
+}
+
+#else
+
+static void queue_channel_work(int ns_to, int silentch) {}
+static void sync_worker_thread(int force) {}
+
+static const void * const worker = NULL;
+
+#endif // P_HAVE_PTHREAD || defined(WANT_THREAD_CODE)
+
+////////////////////////////////////////////////////////////////////////
+// MAIN SPU FUNCTION
+// here is the main job handler...
+////////////////////////////////////////////////////////////////////////