int main(int argc, char **argv) { signal_setup(); memset(&config, 0, sizeof(config)); // set defaults config.buffer_start_fill = 220; config.port = 5002; char hostname[100]; gethostname(hostname, 100); config.apname = malloc(20 + 100); snprintf(config.apname, 20 + 100, "Shairport on %s", hostname); // parse arguments into config int audio_arg = parse_options(argc, argv); // mDNS supports maximum of 63-character names (we append 13). if (strlen(config.apname) > 50) die("Supplied name too long (max 50 characters)"); if (config.daemonise) { daemon_init(); } log_setup(); config.output = audio_get_output(config.output_name); if (!config.output) { audio_ls_outputs(); die("Invalid audio output specified!"); } config.output->init(argc-audio_arg, argv+audio_arg); uint8_t ap_md5[16]; MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, config.apname, strlen(config.apname)); MD5_Final(ap_md5, &ctx); memcpy(config.hw_addr, ap_md5, sizeof(config.hw_addr)); rtsp_listen_loop(); // should not. shairport_shutdown(1); return 1; }
void usage(char *progname) { printf("Usage: %s [options...]\n", progname); printf(" or: %s [options...] -- [audio output-specific options]\n", progname); printf("\n"); printf("Mandatory arguments to long options are mandatory for short options too.\n"); printf("\n"); printf("Options:\n"); printf(" -h, --help show this help\n"); printf(" -p, --port=PORT set RTSP listening port\n"); printf(" -a, --name=NAME set advertised name\n"); printf(" -k, --password=PW require password to stream audio\n"); printf(" -b FILL set how full the buffer must be before audio output\n"); printf(" starts. This value is in frames; default %d\n", config.buffer_start_fill); printf(" -d, --daemon fork (daemonise). The PID of the child process is\n"); printf(" written to stdout, unless a pidfile is used.\n"); printf(" -P, --pidfile=FILE write daemon's pid to FILE on startup.\n"); printf(" Has no effect if -d is not specified\n"); printf(" -l, --log=FILE redirect shairport's standard output to FILE\n"); printf(" If --error is not specified, it also redirects\n"); printf(" error output to FILE\n"); printf(" -e, --error=FILE redirect shairport's standard error output to FILE\n"); printf(" -B, --on-start=COMMAND run a shell command when playback begins\n"); printf(" -E, --on-stop=COMMAND run a shell command when playback ends\n"); printf(" -w, --wait-cmd block while the shell command(s) run\n"); printf(" -M, --meta-dir=DIR set a directory to write metadata and album cover art to\n"); printf(" -o, --output=BACKEND select audio output method\n"); printf(" -m, --mdns=BACKEND force the use of BACKEND to advertise the service\n"); printf(" if no mdns provider is specified,\n"); printf(" shairport tries them all until one works.\n"); printf("\n"); mdns_ls_backends(); printf("\n"); audio_ls_outputs(); }
void usage(char *progname) { printf("Usage: %s [options...]\n", progname); printf(" or: %s [options...] -- [audio output-specific options]\n", progname); printf("\n"); printf("Options:\n"); printf(" -h, --help show this help.\n"); printf(" -d, --daemon daemonise.\n"); printf(" -V, --version show version information.\n"); printf(" -k, --kill kill the existing shairport daemon.\n"); printf(" -D, --disconnectFromOutput disconnect immediately from the output device.\n"); printf(" -R, --reconnectToOutput reconnect to the output device.\n"); printf(" -c, --configfile=FILE read configuration settings from FILE. Default is " "/etc/shairport-sync.conf.\n"); printf("\n"); printf("The following general options are for backward compatability. These and all new options have settings in the configuration file, by default /etc/shairport-sync.conf:\n"); printf(" -v, --verbose -v print debug information; -vv more; -vvv lots.\n"); printf(" -p, --port=PORT set RTSP listening port.\n"); printf(" -a, --name=NAME set advertised name.\n"); printf( " -A, --AirPlayLatency=FRAMES [Deprecated] Set the latency for audio sent from an AirPlay device.\n"); printf(" The default is to set it automatically.\n"); printf( " -i, --iTunesLatency=FRAMES [Deprecated] Set the latency for audio sent from iTunes 10 or later.\n"); printf(" The default is to set it automatically.\n"); printf(" -L, --latency=FRAMES [Deprecated] Set the latency for audio sent from an unknown device.\n"); printf(" The default is to set it automatically.\n"); printf(" --forkedDaapdLatency=FRAMES [Deprecated] Set the latency for audio sent from forked-daapd.\n"); printf(" The default is to set it automatically.\n"); printf(" -S, --stuffing=MODE set how to adjust current latency to match desired latency, where \n"); printf(" \"basic\" (default) inserts or deletes audio frames from " "packet frames with low processor overhead, and \n"); printf(" \"soxr\" uses libsoxr to minimally resample packet frames -- " "moderate processor overhead.\n"); printf( " \"soxr\" option only available if built with soxr support.\n"); printf(" -B, --on-start=PROGRAM run PROGRAM when playback is about to begin.\n"); printf(" -E, --on-stop=PROGRAM run PROGRAM when playback has ended.\n"); printf(" For -B and -E options, specify the full path to the program, " "e.g. /usr/bin/logger.\n"); printf(" Executable scripts work, but must have #!/bin/sh (or " "whatever) in the headline.\n"); printf(" -w, --wait-cmd wait until the -B or -E programs finish before continuing.\n"); printf(" -o, --output=BACKEND select audio output method.\n"); printf(" -m, --mdns=BACKEND force the use of BACKEND to advertize the service.\n"); printf(" if no mdns provider is specified,\n"); printf(" shairport tries them all until one works.\n"); printf(" -r, --resync=THRESHOLD resync if error exceeds this number of frames. Set to 0 to " "stop resyncing.\n"); printf(" -t, --timeout=SECONDS go back to idle mode from play mode after a break in " "communications of this many seconds (default 120). Set to 0 never to exit play mode.\n"); printf(" --statistics print some interesting statistics -- output to the logfile " "if running as a daemon.\n"); printf(" --tolerance=TOLERANCE allow a synchronization error of TOLERANCE frames (default " "88) before trying to correct it.\n"); printf(" --password=PASSWORD require PASSWORD to connect. Default is not to require a " "password.\n"); #ifdef CONFIG_METADATA printf(" --metadata-pipename=PIPE send metadata to PIPE, e.g. " "--metadata-pipename=/tmp/shairport-sync-metadata.\n"); printf(" The default is /tmp/shairport-sync-metadata.\n"); printf(" --get-coverart send cover art through the metadata pipe.\n"); #endif printf("\n"); mdns_ls_backends(); printf("\n"); audio_ls_outputs(); }
int main(int argc, char **argv) { /* struct mpd_connection *conn = NULL; conn = mpd_connection_new(NULL, 0, 3000); if (conn == NULL) {printf("%s", "Out of memory"); return -1;} mpd_run_stop(conn); mpd_connection_free(conn); */ signal_setup(); memset(&config, 0, sizeof(config)); // set defaults config.buffer_start_fill = 220; config.port = 5002; char hostname[100]; gethostname(hostname, 100); config.apname = malloc(20 + 100); snprintf(config.apname, 20 + 100, "%s", hostname); // parse arguments into config int audio_arg = parse_options(argc, argv); // mDNS supports maximum of 63-character names (we append 13). if (strlen(config.apname) > 50) die("Supplied name too long (max 50 characters)"); if (config.daemonise) { daemon_init(); } if(ggshutdown) { if (kill(0, SIGTERM)) { printf("kill(0, SIGTERM))"); } die("shairport shutted down...!"); } printf("stop mpc:\n"); system("mpc stop"); printf("mpc stopped\n"); printf("Starting Shairport %s\n", version); log_setup(); config.output = audio_get_output(config.output_name); if (!config.output) { audio_ls_outputs(); die("Invalid audio output specified!"); } config.output->init(argc-audio_arg, argv+audio_arg); uint8_t ap_md5[16]; MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, config.apname, strlen(config.apname)); MD5_Final(ap_md5, &ctx); memcpy(config.hw_addr, ap_md5, sizeof(config.hw_addr)); if (config.meta_dir) metadata_open(); rtsp_listen_loop(); // should not. shairport_shutdown(1); return 1; }