make OSS detect blocking, adjust audio API
[picodrive.git] / pico / sound / sound.c
index 5bb8e9d..615e324 100644 (file)
@@ -375,7 +375,8 @@ PICO_INTERNAL void PsndGetSamples(int y)
 #if SIMPLE_WRITE_SOUND\r
   if (y != 224) return;\r
   PsndRender(0, PsndLen);\r
-  if (PicoWriteSound) PicoWriteSound(PsndLen);\r
+  if (PicoWriteSound)\r
+    PicoWriteSound(PsndLen * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2));\r
   PsndClear();\r
 #else\r
   static int curr_pos = 0;\r
@@ -385,8 +386,11 @@ PICO_INTERNAL void PsndGetSamples(int y)
     if (emustatus & 2)\r
          curr_pos += PsndRender(curr_pos, PsndLen-PsndLen/2);\r
     else curr_pos  = PsndRender(0, PsndLen);\r
-    if (emustatus&1) emustatus|=2; else emustatus&=~2;\r
-    if (PicoWriteSound) PicoWriteSound(curr_pos);\r
+    if (emustatus & 1)\r
+         emustatus |=  2;\r
+    else emustatus &= ~2;\r
+    if (PicoWriteSound)\r
+      PicoWriteSound(curr_pos * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2));\r
     // clear sound buffer\r
     PsndClear();\r
   }\r
@@ -424,7 +428,7 @@ PICO_INTERNAL void PsndGetSamplesMS(void)
   }\r
 \r
   if (PicoWriteSound != NULL)\r
-    PicoWriteSound(length);\r
+    PicoWriteSound(length * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2));\r
   PsndClear();\r
 }\r
 \r