12
12
********************************************************************
14
last mod: $Id: cmdline_options.c,v 1.9 2002/01/01 02:22:14 jack Exp $
14
last mod: $Id: cmdline_options.c,v 1.15 2003/09/01 23:54:01 volsung Exp $
16
16
********************************************************************/
36
37
{"device", required_argument, 0, 'd'},
37
38
{"file", required_argument, 0, 'f'},
38
39
{"skip", required_argument, 0, 'k'},
40
{"end", required_argument, 0, 'K'},
39
41
{"delay", required_argument, 0, 'l'},
40
42
{"device-option", required_argument, 0, 'o'},
41
43
{"prebuffer", required_argument, 0, 'p'},
44
46
{"nth", required_argument, 0, 'x'},
45
47
{"ntimes", required_argument, 0, 'y'},
46
48
{"shuffle", no_argument, 0, 'z'},
49
{"list", required_argument, 0, '@'},
50
{"audio-buffer", required_argument, 0, 0},
54
double strtotime(char *s)
61
time = 60 * time + strtod(s + 1, &s);
51
66
int parse_cmdline_options (int argc, char **argv,
52
67
ogg123_options_t *ogg123_opts,
60
75
audio_device_t *current;
63
while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:o:p:qvVx:y:z",
78
while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:K:o:p:qvVx:y:z@:",
64
79
long_options, &option_index))) {
68
status_error("Internal error: long option given when none expected.\n");
83
if(!strcmp(long_options[option_index].name, "audio-buffer")) {
84
ogg123_opts->buffer_size = 1024 * atoi(optarg);
86
status_error(_("Internal error parsing command line options.\n"));
72
91
ogg123_opts->input_buffer_size = atoi(optarg) * 1024;
73
92
if (ogg123_opts->input_buffer_size < MIN_INPUT_BUFFER_SIZE * 1024) {
74
status_error("Input buffer size smaller than minimum size of %dkB.",
93
status_error(_("Input buffer size smaller than minimum size of %dkB."),
75
94
MIN_INPUT_BUFFER_SIZE);
76
95
ogg123_opts->input_buffer_size = MIN_INPUT_BUFFER_SIZE * 1024;
83
102
parse_code_t pcode = parse_line(file_opts, tmp);
85
104
if (pcode != parse_ok)
86
status_error("=== Error \"%s\" while parsing config option from command line.\n"
87
"=== Option was: %s\n",
105
status_error(_("=== Error \"%s\" while parsing config option from command line.\n"
106
"=== Option was: %s\n"),
88
107
parse_error_string(pcode), optarg);
92
111
/* not using the status interface here */
93
fprintf (stdout, "Available options:\n");
112
fprintf (stdout, _("Available options:\n"));
94
113
file_options_describe(file_opts, stdout);
100
119
temp_driver_id = ao_driver_id(optarg);
101
120
if (temp_driver_id < 0) {
102
status_error("=== No such device %s.\n", optarg);
121
status_error(_("=== No such device %s.\n"), optarg);
119
138
free(current->filename);
120
139
current->filename = strdup(optarg);
122
status_error("=== Driver %s is not a file output driver.\n",
141
status_error(_("=== Driver %s is not a file output driver.\n"),
123
142
info->short_name);
127
status_error("=== Cannot specify output file without specifying a driver.\n");
146
status_error(_("=== Cannot specify output file without specifying a driver.\n"));
133
ogg123_opts->seekpos = atof(optarg);
152
ogg123_opts->seekpos = strtotime(optarg);
156
ogg123_opts->endpos = strtotime(optarg);
154
177
if (ogg123_opts->input_prebuffer < 0.0f ||
155
178
ogg123_opts->input_prebuffer > 100.0f) {
157
status_error ("--- Prebuffer value invalid. Range is 0-100.\n");
180
status_error (_("--- Prebuffer value invalid. Range is 0-100.\n"));
158
181
ogg123_opts->input_prebuffer =
159
182
ogg123_opts->input_prebuffer < 0.0f ? 0.0f : 100.0f;
172
status_error("ogg123 from " PACKAGE " " VERSION "\n");
195
status_error(_("ogg123 from %s %s\n"), PACKAGE, VERSION);
177
200
ogg123_opts->nth = atoi(optarg);
178
201
if (ogg123_opts->nth == 0) {
179
status_error("--- Cannot play every 0th chunk!\n");
202
status_error(_("--- Cannot play every 0th chunk!\n"));
180
203
ogg123_opts->nth = 1;
185
208
ogg123_opts->ntimes = atoi(optarg);
186
209
if (ogg123_opts->ntimes == 0) {
187
status_error("--- Cannot play every chunk 0 times.\n"
188
"--- To do a test decode, use the null output driver.\n");
210
status_error(_("--- Cannot play every chunk 0 times.\n"
211
"--- To do a test decode, use the null output driver.\n"));
189
212
ogg123_opts->ntimes = 1;
235
/* Sanity check bad option combinations */
236
if (ogg123_opts->endpos > 0.0 &&
237
ogg123_opts->seekpos > ogg123_opts->endpos) {
238
status_error(_("=== Option conflict: End time is before start time.\n"));
206
243
/* Add last device to device list or use the default device */
207
244
if (temp_driver_id < 0) {
211
248
temp_driver_id = ao_driver_id(ogg123_opts->default_device);
213
250
if (temp_driver_id < 0)
214
status_error("--- Driver %s specified in configuration file invalid.\n",
251
status_error(_("--- Driver %s specified in configuration file invalid.\n"),
215
252
ogg123_opts->default_device);
242
279
ao_info **devices = ao_driver_info_list(&driver_count);
245
"ogg123 from " PACKAGE " " VERSION "\n"
246
" by the Xiphophorus Team (http://www.xiph.org/)\n\n"
282
_("ogg123 from %s %s\n"
283
" by the Xiph.org Foundation (http://www.xiph.org/)\n\n"
247
284
"Usage: ogg123 [<options>] <input file> ...\n\n"
248
285
" -h, --help this help\n"
249
286
" -V, --version display Ogg123 version\n"
250
287
" -d, --device=d uses 'd' as an output device\n"
251
288
" Possible devices are ('*'=live, '@'=file):\n"
289
" "), PACKAGE, VERSION);
254
291
for(i = 0; i < driver_count; i++) {
255
292
printf ("%s", devices[i]->short_name);
266
" -f, --file=filename Set the output filename for a previously\n"
303
_(" -f, --file=filename Set the output filename for a previously\n"
267
304
" specified file device (with -d).\n"
268
" -k n, --skip n Skip the first 'n' seconds\n"
305
" -k n, --skip n Skip the first 'n' seconds (or hh:mm:ss format)\n"
306
" -K n, --end n End at 'n' seconds (or hh:mm:ss format)\n"
269
307
" -o, --device-option=k:v passes special option k with value\n"
270
308
" v to previously specified device (with -d). See\n"
271
309
" man page for more info.\n"
272
" -b n, --buffer n use an input buffer of 'n' kilobytes\n"
273
" -p n, --prebuffer n load n%% of the input buffer before playing\n"
274
" -v, --verbose display progress and other status information\n"
275
" -q, --quiet don't display anything (no title)\n"
276
" -x n, --nth play every 'n'th block\n"
277
" -y n, --ntimes repeat every played block 'n' times\n"
278
" -z, --shuffle shuffle play\n"
310
" -@, --list=filename Read playlist of files and URLs from \"filename\"\n"
311
" -b n, --buffer n Use an input buffer of 'n' kilobytes\n"
312
" -p n, --prebuffer n Load n%% of the input buffer before playing\n"
313
" -v, --verbose Display progress and other status information\n"
314
" -q, --quiet Don't display anything (no title)\n"
315
" -x n, --nth Play every 'n'th block\n"
316
" -y n, --ntimes Repeat every played block 'n' times\n"
317
" -z, --shuffle Shuffle play\n"
280
319
"ogg123 will skip to the next song on SIGINT (Ctrl-C); two SIGINTs within\n"
281
320
"s milliseconds make ogg123 terminate.\n"
282
" -l, --delay=s set s [milliseconds] (default 500).\n");
321
" -l, --delay=s Set s [milliseconds] (default 500).\n"));