conf: no CamelCase, part I
Renamed functions, types, variables.
This commit is contained in:
src
audio.caudio.hclient.ccmdline.cconf.cconf.hdaemon.cdatabase.cinput_curl.clisten.clog.cmain.cmapper.c
mixer
mixer_api.cmixer_api.houtput
alsa_plugin.cao_plugin.cfifo_plugin.cjack_plugin.cmvp_plugin.cnull_plugin.coss_plugin.cosx_plugin.cpulse_plugin.cshout_plugin.c
output_api.houtput_control.houtput_init.cpath.cpermission.cplayerData.cplaylist.creplay_gain.cstate_file.ctag.cutils.cvolume.czeroconf.c
12
src/audio.c
12
src/audio.c
@ -43,9 +43,9 @@ static unsigned int audioOutputArraySize;
|
|||||||
unsigned int audio_output_count(void)
|
unsigned int audio_output_count(void)
|
||||||
{
|
{
|
||||||
unsigned int nr = 0;
|
unsigned int nr = 0;
|
||||||
ConfigParam *param = NULL;
|
struct config_param *param = NULL;
|
||||||
|
|
||||||
while ((param = getNextConfigParam(CONF_AUDIO_OUTPUT, param)))
|
while ((param = config_get_next_param(CONF_AUDIO_OUTPUT, param)))
|
||||||
nr++;
|
nr++;
|
||||||
if (!nr)
|
if (!nr)
|
||||||
nr = 1; /* we'll always have at least one device */
|
nr = 1; /* we'll always have at least one device */
|
||||||
@ -55,7 +55,7 @@ unsigned int audio_output_count(void)
|
|||||||
/* make sure initPlayerData is called before this function!! */
|
/* make sure initPlayerData is called before this function!! */
|
||||||
void initAudioDriver(void)
|
void initAudioDriver(void)
|
||||||
{
|
{
|
||||||
ConfigParam *param = NULL;
|
struct config_param *param = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
notify_init(&audio_output_client_notify);
|
notify_init(&audio_output_client_notify);
|
||||||
@ -68,7 +68,7 @@ void initAudioDriver(void)
|
|||||||
struct audio_output *output = &audioOutputArray[i];
|
struct audio_output *output = &audioOutputArray[i];
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
param = getNextConfigParam(CONF_AUDIO_OUTPUT, param);
|
param = config_get_next_param(CONF_AUDIO_OUTPUT, param);
|
||||||
|
|
||||||
/* only allow param to be NULL if there just one audioOutput */
|
/* only allow param to be NULL if there just one audioOutput */
|
||||||
assert(param || (audioOutputArraySize == 1));
|
assert(param || (audioOutputArraySize == 1));
|
||||||
@ -106,7 +106,7 @@ void getOutputAudioFormat(const struct audio_format *inAudioFormat,
|
|||||||
|
|
||||||
void initAudioConfig(void)
|
void initAudioConfig(void)
|
||||||
{
|
{
|
||||||
ConfigParam *param = getConfigParam(CONF_AUDIO_OUTPUT_FORMAT);
|
struct config_param *param = config_get_param(CONF_AUDIO_OUTPUT_FORMAT);
|
||||||
|
|
||||||
if (NULL == param || NULL == param->value)
|
if (NULL == param || NULL == param->value)
|
||||||
return;
|
return;
|
||||||
@ -467,7 +467,7 @@ bool mixer_control_getvol(unsigned int device, int *volume)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mixer_configure_legacy(char *name, ConfigParam *param)
|
bool mixer_configure_legacy(char *name, struct config_param *param)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
struct audio_output *output;
|
struct audio_output *output;
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "conf.h"
|
|
||||||
|
|
||||||
#define AUDIO_AO_DRIVER_DEFAULT "default"
|
#define AUDIO_AO_DRIVER_DEFAULT "default"
|
||||||
|
|
||||||
struct audio_format;
|
struct audio_format;
|
||||||
struct tag;
|
struct tag;
|
||||||
struct client;
|
struct client;
|
||||||
|
struct config_param;
|
||||||
|
|
||||||
unsigned int audio_output_count(void);
|
unsigned int audio_output_count(void);
|
||||||
|
|
||||||
@ -73,6 +73,6 @@ void saveAudioDevicesState(FILE *fp);
|
|||||||
|
|
||||||
bool mixer_control_setvol(unsigned int device, int volume, int rel);
|
bool mixer_control_setvol(unsigned int device, int volume, int rel);
|
||||||
bool mixer_control_getvol(unsigned int device, int *volume);
|
bool mixer_control_getvol(unsigned int device, int *volume);
|
||||||
bool mixer_configure_legacy(char *name, ConfigParam *param);
|
bool mixer_configure_legacy(char *name, struct config_param *param);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
src/client.c
10
src/client.c
@ -554,9 +554,9 @@ client_out_event(G_GNUC_UNUSED GIOChannel *source,
|
|||||||
void client_manager_init(void)
|
void client_manager_init(void)
|
||||||
{
|
{
|
||||||
char *test;
|
char *test;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
|
|
||||||
param = getConfigParam(CONF_CONN_TIMEOUT);
|
param = config_get_param(CONF_CONN_TIMEOUT);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
client_timeout = strtol(param->value, &test, 10);
|
client_timeout = strtol(param->value, &test, 10);
|
||||||
@ -567,7 +567,7 @@ void client_manager_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
param = getConfigParam(CONF_MAX_CONN);
|
param = config_get_param(CONF_MAX_CONN);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
client_max_connections = strtol(param->value, &test, 10);
|
client_max_connections = strtol(param->value, &test, 10);
|
||||||
@ -579,7 +579,7 @@ void client_manager_init(void)
|
|||||||
} else
|
} else
|
||||||
client_max_connections = CLIENT_MAX_CONNECTIONS_DEFAULT;
|
client_max_connections = CLIENT_MAX_CONNECTIONS_DEFAULT;
|
||||||
|
|
||||||
param = getConfigParam(CONF_MAX_COMMAND_LIST_SIZE);
|
param = config_get_param(CONF_MAX_COMMAND_LIST_SIZE);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
long tmp = strtol(param->value, &test, 10);
|
long tmp = strtol(param->value, &test, 10);
|
||||||
@ -591,7 +591,7 @@ void client_manager_init(void)
|
|||||||
client_max_command_list_size = tmp * 1024;
|
client_max_command_list_size = tmp * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
param = getConfigParam(CONF_MAX_OUTPUT_BUFFER_SIZE);
|
param = config_get_param(CONF_MAX_OUTPUT_BUFFER_SIZE);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
long tmp = strtol(param->value, &test, 10);
|
long tmp = strtol(param->value, &test, 10);
|
||||||
|
@ -143,17 +143,17 @@ void parseOptions(int argc, char **argv, Options *options)
|
|||||||
path2 = g_build_filename(g_get_home_dir(),
|
path2 = g_build_filename(g_get_home_dir(),
|
||||||
USER_CONFIG_FILE_LOCATION2, NULL);
|
USER_CONFIG_FILE_LOCATION2, NULL);
|
||||||
if (g_file_test(path1, G_FILE_TEST_IS_REGULAR))
|
if (g_file_test(path1, G_FILE_TEST_IS_REGULAR))
|
||||||
readConf(path1);
|
config_read_file(path1);
|
||||||
else if (g_file_test(path2, G_FILE_TEST_IS_REGULAR))
|
else if (g_file_test(path2, G_FILE_TEST_IS_REGULAR))
|
||||||
readConf(path2);
|
config_read_file(path2);
|
||||||
else if (g_file_test(SYSTEM_CONFIG_FILE_LOCATION,
|
else if (g_file_test(SYSTEM_CONFIG_FILE_LOCATION,
|
||||||
G_FILE_TEST_IS_REGULAR))
|
G_FILE_TEST_IS_REGULAR))
|
||||||
readConf(SYSTEM_CONFIG_FILE_LOCATION);
|
config_read_file(SYSTEM_CONFIG_FILE_LOCATION);
|
||||||
g_free(path1);
|
g_free(path1);
|
||||||
g_free(path2);
|
g_free(path2);
|
||||||
} else if (argc == 2) {
|
} else if (argc == 2) {
|
||||||
/* specified configuration file */
|
/* specified configuration file */
|
||||||
readConf(argv[1]);
|
config_read_file(argv[1]);
|
||||||
} else
|
} else
|
||||||
g_error("too many arguments");
|
g_error("too many arguments");
|
||||||
}
|
}
|
||||||
|
110
src/conf.c
110
src/conf.c
@ -37,12 +37,12 @@
|
|||||||
#define CONF_BLOCK_MASK 0x02
|
#define CONF_BLOCK_MASK 0x02
|
||||||
#define CONF_LINE_TOKEN_MAX 3
|
#define CONF_LINE_TOKEN_MAX 3
|
||||||
|
|
||||||
typedef struct _configEntry {
|
struct config_entry {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned char mask;
|
unsigned char mask;
|
||||||
|
|
||||||
GSList *params;
|
GSList *params;
|
||||||
} ConfigEntry;
|
};
|
||||||
|
|
||||||
static GSList *config_entries;
|
static GSList *config_entries;
|
||||||
|
|
||||||
@ -63,9 +63,10 @@ static int get_bool(const char *value)
|
|||||||
return CONF_BOOL_INVALID;
|
return CONF_BOOL_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigParam *newConfigParam(const char *value, int line)
|
struct config_param *
|
||||||
|
newConfigParam(const char *value, int line)
|
||||||
{
|
{
|
||||||
ConfigParam *ret = g_new(ConfigParam, 1);
|
struct config_param *ret = g_new(struct config_param, 1);
|
||||||
|
|
||||||
if (!value)
|
if (!value)
|
||||||
ret->value = NULL;
|
ret->value = NULL;
|
||||||
@ -74,8 +75,8 @@ ConfigParam *newConfigParam(const char *value, int line)
|
|||||||
|
|
||||||
ret->line = line;
|
ret->line = line;
|
||||||
|
|
||||||
ret->numberOfBlockParams = 0;
|
ret->num_block_params = 0;
|
||||||
ret->blockParams = NULL;
|
ret->block_params = NULL;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -83,26 +84,26 @@ ConfigParam *newConfigParam(const char *value, int line)
|
|||||||
void
|
void
|
||||||
config_param_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
config_param_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
||||||
{
|
{
|
||||||
ConfigParam *param = data;
|
struct config_param *param = data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_free(param->value);
|
g_free(param->value);
|
||||||
|
|
||||||
for (i = 0; i < param->numberOfBlockParams; i++) {
|
for (i = 0; i < param->num_block_params; i++) {
|
||||||
g_free(param->blockParams[i].name);
|
g_free(param->block_params[i].name);
|
||||||
g_free(param->blockParams[i].value);
|
g_free(param->block_params[i].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->numberOfBlockParams)
|
if (param->num_block_params)
|
||||||
g_free(param->blockParams);
|
g_free(param->block_params);
|
||||||
|
|
||||||
g_free(param);
|
g_free(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConfigEntry *
|
static struct config_entry *
|
||||||
newConfigEntry(const char *name, int repeatable, int block)
|
newConfigEntry(const char *name, int repeatable, int block)
|
||||||
{
|
{
|
||||||
ConfigEntry *ret = g_new(ConfigEntry, 1);
|
struct config_entry *ret = g_new(struct config_entry, 1);
|
||||||
|
|
||||||
ret->name = name;
|
ret->name = name;
|
||||||
ret->mask = 0;
|
ret->mask = 0;
|
||||||
@ -119,7 +120,7 @@ newConfigEntry(const char *name, int repeatable, int block)
|
|||||||
static void
|
static void
|
||||||
config_entry_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
config_entry_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
||||||
{
|
{
|
||||||
ConfigEntry *entry = data;
|
struct config_entry *entry = data;
|
||||||
|
|
||||||
g_slist_foreach(entry->params, config_param_free, NULL);
|
g_slist_foreach(entry->params, config_param_free, NULL);
|
||||||
g_slist_free(entry->params);
|
g_slist_free(entry->params);
|
||||||
@ -127,14 +128,14 @@ config_entry_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
|||||||
g_free(entry);
|
g_free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConfigEntry *
|
static struct config_entry *
|
||||||
config_entry_get(const char *name)
|
config_entry_get(const char *name)
|
||||||
{
|
{
|
||||||
GSList *list;
|
GSList *list;
|
||||||
|
|
||||||
for (list = config_entries; list != NULL;
|
for (list = config_entries; list != NULL;
|
||||||
list = g_slist_next(list)) {
|
list = g_slist_next(list)) {
|
||||||
ConfigEntry *entry = list->data;
|
struct config_entry *entry = list->data;
|
||||||
if (strcmp(entry->name, name) == 0)
|
if (strcmp(entry->name, name) == 0)
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@ -144,7 +145,7 @@ config_entry_get(const char *name)
|
|||||||
|
|
||||||
static void registerConfigParam(const char *name, int repeatable, int block)
|
static void registerConfigParam(const char *name, int repeatable, int block)
|
||||||
{
|
{
|
||||||
ConfigEntry *entry;
|
struct config_entry *entry;
|
||||||
|
|
||||||
entry = config_entry_get(name);
|
entry = config_entry_get(name);
|
||||||
if (entry != NULL)
|
if (entry != NULL)
|
||||||
@ -154,13 +155,13 @@ static void registerConfigParam(const char *name, int repeatable, int block)
|
|||||||
config_entries = g_slist_prepend(config_entries, entry);
|
config_entries = g_slist_prepend(config_entries, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishConf(void)
|
void config_global_finish(void)
|
||||||
{
|
{
|
||||||
g_slist_foreach(config_entries, config_entry_free, NULL);
|
g_slist_foreach(config_entries, config_entry_free, NULL);
|
||||||
g_slist_free(config_entries);
|
g_slist_free(config_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initConf(void)
|
void config_global_init(void)
|
||||||
{
|
{
|
||||||
config_entries = NULL;
|
config_entries = NULL;
|
||||||
|
|
||||||
@ -209,24 +210,29 @@ void initConf(void)
|
|||||||
registerConfigParam(CONF_GAPLESS_MP3_PLAYBACK, 0, 0);
|
registerConfigParam(CONF_GAPLESS_MP3_PLAYBACK, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addBlockParam(ConfigParam * param, const char *name, const char *value,
|
void
|
||||||
|
addBlockParam(struct config_param * param, const char *name, const char *value,
|
||||||
int line)
|
int line)
|
||||||
{
|
{
|
||||||
param->numberOfBlockParams++;
|
struct block_param *bp;
|
||||||
|
|
||||||
param->blockParams = g_realloc(param->blockParams,
|
param->num_block_params++;
|
||||||
param->numberOfBlockParams *
|
|
||||||
sizeof(BlockParam));
|
|
||||||
|
|
||||||
param->blockParams[param->numberOfBlockParams - 1].name = g_strdup(name);
|
param->block_params = g_realloc(param->block_params,
|
||||||
param->blockParams[param->numberOfBlockParams - 1].value =
|
param->num_block_params *
|
||||||
g_strdup(value);
|
sizeof(param->block_params[0]));
|
||||||
param->blockParams[param->numberOfBlockParams - 1].line = line;
|
|
||||||
|
bp = ¶m->block_params[param->num_block_params - 1];
|
||||||
|
|
||||||
|
bp->name = g_strdup(name);
|
||||||
|
bp->value = g_strdup(value);
|
||||||
|
bp->line = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
|
static struct config_param *
|
||||||
|
config_read_fileigBlock(FILE * fp, int *count, char *string)
|
||||||
{
|
{
|
||||||
ConfigParam *ret = newConfigParam(NULL, *count);
|
struct config_param *ret = newConfigParam(NULL, *count);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int numberOfArgs;
|
int numberOfArgs;
|
||||||
@ -275,7 +281,7 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void readConf(const char *file)
|
void config_read_file(const char *file)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char string[MAX_STRING_SIZE + 1];
|
char string[MAX_STRING_SIZE + 1];
|
||||||
@ -283,8 +289,8 @@ void readConf(const char *file)
|
|||||||
int numberOfArgs;
|
int numberOfArgs;
|
||||||
int argsMinusComment;
|
int argsMinusComment;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
ConfigEntry *entry;
|
struct config_entry *entry;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
|
|
||||||
if (!(fp = fopen(file, "r"))) {
|
if (!(fp = fopen(file, "r"))) {
|
||||||
g_error("problems opening file %s for reading: %s\n",
|
g_error("problems opening file %s for reading: %s\n",
|
||||||
@ -332,7 +338,7 @@ void readConf(const char *file)
|
|||||||
g_error("improperly formatted config file at "
|
g_error("improperly formatted config file at "
|
||||||
"line %i: %s\n", count, string);
|
"line %i: %s\n", count, string);
|
||||||
}
|
}
|
||||||
param = readConfigBlock(fp, &count, string);
|
param = config_read_fileigBlock(fp, &count, string);
|
||||||
} else
|
} else
|
||||||
param = newConfigParam(array[1], count);
|
param = newConfigParam(array[1], count);
|
||||||
|
|
||||||
@ -341,11 +347,12 @@ void readConf(const char *file)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigParam *getNextConfigParam(const char *name, ConfigParam * last)
|
struct config_param *
|
||||||
|
config_get_next_param(const char *name, struct config_param * last)
|
||||||
{
|
{
|
||||||
ConfigEntry *entry;
|
struct config_entry *entry;
|
||||||
GSList *node;
|
GSList *node;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
|
|
||||||
entry = config_entry_get(name);
|
entry = config_entry_get(name);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
@ -371,7 +378,7 @@ ConfigParam *getNextConfigParam(const char *name, ConfigParam * last)
|
|||||||
|
|
||||||
char *getConfigParamValue(const char *name)
|
char *getConfigParamValue(const char *name)
|
||||||
{
|
{
|
||||||
ConfigParam *param = getConfigParam(name);
|
struct config_param *param = config_get_param(name);
|
||||||
|
|
||||||
if (!param)
|
if (!param)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -379,28 +386,30 @@ char *getConfigParamValue(const char *name)
|
|||||||
return param->value;
|
return param->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockParam *getBlockParam(ConfigParam * param, const char *name)
|
struct block_param *
|
||||||
|
getBlockParam(struct config_param * param, const char *name)
|
||||||
{
|
{
|
||||||
BlockParam *ret = NULL;
|
struct block_param *ret = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < param->numberOfBlockParams; i++) {
|
for (i = 0; i < param->num_block_params; i++) {
|
||||||
if (0 == strcmp(name, param->blockParams[i].name)) {
|
if (0 == strcmp(name, param->block_params[i].name)) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
g_warning("\"%s\" first defined on line %i, and "
|
g_warning("\"%s\" first defined on line %i, and "
|
||||||
"redefined on line %i\n", name,
|
"redefined on line %i\n", name,
|
||||||
ret->line, param->blockParams[i].line);
|
ret->line, param->block_params[i].line);
|
||||||
}
|
}
|
||||||
ret = param->blockParams + i;
|
ret = param->block_params + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigParam *parseConfigFilePath(const char *name, int force)
|
struct config_param *
|
||||||
|
parseConfigFilePath(const char *name, int force)
|
||||||
{
|
{
|
||||||
ConfigParam *param = getConfigParam(name);
|
struct config_param *param = config_get_param(name);
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
if (!param && force)
|
if (!param && force)
|
||||||
@ -423,7 +432,7 @@ ConfigParam *parseConfigFilePath(const char *name, int force)
|
|||||||
int getBoolConfigParam(const char *name, int force)
|
int getBoolConfigParam(const char *name, int force)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ConfigParam *param = getConfigParam(name);
|
struct config_param *param = config_get_param(name);
|
||||||
|
|
||||||
if (!param)
|
if (!param)
|
||||||
return CONF_BOOL_UNSET;
|
return CONF_BOOL_UNSET;
|
||||||
@ -446,10 +455,11 @@ bool config_get_bool(const char *name, bool default_value)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBoolBlockParam(ConfigParam *param, const char *name, int force)
|
int
|
||||||
|
getBoolBlockParam(struct config_param *param, const char *name, int force)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
BlockParam *bp = getBlockParam(param, name);
|
struct block_param *bp = getBlockParam(param, name);
|
||||||
|
|
||||||
if (!bp)
|
if (!bp)
|
||||||
return CONF_BOOL_UNSET;
|
return CONF_BOOL_UNSET;
|
||||||
|
43
src/conf.h
43
src/conf.h
@ -68,46 +68,57 @@
|
|||||||
#define CONF_BOOL_UNSET -1
|
#define CONF_BOOL_UNSET -1
|
||||||
#define CONF_BOOL_INVALID -2
|
#define CONF_BOOL_INVALID -2
|
||||||
|
|
||||||
typedef struct _BlockParam {
|
struct block_param {
|
||||||
char *name;
|
char *name;
|
||||||
char *value;
|
char *value;
|
||||||
int line;
|
int line;
|
||||||
} BlockParam;
|
};
|
||||||
|
|
||||||
typedef struct _ConfigParam {
|
struct config_param {
|
||||||
char *value;
|
char *value;
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
BlockParam *blockParams;
|
|
||||||
int numberOfBlockParams;
|
|
||||||
} ConfigParam;
|
|
||||||
|
|
||||||
void initConf(void);
|
struct block_param *block_params;
|
||||||
void finishConf(void);
|
int num_block_params;
|
||||||
|
};
|
||||||
|
|
||||||
void readConf(const char *file);
|
void config_global_init(void);
|
||||||
|
void config_global_finish(void);
|
||||||
|
|
||||||
|
void config_read_file(const char *file);
|
||||||
|
|
||||||
/* don't free the returned value
|
/* don't free the returned value
|
||||||
set _last_ to NULL to get first entry */
|
set _last_ to NULL to get first entry */
|
||||||
ConfigParam *getNextConfigParam(const char *name, ConfigParam * last);
|
struct config_param *
|
||||||
|
config_get_next_param(const char *name, struct config_param *last);
|
||||||
|
|
||||||
#define getConfigParam(name) getNextConfigParam(name, NULL)
|
static inline struct config_param *
|
||||||
|
config_get_param(const char *name)
|
||||||
|
{
|
||||||
|
return config_get_next_param(name, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
char *getConfigParamValue(const char *name);
|
char *getConfigParamValue(const char *name);
|
||||||
|
|
||||||
BlockParam *getBlockParam(ConfigParam * param, const char *name);
|
struct block_param *
|
||||||
|
getBlockParam(struct config_param *param, const char *name);
|
||||||
|
|
||||||
ConfigParam *parseConfigFilePath(const char *name, int force);
|
struct config_param *
|
||||||
|
parseConfigFilePath(const char *name, int force);
|
||||||
|
|
||||||
int getBoolConfigParam(const char *name, int force);
|
int getBoolConfigParam(const char *name, int force);
|
||||||
|
|
||||||
bool config_get_bool(const char *name, bool default_value);
|
bool config_get_bool(const char *name, bool default_value);
|
||||||
|
|
||||||
int getBoolBlockParam(ConfigParam *param, const char *name, int force);
|
int
|
||||||
|
getBoolBlockParam(struct config_param *param, const char *name, int force);
|
||||||
|
|
||||||
ConfigParam *newConfigParam(const char *value, int line);
|
struct config_param *
|
||||||
|
newConfigParam(const char *value, int line);
|
||||||
|
|
||||||
void config_param_free(gpointer data, gpointer user_data);
|
void config_param_free(gpointer data, gpointer user_data);
|
||||||
|
|
||||||
void addBlockParam(ConfigParam * param, const char *name, const char *value, int line);
|
void
|
||||||
|
addBlockParam(struct config_param *param, const char *name, const char *value, int line);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,7 +46,8 @@ daemonize(Options *options)
|
|||||||
{
|
{
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
ConfigParam *pidFileParam = parseConfigFilePath(CONF_PID_FILE, 0);
|
struct config_param *pidFileParam =
|
||||||
|
parseConfigFilePath(CONF_PID_FILE, 0);
|
||||||
|
|
||||||
if (pidFileParam) {
|
if (pidFileParam) {
|
||||||
/* do this before daemon'izing so we can fail gracefully if we can't
|
/* do this before daemon'izing so we can fail gracefully if we can't
|
||||||
|
@ -123,7 +123,7 @@ db_walk(const char *name,
|
|||||||
static char *
|
static char *
|
||||||
db_get_file(void)
|
db_get_file(void)
|
||||||
{
|
{
|
||||||
ConfigParam *param = parseConfigFilePath(CONF_DB_FILE, 1);
|
struct config_param *param = parseConfigFilePath(CONF_DB_FILE, 1);
|
||||||
|
|
||||||
assert(param);
|
assert(param);
|
||||||
assert(param->value);
|
assert(param->value);
|
||||||
|
@ -630,10 +630,10 @@ input_curl_easy_init(struct input_stream *is)
|
|||||||
struct input_curl *c = is->data;
|
struct input_curl *c = is->data;
|
||||||
CURLcode code;
|
CURLcode code;
|
||||||
CURLMcode mcode;
|
CURLMcode mcode;
|
||||||
ConfigParam *proxy_host;
|
struct config_param *proxy_host;
|
||||||
ConfigParam *proxy_port;
|
struct config_param *proxy_port;
|
||||||
ConfigParam *proxy_user;
|
struct config_param *proxy_user;
|
||||||
ConfigParam *proxy_pass;
|
struct config_param *proxy_pass;
|
||||||
|
|
||||||
c->eof = false;
|
c->eof = false;
|
||||||
|
|
||||||
@ -661,10 +661,10 @@ input_curl_easy_init(struct input_stream *is)
|
|||||||
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true);
|
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true);
|
||||||
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
|
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
|
||||||
|
|
||||||
proxy_host = getConfigParam(CONF_HTTP_PROXY_HOST);
|
proxy_host = config_get_param(CONF_HTTP_PROXY_HOST);
|
||||||
proxy_port = getConfigParam(CONF_HTTP_PROXY_PORT);
|
proxy_port = config_get_param(CONF_HTTP_PROXY_PORT);
|
||||||
proxy_user = getConfigParam(CONF_HTTP_PROXY_USER);
|
proxy_user = config_get_param(CONF_HTTP_PROXY_USER);
|
||||||
proxy_pass = getConfigParam(CONF_HTTP_PROXY_PASSWORD);
|
proxy_pass = config_get_param(CONF_HTTP_PROXY_PASSWORD);
|
||||||
|
|
||||||
if (proxy_host != NULL) {
|
if (proxy_host != NULL) {
|
||||||
char *proxy_host_str;
|
char *proxy_host_str;
|
||||||
|
10
src/listen.c
10
src/listen.c
@ -127,7 +127,8 @@ static bool ipv6Supported(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parseListenConfigParam(G_GNUC_UNUSED unsigned int port, ConfigParam * param)
|
parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
|
||||||
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
const struct sockaddr *addrp;
|
const struct sockaddr *addrp;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
@ -253,8 +254,9 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port, ConfigParam * param)
|
|||||||
void listenOnPort(void)
|
void listenOnPort(void)
|
||||||
{
|
{
|
||||||
int port = DEFAULT_PORT;
|
int port = DEFAULT_PORT;
|
||||||
ConfigParam *param = getNextConfigParam(CONF_BIND_TO_ADDRESS, NULL);
|
struct config_param *param =
|
||||||
ConfigParam *portParam = getConfigParam(CONF_PORT);
|
config_get_next_param(CONF_BIND_TO_ADDRESS, NULL);
|
||||||
|
struct config_param *portParam = config_get_param(CONF_PORT);
|
||||||
|
|
||||||
if (portParam) {
|
if (portParam) {
|
||||||
char *test;
|
char *test;
|
||||||
@ -271,7 +273,7 @@ void listenOnPort(void)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
parseListenConfigParam(port, param);
|
parseListenConfigParam(port, param);
|
||||||
} while ((param = getNextConfigParam(CONF_BIND_TO_ADDRESS, param)));
|
} while ((param = config_get_next_param(CONF_BIND_TO_ADDRESS, param)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeAllListenSockets(void)
|
void closeAllListenSockets(void)
|
||||||
|
@ -219,19 +219,19 @@ parse_log_level(const char *value, unsigned line)
|
|||||||
|
|
||||||
void log_init(bool verbose, bool use_stdout)
|
void log_init(bool verbose, bool use_stdout)
|
||||||
{
|
{
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
|
|
||||||
g_get_charset(&log_charset);
|
g_get_charset(&log_charset);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
log_threshold = G_LOG_LEVEL_DEBUG;
|
log_threshold = G_LOG_LEVEL_DEBUG;
|
||||||
else if ((param = getConfigParam(CONF_LOG_LEVEL)) != NULL)
|
else if ((param = config_get_param(CONF_LOG_LEVEL)) != NULL)
|
||||||
log_threshold = parse_log_level(param->value, param->line);
|
log_threshold = parse_log_level(param->value, param->line);
|
||||||
|
|
||||||
if (use_stdout) {
|
if (use_stdout) {
|
||||||
log_init_stdout();
|
log_init_stdout();
|
||||||
} else {
|
} else {
|
||||||
param = getConfigParam(CONF_LOG_FILE);
|
param = config_get_param(CONF_LOG_FILE);
|
||||||
if (param == NULL) {
|
if (param == NULL) {
|
||||||
#ifdef HAVE_SYSLOG
|
#ifdef HAVE_SYSLOG
|
||||||
/* no configuration: default to syslog (if
|
/* no configuration: default to syslog (if
|
||||||
|
12
src/main.c
12
src/main.c
@ -84,7 +84,7 @@ struct notify main_notify;
|
|||||||
static void changeToUser(void)
|
static void changeToUser(void)
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
ConfigParam *param = getConfigParam(CONF_USER);
|
struct config_param *param = config_get_param(CONF_USER);
|
||||||
|
|
||||||
if (param && strlen(param->value)) {
|
if (param && strlen(param->value)) {
|
||||||
/* get uid */
|
/* get uid */
|
||||||
@ -150,7 +150,8 @@ static void openDB(Options * options, char *argv0)
|
|||||||
|
|
||||||
static void cleanUpPidFile(void)
|
static void cleanUpPidFile(void)
|
||||||
{
|
{
|
||||||
ConfigParam *pidFileParam = parseConfigFilePath(CONF_PID_FILE, 0);
|
struct config_param *pidFileParam =
|
||||||
|
parseConfigFilePath(CONF_PID_FILE, 0);
|
||||||
|
|
||||||
if (!pidFileParam)
|
if (!pidFileParam)
|
||||||
return;
|
return;
|
||||||
@ -164,7 +165,8 @@ static void killFromPidFile(void)
|
|||||||
{
|
{
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
ConfigParam *pidFileParam = parseConfigFilePath(CONF_PID_FILE, 0);
|
struct config_param *pidFileParam =
|
||||||
|
parseConfigFilePath(CONF_PID_FILE, 0);
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
if (!pidFileParam) {
|
if (!pidFileParam) {
|
||||||
@ -234,7 +236,7 @@ int main(int argc, char *argv[])
|
|||||||
dirvec_init();
|
dirvec_init();
|
||||||
songvec_init();
|
songvec_init();
|
||||||
tag_pool_init();
|
tag_pool_init();
|
||||||
initConf();
|
config_global_init();
|
||||||
|
|
||||||
parseOptions(argc, argv, &options);
|
parseOptions(argc, argv, &options);
|
||||||
|
|
||||||
@ -343,7 +345,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
music_pipe_free();
|
music_pipe_free();
|
||||||
cleanUpPidFile();
|
cleanUpPidFile();
|
||||||
finishConf();
|
config_global_finish();
|
||||||
tag_pool_deinit();
|
tag_pool_deinit();
|
||||||
songvec_deinit();
|
songvec_deinit();
|
||||||
dirvec_deinit();
|
dirvec_deinit();
|
||||||
|
@ -43,8 +43,10 @@ static size_t playlist_dir_length;
|
|||||||
|
|
||||||
void mapper_init(void)
|
void mapper_init(void)
|
||||||
{
|
{
|
||||||
ConfigParam *music_dir_param = parseConfigFilePath(CONF_MUSIC_DIR, false);
|
struct config_param *music_dir_param =
|
||||||
ConfigParam *playlist_dir_param = parseConfigFilePath(CONF_PLAYLIST_DIR, 1);
|
parseConfigFilePath(CONF_MUSIC_DIR, false);
|
||||||
|
struct config_param *playlist_dir_param =
|
||||||
|
parseConfigFilePath(CONF_PLAYLIST_DIR, 1);
|
||||||
int ret;
|
int ret;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ alsa_mixer_finish(struct mixer_data *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
alsa_mixer_configure(struct mixer_data *data, ConfigParam *param)
|
alsa_mixer_configure(struct mixer_data *data, struct config_param *param)
|
||||||
{
|
{
|
||||||
struct alsa_mixer *am = (struct alsa_mixer *)data;
|
struct alsa_mixer *am = (struct alsa_mixer *)data;
|
||||||
BlockParam *bp;
|
struct block_param *bp;
|
||||||
|
|
||||||
if (param == NULL)
|
if (param == NULL)
|
||||||
return;
|
return;
|
||||||
@ -149,7 +149,7 @@ alsa_mixer_control(struct mixer_data *data, int cmd, void *arg)
|
|||||||
struct alsa_mixer *am = (struct alsa_mixer *)data;
|
struct alsa_mixer *am = (struct alsa_mixer *)data;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case AC_MIXER_CONFIGURE:
|
case AC_MIXER_CONFIGURE:
|
||||||
alsa_mixer_configure(data, (ConfigParam *)arg);
|
alsa_mixer_configure(data, (struct config_param *)arg);
|
||||||
if (am->handle)
|
if (am->handle)
|
||||||
alsa_mixer_close(data);
|
alsa_mixer_close(data);
|
||||||
return true;
|
return true;
|
||||||
|
@ -48,10 +48,10 @@ oss_mixer_finish(struct mixer_data *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
oss_mixer_configure(struct mixer_data *data, ConfigParam *param)
|
oss_mixer_configure(struct mixer_data *data, struct config_param *param)
|
||||||
{
|
{
|
||||||
struct oss_mixer *om = (struct oss_mixer *) data;
|
struct oss_mixer *om = (struct oss_mixer *) data;
|
||||||
BlockParam *bp;
|
struct block_param *bp;
|
||||||
|
|
||||||
if (param == NULL)
|
if (param == NULL)
|
||||||
return;
|
return;
|
||||||
@ -142,7 +142,7 @@ oss_mixer_control(struct mixer_data *data, int cmd, void *arg)
|
|||||||
struct oss_mixer *om = (struct oss_mixer *) data;
|
struct oss_mixer *om = (struct oss_mixer *) data;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case AC_MIXER_CONFIGURE:
|
case AC_MIXER_CONFIGURE:
|
||||||
oss_mixer_configure(data, (ConfigParam *)arg);
|
oss_mixer_configure(data, (struct config_param *)arg);
|
||||||
if (om->device_fd >= 0)
|
if (om->device_fd >= 0)
|
||||||
oss_mixer_close(data);
|
oss_mixer_close(data);
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,7 +20,7 @@ void mixer_finish(struct mixer *mixer)
|
|||||||
mixer->plugin = NULL;
|
mixer->plugin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mixer_configure(struct mixer *mixer, ConfigParam *param)
|
void mixer_configure(struct mixer *mixer, struct config_param *param)
|
||||||
{
|
{
|
||||||
assert(mixer != NULL && mixer->plugin != NULL);
|
assert(mixer != NULL && mixer->plugin != NULL);
|
||||||
mixer->plugin->configure(mixer->data, param);
|
mixer->plugin->configure(mixer->data, param);
|
||||||
|
@ -28,7 +28,7 @@ struct mixer_plugin {
|
|||||||
/**
|
/**
|
||||||
* Setup and configure mixer
|
* Setup and configure mixer
|
||||||
*/
|
*/
|
||||||
void (*configure)(struct mixer_data *data, ConfigParam *param);
|
void (*configure)(struct mixer_data *data, struct config_param *param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open mixer device
|
* Open mixer device
|
||||||
@ -53,7 +53,7 @@ struct mixer {
|
|||||||
|
|
||||||
void mixer_init(struct mixer *mixer, struct mixer_plugin *plugin);
|
void mixer_init(struct mixer *mixer, struct mixer_plugin *plugin);
|
||||||
void mixer_finish(struct mixer *mixer);
|
void mixer_finish(struct mixer *mixer);
|
||||||
void mixer_configure(struct mixer *mixer, ConfigParam *param);
|
void mixer_configure(struct mixer *mixer, struct config_param *param);
|
||||||
bool mixer_open(struct mixer *mixer);
|
bool mixer_open(struct mixer *mixer);
|
||||||
bool mixer_control(struct mixer *mixer, int cmd, void *arg);
|
bool mixer_control(struct mixer *mixer, int cmd, void *arg);
|
||||||
void mixer_close(struct mixer *mixer);
|
void mixer_close(struct mixer *mixer);
|
||||||
|
@ -88,9 +88,9 @@ static void freeAlsaData(AlsaData * ad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
alsa_configure(AlsaData *ad, ConfigParam *param)
|
alsa_configure(AlsaData *ad, struct config_param *param)
|
||||||
{
|
{
|
||||||
BlockParam *bp;
|
struct block_param *bp;
|
||||||
|
|
||||||
if ((bp = getBlockParam(param, "device")))
|
if ((bp = getBlockParam(param, "device")))
|
||||||
ad->device = g_strdup(bp->value);
|
ad->device = g_strdup(bp->value);
|
||||||
@ -119,9 +119,10 @@ alsa_configure(AlsaData *ad, ConfigParam *param)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *alsa_initDriver(G_GNUC_UNUSED struct audio_output *ao,
|
static void *
|
||||||
|
alsa_initDriver(G_GNUC_UNUSED struct audio_output *ao,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
ConfigParam * param)
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
/* no need for pthread_once thread-safety when reading config */
|
/* no need for pthread_once thread-safety when reading config */
|
||||||
static int free_global_registered;
|
static int free_global_registered;
|
||||||
|
@ -74,14 +74,15 @@ static void audioOutputAo_error(const char *msg)
|
|||||||
g_warning("%s: %s\n", msg, error);
|
g_warning("%s: %s\n", msg, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *audioOutputAo_initDriver(struct audio_output *ao,
|
static void *
|
||||||
|
audioOutputAo_initDriver(struct audio_output *ao,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
ConfigParam * param)
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
ao_info *ai;
|
ao_info *ai;
|
||||||
char *test;
|
char *test;
|
||||||
AoData *ad = newAoData();
|
AoData *ad = newAoData();
|
||||||
BlockParam *blockParam;
|
struct block_param *blockParam;
|
||||||
|
|
||||||
if ((blockParam = getBlockParam(param, "write_size"))) {
|
if ((blockParam = getBlockParam(param, "write_size"))) {
|
||||||
ad->writeSize = strtol(blockParam->value, &test, 10);
|
ad->writeSize = strtol(blockParam->value, &test, 10);
|
||||||
|
@ -161,10 +161,10 @@ static bool openFifo(FifoData *fd)
|
|||||||
|
|
||||||
static void *fifo_initDriver(G_GNUC_UNUSED struct audio_output *ao,
|
static void *fifo_initDriver(G_GNUC_UNUSED struct audio_output *ao,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
ConfigParam *param)
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
FifoData *fd;
|
FifoData *fd;
|
||||||
BlockParam *blockParam;
|
struct block_param *blockParam;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
blockParam = getBlockParam(param, "path");
|
blockParam = getBlockParam(param, "path");
|
||||||
|
@ -186,10 +186,10 @@ mpd_jack_error(const char *msg)
|
|||||||
static void *
|
static void *
|
||||||
mpd_jack_init(struct audio_output *ao,
|
mpd_jack_init(struct audio_output *ao,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
ConfigParam *param)
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
struct jack_data *jd;
|
struct jack_data *jd;
|
||||||
BlockParam *bp;
|
struct block_param *bp;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
int val;
|
int val;
|
||||||
char *cp = NULL;
|
char *cp = NULL;
|
||||||
|
@ -112,7 +112,7 @@ static bool mvp_testDefault(void)
|
|||||||
|
|
||||||
static void *mvp_initDriver(G_GNUC_UNUSED struct audio_output *audio_output,
|
static void *mvp_initDriver(G_GNUC_UNUSED struct audio_output *audio_output,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
G_GNUC_UNUSED ConfigParam *param)
|
G_GNUC_UNUSED struct config_param *param)
|
||||||
{
|
{
|
||||||
MvpData *md = g_new(MvpData, 1);
|
MvpData *md = g_new(MvpData, 1);
|
||||||
md->audio_output = audio_output;
|
md->audio_output = audio_output;
|
||||||
|
@ -28,7 +28,7 @@ struct null_data {
|
|||||||
static void *
|
static void *
|
||||||
null_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
null_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
G_GNUC_UNUSED ConfigParam *param)
|
G_GNUC_UNUSED struct config_param *param)
|
||||||
{
|
{
|
||||||
struct null_data *nd = g_new(struct null_data, 1);
|
struct null_data *nd = g_new(struct null_data, 1);
|
||||||
nd->timer = NULL;
|
nd->timer = NULL;
|
||||||
|
@ -344,7 +344,7 @@ static bool oss_testDefault(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *oss_open_default(ConfigParam *param)
|
static void *oss_open_default(struct config_param *param)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int err[G_N_ELEMENTS(default_devices)];
|
int err[G_N_ELEMENTS(default_devices)];
|
||||||
@ -387,12 +387,13 @@ static void *oss_open_default(ConfigParam *param)
|
|||||||
return NULL; /* some compilers can be dumb... */
|
return NULL; /* some compilers can be dumb... */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *oss_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
static void *
|
||||||
|
oss_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
ConfigParam * param)
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
if (param) {
|
if (param) {
|
||||||
BlockParam *bp = getBlockParam(param, "device");
|
struct block_param *bp = getBlockParam(param, "device");
|
||||||
if (bp) {
|
if (bp) {
|
||||||
OssData *od = newOssData();
|
OssData *od = newOssData();
|
||||||
od->device = bp->value;
|
od->device = bp->value;
|
||||||
|
@ -83,7 +83,7 @@ static bool osx_testDefault(void)
|
|||||||
static void *
|
static void *
|
||||||
osx_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
osx_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
G_GNUC_UNUSED ConfigParam * param)
|
G_GNUC_UNUSED struct config_param *param)
|
||||||
{
|
{
|
||||||
return newOsxData();
|
return newOsxData();
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,10 @@ static void pulse_free_data(struct pulse_data *pd)
|
|||||||
static void *
|
static void *
|
||||||
pulse_init(struct audio_output *ao,
|
pulse_init(struct audio_output *ao,
|
||||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||||
ConfigParam *param)
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
BlockParam *server = NULL;
|
struct block_param *server = NULL;
|
||||||
BlockParam *sink = NULL;
|
struct block_param *sink = NULL;
|
||||||
struct pulse_data *pd;
|
struct pulse_data *pd;
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
|
@ -94,7 +94,7 @@ static void free_shout_data(struct shout_data *sd)
|
|||||||
|
|
||||||
static void *my_shout_init_driver(struct audio_output *audio_output,
|
static void *my_shout_init_driver(struct audio_output *audio_output,
|
||||||
const struct audio_format *audio_format,
|
const struct audio_format *audio_format,
|
||||||
ConfigParam *param)
|
struct config_param *param)
|
||||||
{
|
{
|
||||||
struct shout_data *sd;
|
struct shout_data *sd;
|
||||||
char *test;
|
char *test;
|
||||||
@ -106,7 +106,7 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
|
|||||||
unsigned protocol;
|
unsigned protocol;
|
||||||
const char *user;
|
const char *user;
|
||||||
char *name;
|
char *name;
|
||||||
BlockParam *block_param;
|
struct block_param *block_param;
|
||||||
int public;
|
int public;
|
||||||
|
|
||||||
sd = new_shout_data();
|
sd = new_shout_data();
|
||||||
|
@ -60,7 +60,7 @@ struct audio_output_plugin {
|
|||||||
*/
|
*/
|
||||||
void *(*init)(struct audio_output *ao,
|
void *(*init)(struct audio_output *ao,
|
||||||
const struct audio_format *audio_format,
|
const struct audio_format *audio_format,
|
||||||
ConfigParam *param);
|
struct config_param *param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free resources allocated by this device.
|
* Free resources allocated by this device.
|
||||||
|
@ -29,7 +29,8 @@ struct audio_output_plugin;
|
|||||||
struct audio_format;
|
struct audio_format;
|
||||||
struct tag;
|
struct tag;
|
||||||
|
|
||||||
int audio_output_init(struct audio_output *, ConfigParam * param);
|
int
|
||||||
|
audio_output_init(struct audio_output *, struct config_param *param);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
audio_output_open(struct audio_output *audioOutput,
|
audio_output_open(struct audio_output *audioOutput,
|
||||||
|
@ -38,11 +38,12 @@
|
|||||||
if(bp) str = bp->value; \
|
if(bp) str = bp->value; \
|
||||||
}
|
}
|
||||||
|
|
||||||
int audio_output_init(struct audio_output *ao, ConfigParam * param)
|
int
|
||||||
|
audio_output_init(struct audio_output *ao, struct config_param *param)
|
||||||
{
|
{
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
BlockParam *bp = NULL;
|
struct block_param *bp = NULL;
|
||||||
const struct audio_output_plugin *plugin = NULL;
|
const struct audio_output_plugin *plugin = NULL;
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
|
@ -66,7 +66,8 @@ const char *path_get_fs_charset(void)
|
|||||||
|
|
||||||
void path_global_init(void)
|
void path_global_init(void)
|
||||||
{
|
{
|
||||||
ConfigParam *fs_charset_param = getConfigParam(CONF_FS_CHARSET);
|
struct config_param *fs_charset_param =
|
||||||
|
config_get_param(CONF_FS_CHARSET);
|
||||||
const char *charset = NULL;
|
const char *charset = NULL;
|
||||||
|
|
||||||
if (fs_charset_param) {
|
if (fs_charset_param) {
|
||||||
|
@ -71,7 +71,7 @@ void initPermissions(void)
|
|||||||
{
|
{
|
||||||
char *password;
|
char *password;
|
||||||
unsigned permission;
|
unsigned permission;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
|
|
||||||
permission_passwords = g_hash_table_new_full(g_str_hash, g_str_equal,
|
permission_passwords = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||||
g_free, NULL);
|
g_free, NULL);
|
||||||
@ -79,7 +79,7 @@ void initPermissions(void)
|
|||||||
permission_default = PERMISSION_READ | PERMISSION_ADD |
|
permission_default = PERMISSION_READ | PERMISSION_ADD |
|
||||||
PERMISSION_CONTROL | PERMISSION_ADMIN;
|
PERMISSION_CONTROL | PERMISSION_ADMIN;
|
||||||
|
|
||||||
param = getNextConfigParam(CONF_PASSWORD, NULL);
|
param = config_get_next_param(CONF_PASSWORD, NULL);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
permission_default = 0;
|
permission_default = 0;
|
||||||
@ -102,10 +102,10 @@ void initPermissions(void)
|
|||||||
g_hash_table_replace(permission_passwords,
|
g_hash_table_replace(permission_passwords,
|
||||||
password,
|
password,
|
||||||
GINT_TO_POINTER(permission));
|
GINT_TO_POINTER(permission));
|
||||||
} while ((param = getNextConfigParam(CONF_PASSWORD, param)));
|
} while ((param = config_get_next_param(CONF_PASSWORD, param)));
|
||||||
}
|
}
|
||||||
|
|
||||||
param = getConfigParam(CONF_DEFAULT_PERMS);
|
param = config_get_param(CONF_DEFAULT_PERMS);
|
||||||
|
|
||||||
if (param)
|
if (param)
|
||||||
permission_default = parsePermissions(param->value);
|
permission_default = parsePermissions(param->value);
|
||||||
|
@ -34,9 +34,9 @@ void initPlayerData(void)
|
|||||||
float perc = DEFAULT_BUFFER_BEFORE_PLAY;
|
float perc = DEFAULT_BUFFER_BEFORE_PLAY;
|
||||||
char *test;
|
char *test;
|
||||||
size_t bufferSize = DEFAULT_BUFFER_SIZE;
|
size_t bufferSize = DEFAULT_BUFFER_SIZE;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
|
|
||||||
param = getConfigParam(CONF_AUDIO_BUFFER_SIZE);
|
param = config_get_param(CONF_AUDIO_BUFFER_SIZE);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
bufferSize = strtol(param->value, &test, 10);
|
bufferSize = strtol(param->value, &test, 10);
|
||||||
@ -54,7 +54,7 @@ void initPlayerData(void)
|
|||||||
FATAL("buffer size \"%li\" is too big\n", (long)bufferSize);
|
FATAL("buffer size \"%li\" is too big\n", (long)bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
param = getConfigParam(CONF_BUFFER_BEFORE_PLAY);
|
param = config_get_param(CONF_BUFFER_BEFORE_PLAY);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
perc = strtod(param->value, &test);
|
perc = strtod(param->value, &test);
|
||||||
|
@ -120,7 +120,7 @@ static void incrPlaylistCurrent(void)
|
|||||||
void initPlaylist(void)
|
void initPlaylist(void)
|
||||||
{
|
{
|
||||||
char *test;
|
char *test;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
g_rand = g_rand_new();
|
g_rand = g_rand_new();
|
||||||
@ -132,7 +132,7 @@ void initPlaylist(void)
|
|||||||
playlist.queued = -1;
|
playlist.queued = -1;
|
||||||
playlist.current = -1;
|
playlist.current = -1;
|
||||||
|
|
||||||
param = getConfigParam(CONF_MAX_PLAYLIST_LENGTH);
|
param = config_get_param(CONF_MAX_PLAYLIST_LENGTH);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
playlist_max_length = strtol(param->value, &test, 10);
|
playlist_max_length = strtol(param->value, &test, 10);
|
||||||
|
@ -38,7 +38,7 @@ static float replay_gain_preamp = 1.0;
|
|||||||
|
|
||||||
void replay_gain_global_init(void)
|
void replay_gain_global_init(void)
|
||||||
{
|
{
|
||||||
ConfigParam *param = getConfigParam(CONF_REPLAYGAIN);
|
struct config_param *param = config_get_param(CONF_REPLAYGAIN);
|
||||||
|
|
||||||
if (!param)
|
if (!param)
|
||||||
return;
|
return;
|
||||||
@ -52,7 +52,7 @@ void replay_gain_global_init(void)
|
|||||||
param->value, param->line);
|
param->value, param->line);
|
||||||
}
|
}
|
||||||
|
|
||||||
param = getConfigParam(CONF_REPLAYGAIN_PREAMP);
|
param = config_get_param(CONF_REPLAYGAIN_PREAMP);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
char *test;
|
char *test;
|
||||||
|
@ -43,7 +43,7 @@ static const char *sfpath;
|
|||||||
|
|
||||||
static void get_state_file_path(void)
|
static void get_state_file_path(void)
|
||||||
{
|
{
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
if (sfpath)
|
if (sfpath)
|
||||||
return;
|
return;
|
||||||
param = parseConfigFilePath(CONF_STATE_FILE, 0);
|
param = parseConfigFilePath(CONF_STATE_FILE, 0);
|
||||||
|
@ -69,7 +69,7 @@ void tag_lib_init(void)
|
|||||||
char *temp;
|
char *temp;
|
||||||
char *s;
|
char *s;
|
||||||
char *c;
|
char *c;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* parse the "metadata_to_use" config parameter below */
|
/* parse the "metadata_to_use" config parameter below */
|
||||||
@ -77,7 +77,7 @@ void tag_lib_init(void)
|
|||||||
memset(ignoreTagItems, 0, TAG_NUM_OF_ITEM_TYPES);
|
memset(ignoreTagItems, 0, TAG_NUM_OF_ITEM_TYPES);
|
||||||
ignoreTagItems[TAG_ITEM_COMMENT] = 1; /* ignore comments by default */
|
ignoreTagItems[TAG_ITEM_COMMENT] = 1; /* ignore comments by default */
|
||||||
|
|
||||||
param = getConfigParam(CONF_METADATA_TO_USE);
|
param = config_get_param(CONF_METADATA_TO_USE);
|
||||||
|
|
||||||
if (!param)
|
if (!param)
|
||||||
return;
|
return;
|
||||||
|
@ -65,7 +65,7 @@ char *parsePath(char *path)
|
|||||||
const char *home;
|
const char *home;
|
||||||
|
|
||||||
if (path[1] == '/' || path[1] == '\0') {
|
if (path[1] == '/' || path[1] == '\0') {
|
||||||
ConfigParam *param = getConfigParam(CONF_USER);
|
struct config_param *param = config_get_param(CONF_USER);
|
||||||
if (param && param->value) {
|
if (param && param->value) {
|
||||||
struct passwd *passwd = getpwnam(param->value);
|
struct passwd *passwd = getpwnam(param->value);
|
||||||
if (!passwd) {
|
if (!passwd) {
|
||||||
|
10
src/volume.c
10
src/volume.c
@ -50,22 +50,22 @@ void volume_finish(void)
|
|||||||
static void
|
static void
|
||||||
mixer_reconfigure(char *driver)
|
mixer_reconfigure(char *driver)
|
||||||
{
|
{
|
||||||
ConfigParam *newparam, *param;
|
struct config_param *newparam, *param;
|
||||||
|
|
||||||
//create parameter list
|
//create parameter list
|
||||||
newparam = newConfigParam(NULL, -1);
|
newparam = newConfigParam(NULL, -1);
|
||||||
|
|
||||||
param = getConfigParam(CONF_MIXER_DEVICE);
|
param = config_get_param(CONF_MIXER_DEVICE);
|
||||||
if (param) {
|
if (param) {
|
||||||
g_warning("deprecated option mixer_device found, translating to %s config section\n", driver);
|
g_warning("deprecated option mixer_device found, translating to %s config section\n", driver);
|
||||||
addBlockParam(newparam, "mixer_device", param->value, -1);
|
addBlockParam(newparam, "mixer_device", param->value, -1);
|
||||||
}
|
}
|
||||||
param = getConfigParam(CONF_MIXER_CONTROL);
|
param = config_get_param(CONF_MIXER_CONTROL);
|
||||||
if (param) {
|
if (param) {
|
||||||
g_warning("deprecated option mixer_control found, translating to %s config section\n", driver);
|
g_warning("deprecated option mixer_control found, translating to %s config section\n", driver);
|
||||||
addBlockParam(newparam, "mixer_control", param->value, -1);
|
addBlockParam(newparam, "mixer_control", param->value, -1);
|
||||||
}
|
}
|
||||||
if (newparam->numberOfBlockParams > 0) {
|
if (newparam->num_block_params > 0) {
|
||||||
//call configure method of corrensponding mixer
|
//call configure method of corrensponding mixer
|
||||||
if (!mixer_configure_legacy(driver, newparam)) {
|
if (!mixer_configure_legacy(driver, newparam)) {
|
||||||
g_error("Using mixer_type '%s' with not enabled %s output", driver, driver);
|
g_error("Using mixer_type '%s' with not enabled %s output", driver, driver);
|
||||||
@ -77,7 +77,7 @@ mixer_reconfigure(char *driver)
|
|||||||
|
|
||||||
void volume_init(void)
|
void volume_init(void)
|
||||||
{
|
{
|
||||||
ConfigParam *param = getConfigParam(CONF_MIXER_TYPE);
|
struct config_param *param = config_get_param(CONF_MIXER_TYPE);
|
||||||
//hw mixing is by default
|
//hw mixing is by default
|
||||||
if (param) {
|
if (param) {
|
||||||
if (strcmp(param->value, VOLUME_MIXER_SOFTWARE) == 0) {
|
if (strcmp(param->value, VOLUME_MIXER_SOFTWARE) == 0) {
|
||||||
|
@ -35,7 +35,7 @@ static int zeroconfEnabled;
|
|||||||
void initZeroconf(void)
|
void initZeroconf(void)
|
||||||
{
|
{
|
||||||
const char *serviceName = SERVICE_NAME;
|
const char *serviceName = SERVICE_NAME;
|
||||||
ConfigParam *param;
|
struct config_param *param;
|
||||||
|
|
||||||
zeroconfEnabled = getBoolConfigParam(CONF_ZEROCONF_ENABLED, 1);
|
zeroconfEnabled = getBoolConfigParam(CONF_ZEROCONF_ENABLED, 1);
|
||||||
if (zeroconfEnabled == CONF_BOOL_UNSET)
|
if (zeroconfEnabled == CONF_BOOL_UNSET)
|
||||||
@ -44,7 +44,7 @@ void initZeroconf(void)
|
|||||||
if (!zeroconfEnabled)
|
if (!zeroconfEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
param = getConfigParam(CONF_ZEROCONF_NAME);
|
param = config_get_param(CONF_ZEROCONF_NAME);
|
||||||
|
|
||||||
if (param && *param->value != 0)
|
if (param && *param->value != 0)
|
||||||
serviceName = param->value;
|
serviceName = param->value;
|
||||||
|
Reference in New Issue
Block a user