📄 core.c
字号:
while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"default_param"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if (key != NULL) strncpy(default_param, (char *) key, MAXLEN-1); xmlFree(key); } cur = cur->next; } xmlFreeDoc(doc); snprintf(cl, MAXLEN-1, "aqualung %s", default_param); while (cl[i] != '\0') { ++(*argc); if ((*argv = realloc(*argv, *argc * sizeof(char *))) == NULL) { fprintf(stderr, "realloc() failed in load_default_cl()\n"); exit(1); } (*argv)[*argc-1] = cl+i; while ((cl[i] != ' ') && (cl[i] != '\0')) ++i; if (cl[i] == ' ') cl[i++] = '\0'; } if ((*argv = realloc(*argv, (*argc+1) * sizeof(char *))) == NULL) { fprintf(stderr, "realloc() failed in load_default_cl()\n"); exit(1); } (*argv)[*argc] = NULL; return;} voidprint_version(void) { fprintf(stderr, "Aqualung -- Music player for GNU/Linux\n"); fprintf(stderr, "Build version: %s\n", aqualung_version); fprintf(stderr, "(C) 2004-2006 Tom Szilagyi <tszilagyi@users.sourceforge.net>\n" "This is free software, and you are welcome to redistribute it\n" "under certain conditions; see the file COPYING for details.\n"); fprintf(stderr, "\nThis Aqualung binary is compiled with:\n" "\n\tFile format support:\n"); fprintf(stderr, "\t\tsndfile (WAV, AIFF, etc.) : ");#ifdef HAVE_SNDFILE fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_SNDFILE */ fprintf(stderr, "\t\tFree Lossless Audio Codec (FLAC) : ");#ifdef HAVE_FLAC fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_FLAC */ fprintf(stderr, "\t\tOgg Vorbis : ");#ifdef HAVE_OGG_VORBIS fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_OGG_VORBIS */ fprintf(stderr, "\t\tOgg Speex : ");#ifdef HAVE_SPEEX fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_SPEEX */ fprintf(stderr, "\t\tMPEG Audio (MPEG 1-2.5 Layer I-III) : ");#ifdef HAVE_MPEG fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_MPEG */ fprintf(stderr, "\t\tMOD Audio (MOD, S3M, XM, IT, etc.) : ");#ifdef HAVE_MOD fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_MOD */ fprintf(stderr, "\t\tMusepack : ");#ifdef HAVE_MPC fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_MPC */ fprintf(stderr, "\t\tMonkey's Audio Codec : ");#ifdef HAVE_MAC fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_MAC */ fprintf(stderr, "\t\tMetadata (ID3, APE, Ogg comments) : ");#ifdef HAVE_TAGLIB fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_TAGLIB */ fprintf(stderr, "\n\tOutput driver support:\n"); fprintf(stderr, "\t\tOSS Audio : ");#ifdef HAVE_OSS fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_OSS */ fprintf(stderr, "\t\tALSA Audio : ");#ifdef HAVE_ALSA fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_ALSA */ fprintf(stderr, "\t\tJACK Audio Server : ");#ifdef HAVE_JACK fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_JACK */ fprintf(stderr, "\t\tWin32 Sound API : ");#ifdef _WIN32 fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* _WIN32 */ fprintf(stderr, "\n\tInternal Sample Rate Converter support : ");#ifdef HAVE_SRC fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_SRC */ fprintf(stderr, "\tLADSPA plugin support : ");#ifdef HAVE_LADSPA fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_LADSPA */ fprintf(stderr, "\tCDDB support : ");#ifdef HAVE_CDDB fprintf(stderr, "yes\n");#else fprintf(stderr, "no\n");#endif /* HAVE_CDDB */ fprintf(stderr, "\tiRiver iFP driver support : ");#ifdef HAVE_IFP fprintf(stderr, "yes\n\n");#else fprintf(stderr, "no\n");#endif /* HAVE_IFP */ fprintf(stderr, "\tSystray support : ");#ifdef HAVE_SYSTRAY fprintf(stderr, "yes\n\n");#else fprintf(stderr, "no\n\n");#endif /* HAVE_SYSTRAY */}voidprint_usage(void) { fprintf(stderr, "Aqualung -- Music player for GNU/Linux\n"); fprintf(stderr, "Build version: %s\n", aqualung_version); fprintf(stderr, "(C) 2004-2006 Tom Szilagyi <tszilagyi@users.sourceforge.net>\n" "This is free software, and you are welcome to redistribute it\n" "under certain conditions; see the file COPYING for details.\n"); fprintf(stderr, "\nInvocation:\n" "aqualung --help\n" "aqualung --version\n" "aqualung [--output (oss|alsa|jack|win32)] [options] [file1 [file2 ...]]\n" "\nGeneral options:\n" "-D, --disk-realtime: Try to use realtime (SCHED_FIFO) scheduling for disk thread.\n" "-Y, --disk-priority <int>: When running -D, set scheduler priority to <int> (defaults to 1).\n" "\nOptions relevant to ALSA output:\n" "-d, --device <name>: Set the output device (defaults to plughw:0,0).\n" "-p, --period <int>: Set ALSA period size (defaults to 8192).\n" "-n, --nperiods <int>: Specify the number of periods in hardware buffer (defaults to 2).\n" "-r, --rate <int>: Set the output sample rate.\n" "-R, --realtime: Try to use realtime (SCHED_FIFO) scheduling for ALSA output thread.\n" "-P, --priority <int>: When running -R, set scheduler priority to <int> (defaults to 1).\n" "\nOptions relevant to OSS output:\n" "-d, --device <name>: Set the output device (defaults to /dev/dsp).\n" "-r, --rate <int>: Set the output sample rate.\n" "\nOptions relevant to JACK output:\n" "-a[<port_L>,<port_R>], --auto[=<port_L>,<port_R>]: Auto-connect output ports to\n" "given JACK ports (defaults to first two hardware playback ports).\n" "-c, --client <name>: Set client name (needed if you want to run multiple instances of the program).\n" "\nOptions relevant to WIN32 output:\n" "-r, --rate <int>: Set the output sample rate.\n" "\nOptions relevant to the Sample Rate Converter:\n" "-s[<int>], --srctype[=<int>]: Choose the SRC type, or print the list of available\n" "types if no number given. The default is SRC type 4 (Linear Interpolator).\n" "\nOptions for remote cue control:\n" "-N, --session <int>: Number of Aqualung instance to control.\n" "-B, --back: Jump to previous track.\n" "-F, --fwd: Jump to next track.\n" "-L, --play: Start playing.\n" "-U, --pause: Pause playback, or resume if already paused.\n" "-T, --stop: Stop playback.\n" "-V, --volume [m|M]|[=]<val>: Set, adjust or mute volume.\n" "-Q, --quit: Terminate remote instance.\n" "Note that these options default to the 0-th instance when no -N option is given,\n" "except for -L which defaults to the present instance (so as to be able to start\n" "playback immediately from the command line).\n" "\nOptions for file loading:\n" "-E, --enqueue: Don't clear the contents of the playlist when adding new items.\n" "\nIf you don't specify a session number via --session, the files will be opened by " "the new\ninstance, otherwise they will be sent to the already running instance you " "specify.\n" "\nOptions for changing state of Playlist/Music Store windows:\n" "-l [yes, no], --show-pl=yes, no: Show/hide playlist window.\n" "-m [yes, no], --show-ms=yes, no: Show/hide music store window.\n" "\nExamples:\n" "$ aqualung -s3 -o alsa -R -r 48000 -d hw:0,0 -p 2048 -n 2\n" "$ aqualung --srctype=1 --output oss --rate 96000\n" "$ aqualung -o jack -a -E `find ./ledzeppelin/ -name \"*.flac\"`\n"); fprintf(stderr, "\nDepending on the compile-time options, not all file formats\n" "and output drivers may be usable. Type aqualung -v to get a\n" "list of all the compiled-in features.\n\n");}#ifdef HAVE_JACKvoidprint_jack_failed_connection(void) { fprintf(stderr, "\nAqualung couldn't connect to JACK.\n"); fprintf(stderr, "There are several possible reasons:\n" "\t1) JACK is not running.\n" "\t2) JACK is running as another user, perhaps root.\n" "\t3) There is already another client called '%s'. (Use the -c option!)\n", client_name); fprintf(stderr, "Please consider the possibilities, and perhaps (re)start JACK.\n");}voidprint_jack_SR_out_of_range(int SR) { fprintf(stderr, "\nThe JACK sample rate (%d Hz) is higher than MAX_SAMPLERATE.\n", SR); fprintf(stderr, "This is an arbitrary limit, which you may safely enlarge " "if you really need to.\n"); fprintf(stderr, "Currently MAX_SAMPLERATE = %d Hz.\n", MAX_SAMPLERATE);}#endif /* HAVE_JACK */intmain(int argc, char ** argv) { int parse_run; int * argc_opt = NULL; char *** argv_opt = NULL; int argc_def = 0; char ** argv_def = NULL; thread_info_t thread_info;#ifndef _WIN32 struct sched_param param;#endif /* !_WIN32 */ int c; int longopt_index = 0; extern int optind, opterr; int show_version = 0; int show_usage = 0; char * output_str = NULL; int rate = 0; int try_realtime = 0; int priority = 1; int disk_try_realtime = 0; int disk_priority = 1; char rcmd; int no_session = -1; int back = 0; int play = 0; int pause = 0; int stop = 0; int fwd = 0; int enqueue = 0; int remote_quit = 0; char * voladj_arg = NULL; char * optstring = "vho:d:c:n:p:r:a::RP:DY:s::l:m:N:BLUTFEV:Q"; struct option long_options[] = { { "version", 0, 0, 'v' }, { "help", 0, 0, 'h' }, { "output", 1, 0, 'o' }, { "device", 1, 0, 'd' }, { "client", 1, 0, 'c' }, { "nperiods", 1, 0, 'n'}, { "period", 1, 0, 'p'}, { "rate", 1, 0, 'r' }, { "auto", 2, 0, 'a' }, { "realtime", 0, 0, 'R' }, { "priority", 1, 0, 'P' }, { "disk-realtime", 0, 0, 'D' }, { "disk-priority", 1, 0, 'Y' }, { "srctype", 2, 0, 's' }, { "show-pl", 1, 0, 'l' }, { "show-ms", 1, 0, 'm' }, { "session", 1, 0, 'N' }, { "back", 0, 0, 'B' }, { "play", 0, 0, 'L' }, { "pause", 0, 0, 'U' }, { "stop", 0, 0, 'T' }, { "fwd", 0, 0, 'F' }, { "enqueue", 0, 0, 'E' }, { "volume", 1, 0, 'V' }, { "quit", 0, 0, 'Q' }, { 0, 0, 0, 0 } };#if defined(HAVE_JACK) || defined(HAVE_ALSA) || defined(HAVE_OSS) int auto_driver_found = 0;#endif /* jack || alsa || oss */#ifndef _WIN32 /* unlock memory (implicitly locked by libjack when Jack runs realtime) */ if (munlockall() < 0) { fprintf(stderr, "aqualung main(): munlockall() failed\n"); }#endif /* !_WIN32 */#ifdef _WIN32 g_thread_init(NULL); disk_thread_lock = g_mutex_new(); disk_thread_wake = g_cond_new();#endif /* _WIN32 */ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, AQUALUNG_LOCALEDIR); textdomain(PACKAGE); setup_app_socket(); if (getcwd(options.cwd, MAXLEN) == NULL) { fprintf(stderr, "main(): warning: getcwd() returned NULL, using . as cwd\n"); strcpy(options.cwd, "."); } load_default_cl(&argc_def, &argv_def); playlist_state = browser_state = -1; for (parse_run = 0; parse_run < 2; parse_run++) { if ((!parse_run) && (argc_def == 1)) ++parse_run; switch (parse_run) { case 0: argc_opt = &argc_def; argv_opt = &argv_def; break; case 1: argc_opt = &argc; argv_opt = &argv; break; } optind = opterr = 0; longopt_index = opterr = 0; while ((c = getopt_long(*argc_opt, *argv_opt, optstring, long_options, &longopt_index)) != -1) { switch (c) { case 1: /* getopt signals end of '-' options */ break; case 'h': show_usage++; break; case 'v': show_version++; break; case 'o': output_str = strdup(optarg); if (strcmp(output_str, "oss") == 0) {#ifdef HAVE_OSS output = OSS_DRIVER;#else fprintf(stderr, "You selected OSS output, but this instance of Aqualung " "is compiled\n" "without OSS output support. Type aqualung -v to get a " "list of\n" "compiled-in features.\n"); exit(1);#endif /* HAVE_OSS*/ break; } if (strcmp(output_str, "alsa") == 0) {#ifdef HAVE_ALSA output = ALSA_DRIVER;#else fprintf(stderr, "You selected ALSA output, but this instance of Aqualung " "is compiled\n" "without ALSA output support. Type aqualung -v to get a " "list of\n" "compiled-in features.\n"); exit(1);#endif /* HAVE_ALSA */ break; } if (strcmp(output_str, "jack") == 0) {#ifdef HAVE_JACK output = JACK_DRIVER;#else fprintf(stderr, "You selected JACK output, but this instance of Aqualung " "is compiled\n" "without JACK output support. Type aqualung -v to get a " "list of\n" "compiled-in features.\n"); exit(1);#endif /* HAVE_JACK */ break; } if (strcmp(output_str, "win32") == 0) {#ifdef _WIN32 output = WIN32_DRIVER;#else fprintf(stderr, "You selected WIN32 output, but this instance of Aqualung " "is compiled\n" "without WIN32 output support. Type aqualung -v to get a " "list of\n" "compiled-in features.\n"); exit(1);#endif /* _WIN32 */ break; } free(output_str); case 'd': device_name = strdup(optarg); break; case 'c':#ifdef HAVE_JACK client_name = strdup(optarg);#endif /* HAVE_JACK */ break; case 'n':#ifdef HAVE_ALSA nperiods = atoi(optarg);#endif /* HAVE_ALSA */ break; case 'p':#ifdef HAVE_ALSA period = atoi(optarg);#endif /* HAVE_ALSA */ break; case 'r': rate = atoi(optarg); break; case 'a':#ifdef HAVE_JACK auto_connect = 1; if (optarg) { char * s; if (strstr(optarg, ",") == NULL) { fprintf(stderr, "Invalid ports specification: %s\n", optarg); exit(0); } s = strtok(optarg, ","); if (s != NULL) { user_port1 = strdup(s); } else { fprintf(stderr, "Invalid ports specification: argument " "contains too few ports\n"); exit(0); } s = strtok(NULL, ","); if (s != NULL) { user_port2 = strdup(s);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -