mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-04 01:51:06 +00:00
Optimized arrays to be fully const and FLUID_N_ELEMENTS() support.
This commit is contained in:
parent
5e0bc7c143
commit
87bff4d3ef
1 changed files with 22 additions and 27 deletions
|
@ -54,21 +54,20 @@ struct _fluid_file_renderer_t {
|
||||||
|
|
||||||
/* File audio format names.
|
/* File audio format names.
|
||||||
* !! Keep in sync with format_ids[] */
|
* !! Keep in sync with format_ids[] */
|
||||||
const char *format_names[] = {
|
static const char * const format_names[] = {
|
||||||
"s8",
|
"s8",
|
||||||
"s16",
|
"s16",
|
||||||
"s24",
|
"s24",
|
||||||
"s32",
|
"s32",
|
||||||
"u8",
|
"u8",
|
||||||
"float",
|
"float",
|
||||||
"double",
|
"double"
|
||||||
NULL /* Terminator */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* File audio format IDs.
|
/* File audio format IDs.
|
||||||
* !! Keep in sync with format_names[] */
|
* !! Keep in sync with format_names[] */
|
||||||
const int format_ids[] = {
|
static const int format_ids[] = {
|
||||||
SF_FORMAT_PCM_S8,
|
SF_FORMAT_PCM_S8,
|
||||||
SF_FORMAT_PCM_16,
|
SF_FORMAT_PCM_16,
|
||||||
SF_FORMAT_PCM_24,
|
SF_FORMAT_PCM_24,
|
||||||
|
@ -80,17 +79,16 @@ const int format_ids[] = {
|
||||||
|
|
||||||
/* File endian byte order names.
|
/* File endian byte order names.
|
||||||
* !! Keep in sync with endian_ids[] */
|
* !! Keep in sync with endian_ids[] */
|
||||||
const char *endian_names[] = {
|
static const char * const endian_names[] = {
|
||||||
"auto",
|
"auto",
|
||||||
"little",
|
"little",
|
||||||
"big",
|
"big",
|
||||||
"cpu",
|
"cpu"
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* File endian byte order ids.
|
/* File endian byte order ids.
|
||||||
* !! Keep in sync with endian_names[] */
|
* !! Keep in sync with endian_names[] */
|
||||||
const int endian_ids[] = {
|
static const int endian_ids[] = {
|
||||||
SF_ENDIAN_FILE,
|
SF_ENDIAN_FILE,
|
||||||
SF_ENDIAN_LITTLE,
|
SF_ENDIAN_LITTLE,
|
||||||
SF_ENDIAN_BIG,
|
SF_ENDIAN_BIG,
|
||||||
|
@ -107,21 +105,18 @@ static int fluid_file_renderer_find_valid_format (SF_INFO *info);
|
||||||
|
|
||||||
|
|
||||||
/* File type names. */
|
/* File type names. */
|
||||||
const char *type_names[] = {
|
static const char * const type_names[] = {
|
||||||
"raw",
|
"raw"
|
||||||
NULL /* Terminator */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* File audio format names. */
|
/* File audio format names. */
|
||||||
const char *format_names[] = {
|
static const char * const format_names[] = {
|
||||||
"s16",
|
"s16"
|
||||||
NULL /* Terminator */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* File endian byte order names. */
|
/* File endian byte order names. */
|
||||||
const char *endian_names[] = {
|
static const char * const endian_names[] = {
|
||||||
"cpu",
|
"cpu"
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -134,7 +129,7 @@ fluid_file_renderer_settings (fluid_settings_t* settings)
|
||||||
SF_FORMAT_INFO finfo, cmpinfo;
|
SF_FORMAT_INFO finfo, cmpinfo;
|
||||||
int major_count;
|
int major_count;
|
||||||
int i, i2;
|
int i, i2;
|
||||||
const char **np;
|
unsigned int n;
|
||||||
|
|
||||||
fluid_settings_register_str(settings, "audio.file.name", "fluidsynth.wav",
|
fluid_settings_register_str(settings, "audio.file.name", "fluidsynth.wav",
|
||||||
FLUID_HINT_FILENAME, NULL, NULL);
|
FLUID_HINT_FILENAME, NULL, NULL);
|
||||||
|
@ -165,11 +160,11 @@ fluid_file_renderer_settings (fluid_settings_t* settings)
|
||||||
fluid_settings_add_option (settings, "audio.file.type", finfo.extension);
|
fluid_settings_add_option (settings, "audio.file.type", finfo.extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (np = format_names; *np; np++)
|
for (n = 0; n < FLUID_N_ELEMENTS(format_names); n++)
|
||||||
fluid_settings_add_option (settings, "audio.file.format", *np);
|
fluid_settings_add_option (settings, "audio.file.format", format_names[n]);
|
||||||
|
|
||||||
for (np = endian_names; *np; np++)
|
for (n = 0; n < FLUID_N_ELEMENTS(endian_names); n++)
|
||||||
fluid_settings_add_option (settings, "audio.file.endian", *np);
|
fluid_settings_add_option (settings, "audio.file.endian", endian_names[n]);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -417,7 +412,7 @@ fluid_file_renderer_parse_options (char *filetype, char *format, char *endian,
|
||||||
{
|
{
|
||||||
int type = -1; /* -1 indicates "auto" type */
|
int type = -1; /* -1 indicates "auto" type */
|
||||||
char *s;
|
char *s;
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
/* If "auto" type, then use extension to search for a match */
|
/* If "auto" type, then use extension to search for a match */
|
||||||
if (!filetype || FLUID_STRCMP (filetype, "auto") == 0)
|
if (!filetype || FLUID_STRCMP (filetype, "auto") == 0)
|
||||||
|
@ -443,11 +438,11 @@ fluid_file_renderer_parse_options (char *filetype, char *format, char *endian,
|
||||||
/* Look for subtype */
|
/* Look for subtype */
|
||||||
if (format)
|
if (format)
|
||||||
{
|
{
|
||||||
for (i = 0; format_names[i]; i++)
|
for (i = 0; i < FLUID_N_ELEMENTS(format_names); i++)
|
||||||
if (FLUID_STRCMP (format, format_names[i]) == 0)
|
if (FLUID_STRCMP (format, format_names[i]) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!format_names[i])
|
if (i >= FLUID_N_ELEMENTS(format_names))
|
||||||
{
|
{
|
||||||
FLUID_LOG (FLUID_ERR, "Invalid or unsupported file audio format '%s'", format);
|
FLUID_LOG (FLUID_ERR, "Invalid or unsupported file audio format '%s'", format);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -466,11 +461,11 @@ fluid_file_renderer_parse_options (char *filetype, char *format, char *endian,
|
||||||
/* Look for endian */
|
/* Look for endian */
|
||||||
if (endian)
|
if (endian)
|
||||||
{
|
{
|
||||||
for (i = 0; endian_names[i]; i++)
|
for (i = 0; i < FLUID_N_ELEMENTS(endian_names); i++)
|
||||||
if (FLUID_STRCMP (endian, endian_names[i]) == 0)
|
if (FLUID_STRCMP (endian, endian_names[i]) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!endian_names[i])
|
if (i >= FLUID_N_ELEMENTS(endian_names))
|
||||||
{
|
{
|
||||||
FLUID_LOG (FLUID_ERR, "Invalid or unsupported endian byte order '%s'", endian);
|
FLUID_LOG (FLUID_ERR, "Invalid or unsupported endian byte order '%s'", endian);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue