73
70
0 , /* force_reopen, always (re)opens audio device for next song */
74
71
/* test_cpu flag is valid for multi and 3dnow.. even if 3dnow is built alone; ensure it appears only once */
75
72
FALSE , /* normal operation */
76
FALSE, /* try to run process in 'realtime mode' */
73
FALSE, /* try to run process in 'realtime mode' */
75
0, /* win32 process priority */
77
77
NULL, /* wav,cdr,au Filename */
78
78
0, /* default is to play all titles in playlist */
79
79
NULL, /* no playlist per default */
136
136
static int filept = -1;
137
137
char *binpath; /* Path to myself. */
139
/* File-global storage of command line arguments.
140
They may be needed for cleanup after charset conversion. */
141
static char **argv = NULL;
144
/* Cleanup marker to know that we intiialized libmpg123 already. */
145
static int cleanup_mpg123 = FALSE;
139
147
void set_intflag()
141
149
debug("set_intflag TRUE");
177
185
if(mh != NULL) mpg123_delete(mh);
187
if(cleanup_mpg123) mpg123_exit();
180
189
httpdata_free(&htd);
191
#ifdef WIN32_WANT_UNICODE
192
win32_cmdline_free(argc, argv); /* This handles the premature argv == NULL, too. */
181
195
/* It's ugly... but let's just fix this still-reachable memory chunk of static char*. */
182
196
split_dir_file("", &dummy, &dammy);
401
415
{'u', "auth", GLO_ARG | GLO_CHAR, 0, &httpauth, 0},
403
#ifdef HAVE_SCHED_SETSCHEDULER
417
#if defined (HAVE_SCHED_SETSCHEDULER) || defined (HAVE_WINDOWS_H)
404
418
/* check why this should be a long variable instead of int! */
405
419
{'T', "realtime", GLO_LONG, 0, ¶m.realtime, TRUE },
407
421
{'T', "realtime", 0, realtime_not_compiled, 0, 0 },
423
#ifdef HAVE_WINDOWS_H
424
{0, "priority", GLO_ARG | GLO_INT, 0, ¶m.w32_priority, 0},
409
426
{0, "title", GLO_INT, 0, ¶m.xterm_title, TRUE },
410
427
{'w', "wav", GLO_ARG | GLO_CHAR, set_out_wav, 0, 0 },
411
428
{0, "cdr", GLO_ARG | GLO_CHAR, set_out_cdr, 0, 0 },
500
517
httpdata_reset(&htd);
501
518
if(MPG123_OK != mpg123_param(mh, MPG123_ICY_INTERVAL, 0, 0))
502
519
error1("Cannot (re)set ICY interval: %s", mpg123_strerror(mh));
503
if(!strcmp(fname, "-")) filept = STDIN_FILENO;
520
if(!strcmp(fname, "-"))
522
filept = STDIN_FILENO;
524
_setmode(STDIN_FILENO, _O_BINARY);
504
527
else if (!strncmp(fname, "http://", 7)) /* http stream */
506
529
filept = http_open(fname, &htd);
507
530
/* now check if we got sth. and if we got sth. good */
508
531
if( (filept >= 0) && (htd.content_type.p != NULL)
509
&& !param.ignore_mime && strcmp(htd.content_type.p, "audio/mpeg") && strcmp(htd.content_type.p, "audio/x-mpeg") )
532
&& !param.ignore_mime && !(debunk_mime(htd.content_type.p) & IS_FILE) )
511
534
error1("Unknown mpeg MIME type %s - is it perhaps a playlist (use -@)?", htd.content_type.p == NULL ? "<nil>" : htd.content_type.p);
512
535
error("If you know the stream is mpeg1/2 audio, then please report this as "PACKAGE_NAME" bug");
675
698
#define skip_or_die(a) TRUE
678
int main(int argc, char *argv[])
701
#if defined (WANT_WIN32_UNICODE)
703
argv_cleanup(void *in)
705
debug ("argv_cleanup running!\n");
714
debug ("argv_cleanup ran!\n");
719
int main(int sys_argc, char ** sys_argv)
686
727
struct timeval start_time;
730
#if defined (WANT_WIN32_UNICODE)
731
if(win32_cmdline_utf8(&argc, &argv) != 0)
733
error("Cannot convert command line to UTF8!");
689
741
/* Extract binary and path, take stuff before/after last / or \ . */
690
742
if((prgName = strrchr(argv[0], '/')) || (prgName = strrchr(argv[0], '\\')))
706
758
if(result != MPG123_OK)
708
760
error1("Cannot initialize mpg123 library: %s", mpg123_plain_strerror(result));
763
cleanup_mpg123 = TRUE;
711
765
mp = mpg123_new_pars(&result); /* This may get leaked on premature exit(), which is mainly a cosmetic issue... */
714
768
error1("Crap! Cannot get mpg123 parameters: %s", mpg123_plain_strerror(result));
718
772
/* get default values */
874
#ifdef HAVE_SCHED_SETSCHEDULER
928
#if defined (HAVE_SCHED_SETSCHEDULER) && !defined (__CYGWIN__)
929
/* Cygwin --realtime seems to fail when accessing network, using win32 set priority instead */
875
930
if (param.realtime) { /* Get real-time priority */
876
931
struct sched_param sp;
877
932
fprintf(stderr,"Getting real-time priority\n");
940
#ifdef HAVE_WINDOWS_H
941
/* argument "3" is equivalent to realtime priority class */
942
win32_set_priority( param.realtime ? 3 : param.w32_priority);
885
945
if(!param.remote) prepare_playlist(argc, argv);
887
947
#if !defined(WIN32) && !defined(GENERIC)
1237
1297
#ifdef HAVE_SETPRIORITY
1238
1298
fprintf(o," --aggressive tries to get higher priority (nice)\n");
1240
#ifdef HAVE_SCHED_SETSCHEDULER
1300
#if defined (HAVE_SCHED_SETSCHEDULER) || defined (HAVE_WINDOWS_H)
1241
1301
fprintf(o," -T --realtime tries to get realtime priority\n");
1303
#ifdef HAVE_WINDOWS_H
1304
fprintf(o," --priority <n> use specified process priority\n");
1305
fprintf(o," accepts -2 to 3 as integer arguments\n");
1306
fprintf(o," -2 as idle, 0 as normal and 3 as realtime.\n");
1243
1308
fprintf(o," -? --help give compact help\n");
1244
1309
fprintf(o," --longhelp give this long help listing\n");
1245
1310
fprintf(o," --version give name / version string\n");