* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
int (*set)(const struct config_state *cs,
const struct conf *whoami,
int nvec, char **vec);
int (*set)(const struct config_state *cs,
const struct conf *whoami,
int nvec, char **vec);
#define VALUE(C, TYPE) (*ADDRESS(C, TYPE))
static int set_signal(const struct config_state *cs,
#define VALUE(C, TYPE) (*ADDRESS(C, TYPE))
static int set_signal(const struct config_state *cs,
error(0, "%s:%d: wrong number of arguments", cs->path, cs->line);
return -1;
}
error(0, "%s:%d: wrong number of arguments", cs->path, cs->line);
return -1;
}
- if (xstrtol(&t, p, &p, 0)) {
+ if(xstrtol(&t, p, &p, 0)) {
error(errno, "%s:%d: converting bits-per-sample", cs->path, cs->line);
return -1;
}
error(errno, "%s:%d: converting bits-per-sample", cs->path, cs->line);
return -1;
}
error(0, "%s:%d: bad bite-per-sample (%ld)", cs->path, cs->line, t);
return -1;
}
error(0, "%s:%d: bad bite-per-sample (%ld)", cs->path, cs->line, t);
return -1;
}
- case 'l': case 'L': t = AO_FMT_LITTLE; p++; break;
- case 'b': case 'B': t = AO_FMT_BIG; p++; break;
- default: t = AO_FMT_NATIVE; break;
+ case 'l': case 'L': t = ENDIAN_LITTLE; p++; break;
+ case 'b': case 'B': t = ENDIAN_BIG; p++; break;
+ default: t = ENDIAN_NATIVE; break;
- if (xstrtol(&t, p, &p, 0)) {
+ if(xstrtol(&t, p, &p, 0)) {
error(errno, "%s:%d: converting sample-rate", cs->path, cs->line);
return -1;
}
error(errno, "%s:%d: converting sample-rate", cs->path, cs->line);
return -1;
}
error(0, "%s:%d: silly sample-rate (%ld)", cs->path, cs->line, t);
return -1;
}
error(0, "%s:%d: silly sample-rate (%ld)", cs->path, cs->line, t);
return -1;
}
- if (xstrtol(&t, p, &p, 0)) {
+ if(xstrtol(&t, p, &p, 0)) {
error(errno, "%s:%d: converting channels", cs->path, cs->line);
return -1;
}
error(errno, "%s:%d: converting channels", cs->path, cs->line);
return -1;
}
error(0, "%s:%d: silly number (%ld) of channels", cs->path, cs->line, t);
return -1;
}
error(0, "%s:%d: silly number (%ld) of channels", cs->path, cs->line, t);
return -1;
}
error(0, "%s:%d: junk after channels", cs->path, cs->line);
return -1;
}
error(0, "%s:%d: junk after channels", cs->path, cs->line);
return -1;
}
static int set_sample_format(const struct config_state *cs,
const struct conf *whoami,
int nvec, char **vec) {
static int set_sample_format(const struct config_state *cs,
const struct conf *whoami,
int nvec, char **vec) {
- return parse_sample_format(cs, ADDRESS(cs->config, ao_sample_format),
+ return parse_sample_format(cs, ADDRESS(cs->config, struct stream_header),
#define C2(x,y) #x, offsetof(struct config, y)
#define C2(x,y) #x, offsetof(struct config, y)
static const struct conf conf[] = {
{ C(alias), &type_string, validate_alias },
{ C(allow), &type_stringlist_accum, validate_allow },
{ C(broadcast), &type_stringlist, validate_addrport },
static const struct conf conf[] = {
{ C(alias), &type_string, validate_alias },
{ C(allow), &type_stringlist_accum, validate_allow },
{ C(broadcast), &type_stringlist, validate_addrport },
- { C(broadcast_from), &type_stringlist, validate_address },
+ { C(broadcast_from), &type_stringlist, validate_addrport },
{ C(channel), &type_string, validate_channel },
{ C(checkpoint_kbyte), &type_integer, validate_non_negative },
{ C(checkpoint_min), &type_integer, validate_non_negative },
{ C(channel), &type_string, validate_channel },
{ C(checkpoint_kbyte), &type_integer, validate_non_negative },
{ C(checkpoint_min), &type_integer, validate_non_negative },
{ C(gap), &type_integer, validate_non_negative },
{ C(history), &type_integer, validate_positive },
{ C(home), &type_string, validate_isdir },
{ C(gap), &type_integer, validate_non_negative },
{ C(history), &type_integer, validate_positive },
{ C(home), &type_string, validate_isdir },
- { C(listen), &type_stringlist, validate_addrport },
+ { C(listen), &type_stringlist, validate_port },
{ C(lock), &type_boolean, validate_any },
{ C(mixer), &type_string, validate_ischr },
{ C(lock), &type_boolean, validate_any },
{ C(mixer), &type_string, validate_ischr },
{ C(namepart), &type_namepart, validate_any },
{ C2(nice, nice_rescan), &type_integer, validate_non_negative },
{ C(nice_rescan), &type_integer, validate_non_negative },
{ C(namepart), &type_namepart, validate_any },
{ C2(nice, nice_rescan), &type_integer, validate_non_negative },
{ C(nice_rescan), &type_integer, validate_non_negative },
{ C(username), &type_string, validate_any },
};
{ C(username), &type_string, validate_any },
};
static int config_set(const struct config_state *cs,
int nvec, char **vec) {
const struct conf *which;
static int config_set(const struct config_state *cs,
int nvec, char **vec) {
const struct conf *which;
|| which->type->set(cs, which, nvec - 1, vec + 1));
}
|| which->type->set(cs, which, nvec - 1, vec + 1));
}
static void config_error(const char *msg, void *u) {
const struct config_state *cs = u;
error(0, "%s:%d: %s", cs->path, cs->line, msg);
}
static void config_error(const char *msg, void *u) {
const struct config_state *cs = u;
error(0, "%s:%d: %s", cs->path, cs->line, msg);
}
static int config_include(struct config *c, const char *path) {
FILE *fp;
char *buffer, *inputbuffer, **vec;
static int config_include(struct config *c, const char *path) {
FILE *fp;
char *buffer, *inputbuffer, **vec;
c->sample_format.bits = 16;
c->sample_format.rate = 44100;
c->sample_format.channels = 2;
c->sample_format.bits = 16;
c->sample_format.rate = 44100;
c->sample_format.channels = 2;
static void set_configfile(void) {
if(!configfile)
byte_xasprintf(&configfile, "%s/config", pkgconfdir);
}
static void set_configfile(void) {
if(!configfile)
byte_xasprintf(&configfile, "%s/config", pkgconfdir);
}
fatal(0, "speaker_backend is command but speaker_command is not set");
if(c->speaker_backend == BACKEND_NETWORK && !c->broadcast.n)
fatal(0, "speaker_backend is network but broadcast is not set");
fatal(0, "speaker_backend is command but speaker_command is not set");
if(c->speaker_backend == BACKEND_NETWORK && !c->broadcast.n)
fatal(0, "speaker_backend is network but broadcast is not set");
+ if(c->speaker_backend) {
+ /* Override sample format */
+ c->sample_format.rate = 44100;
+ c->sample_format.channels = 2;
+ c->sample_format.bits = 16;
+ c->sample_format.endian = ENDIAN_BIG;
+ }
- if(config_include(c, configfile))
- return -1;
+ /* standalone Disobedience installs might not have a global config file */
+ if(access(configfile, F_OK) == 0)
+ if(config_include(c, configfile))
+ return -1;
/* if we can read the private config file, do */
if((privconf = config_private())
&& access(privconf, R_OK) == 0
/* if we can read the private config file, do */
if((privconf = config_private())
&& access(privconf, R_OK) == 0