changeset 34:32ec3c0d1b6c

Fix a horrible think-o bug in the SDL sound callback fragmentation code.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 May 2010 01:16:43 +0300
parents 8b2b0677eb99
children b9d679965320
files pwplib/snd-sdl.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pwplib/snd-sdl.c	Mon May 24 00:22:37 2010 +0300
+++ b/pwplib/snd-sdl.c	Mon May 24 01:16:43 2010 +0300
@@ -17,7 +17,7 @@
 
 #include "pwplib.h"
 
-#define TIMERHZ (72/3)
+#define TIMERHZ 72
 
 static int pwp_sdlaudio_run = 1;
 static int pwp_sdlaudio_frag = -1, pwp_sdlaudio_curr;
@@ -29,11 +29,10 @@
 {
     (void) udata;
     while (len > 0) {
-        if (pwp_sdlaudio_curr > len) {
+        if (pwp_sdlaudio_curr >= len) {
             pwp_sdlaudio_curr -= len;
             gb_genwave(buf, len);
             len = 0;
-            pwplib.player();
         } else {
             gb_genwave(buf, pwp_sdlaudio_curr);
             buf += pwp_sdlaudio_curr;
@@ -49,6 +48,7 @@
     if (pwp_sdlaudio_run) {
         pwp_sdlaudio_curr = pwp_sdlaudio_frag;
         pwp_sdlaudio_run = 0;
+        pwplib.player();
         SDL_PauseAudio(0);
     }
 }
@@ -62,7 +62,7 @@
     fmt.freq = 44100;
     fmt.format = AUDIO_U8;
     fmt.channels = 1;
-    fmt.samples = 2048;
+    fmt.samples = 512;
     fmt.callback = pwp_sdlaudio_fill;
 
     if (SDL_OpenAudio(&fmt, NULL) < 0)