audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20170621043401.19842-2-hpoussin@reactos.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Hervé Poussineau 2017-06-21 06:34:00 +02:00 committed by Gerd Hoffmann
parent facd0e9773
commit c57fbf50e7
3 changed files with 18 additions and 9 deletions

View File

@ -130,7 +130,7 @@ static uint32_t adlib_read(void *opaque, uint32_t nport)
return data; return data;
} }
static void timer_handler (int c, double interval_Sec) static void timer_handler (void *opaque, int c, double interval_Sec)
{ {
AdlibState *s = glob_adlib; AdlibState *s = glob_adlib;
unsigned n = c & 1; unsigned n = c & 1;

View File

@ -788,14 +788,18 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
{ {
double interval = st2 ? (double)OPL->T[1]*OPL->TimerBase : 0.0; double interval = st2 ? (double)OPL->T[1]*OPL->TimerBase : 0.0;
OPL->st[1] = st2; OPL->st[1] = st2;
if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+1,interval); if (OPL->TimerHandler) {
(OPL->TimerHandler)(OPL->TimerParam, 1, interval);
}
} }
/* timer 1 */ /* timer 1 */
if(OPL->st[0] != st1) if(OPL->st[0] != st1)
{ {
double interval = st1 ? (double)OPL->T[0]*OPL->TimerBase : 0.0; double interval = st1 ? (double)OPL->T[0]*OPL->TimerBase : 0.0;
OPL->st[0] = st1; OPL->st[0] = st1;
if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+0,interval); if (OPL->TimerHandler) {
(OPL->TimerHandler)(OPL->TimerParam, 0, interval);
}
} }
} }
return; return;
@ -1128,10 +1132,11 @@ void OPLDestroy(FM_OPL *OPL)
/* ---------- Option handlers ---------- */ /* ---------- Option handlers ---------- */
void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset) void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
void *param)
{ {
OPL->TimerHandler = TimerHandler; OPL->TimerHandler = TimerHandler;
OPL->TimerParam = channelOffset; OPL->TimerParam = param;
} }
/* ---------- YM3812 I/O interface ---------- */ /* ---------- YM3812 I/O interface ---------- */
@ -1197,6 +1202,9 @@ int OPLTimerOver(FM_OPL *OPL,int c)
} }
} }
/* reload timer */ /* reload timer */
if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+c,(double)OPL->T[c]*OPL->TimerBase); if (OPL->TimerHandler) {
(OPL->TimerHandler)(OPL->TimerParam, c,
(double)OPL->T[c] * OPL->TimerBase);
}
return OPL->status>>7; return OPL->status>>7;
} }

View File

@ -3,7 +3,7 @@
#include <stdint.h> #include <stdint.h>
typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec); typedef void (*OPL_TIMERHANDLER)(void *param, int channel, double interval_Sec);
/* !!!!! here is private section , do not access there member direct !!!!! */ /* !!!!! here is private section , do not access there member direct !!!!! */
@ -87,13 +87,14 @@ typedef struct fm_opl_f {
uint8_t wavesel; uint8_t wavesel;
/* external event callback handler */ /* external event callback handler */
OPL_TIMERHANDLER TimerHandler; /* TIMER handler */ OPL_TIMERHANDLER TimerHandler; /* TIMER handler */
int TimerParam; /* TIMER parameter */ void *TimerParam; /* TIMER parameter */
} FM_OPL; } FM_OPL;
/* ---------- Generic interface section ---------- */ /* ---------- Generic interface section ---------- */
FM_OPL *OPLCreate(int clock, int rate); FM_OPL *OPLCreate(int clock, int rate);
void OPLDestroy(FM_OPL *OPL); void OPLDestroy(FM_OPL *OPL);
void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset); void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
void *param);
int OPLWrite(FM_OPL *OPL,int a,int v); int OPLWrite(FM_OPL *OPL,int a,int v);
unsigned char OPLRead(FM_OPL *OPL,int a); unsigned char OPLRead(FM_OPL *OPL,int a);