Codebase list squeezelite / fe9fac7
option to explicitly exclude codecs Adrian Smith 10 years ago
3 changed file(s) with 40 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
120120
121121 static thread_type thread;
122122
123 void decode_init(log_level level, const char *opt) {
123 void decode_init(log_level level, const char *include_codecs, const char *exclude_codecs) {
124124 int i;
125125
126126 loglevel = level;
127127
128 LOG_INFO("init decode");
128 LOG_INFO("init decode, include codecs: %s exclude codecs: %s", include_codecs ? include_codecs : "", exclude_codecs);
129129
130130 // register codecs
131131 // dsf,dff,alc,wma,wmap,wmal,aac,spt,ogg,ogf,flc,aif,pcm,mp3
132132 i = 0;
133133 #if DSD
134 if (!opt || strstr(opt, "dsd")) codecs[i++] = register_dsd();
134 if (!strstr(exclude_codecs, "dsd") && (!include_codecs || strstr(include_codecs, "dsd"))) codecs[i++] = register_dsd();
135135 #endif
136136 #if FFMPEG
137 if (!opt || strstr(opt, "alac")) codecs[i++] = register_ff("alc");
138 if (!opt || strstr(opt, "wma")) codecs[i++] = register_ff("wma");
139 #endif
140 if (!opt || strstr(opt, "aac")) codecs[i++] = register_faad();
141 if (!opt || strstr(opt, "ogg")) codecs[i++] = register_vorbis();
142 if (!opt || strstr(opt, "flac")) codecs[i++] = register_flac();
143 if (!opt || strstr(opt, "pcm")) codecs[i++] = register_pcm();
137 if (!strstr(exclude_codecs, "alac") && (!include_codecs || strstr(include_codecs, "alac"))) codecs[i++] = register_ff("alc");
138 if (!strstr(exclude_codecs, "wma") && (!include_codecs || strstr(include_codecs, "wma"))) codecs[i++] = register_ff("wma");
139 #endif
140 if (!strstr(exclude_codecs, "aac") && (!include_codecs || strstr(include_codecs, "aac"))) codecs[i++] = register_faad();
141 if (!strstr(exclude_codecs, "ogg") && (!include_codecs || strstr(include_codecs, "ogg"))) codecs[i++] = register_vorbis();
142 if (!strstr(exclude_codecs, "flac") && (!include_codecs || strstr(include_codecs, "flac"))) codecs[i++] = register_flac();
143 if (!strstr(exclude_codecs, "pcm") && (!include_codecs || strstr(include_codecs, "pcm"))) codecs[i++] = register_pcm();
144144
145145 // try mad then mpg for mp3 unless command line option passed
146 if ( !opt || strstr(opt, "mp3") || strstr(opt, "mad")) codecs[i] = register_mad();
147 if ((!opt || strstr(opt, "mp3") || strstr(opt, "mpg")) && !codecs[i]) codecs[i] = register_mpg();
146 if (!(strstr(exclude_codecs, "mp3") || strstr(exclude_codecs, "mad")) &&
147 (!include_codecs || strstr(include_codecs, "mp3") || strstr(include_codecs, "mad"))) codecs[i] = register_mad();
148 if (!(strstr(exclude_codecs, "mp3") || strstr(exclude_codecs, "mpg")) && !codecs[i] &&
149 (!include_codecs || strstr(include_codecs, "mp3") || strstr(include_codecs, "mpg"))) codecs[i] = register_mpg();
148150
149151 mutex_create(decode.mutex);
150152
2323
2424 #define TITLE "Squeezelite " VERSION ", Copyright 2012-2014 Adrian Smith."
2525
26 #define CODECS_BASE "flac,pcm,mp3,ogg,aac"
27 #if FFMPEG
28 #define CODECS_FF ",wma,alac"
29 #else
30 #define CODECS_FF ""
31 #endif
32 #if DSD
33 #define CODECS_DSD ",dsd"
34 #else
35 #define CODECS_DSD ""
36 #endif
37 #define CODECS_MP3 " (mad,mpg for specific mp3 codec)"
38
39 #define CODECS CODECS_BASE CODECS_FF CODECS_DSD CODECS_MP3
40
2641 static void usage(const char *argv0) {
2742 printf(TITLE " See -t for license terms\n"
2843 "Usage: %s [options]\n"
4156 #endif
4257 " -a <f>\t\tSpecify sample format (16|24|32) of output file when using -o - to output samples to stdout (interleaved little endian only)\n"
4358 " -b <stream>:<output>\tSpecify internal Stream and Output buffer sizes in Kbytes\n"
44 " -c <codec1>,<codec2>\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: "
45 "flac,pcm,mp3,ogg,aac"
46 #if FFMPEG
47 ",wma,alac"
48 #endif
49 #if DSD
50 ",dsd"
51 #endif
52 " (mad,mpg for specific mp3 codec)\n"
59 " -c <codec1>,<codec2>\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: " CODECS "\n"
5360 " -d <log>=<level>\tSet logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug\n"
61 " -e <codec1>,<codec2>\tExplicitly exclude native support of one or more codecs; known codecs: " CODECS "\n"
5462 " -f <logfile>\t\tWrite debug to logfile\n"
5563 " -m <mac addr>\t\tSet mac address, format: ab:cd:ef:12:34:56\n"
5664 " -n <name>\t\tSet the player name\n"
156164 int main(int argc, char **argv) {
157165 char *server = NULL;
158166 char *output_device = "default";
159 char *codecs = NULL;
167 char *include_codecs = NULL;
168 char *exclude_codecs = "";
160169 char *name = NULL;
161170 char *namefile = NULL;
162171 char *logfile = NULL;
202211
203212 while (optind < argc && strlen(argv[optind]) >= 2 && argv[optind][0] == '-') {
204213 char *opt = argv[optind] + 1;
205 if (strstr("oabcdfmnNprs", opt) && optind < argc - 1) {
214 if (strstr("oabcdefmnNprs", opt) && optind < argc - 1) {
206215 optarg = argv[optind + 1];
207216 optind += 2;
208217 } else if (strstr("ltz"
239248 }
240249 break;
241250 case 'c':
242 codecs = optarg;
251 include_codecs = optarg;
252 break;
253 case 'e':
254 exclude_codecs = optarg;
243255 break;
244256 case 'd':
245257 {
451463 }
452464 #endif
453465
454 decode_init(log_decode, codecs);
466 decode_init(log_decode, include_codecs, exclude_codecs);
455467
456468 #if RESAMPLE
457469 if (resample) {
465465 decode_state (*decode)(void);
466466 };
467467
468 void decode_init(log_level level, const char *opt);
468 void decode_init(log_level level, const char *include_codecs, const char *exclude_codecs);
469469 void decode_close(void);
470470 void decode_flush(void);
471471 unsigned decode_newstream(unsigned sample_rate, unsigned supported_rates[]);