mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-02 17:12:15 +00:00
Merge pull request #239 from carlo-bramini/fluidsynth_no_glib_1
Fluidsynth no glib 1
This commit is contained in:
commit
7146ecd61b
5 changed files with 36 additions and 60 deletions
|
@ -42,8 +42,8 @@
|
|||
/* Private data for SEQUENCER */
|
||||
struct _fluid_sequencer_t {
|
||||
unsigned int startMs;
|
||||
gint currentMs;
|
||||
gboolean useSystemTimer;
|
||||
int currentMs;
|
||||
int useSystemTimer;
|
||||
double scale; // ticks per second
|
||||
fluid_list_t* clients;
|
||||
short clientsID;
|
||||
|
@ -121,7 +121,7 @@ new_fluid_sequencer2 (int use_system_timer)
|
|||
FLUID_MEMSET(seq, 0, sizeof(fluid_sequencer_t));
|
||||
|
||||
seq->scale = 1000; // default value
|
||||
seq->useSystemTimer = use_system_timer ? TRUE : FALSE;
|
||||
seq->useSystemTimer = use_system_timer ? 1 : 0;
|
||||
seq->startMs = seq->useSystemTimer ? fluid_curtime() : 0;
|
||||
seq->clients = NULL;
|
||||
seq->clientsID = 0;
|
||||
|
@ -196,7 +196,7 @@ delete_fluid_sequencer (fluid_sequencer_t* seq)
|
|||
int
|
||||
fluid_sequencer_get_use_system_timer (fluid_sequencer_t* seq)
|
||||
{
|
||||
return seq->useSystemTimer ? 1 : 0;
|
||||
return seq->useSystemTimer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -500,7 +500,7 @@ fluid_sequencer_remove_events (fluid_sequencer_t* seq, short source,
|
|||
unsigned int
|
||||
fluid_sequencer_get_tick (fluid_sequencer_t* seq)
|
||||
{
|
||||
unsigned int absMs = seq->useSystemTimer ? (int) fluid_curtime() : g_atomic_int_get(&seq->currentMs);
|
||||
unsigned int absMs = seq->useSystemTimer ? (int) fluid_curtime() : fluid_atomic_int_get(&seq->currentMs);
|
||||
double nowFloat;
|
||||
unsigned int now;
|
||||
nowFloat = ((double)(absMs - seq->startMs))*seq->scale/1000.0f;
|
||||
|
@ -846,7 +846,7 @@ fluid_sequencer_process(fluid_sequencer_t* seq, unsigned int msec)
|
|||
}
|
||||
|
||||
/* send queued events */
|
||||
g_atomic_int_set(&seq->currentMs, msec);
|
||||
fluid_atomic_int_set(&seq->currentMs, msec);
|
||||
_fluid_seq_queue_send_queued_events(seq);
|
||||
|
||||
}
|
||||
|
|
|
@ -2030,86 +2030,59 @@ fluid_sample_import_sfont(fluid_sample_t* sample, SFSample* sfsample, fluid_defs
|
|||
equivalent to the matching ID list in memory regardless of LE/BE machine
|
||||
*/
|
||||
|
||||
#if FLUID_IS_BIG_ENDIAN
|
||||
|
||||
#define READCHUNK(var,fd) G_STMT_START { \
|
||||
#define READCHUNK(var,fd) FLUID_STMT_START { \
|
||||
if (!safe_fread(var, 8, fd)) \
|
||||
return(FAIL); \
|
||||
((SFChunk *)(var))->size = GUINT32_FROM_LE(((SFChunk *)(var))->size); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
#define READD(var,fd) G_STMT_START { \
|
||||
#define READD(var,fd) FLUID_STMT_START { \
|
||||
unsigned int _temp; \
|
||||
if (!safe_fread(&_temp, 4, fd)) \
|
||||
return(FAIL); \
|
||||
var = GINT32_FROM_LE(_temp); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
#define READW(var,fd) G_STMT_START { \
|
||||
#define READW(var,fd) FLUID_STMT_START { \
|
||||
unsigned short _temp; \
|
||||
if (!safe_fread(&_temp, 2, fd)) \
|
||||
return(FAIL); \
|
||||
var = GINT16_FROM_LE(_temp); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
#else
|
||||
|
||||
#define READCHUNK(var,fd) G_STMT_START { \
|
||||
if (!safe_fread(var, 8, fd)) \
|
||||
return(FAIL); \
|
||||
((SFChunk *)(var))->size = GUINT32_FROM_LE(((SFChunk *)(var))->size); \
|
||||
} G_STMT_END
|
||||
|
||||
#define READD(var,fd) G_STMT_START { \
|
||||
unsigned int _temp; \
|
||||
if (!safe_fread(&_temp, 4, fd)) \
|
||||
return(FAIL); \
|
||||
var = GINT32_FROM_LE(_temp); \
|
||||
} G_STMT_END
|
||||
|
||||
#define READW(var,fd) G_STMT_START { \
|
||||
unsigned short _temp; \
|
||||
if (!safe_fread(&_temp, 2, fd)) \
|
||||
return(FAIL); \
|
||||
var = GINT16_FROM_LE(_temp); \
|
||||
} G_STMT_END
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define READID(var,fd) G_STMT_START { \
|
||||
#define READID(var,fd) FLUID_STMT_START { \
|
||||
if (!safe_fread(var, 4, fd)) \
|
||||
return(FAIL); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
#define READSTR(var,fd) G_STMT_START { \
|
||||
#define READSTR(var,fd) FLUID_STMT_START { \
|
||||
if (!safe_fread(var, 20, fd)) \
|
||||
return(FAIL); \
|
||||
(*var)[20] = '\0'; \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
#define READB(var,fd) G_STMT_START { \
|
||||
#define READB(var,fd) FLUID_STMT_START { \
|
||||
if (!safe_fread(&var, 1, fd)) \
|
||||
return(FAIL); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
#define FSKIP(size,fd) G_STMT_START { \
|
||||
#define FSKIP(size,fd) FLUID_STMT_START { \
|
||||
if (!safe_fseek(fd, size, SEEK_CUR)) \
|
||||
return(FAIL); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
#define FSKIPW(fd) G_STMT_START { \
|
||||
#define FSKIPW(fd) FLUID_STMT_START { \
|
||||
if (!safe_fseek(fd, 2, SEEK_CUR)) \
|
||||
return(FAIL); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
/* removes and advances a fluid_list_t pointer */
|
||||
#define SLADVREM(list, item) G_STMT_START { \
|
||||
#define SLADVREM(list, item) FLUID_STMT_START { \
|
||||
fluid_list_t *_temp = item; \
|
||||
item = fluid_list_next(item); \
|
||||
list = fluid_list_remove_link(list, _temp); \
|
||||
delete1_fluid_list(_temp); \
|
||||
} G_STMT_END
|
||||
} FLUID_STMT_END
|
||||
|
||||
static int chunkid (unsigned int id);
|
||||
static int load_body (unsigned int size, SFData * sf, FILE * fd);
|
||||
|
@ -2760,7 +2733,7 @@ load_pgen (int size, SFData * sf, FILE * fd)
|
|||
{ /* inst is last gen */
|
||||
level = 3;
|
||||
READW (genval.uword, fd);
|
||||
((SFZone *) (p2->data))->instsamp = GINT_TO_POINTER (genval.uword + 1);
|
||||
((SFZone *) (p2->data))->instsamp = FLUID_INT_TO_POINTER (genval.uword + 1);
|
||||
break; /* break out of generator loop */
|
||||
}
|
||||
else
|
||||
|
@ -3110,7 +3083,7 @@ load_igen (int size, SFData * sf, FILE * fd)
|
|||
{ /* sample is last gen */
|
||||
level = 3;
|
||||
READW (genval.uword, fd);
|
||||
((SFZone *) (p2->data))->instsamp = GINT_TO_POINTER (genval.uword + 1);
|
||||
((SFZone *) (p2->data))->instsamp = FLUID_INT_TO_POINTER (genval.uword + 1);
|
||||
break; /* break out of generator loop */
|
||||
}
|
||||
else
|
||||
|
@ -3270,7 +3243,7 @@ fixup_pgen (SFData * sf)
|
|||
while (p2)
|
||||
{ /* traverse this preset's zones */
|
||||
z = (SFZone *) (p2->data);
|
||||
if ((i = GPOINTER_TO_INT (z->instsamp)))
|
||||
if ((i = FLUID_POINTER_TO_INT (z->instsamp)))
|
||||
{ /* load instrument # */
|
||||
p3 = fluid_list_nth (sf->inst, i - 1);
|
||||
if (!p3)
|
||||
|
@ -3305,7 +3278,7 @@ fixup_igen (SFData * sf)
|
|||
while (p2)
|
||||
{ /* traverse instrument's zones */
|
||||
z = (SFZone *) (p2->data);
|
||||
if ((i = GPOINTER_TO_INT (z->instsamp)))
|
||||
if ((i = FLUID_POINTER_TO_INT (z->instsamp)))
|
||||
{ /* load sample # */
|
||||
p3 = fluid_list_nth (sf->sample, i - 1);
|
||||
if (!p3)
|
||||
|
|
|
@ -3353,13 +3353,12 @@ fluid_synth_start_voice(fluid_synth_t* synth, fluid_voice_t* voice)
|
|||
void
|
||||
fluid_synth_add_sfloader(fluid_synth_t* synth, fluid_sfloader_t* loader)
|
||||
{
|
||||
gboolean sfont_already_loaded;
|
||||
|
||||
fluid_return_if_fail (synth != NULL);
|
||||
fluid_return_if_fail (loader != NULL);
|
||||
fluid_synth_api_enter(synth);
|
||||
sfont_already_loaded = synth->sfont_info != NULL;
|
||||
if (!sfont_already_loaded)
|
||||
|
||||
/* Test if sfont is already loaded */
|
||||
if (synth->sfont_info == NULL)
|
||||
synth->loaders = fluid_list_prepend(synth->loaders, loader);
|
||||
fluid_synth_api_exit(synth);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef struct
|
|||
|
||||
/* Excerpt from glib gprimes.c */
|
||||
|
||||
static const guint primes[] =
|
||||
static const unsigned int primes[] =
|
||||
{
|
||||
11,
|
||||
19,
|
||||
|
|
|
@ -65,6 +65,10 @@ void fluid_time_config(void);
|
|||
#define FLUID_INT_TO_POINTER GINT_TO_POINTER
|
||||
#define FLUID_N_ELEMENTS(struct) (sizeof (struct) / sizeof (struct[0]))
|
||||
|
||||
/* Open/closes statement block */
|
||||
#define FLUID_STMT_START do
|
||||
#define FLUID_STMT_END while (0)
|
||||
|
||||
#define FLUID_IS_BIG_ENDIAN (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue