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
98 o Can now use `u' & `d' keys to adjust volume whilst playing audio (on some98 o Can now use `u' & `d' keys to adjust volume whilst playing audio (on some
99 systems). (robs)99 systems). (robs)
100 o New bitrate, time in seconds, & total options for soxi. (robs)100 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).
101 103
102Other bug fixes:104Other bug fixes:
103 105
sox.1+4−0
@@ -728,6 +728,10 @@ selects `merge'. · 727 unmodified lines
728See \fBInput File Combining\fR above for a description of the different728See \fBInput File Combining\fR above for a description of the different
729combining methods.729combining methods.
730.TP730.TP
731.B \-\-magic
732If SoX has been built with the optional `libmagic' library, then this
733option can be given to enable its use in helping to detect audio file types.
734.TP
731\fB\-D\fR, \fB\-\-no\-dither\fR735\fB\-D\fR, \fB\-\-no\-dither\fR
732SoX, by default, automatically invokes the dither effect (with TPDF) when reducing736SoX, by default, automatically invokes the dither effect (with TPDF) when reducing
733bit-depth. This option can be given to prevent this behaviour.737bit-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
418 filetype = detect_format(ft, lsx_find_file_extension(path));418 filetype = detect_format(ft, lsx_find_file_extension(path));
419 lsx_rewind(ft);419 lsx_rewind(ft);
420#if HAVE_MAGIC420#if HAVE_MAGIC
421 if (!filetype) {421 if (sox_globals.use_magic && !filetype) {
422 static magic_t magic;422 static magic_t magic;
423 if (!magic) {423 if (!magic) {
424 magic = magic_open(MAGIC_MIME | MAGIC_SYMLINK);424 magic = magic_open(MAGIC_MIME | MAGIC_SYMLINK);
src/libsox.c+2−1
@@ -52,7 +52,8 @@ sox_globals_t sox_globals = { · 51 unmodified lines
52 NULL, /* char const * stdin_in_use_by */52 NULL, /* char const * stdin_in_use_by */
53 NULL, /* char const * stdout_in_use_by */53 NULL, /* char const * stdout_in_use_by */
54 NULL, /* char const * subsystem */54 NULL, /* char const * subsystem */
55 NULL /* char * tmp_path */55 NULL, /* char * tmp_path */
56 sox_false /* sox_bool use_magic */
56};57};
57 58
58char const * sox_strerror(int sox_errno)59char const * sox_strerror(int sox_errno)
src/sox.c+7−0
@@ -1742,6 +1742,7 @@ static void usage(char const * message) · 1741 unmodified lines
1742"--interactive Prompt to overwrite output file",1742"--interactive Prompt to overwrite output file",
1743"-m, --combine mix Mix multiple input files (instead of concatenating)",1743"-m, --combine mix Mix multiple input files (instead of concatenating)",
1744"-M, --combine merge Merge multiple input files (instead of concatenating)",1744"-M, --combine merge Merge multiple input files (instead of concatenating)",
1745"--magic Use `magic' file-type detection",
1745"--norm Guard (see --guard) & normalise",1746"--norm Guard (see --guard) & normalise",
1746"--plot gnuplot|octave Generate script to plot response of filter effect",1747"--plot gnuplot|octave Generate script to plot response of filter effect",
1747"-q, --no-show-progress Run in quiet mode; opposite of -S",1748"-q, --no-show-progress Run in quiet mode; opposite of -S",
@@ -1954,6 +1955,7 @@ static struct option long_options[] = · 206 unmodified lines
1954 {"single-threaded" , no_argument, NULL, 0},1955 {"single-threaded" , no_argument, NULL, 0},
1955 {"ignore-length" , no_argument, NULL, 0},1956 {"ignore-length" , no_argument, NULL, 0},
1956 {"norm" , no_argument, NULL, 0},1957 {"norm" , no_argument, NULL, 0},
1958 {"magic" , no_argument, NULL, 0},
1957 1959
1958 {"bits" , required_argument, NULL, 'b'},1960 {"bits" , required_argument, NULL, 'b'},
1959 {"channels" , required_argument, NULL, 'c'},1961 {"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
2120 case 17: single_threaded = sox_true; break;2122 case 17: single_threaded = sox_true; break;
2121 case 18: f->signal.length = SOX_IGNORE_LENGTH; break;2123 case 18: f->signal.length = SOX_IGNORE_LENGTH; break;
2122 case 19: do_guarded_norm = is_guarded = sox_true; break;2124 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
2123 }2130 }
2124 break;2131 break;
2125 2132
src/sox.h+1−0
@@ -181,6 +181,7 @@ typedef struct { /* Global parameters (for effects & formats) */ · 180 unmodified lines
181 char const * stdout_in_use_by;181 char const * stdout_in_use_by;
182 char const * subsystem;182 char const * subsystem;
183 char * tmp_path;183 char * tmp_path;
184 sox_bool use_magic;
184} sox_globals_t;185} sox_globals_t;
185extern sox_globals_t sox_globals;186extern sox_globals_t sox_globals;
186 187

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