Revision: 46096
http://sourceforge.net/p/vice-emu/code/46096
Author: gpz
Date: 2026-05-10 17:04:09 +0000 (Sun, 10 May 2026)
Log Message:
-----------
fixed the sound buffer overflows with residfp, also fixed the case when the SID is not running at system clock ("SID card")
Modified Paths:
--------------
trunk/vice/src/sid/resid.cc
trunk/vice/src/sid/residfp.cc
Modified: trunk/vice/src/sid/resid.cc
===================================================================
--- trunk/vice/src/sid/resid.cc 2026-05-10 14:58:45 UTC (rev 46095)
+++ trunk/vice/src/sid/resid.cc 2026-05-10 17:04:09 UTC (rev 46096)
@@ -305,15 +305,17 @@
/* Tried not to mess with resid during 64-bit conversion. clock(...) wants to modify *delta_t ... */
if (psid->factor == 1000) {
+ /* CAUTION: modifies int_delta_t so it contains "cycles left to do" after exit (usually 0) */
retval = psid->sid->clock(int_delta_t, pbuf, nr, interleave);
(*delta_t) += int_delta_t - int_delta_t_original;
return retval;
}
+ /* Used when SID does not run at system clock ("SID card") */
tmp_buf = getbuf(2 * nr * psid->factor / 1000);
- retval = psid->sid->clock(int_delta_t, tmp_buf, nr * psid->factor / 1000, interleave) * 1000 / psid->factor;
+ retval = psid->sid->clock(int_delta_t, tmp_buf, nr * psid->factor / 1000, interleave);
(*delta_t) += int_delta_t - int_delta_t_original;
- memcpy(pbuf, tmp_buf, 2 * nr);
+ memcpy(pbuf, tmp_buf, retval * 2);
return retval;
}
Modified: trunk/vice/src/sid/residfp.cc
===================================================================
--- trunk/vice/src/sid/residfp.cc 2026-05-10 14:58:45 UTC (rev 46095)
+++ trunk/vice/src/sid/residfp.cc 2026-05-10 17:04:09 UTC (rev 46096)
@@ -269,17 +269,13 @@
{
short *tmp_buf;
int retval;
- /*int int_delta_t_original = (int)*delta_t;*/
int int_delta_t = (int)*delta_t;
/* Tried not to mess with resid during 64-bit conversion. clock(...) wants to modify *delta_t ... */
if (psid->factor == 1000) {
- /* FIXME: the sound code constantly spits out "buffer overrun" warnings, but sound plays fine,
- * something is wrong there */
- /*retval = psid->sid->clock(int_delta_t, pbuf, nr, interleave);*/
-
tmp_buf = getbuf(2 * nr);
+ /* CAUTION: unlike ReSID; this does NOT return the number of cycles "left to do" in int_delta_t */
retval = psid->sid->clock(int_delta_t, tmp_buf);
{
int n, p = 0;
@@ -289,19 +285,22 @@
}
}
- /* printf("%p %p nr:%d interleave:%d retval:%d delta:%d\n", psid, pbuf, nr, interleave, retval, int_delta_t); */
- /* (*delta_t) += int_delta_t - int_delta_t_original; */
+ (*delta_t) = 0;
return retval;
}
- /* FIXME: how to trigger this case for testing? */
-
- /* retval = psid->sid->clock(int_delta_t, tmp_buf, nr * psid->factor / 1000, interleave) * 1000 / psid->factor; */
+ /* Used when SID does not run at system clock ("SID card") */
tmp_buf = getbuf(2 * nr * psid->factor / 1000);
retval = psid->sid->clock(int_delta_t, tmp_buf);
- /* (*delta_t) += int_delta_t - int_delta_t_original; */
- memcpy(pbuf, tmp_buf, 2 * nr);
+ {
+ int n, p = 0;
+ for (n = 0; n < retval; n++) {
+ pbuf[p] = tmp_buf[n];
+ p += interleave;
+ }
+ }
+ (*delta_t) = 0;
return retval;
}
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|