History

use --magic to enable libmagic

robs committed 17 years ago

Commit f8a42f41 parent faca3a36 files · +17 −2Browse files

Unified · Split

6 files
  1. ChangeLog +2 −0
  2. sox.1 +4 −0
  3. src/formats.c +1 −1
  4. src/libsox.c +2 −1
  5. src/sox.c +7 −0
  6. src/sox.h +1 −0
ChangeLog+2−0
@@ -98,6 +98,8 @@ Other new features: · 97 unmodified lines
9898 o Can now use `u' & `d' keys to adjust volume whilst playing audio (on some
9999 systems). (robs)
100100 o New bitrate, time in seconds, & total options for soxi. (robs)
101+ o `Magic' (libmagic) file type detection now selected using `--magic'
102+ option (where supported).
101103
102104 Other bug fixes:
103105
sox.1+4−0
@@ -728,6 +728,10 @@ selects `merge'. · 727 unmodified lines
728728 See \fBInput File Combining\fR above for a description of the different
729729 combining methods.
730730 .TP
731+.B \-\-magic
732+If SoX has been built with the optional `libmagic' library, then this
733+option can be given to enable its use in helping to detect audio file types.
734+.TP
731735 \fB\-D\fR, \fB\-\-no\-dither\fR
732736 SoX, by default, automatically invokes the dither effect (with TPDF) when reducing
733737 bit-depth. This option can be given to prevent this behaviour.
src/formats.c+1−1
@@ -418,7 +418,7 @@ sox_format_t * sox_open_read( · 417 unmodified lines
418418 filetype = detect_format(ft, lsx_find_file_extension(path));
419419 lsx_rewind(ft);
420420 #if HAVE_MAGIC
421− if (!filetype) {
421+ if (sox_globals.use_magic && !filetype) {
422422 static magic_t magic;
423423 if (!magic) {
424424 magic = magic_open(MAGIC_MIME | MAGIC_SYMLINK);
src/libsox.c+2−1
@@ -52,7 +52,8 @@ sox_globals_t sox_globals = { · 51 unmodified lines
5252 NULL, /* char const * stdin_in_use_by */
5353 NULL, /* char const * stdout_in_use_by */
5454 NULL, /* char const * subsystem */
55− NULL /* char * tmp_path */
55+ NULL, /* char * tmp_path */
56+ sox_false /* sox_bool use_magic */
5657 };
5758
5859 char const * sox_strerror(int sox_errno)
src/sox.c+7−0
@@ -1742,6 +1742,7 @@ static void usage(char const * message) · 1741 unmodified lines
17421742 "--interactive Prompt to overwrite output file",
17431743 "-m, --combine mix Mix multiple input files (instead of concatenating)",
17441744 "-M, --combine merge Merge multiple input files (instead of concatenating)",
1745+"--magic Use `magic' file-type detection",
17451746 "--norm Guard (see --guard) & normalise",
17461747 "--plot gnuplot|octave Generate script to plot response of filter effect",
17471748 "-q, --no-show-progress Run in quiet mode; opposite of -S",
@@ -1954,6 +1955,7 @@ static struct option long_options[] = · 206 unmodified lines
19541955 {"single-threaded" , no_argument, NULL, 0},
19551956 {"ignore-length" , no_argument, NULL, 0},
19561957 {"norm" , no_argument, NULL, 0},
1958+ {"magic" , no_argument, NULL, 0},
19571959
19581960 {"bits" , required_argument, NULL, 'b'},
19591961 {"channels" , required_argument, NULL, 'c'},
@@ -2120,6 +2122,11 @@ static char parse_gopts_and_fopts(file_t * f, int argc, char **argv) · 160 unmodified lines
21202122 case 17: single_threaded = sox_true; break;
21212123 case 18: f->signal.length = SOX_IGNORE_LENGTH; break;
21222124 case 19: do_guarded_norm = is_guarded = sox_true; break;
2125+#if HAVE_MAGIC
2126+ case 20: sox_globals.use_magic = sox_true; break;
2127+#else
2128+ case 20: lsx_warn("this build of SoX does not include `magic'"); break;
2129+#endif
21232130 }
21242131 break;
21252132
src/sox.h+1−0
@@ -181,6 +181,7 @@ typedef struct { /* Global parameters (for effects & formats) */ · 180 unmodified lines
181181 char const * stdout_in_use_by;
182182 char const * subsystem;
183183 char * tmp_path;
184+ sox_bool use_magic;
184185 } sox_globals_t;
185186 extern sox_globals_t sox_globals;
186187

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t