conf: const pointers in block get functions
All config_get_block_*() functions should accept constant config_param pointers.
This commit is contained in:
parent
80799fa84e
commit
5f77910097
@ -43,7 +43,7 @@ static unsigned int audioOutputArraySize;
|
||||
unsigned int audio_output_count(void)
|
||||
{
|
||||
unsigned int nr = 0;
|
||||
struct config_param *param = NULL;
|
||||
const struct config_param *param = NULL;
|
||||
|
||||
while ((param = config_get_next_param(CONF_AUDIO_OUTPUT, param)))
|
||||
nr++;
|
||||
@ -55,7 +55,7 @@ unsigned int audio_output_count(void)
|
||||
/* make sure initPlayerData is called before this function!! */
|
||||
void initAudioDriver(void)
|
||||
{
|
||||
struct config_param *param = NULL;
|
||||
const struct config_param *param = NULL;
|
||||
unsigned int i;
|
||||
|
||||
notify_init(&audio_output_client_notify);
|
||||
@ -106,7 +106,7 @@ void getOutputAudioFormat(const struct audio_format *inAudioFormat,
|
||||
|
||||
void initAudioConfig(void)
|
||||
{
|
||||
struct config_param *param = config_get_param(CONF_AUDIO_OUTPUT_FORMAT);
|
||||
const struct config_param *param = config_get_param(CONF_AUDIO_OUTPUT_FORMAT);
|
||||
|
||||
if (NULL == param || NULL == param->value)
|
||||
return;
|
||||
|
16
src/conf.c
16
src/conf.c
@ -350,7 +350,7 @@ void config_read_file(const char *file)
|
||||
}
|
||||
|
||||
struct config_param *
|
||||
config_get_next_param(const char *name, struct config_param * last)
|
||||
config_get_next_param(const char *name, const struct config_param * last)
|
||||
{
|
||||
struct config_entry *entry;
|
||||
GSList *node;
|
||||
@ -381,7 +381,7 @@ config_get_next_param(const char *name, struct config_param * last)
|
||||
const char *
|
||||
config_get_string(const char *name, const char *default_value)
|
||||
{
|
||||
struct config_param *param = config_get_param(name);
|
||||
const struct config_param *param = config_get_param(name);
|
||||
|
||||
if (param == NULL)
|
||||
return default_value;
|
||||
@ -410,7 +410,7 @@ config_get_path(const char *name)
|
||||
unsigned
|
||||
config_get_positive(const char *name, unsigned default_value)
|
||||
{
|
||||
struct config_param *param = config_get_param(name);
|
||||
const struct config_param *param = config_get_param(name);
|
||||
long value;
|
||||
char *endptr;
|
||||
|
||||
@ -428,7 +428,7 @@ config_get_positive(const char *name, unsigned default_value)
|
||||
}
|
||||
|
||||
struct block_param *
|
||||
getBlockParam(struct config_param * param, const char *name)
|
||||
getBlockParam(const struct config_param * param, const char *name)
|
||||
{
|
||||
struct block_param *ret = NULL;
|
||||
int i;
|
||||
@ -449,7 +449,7 @@ getBlockParam(struct config_param * param, const char *name)
|
||||
|
||||
bool config_get_bool(const char *name, bool default_value)
|
||||
{
|
||||
struct config_param *param = config_get_param(name);
|
||||
const struct config_param *param = config_get_param(name);
|
||||
int value;
|
||||
|
||||
if (param == NULL)
|
||||
@ -468,7 +468,7 @@ bool config_get_bool(const char *name, bool default_value)
|
||||
}
|
||||
|
||||
const char *
|
||||
config_get_block_string(struct config_param *param, const char *name,
|
||||
config_get_block_string(const struct config_param *param, const char *name,
|
||||
const char *default_value)
|
||||
{
|
||||
struct block_param *bp = getBlockParam(param, name);
|
||||
@ -480,7 +480,7 @@ config_get_block_string(struct config_param *param, const char *name,
|
||||
}
|
||||
|
||||
unsigned
|
||||
config_get_block_unsigned(struct config_param *param, const char *name,
|
||||
config_get_block_unsigned(const struct config_param *param, const char *name,
|
||||
unsigned default_value)
|
||||
{
|
||||
struct block_param *bp = getBlockParam(param, name);
|
||||
@ -501,7 +501,7 @@ config_get_block_unsigned(struct config_param *param, const char *name,
|
||||
}
|
||||
|
||||
bool
|
||||
config_get_block_bool(struct config_param *param, const char *name,
|
||||
config_get_block_bool(const struct config_param *param, const char *name,
|
||||
bool default_value)
|
||||
{
|
||||
struct block_param *bp = getBlockParam(param, name);
|
||||
|
12
src/conf.h
12
src/conf.h
@ -94,7 +94,7 @@ void config_read_file(const char *file);
|
||||
/* don't free the returned value
|
||||
set _last_ to NULL to get first entry */
|
||||
struct config_param *
|
||||
config_get_next_param(const char *name, struct config_param *last);
|
||||
config_get_next_param(const char *name, const struct config_param *last);
|
||||
|
||||
static inline struct config_param *
|
||||
config_get_param(const char *name)
|
||||
@ -117,27 +117,27 @@ unsigned
|
||||
config_get_positive(const char *name, unsigned default_value);
|
||||
|
||||
struct block_param *
|
||||
getBlockParam(struct config_param *param, const char *name);
|
||||
getBlockParam(const struct config_param *param, const char *name);
|
||||
|
||||
bool config_get_bool(const char *name, bool default_value);
|
||||
|
||||
const char *
|
||||
config_get_block_string(struct config_param *param, const char *name,
|
||||
config_get_block_string(const struct config_param *param, const char *name,
|
||||
const char *default_value);
|
||||
|
||||
static inline char *
|
||||
config_dup_block_string(struct config_param *param, const char *name,
|
||||
config_dup_block_string(const struct config_param *param, const char *name,
|
||||
const char *default_value)
|
||||
{
|
||||
return g_strdup(config_get_block_string(param, name, default_value));
|
||||
}
|
||||
|
||||
unsigned
|
||||
config_get_block_unsigned(struct config_param *param, const char *name,
|
||||
config_get_block_unsigned(const struct config_param *param, const char *name,
|
||||
unsigned default_value);
|
||||
|
||||
bool
|
||||
config_get_block_bool(struct config_param *param, const char *name,
|
||||
config_get_block_bool(const struct config_param *param, const char *name,
|
||||
bool default_value);
|
||||
|
||||
struct config_param *
|
||||
|
@ -128,7 +128,7 @@ static bool ipv6Supported(void)
|
||||
|
||||
static void
|
||||
parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
const struct sockaddr *addrp;
|
||||
socklen_t addrlen;
|
||||
@ -254,7 +254,7 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port,
|
||||
void listenOnPort(void)
|
||||
{
|
||||
int port = config_get_positive(CONF_PORT, DEFAULT_PORT);
|
||||
struct config_param *param =
|
||||
const struct config_param *param =
|
||||
config_get_next_param(CONF_BIND_TO_ADDRESS, NULL);
|
||||
|
||||
do {
|
||||
|
@ -219,7 +219,7 @@ parse_log_level(const char *value, unsigned line)
|
||||
|
||||
void log_init(bool verbose, bool use_stdout)
|
||||
{
|
||||
struct config_param *param;
|
||||
const struct config_param *param;
|
||||
|
||||
g_get_charset(&log_charset);
|
||||
|
||||
@ -252,9 +252,8 @@ void log_init(bool verbose, bool use_stdout)
|
||||
if (path == NULL)
|
||||
g_error("error parsing \"%s\" at line %i\n",
|
||||
CONF_LOG_FILE, param->line);
|
||||
param->value = path;
|
||||
|
||||
log_init_file(param->value, param->line);
|
||||
log_init_file(path, param->line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ static void openDB(Options * options, char *argv0)
|
||||
static void
|
||||
initialize_decoder_and_player(void)
|
||||
{
|
||||
struct config_param *param;
|
||||
const struct config_param *param;
|
||||
char *test;
|
||||
size_t buffer_size;
|
||||
float perc;
|
||||
|
@ -43,7 +43,7 @@ alsa_mixer_finish(struct mixer_data *data)
|
||||
}
|
||||
|
||||
static void
|
||||
alsa_mixer_configure(struct mixer_data *data, struct config_param *param)
|
||||
alsa_mixer_configure(struct mixer_data *data, const struct config_param *param)
|
||||
{
|
||||
struct alsa_mixer *am = (struct alsa_mixer *)data;
|
||||
const char *value;
|
||||
@ -149,7 +149,7 @@ alsa_mixer_control(struct mixer_data *data, int cmd, void *arg)
|
||||
struct alsa_mixer *am = (struct alsa_mixer *)data;
|
||||
switch (cmd) {
|
||||
case AC_MIXER_CONFIGURE:
|
||||
alsa_mixer_configure(data, (struct config_param *)arg);
|
||||
alsa_mixer_configure(data, (const struct config_param *)arg);
|
||||
if (am->handle)
|
||||
alsa_mixer_close(data);
|
||||
return true;
|
||||
|
@ -47,7 +47,7 @@ oss_mixer_finish(struct mixer_data *data)
|
||||
}
|
||||
|
||||
static void
|
||||
oss_mixer_configure(struct mixer_data *data, struct config_param *param)
|
||||
oss_mixer_configure(struct mixer_data *data, const struct config_param *param)
|
||||
{
|
||||
struct oss_mixer *om = (struct oss_mixer *) data;
|
||||
const char *value;
|
||||
@ -140,7 +140,7 @@ oss_mixer_control(struct mixer_data *data, int cmd, void *arg)
|
||||
struct oss_mixer *om = (struct oss_mixer *) data;
|
||||
switch (cmd) {
|
||||
case AC_MIXER_CONFIGURE:
|
||||
oss_mixer_configure(data, (struct config_param *)arg);
|
||||
oss_mixer_configure(data, (const struct config_param *)arg);
|
||||
if (om->device_fd >= 0)
|
||||
oss_mixer_close(data);
|
||||
return true;
|
||||
|
@ -20,7 +20,7 @@ void mixer_finish(struct mixer *mixer)
|
||||
mixer->plugin = NULL;
|
||||
}
|
||||
|
||||
void mixer_configure(struct mixer *mixer, struct config_param *param)
|
||||
void mixer_configure(struct mixer *mixer, const struct config_param *param)
|
||||
{
|
||||
assert(mixer != NULL && mixer->plugin != NULL);
|
||||
mixer->plugin->configure(mixer->data, param);
|
||||
|
@ -28,7 +28,8 @@ struct mixer_plugin {
|
||||
/**
|
||||
* Setup and configure mixer
|
||||
*/
|
||||
void (*configure)(struct mixer_data *data, struct config_param *param);
|
||||
void (*configure)(struct mixer_data *data,
|
||||
const struct config_param *param);
|
||||
|
||||
/**
|
||||
* Open mixer device
|
||||
@ -53,7 +54,7 @@ struct mixer {
|
||||
|
||||
void mixer_init(struct mixer *mixer, struct mixer_plugin *plugin);
|
||||
void mixer_finish(struct mixer *mixer);
|
||||
void mixer_configure(struct mixer *mixer, struct config_param *param);
|
||||
void mixer_configure(struct mixer *mixer, const struct config_param *param);
|
||||
bool mixer_open(struct mixer *mixer);
|
||||
bool mixer_control(struct mixer *mixer, int cmd, void *arg);
|
||||
void mixer_close(struct mixer *mixer);
|
||||
|
@ -108,7 +108,7 @@ alsa_data_free(struct alsa_data *ad)
|
||||
}
|
||||
|
||||
static void
|
||||
alsa_configure(struct alsa_data *ad, struct config_param *param)
|
||||
alsa_configure(struct alsa_data *ad, const struct config_param *param)
|
||||
{
|
||||
ad->device = config_dup_block_string(param, "device", NULL);
|
||||
|
||||
@ -138,7 +138,7 @@ alsa_configure(struct alsa_data *ad, struct config_param *param)
|
||||
static void *
|
||||
alsa_init(G_GNUC_UNUSED struct audio_output *ao,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
/* no need for pthread_once thread-safety when reading config */
|
||||
static int free_global_registered;
|
||||
|
@ -77,7 +77,7 @@ static void audioOutputAo_error(const char *msg)
|
||||
static void *
|
||||
audioOutputAo_initDriver(struct audio_output *ao,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
ao_info *ai;
|
||||
AoData *ad = newAoData();
|
||||
|
@ -161,7 +161,7 @@ static bool openFifo(FifoData *fd)
|
||||
|
||||
static void *fifo_initDriver(G_GNUC_UNUSED struct audio_output *ao,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
FifoData *fd;
|
||||
char *value, *path;
|
||||
|
@ -183,7 +183,7 @@ mpd_jack_error(const char *msg)
|
||||
static void *
|
||||
mpd_jack_init(struct audio_output *ao,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
struct jack_data *jd;
|
||||
const char *value;
|
||||
|
@ -112,7 +112,7 @@ static bool mvp_testDefault(void)
|
||||
|
||||
static void *mvp_initDriver(G_GNUC_UNUSED struct audio_output *audio_output,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
G_GNUC_UNUSED struct config_param *param)
|
||||
G_GNUC_UNUSED const struct config_param *param)
|
||||
{
|
||||
MvpData *md = g_new(MvpData, 1);
|
||||
md->audio_output = audio_output;
|
||||
|
@ -32,7 +32,7 @@ struct null_data {
|
||||
static void *
|
||||
null_init(G_GNUC_UNUSED struct audio_output *audio_output,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
G_GNUC_UNUSED struct config_param *param)
|
||||
G_GNUC_UNUSED const struct config_param *param)
|
||||
{
|
||||
struct null_data *nd = g_new(struct null_data, 1);
|
||||
|
||||
|
@ -344,7 +344,7 @@ static bool oss_testDefault(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void *oss_open_default(struct config_param *param)
|
||||
static void *oss_open_default(const struct config_param *param)
|
||||
{
|
||||
int i;
|
||||
int err[G_N_ELEMENTS(default_devices)];
|
||||
@ -390,7 +390,7 @@ static void *oss_open_default(struct config_param *param)
|
||||
static void *
|
||||
oss_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
if (param) {
|
||||
const char *device =
|
||||
|
@ -83,7 +83,7 @@ static bool osx_testDefault(void)
|
||||
static void *
|
||||
osx_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
G_GNUC_UNUSED struct config_param *param)
|
||||
G_GNUC_UNUSED const struct config_param *param)
|
||||
{
|
||||
return newOsxData();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ static void pulse_free_data(struct pulse_data *pd)
|
||||
static void *
|
||||
pulse_init(struct audio_output *ao,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
struct pulse_data *pd;
|
||||
|
||||
|
@ -94,7 +94,7 @@ static void free_shout_data(struct shout_data *sd)
|
||||
|
||||
static void *my_shout_init_driver(struct audio_output *audio_output,
|
||||
const struct audio_format *audio_format,
|
||||
struct config_param *param)
|
||||
const struct config_param *param)
|
||||
{
|
||||
struct shout_data *sd;
|
||||
char *test;
|
||||
|
@ -60,7 +60,7 @@ struct audio_output_plugin {
|
||||
*/
|
||||
void *(*init)(struct audio_output *ao,
|
||||
const struct audio_format *audio_format,
|
||||
struct config_param *param);
|
||||
const struct config_param *param);
|
||||
|
||||
/**
|
||||
* Free resources allocated by this device.
|
||||
|
@ -29,7 +29,7 @@ struct tag;
|
||||
struct config_param;
|
||||
|
||||
int
|
||||
audio_output_init(struct audio_output *, struct config_param *param);
|
||||
audio_output_init(struct audio_output *, const struct config_param *param);
|
||||
|
||||
bool
|
||||
audio_output_open(struct audio_output *audioOutput,
|
||||
|
@ -39,7 +39,7 @@
|
||||
}
|
||||
|
||||
int
|
||||
audio_output_init(struct audio_output *ao, struct config_param *param)
|
||||
audio_output_init(struct audio_output *ao, const struct config_param *param)
|
||||
{
|
||||
const char *name = NULL;
|
||||
char *format = NULL;
|
||||
|
@ -71,7 +71,7 @@ void initPermissions(void)
|
||||
{
|
||||
char *password;
|
||||
unsigned permission;
|
||||
struct config_param *param;
|
||||
const struct config_param *param;
|
||||
|
||||
permission_passwords = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
|
@ -38,7 +38,7 @@ static float replay_gain_preamp = 1.0;
|
||||
|
||||
void replay_gain_global_init(void)
|
||||
{
|
||||
struct config_param *param = config_get_param(CONF_REPLAYGAIN);
|
||||
const struct config_param *param = config_get_param(CONF_REPLAYGAIN);
|
||||
|
||||
if (!param)
|
||||
return;
|
||||
|
@ -76,7 +76,7 @@ void tag_lib_init(void)
|
||||
char *temp;
|
||||
char *s;
|
||||
char *c;
|
||||
struct config_param *param;
|
||||
const struct config_param *param;
|
||||
int i;
|
||||
|
||||
/* parse the "metadata_to_use" config parameter below */
|
||||
|
@ -77,7 +77,7 @@ mixer_reconfigure(char *driver)
|
||||
|
||||
void volume_init(void)
|
||||
{
|
||||
struct config_param *param = config_get_param(CONF_MIXER_TYPE);
|
||||
const struct config_param *param = config_get_param(CONF_MIXER_TYPE);
|
||||
//hw mixing is by default
|
||||
if (param) {
|
||||
if (strcmp(param->value, VOLUME_MIXER_SOFTWARE) == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user