shithub: choc

Download patch

ref: e1ac9379f676b38d2c2c003efc41b81bcfcdb29c
parent: c3e9173772e07ee21f3cea39fd6e3935ed95a02c
parent: 8921099fb0ecc9497cbd433a96dfa243a593cffc
author: Simon Howard <fraggle@soulsphere.org>
date: Mon Jul 19 10:49:46 EDT 2021

Merge pull request #1380 from mikeday0/pc-speaker-fix

Fix PC speaker emulation when using OPL

--- a/opl/opl_sdl.c
+++ b/opl/opl_sdl.c
@@ -172,9 +172,10 @@
 
 // Callback function to fill a new sound buffer:
 
-static void OPL_Mix_Callback(void *udata, Uint8 *buffer, int len)
+static void OPL_Mix_Callback(int chan, void *stream, int len, void *udata)
 {
     unsigned int filled, buffer_samples;
+    Uint8 *buffer = (Uint8*)stream;
 
     // Repeatedly call the OPL emulator update function until the buffer is
     // full.
@@ -351,7 +352,7 @@
     // Set postmix that adds the OPL music. This is deliberately done
     // as a postmix and not using Mix_HookMusic() as the latter disables
     // normal SDL_mixer music mixing.
-    Mix_SetPostMix(OPL_Mix_Callback, NULL);
+    Mix_RegisterEffect(MIX_CHANNEL_POST, OPL_Mix_Callback, NULL, NULL);
 
     return 1;
 }
--- a/pcsound/pcsound_sdl.c
+++ b/pcsound/pcsound_sdl.c
@@ -53,7 +53,7 @@
 
 // Mixer function that does the PC speaker emulation
 
-static void PCSound_Mix_Callback(void *udata, Uint8 *stream, int len)
+static void PCSound_Mix_Callback(int chan, void *stream, int len, void *udata)
 {
     Sint16 *leftptr;
     Sint16 *rightptr;
@@ -236,7 +236,7 @@
     current_freq = 0;
     current_remaining = 0;
 
-    Mix_SetPostMix(PCSound_Mix_Callback, NULL);
+    Mix_RegisterEffect(MIX_CHANNEL_POST, PCSound_Mix_Callback, NULL, NULL);
 
     return 1;
 }