Submitted By: Jim Gifford (patches at jg555 dot com) Date: 2006-06-24 Initial Package Version: 0.2.6 Origin: Gentoo Upstream Status: Unknown Description: Fixes M4 Warning and memory leak diff -Naur audiofile-0.2.6.orig/audiofile.m4 audiofile-0.2.6/audiofile.m4 --- audiofile-0.2.6.orig/audiofile.m4 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/audiofile.m4 2006-06-24 16:29:54.000000000 -0700 @@ -9,7 +9,7 @@ dnl AM_PATH_AUDIOFILE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for Audio File Library, and define AUDIOFILE_CFLAGS and AUDIOFILE_LIBS. dnl -AC_DEFUN(AM_PATH_AUDIOFILE, +AC_DEFUN([AM_PATH_AUDIOFILE], [dnl dnl Get compiler flags and libraries from the audiofile-config script. dnl diff -Naur audiofile-0.2.6.orig/libaudiofile/aiff.c audiofile-0.2.6/libaudiofile/aiff.c --- audiofile-0.2.6.orig/libaudiofile/aiff.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/aiff.c 2006-06-24 16:29:33.000000000 -0700 @@ -64,7 +64,7 @@ static status ParseSSND (AFfilehandle file, AFvirtualfile *fh, u_int32_t type, size_t size); -_InstParamInfo _af_aiff_inst_params[_AF_AIFF_NUM_INSTPARAMS] = +const _InstParamInfo _af_aiff_inst_params[_AF_AIFF_NUM_INSTPARAMS] = { { AF_INST_MIDI_BASENOTE, AU_PVTYPE_LONG, "MIDI base note", {60} }, { AF_INST_NUMCENTS_DETUNE, AU_PVTYPE_LONG, "Detune in cents", {0} }, @@ -77,7 +77,7 @@ { AF_INST_RELLOOPID, AU_PVTYPE_LONG, "Release loop id", {0} } }; -int _af_aiffc_compression_types[_AF_AIFF_NUM_COMPTYPES] = +const int _af_aiffc_compression_types[_AF_AIFF_NUM_COMPTYPES] = { AF_COMPRESSION_G711_ULAW, AF_COMPRESSION_G711_ALAW diff -Naur audiofile-0.2.6.orig/libaudiofile/compression.c audiofile-0.2.6/libaudiofile/compression.c --- audiofile-0.2.6.orig/libaudiofile/compression.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/compression.c 2006-06-24 16:29:33.000000000 -0700 @@ -37,7 +37,7 @@ #include "units.h" #include "util.h" -extern _CompressionUnit _af_compression[]; +extern const _CompressionUnit _af_compression[]; int _af_compression_index_from_id (int compressionid) { @@ -54,7 +54,7 @@ return -1; } -static _CompressionUnit *findCompression (int compressionid) +static const _CompressionUnit *findCompression (int compressionid) { int compressionno; diff -Naur audiofile-0.2.6.orig/libaudiofile/debug.c audiofile-0.2.6/libaudiofile/debug.c --- audiofile-0.2.6.orig/libaudiofile/debug.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/debug.c 2006-06-24 16:29:33.000000000 -0700 @@ -49,7 +49,7 @@ #include "print.h" #include "debug.h" -extern _CompressionUnit _af_compression[]; +extern const _CompressionUnit _af_compression[]; void _af_printid (u_int32_t id) { diff -Naur audiofile-0.2.6.orig/libaudiofile/format.c audiofile-0.2.6/libaudiofile/format.c --- audiofile-0.2.6.orig/libaudiofile/format.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/format.c 2006-06-24 16:29:33.000000000 -0700 @@ -43,7 +43,7 @@ #include "units.h" #include "modules.h" -extern _Unit _af_units[]; +extern const _Unit _af_units[]; AFfileoffset afGetDataOffset (AFfilehandle file, int trackid) { diff -Naur audiofile-0.2.6.orig/libaudiofile/g711.c audiofile-0.2.6/libaudiofile/g711.c --- audiofile-0.2.6.orig/libaudiofile/g711.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/g711.c 2006-06-24 16:29:33.000000000 -0700 @@ -38,7 +38,7 @@ #define SEG_MASK (0x70) /* Segment field mask. */ /* copy from CCITT G.711 specifications */ -static unsigned char _u2a[128] = { /* u- to A-law conversions */ +static const unsigned char _u2a[128] = { /* u- to A-law conversions */ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -56,7 +56,7 @@ 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128}; -static unsigned char _a2u[128] = { /* A- to u-law conversions */ +static const unsigned char _a2u[128] = { /* A- to u-law conversions */ 1, 3, 5, 7, 9, 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -77,7 +77,7 @@ /* see libst.h */ #ifdef SUPERCEDED -static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF, +static const short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF}; static int diff -Naur audiofile-0.2.6.orig/libaudiofile/instrument.c audiofile-0.2.6/libaudiofile/instrument.c --- audiofile-0.2.6.orig/libaudiofile/instrument.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/instrument.c 2006-06-24 16:29:33.000000000 -0700 @@ -55,7 +55,7 @@ #include -extern _Unit _af_units[]; +extern const _Unit _af_units[]; /* Initialize instrument id list for audio file. diff -Naur audiofile-0.2.6.orig/libaudiofile/modules.c audiofile-0.2.6/libaudiofile/modules.c --- audiofile-0.2.6.orig/libaudiofile/modules.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/modules.c 2006-06-24 16:29:33.000000000 -0700 @@ -56,15 +56,15 @@ #define NULLMODULEPARAM -extern _PCMInfo _af_default_signed_integer_pcm_mappings[]; -extern _PCMInfo _af_default_unsigned_integer_pcm_mappings[]; -extern _PCMInfo _af_default_float_pcm_mapping; -extern _PCMInfo _af_default_double_pcm_mapping; +extern const _PCMInfo _af_default_signed_integer_pcm_mappings[]; +extern const _PCMInfo _af_default_unsigned_integer_pcm_mappings[]; +extern const _PCMInfo _af_default_float_pcm_mapping; +extern const _PCMInfo _af_default_double_pcm_mapping; extern _CompressionUnit _af_compression[]; /* Define rebuffering modules. */ -extern _AFmodule int2rebufferv2f, int2rebufferf2v; +extern const _AFmodule int2rebufferv2f, int2rebufferf2v; /* module utility routines @@ -1511,7 +1511,7 @@ } }; -static _PCMInfo *intmappings[6] = +static const _PCMInfo *intmappings[6] = { &_af_default_signed_integer_pcm_mappings[1], &_af_default_signed_integer_pcm_mappings[2], diff -Naur audiofile-0.2.6.orig/libaudiofile/next.c audiofile-0.2.6/libaudiofile/next.c --- audiofile-0.2.6.orig/libaudiofile/next.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/next.c 2006-06-24 16:29:33.000000000 -0700 @@ -47,7 +47,7 @@ #include "setup.h" #include "byteorder.h" -int _af_next_compression_types[_AF_NEXT_NUM_COMPTYPES] = +const int _af_next_compression_types[_AF_NEXT_NUM_COMPTYPES] = { AF_COMPRESSION_G711_ULAW, AF_COMPRESSION_G711_ALAW diff -Naur audiofile-0.2.6.orig/libaudiofile/openclose.c audiofile-0.2.6/libaudiofile/openclose.c --- audiofile-0.2.6.orig/libaudiofile/openclose.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/openclose.c 2006-06-24 16:29:33.000000000 -0700 @@ -45,7 +45,7 @@ #define SETBINARYMODE(x) #endif /* WIN32 || __CYGWIN__ */ -extern _Unit _af_units[]; +extern const _Unit _af_units[]; static void freeFileHandle (AFfilehandle filehandle); static void freeInstParams (AFPVu *values, int fileFormat); diff -Naur audiofile-0.2.6.orig/libaudiofile/pcm.c audiofile-0.2.6/libaudiofile/pcm.c --- audiofile-0.2.6.orig/libaudiofile/pcm.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/pcm.c 2006-06-24 16:29:33.000000000 -0700 @@ -33,7 +33,7 @@ #include "pcm.h" #include "util.h" -_PCMInfo _af_default_signed_integer_pcm_mappings[] = +const _PCMInfo _af_default_signed_integer_pcm_mappings[] = { {0, 0, 0, 0}, {SLOPE_INT8, 0, MIN_INT8, MAX_INT8}, @@ -42,7 +42,7 @@ {SLOPE_INT32, 0, MIN_INT32, MAX_INT32} }; -_PCMInfo _af_default_unsigned_integer_pcm_mappings[] = +const _PCMInfo _af_default_unsigned_integer_pcm_mappings[] = { {0, 0, 0, 0}, {SLOPE_INT8, INTERCEPT_U_INT8, 0, MAX_U_INT8}, @@ -51,10 +51,10 @@ {SLOPE_INT32, INTERCEPT_U_INT32, 0, MAX_U_INT32} }; -_PCMInfo _af_default_float_pcm_mapping = +const _PCMInfo _af_default_float_pcm_mapping = {1, 0, 0, 0}; -_PCMInfo _af_default_double_pcm_mapping = +const _PCMInfo _af_default_double_pcm_mapping = {1, 0, 0, 0}; /* diff -Naur audiofile-0.2.6.orig/libaudiofile/query.c audiofile-0.2.6/libaudiofile/query.c --- audiofile-0.2.6.orig/libaudiofile/query.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/query.c 2006-06-24 16:29:33.000000000 -0700 @@ -43,8 +43,8 @@ #include "compression.h" #include "instrument.h" -extern _Unit _af_units[]; -extern _CompressionUnit _af_compression[]; +extern const _Unit _af_units[]; +extern const _CompressionUnit _af_compression[]; AUpvlist _afQueryFileFormat (int arg1, int arg2, int arg3, int arg4); AUpvlist _afQueryInstrument (int arg1, int arg2, int arg3, int arg4); diff -Naur audiofile-0.2.6.orig/libaudiofile/raw.c audiofile-0.2.6/libaudiofile/raw.c --- audiofile-0.2.6.orig/libaudiofile/raw.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/raw.c 2006-06-24 16:29:33.000000000 -0700 @@ -50,7 +50,7 @@ NULL /* miscellaneous */ }; -int _af_raw_compression_types[_AF_RAW_NUM_COMPTYPES] = +const int _af_raw_compression_types[_AF_RAW_NUM_COMPTYPES] = { AF_COMPRESSION_G711_ULAW, AF_COMPRESSION_G711_ALAW diff -Naur audiofile-0.2.6.orig/libaudiofile/setup.c audiofile-0.2.6/libaudiofile/setup.c --- audiofile-0.2.6.orig/libaudiofile/setup.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/setup.c 2006-06-24 16:29:33.000000000 -0700 @@ -39,7 +39,7 @@ extern _Unit _af_units[]; -_AFfilesetup _af_default_file_setup = +const _AFfilesetup _af_default_file_setup = { _AF_VALID_FILESETUP, /* valid */ #if WORDS_BIGENDIAN @@ -58,7 +58,7 @@ NULL /* miscellaneous */ }; -_InstrumentSetup _af_default_instrumentsetup = +const _InstrumentSetup _af_default_instrumentsetup = { 0, /* id */ 2, /* loopCount */ @@ -66,7 +66,7 @@ AF_FALSE /* loopSet */ }; -_TrackSetup _af_default_tracksetup = +const _TrackSetup _af_default_tracksetup = { 0, { diff -Naur audiofile-0.2.6.orig/libaudiofile/units.c audiofile-0.2.6/libaudiofile/units.c --- audiofile-0.2.6.orig/libaudiofile/units.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/units.c 2006-06-24 16:29:33.000000000 -0700 @@ -56,7 +56,7 @@ extern int _af_next_compression_types[]; extern int _af_wave_compression_types[]; -_Unit _af_units[_AF_NUM_UNITS] = +const _Unit _af_units[_AF_NUM_UNITS] = { { AF_FILE_RAWDATA, @@ -221,7 +221,7 @@ } }; -_CompressionUnit _af_compression[_AF_NUM_COMPRESSION] = +const _CompressionUnit _af_compression[_AF_NUM_COMPRESSION] = { { AF_COMPRESSION_NONE, diff -Naur audiofile-0.2.6.orig/libaudiofile/util.c audiofile-0.2.6/libaudiofile/util.c --- audiofile-0.2.6.orig/libaudiofile/util.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/util.c 2006-06-24 16:29:33.000000000 -0700 @@ -46,12 +46,12 @@ #include "byteorder.h" #include "aupvinternal.h" -extern _PCMInfo _af_default_signed_integer_pcm_mappings[]; -extern _PCMInfo _af_default_unsigned_integer_pcm_mappings[]; -extern _PCMInfo _af_default_float_pcm_mapping; -extern _PCMInfo _af_default_double_pcm_mapping; +extern const _PCMInfo _af_default_signed_integer_pcm_mappings[]; +extern const _PCMInfo _af_default_unsigned_integer_pcm_mappings[]; +extern const _PCMInfo _af_default_float_pcm_mapping; +extern const _PCMInfo _af_default_double_pcm_mapping; -extern _CompressionUnit _af_compression[]; +extern const _CompressionUnit _af_compression[]; /* _af_filesetup_ok and _af_filehandle_ok are sanity check routines diff -Naur audiofile-0.2.6.orig/libaudiofile/wave.c audiofile-0.2.6/libaudiofile/wave.c --- audiofile-0.2.6.orig/libaudiofile/wave.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/libaudiofile/wave.c 2006-06-24 16:29:33.000000000 -0700 @@ -49,13 +49,13 @@ #include "setup.h" #include "marker.h" -int _af_wave_compression_types[_AF_WAVE_NUM_COMPTYPES] = +const int _af_wave_compression_types[_AF_WAVE_NUM_COMPTYPES] = { AF_COMPRESSION_G711_ULAW, AF_COMPRESSION_G711_ALAW }; -_InstParamInfo _af_wave_inst_params[_AF_WAVE_NUM_INSTPARAMS] = +const _InstParamInfo _af_wave_inst_params[_AF_WAVE_NUM_INSTPARAMS] = { { AF_INST_MIDI_BASENOTE, AU_PVTYPE_LONG, "MIDI base note", {60} }, { AF_INST_NUMCENTS_DETUNE, AU_PVTYPE_LONG, "Detune in cents", {0} }, diff -Naur audiofile-0.2.6.orig/sfcommands/sfconvert.c audiofile-0.2.6/sfcommands/sfconvert.c --- audiofile-0.2.6.orig/sfcommands/sfconvert.c 2004-03-05 22:39:23.000000000 -0800 +++ audiofile-0.2.6/sfcommands/sfconvert.c 2006-06-24 16:26:22.000000000 -0700 @@ -66,12 +66,14 @@ AFfilehandle infile, outfile; AFfilesetup outfilesetup; - int sampleFormat, sampleWidth, channelCount; - double sampleRate; + int sampleFormat, sampleWidth, channelCount, byteOrder; + double sampleRate, outSampleRate; + int outSampleRateInt = -1; int outSampleFormat = -1, outSampleWidth = -1, - outChannelCount = -1; + outChannelCount = -1, outByteOrder = -1; double outMaxAmp = 1.0; + AFframecount totalFrames; if (argc < 3) @@ -88,7 +90,10 @@ { if (i + 1 >= argc) usageerror(); - if (!strcmp(argv[i+1], "aiff")) + + if (!strcmp(argv[i+1], "raw")) + outFileFormat = AF_FILE_RAWDATA; + else if (!strcmp(argv[i+1], "aiff")) outFileFormat = AF_FILE_AIFF; else if (!strcmp(argv[i+1], "aifc")) outFileFormat = AF_FILE_AIFFC; @@ -98,6 +103,12 @@ outFileFormat = AF_FILE_NEXTSND; else if (!strcmp(argv[i+1], "bics")) outFileFormat = AF_FILE_BICSF; + else if (!strcmp(argv[i+1], "avr")) + outFileFormat = AF_FILE_AVR; + else if (!strcmp(argv[i+1], "iff")) + outFileFormat = AF_FILE_IFF_8SVX; + else if (!strcmp(argv[i+1], "nist")) + outFileFormat = AF_FILE_NIST_SPHERE; else { fprintf(stderr, "sfconvert: Unknown format %s.\n", argv[i+1]); @@ -107,6 +118,22 @@ /* Increment for argument. */ i++; } + else if (!strcmp(argv[i], "byteorder")) + { + if (i + 1 >= argc) + usageerror(); + + if(!strcmp("big", argv[i+1])) { + outByteOrder = AF_BYTEORDER_BIGENDIAN; + } else if(!strcmp("little", argv[i+1])) { + outByteOrder = AF_BYTEORDER_LITTLEENDIAN; + } else { + usageerror(); + } + + /* Increment for argument. */ + i++; + } else if (!strcmp(argv[i], "channels")) { if (i + 1 >= argc) @@ -119,6 +146,20 @@ /* Increment for argument. */ i++; } + else if (!strcmp(argv[i], "rate")) + { + if (i + 1 >= argc) + usageerror(); + + outSampleRateInt = atoi(argv[i+1]); + if (outSampleRateInt <= 0) + usageerror(); + + outSampleRate = (double)outSampleRateInt; + + /* Increment for argument. */ + i++; + } else if (!strcmp(argv[i], "float")) { if (i + 1 >= argc) @@ -170,6 +211,7 @@ totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK); channelCount = afGetChannels(infile, AF_DEFAULT_TRACK); sampleRate = afGetRate(infile, AF_DEFAULT_TRACK); + byteOrder = afGetByteOrder(infile, AF_DEFAULT_TRACK); afGetSampleFormat(infile, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); /* Initialize output audio format parameters. */ @@ -184,14 +226,21 @@ outSampleWidth = sampleWidth; } + if (outByteOrder == -1) + outByteOrder = byteOrder; + if (outChannelCount == -1) outChannelCount = channelCount; + if (outSampleRateInt == -1) + outSampleRate = sampleRate; + afInitFileFormat(outfilesetup, outFileFormat); afInitSampleFormat(outfilesetup, AF_DEFAULT_TRACK, outSampleFormat, outSampleWidth); afInitChannels(outfilesetup, AF_DEFAULT_TRACK, outChannelCount); - afInitRate(outfilesetup, AF_DEFAULT_TRACK, sampleRate); + afInitRate(outfilesetup, AF_DEFAULT_TRACK, outSampleRate); + afInitByteOrder(outfilesetup, AF_DEFAULT_TRACK, outByteOrder); outfile = afOpenFile(outfilename, "w", outfilesetup); if (outfile == AF_NULL_FILEHANDLE) @@ -228,6 +277,7 @@ printf("\n"); printf("Where keywords specify format of input or output soundfile:\n"); + printf(" rate n sample rate (22050, 44100, 48000, etc.)\n"); printf(" byteorder e endian (e is big or little)\n"); printf(" channels n n-channel file (1 or 2)\n"); printf(" format f file format f (see below)\n"); @@ -239,11 +289,15 @@ printf("Currently supported formats are:\n"); printf("\n"); + printf(" raw \n"); printf(" aiff Audio Interchange File Format\n"); printf(" aifc AIFF-C File Format\n"); printf(" next NeXT/Sun Format\n"); printf(" wave MS RIFF WAVE Format\n"); printf(" bics Berkeley/IRCAM/CARL Sound File Format\n"); + printf(" avr Audio Visual Research File Format\n"); + printf(" iff Amiga IFF/8SVX Sound File Format\n"); + printf(" nist NIST SPHERE File Format\n"); printf("\n"); exit(EXIT_FAILURE);