alsaloop: add -z,--syslog option to use syslog for errors

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2013-07-26 16:16:00 +02:00
parent 719faff809
commit 87bcda4b8a

View file

@ -195,6 +195,7 @@ void help(void)
"-w,--workaround use workaround (serialopen)\n" "-w,--workaround use workaround (serialopen)\n"
"-U,--xrun xrun profiling\n" "-U,--xrun xrun profiling\n"
"-W,--wake process wake timeout in ms\n" "-W,--wake process wake timeout in ms\n"
"-z,--syslog use syslog for errors\n"
); );
printf("\nRecognized sample formats are:"); printf("\nRecognized sample formats are:");
for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) { for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
@ -334,6 +335,14 @@ static int add_oss_mixers(struct loopback *loop,
return 0; return 0;
} }
static void enable_syslog(void)
{
if (!use_syslog) {
use_syslog = 1;
openlog("alsaloop", LOG_NDELAY|LOG_PID, LOG_DAEMON);
}
}
static int parse_config_file(const char *file, snd_output_t *output); static int parse_config_file(const char *file, snd_output_t *output);
static int parse_config(int argc, char *argv[], snd_output_t *output, static int parse_config(int argc, char *argv[], snd_output_t *output,
@ -368,6 +377,7 @@ static int parse_config(int argc, char *argv[], snd_output_t *output,
{"ossmixer", 1, NULL, 'O'}, {"ossmixer", 1, NULL, 'O'},
{"workaround", 1, NULL, 'w'}, {"workaround", 1, NULL, 'w'},
{"xrun", 0, NULL, 'U'}, {"xrun", 0, NULL, 'U'},
{"syslog", 0, NULL, 'z'},
{NULL, 0, NULL, 0}, {NULL, 0, NULL, 0},
}; };
int err, morehelp; int err, morehelp;
@ -405,7 +415,7 @@ static int parse_config(int argc, char *argv[], snd_output_t *output,
while (1) { while (1) {
int c; int c;
if ((c = getopt_long(argc, argv, if ((c = getopt_long(argc, argv,
"hdg:P:C:X:Y:l:t:F:f:c:r:s:benvA:S:a:m:T:O:w:UW:", "hdg:P:C:X:Y:l:t:F:f:c:r:s:benvA:S:a:m:T:O:w:UW:z",
long_option, NULL)) < 0) long_option, NULL)) < 0)
break; break;
switch (c) { switch (c) {
@ -417,8 +427,7 @@ static int parse_config(int argc, char *argv[], snd_output_t *output,
break; break;
case 'd': case 'd':
daemonize = 1; daemonize = 1;
use_syslog = 1; enable_syslog();
openlog("alsaloop", LOG_NDELAY|LOG_PID, LOG_DAEMON);
break; break;
case 'P': case 'P':
arg_pdevice = strdup(optarg); arg_pdevice = strdup(optarg);
@ -561,6 +570,9 @@ static int parse_config(int argc, char *argv[], snd_output_t *output,
if (cmdline) if (cmdline)
arg_default_wake = arg_wake; arg_default_wake = arg_wake;
break; break;
case 'z':
enable_syslog();
break;
} }
} }