Fix fluid_curtime() returning very incorrect timings (#1076)

This commit is contained in:
Tom M 2022-04-05 22:10:39 +02:00 committed by GitHub
parent 8b00644751
commit 88e039efeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View file

@ -39,7 +39,6 @@
typedef struct typedef struct
{ {
fluid_audio_driver_t driver; fluid_audio_driver_t driver;
fluid_audio_func_t callback;
void *data; void *data;
fluid_file_renderer_t *renderer; fluid_file_renderer_t *renderer;
int period_size; int period_size;
@ -49,7 +48,7 @@ typedef struct
} fluid_file_audio_driver_t; } fluid_file_audio_driver_t;
static int fluid_file_audio_run_s16(void *d, unsigned int msec); static int fluid_file_audio_run(void *d, unsigned int msec);
/************************************************************** /**************************************************************
* *
@ -78,7 +77,6 @@ new_fluid_file_audio_driver(fluid_settings_t *settings,
fluid_settings_getnum(settings, "synth.sample-rate", &dev->sample_rate); fluid_settings_getnum(settings, "synth.sample-rate", &dev->sample_rate);
dev->data = synth; dev->data = synth;
dev->callback = (fluid_audio_func_t) fluid_synth_process;
dev->samples = 0; dev->samples = 0;
dev->renderer = new_fluid_file_renderer(synth); dev->renderer = new_fluid_file_renderer(synth);
@ -89,7 +87,7 @@ new_fluid_file_audio_driver(fluid_settings_t *settings,
} }
msec = (int)(0.5 + dev->period_size / dev->sample_rate * 1000.0); msec = (int)(0.5 + dev->period_size / dev->sample_rate * 1000.0);
dev->timer = new_fluid_timer(msec, fluid_file_audio_run_s16, (void *) dev, TRUE, FALSE, TRUE); dev->timer = new_fluid_timer(msec, fluid_file_audio_run, (void *) dev, TRUE, FALSE, TRUE);
if(dev->timer == NULL) if(dev->timer == NULL)
{ {
@ -115,7 +113,7 @@ void delete_fluid_file_audio_driver(fluid_audio_driver_t *p)
FLUID_FREE(dev); FLUID_FREE(dev);
} }
static int fluid_file_audio_run_s16(void *d, unsigned int clock_time) static int fluid_file_audio_run(void *d, unsigned int clock_time)
{ {
fluid_file_audio_driver_t *dev = (fluid_file_audio_driver_t *) d; fluid_file_audio_driver_t *dev = (fluid_file_audio_driver_t *) d;
unsigned int sample_time; unsigned int sample_time;

View file

@ -387,17 +387,17 @@ void fluid_msleep(unsigned int msecs)
*/ */
unsigned int fluid_curtime(void) unsigned int fluid_curtime(void)
{ {
float now; double now;
static float initial_time = 0; static double initial_time = 0;
if(initial_time == 0) if(initial_time == 0)
{ {
initial_time = (float)fluid_utime(); initial_time = fluid_utime();
} }
now = (float)fluid_utime(); now = fluid_utime();
return (unsigned int)((now - initial_time) / 1000.0f); return (unsigned int)((now - initial_time) / 1000.0);
} }
/** /**