~ubuntu-branches/ubuntu/precise/vorbis-tools/precise

« back to all changes in this revision

Viewing changes to ogg123/cmdline_options.c

  • Committer: Bazaar Package Importer
  • Author(s): Jesus Climent
  • Date: 2005-04-10 09:22:24 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050410092224-xtukpa3qghghhjje
Tags: 1.0.1-1.3
* Authorized NMU.
* Modified alsa to mention alsa09 (although the device might be nowadays
  alsa, back, since alsa1.0 has been already released). (Closes: #258286)
* Modified the manpage/help message for vorbiscomment to make it a bit more
  userfiendly: Closes: #252531.
* Added oggdec to the long description field, so that it triggers apt-cache
  searches: Closes: #274894.
* Typos in manpages: Closes: #302150.
* Escaped dashes in manpage: Closes: #264365.
* Quiet option is actually with -Q, not -q (Closes: #211289) Reported
  upstream but patched for Debian.
* Change input.wav with inputfile, since we accept flac-formated files:
  Closes: #262509.
* Translation bits:
  * Updated translation hu.po: Closes: #272037.
  * French translation correction: Encodage -> Codage (Closes: #248431).
  * debian/rules: remove .gmo's to avoid clash with uploaded tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 *                                                                  *
12
12
 ********************************************************************
13
13
 
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 $
15
15
 
16
16
 ********************************************************************/
17
17
 
23
23
#include "getopt.h"
24
24
#include "cmdline_options.h"
25
25
#include "status.h"
 
26
#include "i18n.h"
26
27
 
27
28
#define MIN_INPUT_BUFFER_SIZE 8
28
29
 
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},
47
51
    {0, 0, 0, 0}
48
52
};
49
53
 
 
54
double strtotime(char *s)
 
55
{
 
56
        double time;
 
57
 
 
58
        time = strtod(s, &s);
 
59
 
 
60
        while (*s == ':')
 
61
                time = 60 * time + strtod(s + 1, &s);
 
62
 
 
63
        return time;
 
64
}
50
65
 
51
66
int parse_cmdline_options (int argc, char **argv,
52
67
                           ogg123_options_t *ogg123_opts,
60
75
  audio_device_t *current;
61
76
  int ret;
62
77
 
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))) {
65
80
 
66
81
      switch (ret) {
67
82
      case 0:
68
 
        status_error("Internal error: long option given when none expected.\n");
69
 
        exit(1);
70
 
        
 
83
        if(!strcmp(long_options[option_index].name, "audio-buffer")) {
 
84
          ogg123_opts->buffer_size = 1024 * atoi(optarg);
 
85
        } else {
 
86
          status_error(_("Internal error parsing command line options.\n"));
 
87
          exit(1);
 
88
        }
 
89
        break;
71
90
      case 'b':
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;
77
96
        }
83
102
          parse_code_t pcode = parse_line(file_opts, tmp);
84
103
 
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);
89
108
          free (tmp);
90
109
        }
91
110
        else {
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);
95
114
          exit (0);
96
115
        }
99
118
      case 'd':
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);
103
122
            exit(1);
104
123
        }
105
124
 
119
138
            free(current->filename);
120
139
            current->filename = strdup(optarg);
121
140
          } else {
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);
124
143
            exit(1);
125
144
          }
126
145
        } else {
127
 
          status_error("=== Cannot specify output file without specifying a driver.\n");
 
146
          status_error(_("=== Cannot specify output file without specifying a driver.\n"));
128
147
          exit (1);
129
148
        }
130
149
        break;
131
150
 
132
151
        case 'k':
133
 
          ogg123_opts->seekpos = atof(optarg);
 
152
          ogg123_opts->seekpos = strtotime(optarg);
 
153
          break;
 
154
          
 
155
        case 'K':
 
156
          ogg123_opts->endpos = strtotime(optarg);
134
157
          break;
135
158
          
136
159
        case 'l':
139
162
          
140
163
        case 'o':
141
164
          if (optarg && !add_ao_option(current_options, optarg)) {
142
 
            status_error("=== Incorrect option format: %s.\n", optarg);
 
165
            status_error(_("=== Incorrect option format: %s.\n"), optarg);
143
166
            exit(1);
144
167
          }
145
168
          break;
154
177
          if (ogg123_opts->input_prebuffer < 0.0f || 
155
178
              ogg123_opts->input_prebuffer > 100.0f) {
156
179
 
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;
160
183
          }
169
192
        break;
170
193
        
171
194
      case 'V':
172
 
        status_error("ogg123 from " PACKAGE " " VERSION "\n");
 
195
        status_error(_("ogg123 from %s %s\n"), PACKAGE, VERSION);
173
196
        exit(0);
174
197
        break;
175
198
 
176
199
      case 'x':
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;
181
204
        }
182
205
        break;
184
207
      case 'y':
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;
190
213
        }
191
214
        break;
193
216
      case 'z':
194
217
        ogg123_opts->shuffle = 1;
195
218
        break;
196
 
        
 
219
 
 
220
      case '@':
 
221
        if (playlist_append_from_file(ogg123_opts->playlist, optarg) == 0)
 
222
          status_error(_("--- Cannot open playlist file %s.  Skipped.\n"),
 
223
                       optarg);
 
224
        break;
 
225
                
197
226
      case '?':
198
227
        break;
199
228
        
203
232
      }
204
233
  }
205
234
 
 
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"));
 
239
    exit(1);
 
240
  }
 
241
 
 
242
 
206
243
  /* Add last device to device list or use the default device */
207
244
  if (temp_driver_id < 0) {
208
245
 
211
248
          temp_driver_id = ao_driver_id(ogg123_opts->default_device);
212
249
 
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);
216
253
      }
217
254
      
221
258
 
222
259
      /* Finally, give up */
223
260
      if (temp_driver_id < 0) {
224
 
        status_error("=== Could not load default driver and no driver specified in config file. Exiting.\n");
 
261
        status_error(_("=== Could not load default driver and no driver specified in config file. Exiting.\n"));
225
262
        exit(1);
226
263
      }
227
264
 
242
279
  ao_info **devices = ao_driver_info_list(&driver_count);
243
280
 
244
281
  printf ( 
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"
252
 
         "        ");
 
289
         "        "), PACKAGE, VERSION);
253
290
  
254
291
  for(i = 0; i < driver_count; i++) {
255
292
    printf ("%s", devices[i]->short_name);
263
300
  printf ("\n");
264
301
  
265
302
  printf (
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"
279
318
         "\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"));
283
322
}