summaryrefslogtreecommitdiff
path: root/third_party/resample/sndlib-20
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-04-07 16:01:41 +0000
committerBenny Prijono <bennylp@teluu.com>2007-04-07 16:01:41 +0000
commit0c4b2974931a0f030c81647c65058fd22108495b (patch)
tree5461e272d2f4cdf39935d7277c56b654dd848f32 /third_party/resample/sndlib-20
parentca07a9833149d270d1e5b44cfa381ac6ac03e39c (diff)
Changed resample to use speex (for now)
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/split-3rd-party@1171 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party/resample/sndlib-20')
-rw-r--r--third_party/resample/sndlib-20/_sndlib.h603
-rw-r--r--third_party/resample/sndlib-20/audio.c9867
-rw-r--r--third_party/resample/sndlib-20/configure13033
-rw-r--r--third_party/resample/sndlib-20/headers.c5797
-rw-r--r--third_party/resample/sndlib-20/io.c1513
-rw-r--r--third_party/resample/sndlib-20/makefile.in88
-rw-r--r--third_party/resample/sndlib-20/mus-config.h103
-rw-r--r--third_party/resample/sndlib-20/sndins/Makefile.in61
-rw-r--r--third_party/resample/sndlib-20/sndlib-strings.h150
-rw-r--r--third_party/resample/sndlib-20/sndlib.h457
-rw-r--r--third_party/resample/sndlib-20/sound.c1072
11 files changed, 0 insertions, 32744 deletions
diff --git a/third_party/resample/sndlib-20/_sndlib.h b/third_party/resample/sndlib-20/_sndlib.h
deleted file mode 100644
index 560290ec..00000000
--- a/third_party/resample/sndlib-20/_sndlib.h
+++ /dev/null
@@ -1,603 +0,0 @@
-#ifndef SNDLIB_H
-#define SNDLIB_H
-
-#define SNDLIB_VERSION 20
-#define SNDLIB_REVISION 0
-#define SNDLIB_DATE "28-Mar-06"
-
-#include <stdio.h>
-#include <mus-config.h>
-
-#if HAVE_UNISTD_H && (!(defined(_MSC_VER)))
- #include <unistd.h>
-#endif
-
-#include <sys/types.h>
-
-#ifndef __cplusplus
-#if HAVE_STDBOOL_H
- #include <stdbool.h>
-#else
-#ifndef true
- #define bool int
- #define true 1
- #define false 0
-#endif
-#endif
-#endif
-
-#if (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T > 4)) || (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64))
- #if (SIZEOF_OFF_T == SIZEOF_LONG)
- #define OFF_TD "%ld"
- #else
- #define OFF_TD "%lld"
- #endif
-#else
- #define OFF_TD "%d"
-#endif
-
-#ifndef MUS_LITTLE_ENDIAN
- #if WORDS_BIGENDIAN
- #define MUS_LITTLE_ENDIAN 0
- #else
- #define MUS_LITTLE_ENDIAN 1
- #endif
-#endif
-
-#ifndef c__FUNCTION__
-#if (HAVE___FUNC__) || (defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
- #define c__FUNCTION__ __func__
-#else
-#ifdef __GNUC__
- #define c__FUNCTION__ __FUNCTION__
-#else
- #define c__FUNCTION__ ""
-#endif
-#endif
-#endif
-
-#if (!defined(M_PI))
- #define M_PI 3.14159265358979323846264338327
- #define M_PI_2 (M_PI / 2.0)
-#endif
-
-#define POWER_OF_2_P(x) ((((x) - 1) & (x)) == 0)
-/* from sys/param.h */
-
-#ifndef SEEK_SET
- #define SEEK_SET 0
- #define SEEK_END 2
-#endif
-
-#if (!SNDLIB_USE_FLOATS)
- #define mus_sample_t int
- #ifndef MUS_SAMPLE_BITS
- #define MUS_SAMPLE_BITS 24
- #endif
- #define MUS_SAMPLE_0 0
- #define MUS_BYTE_TO_SAMPLE(n) ((mus_sample_t)((n) << (MUS_SAMPLE_BITS - 8)))
- #define MUS_SAMPLE_TO_BYTE(n) ((n) >> (MUS_SAMPLE_BITS - 8))
- #define MUS_SHORT_TO_SAMPLE(n) ((mus_sample_t)((n) << (MUS_SAMPLE_BITS - 16)))
- #define MUS_SAMPLE_TO_SHORT(n) ((short)((n) >> (MUS_SAMPLE_BITS - 16)))
- #if (MUS_SAMPLE_BITS < 24)
- #define MUS_INT24_TO_SAMPLE(n) ((mus_sample_t)((n) >> (24 - MUS_SAMPLE_BITS)))
- #define MUS_SAMPLE_TO_INT24(n) ((int)((n) << (24 - MUS_SAMPLE_BITS)))
- #else
- #define MUS_INT24_TO_SAMPLE(n) ((mus_sample_t)((n) << (MUS_SAMPLE_BITS - 24)))
- #define MUS_SAMPLE_TO_INT24(n) ((int)((n) >> (MUS_SAMPLE_BITS - 24)))
- #endif
- #define MUS_INT_TO_SAMPLE(n) ((mus_sample_t)(n))
- #define MUS_SAMPLE_TO_INT(n) ((int)(n))
- /* these are for direct read/write (no cross-image assumption is made about 32 bit int scaling) */
- #define MUS_FLOAT_TO_FIX ((MUS_SAMPLE_BITS < 32) ? (1 << (MUS_SAMPLE_BITS - 1)) : 0x7fffffff)
- #define MUS_FIX_TO_FLOAT (1.0 / (float)(MUS_FLOAT_TO_FIX))
- #define MUS_FLOAT_TO_SAMPLE(n) ((mus_sample_t)((n) * MUS_FLOAT_TO_FIX))
- #define MUS_SAMPLE_TO_FLOAT(n) ((float)((n) * MUS_FIX_TO_FLOAT))
- #define MUS_DOUBLE_TO_SAMPLE(n) ((mus_sample_t)((n) * MUS_FLOAT_TO_FIX))
- #define MUS_SAMPLE_TO_DOUBLE(n) ((double)((n) * MUS_FIX_TO_FLOAT))
- #define MUS_SAMPLE_MAX ((mus_sample_t)((MUS_SAMPLE_BITS < 32) ? (MUS_FLOAT_TO_FIX - 1) : 0x7fffffff))
- #define MUS_SAMPLE_MIN ((mus_sample_t)((MUS_SAMPLE_BITS < 32) ? (-(MUS_FLOAT_TO_FIX)) : -0x7fffffff))
- #define mus_sample_abs(Sample) abs(Sample)
-#else
- #define mus_sample_t Float
- #ifndef MUS_SAMPLE_BITS
- #define MUS_SAMPLE_BITS 24
- #endif
- #define MUS_SAMPLE_0 0.0
- #define MUS_BYTE_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << 7)))
- #define MUS_SHORT_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << 15)))
- #define MUS_INT_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << (MUS_SAMPLE_BITS - 1))))
- #define MUS_INT24_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << 23)))
- #define MUS_FLOAT_TO_FIX 1.0
- #define MUS_FIX_TO_FLOAT 1.0
- #define MUS_FLOAT_TO_SAMPLE(n) ((mus_sample_t)(n))
- #define MUS_DOUBLE_TO_SAMPLE(n) ((mus_sample_t)(n))
- #define MUS_SAMPLE_TO_FLOAT(n) ((Float)(n))
- #define MUS_SAMPLE_TO_DOUBLE(n) ((double)(n))
- #define MUS_SAMPLE_TO_INT(n) ((int)((n) * (1 << (MUS_SAMPLE_BITS - 1))))
- #define MUS_SAMPLE_TO_INT24(n) ((int)((n) * (1 << 23)))
- #define MUS_SAMPLE_TO_SHORT(n) ((short)((n) * (1 << 15)))
- #define MUS_SAMPLE_TO_BYTE(n) ((char)((n) * (1 << 7)))
- #define MUS_SAMPLE_MAX 0.99999
- #define MUS_SAMPLE_MIN (-1.0)
- #define mus_sample_abs(Sample) fabs(Sample)
-#endif
-
-enum {MUS_UNSUPPORTED, MUS_NEXT, MUS_AIFC, MUS_RIFF, MUS_BICSF, MUS_NIST, MUS_INRS, MUS_ESPS, MUS_SVX, MUS_VOC,
- MUS_SNDT, MUS_RAW, MUS_SMP, MUS_AVR, MUS_IRCAM, MUS_SD1, MUS_SPPACK, MUS_MUS10, MUS_HCOM, MUS_PSION, MUS_MAUD,
- MUS_IEEE, MUS_MATLAB, MUS_ADC, MUS_MIDI, MUS_SOUNDFONT, MUS_GRAVIS, MUS_COMDISCO, MUS_GOLDWAVE, MUS_SRFS,
- MUS_MIDI_SAMPLE_DUMP, MUS_DIAMONDWARE, MUS_ADF, MUS_SBSTUDIOII, MUS_DELUSION,
- MUS_FARANDOLE, MUS_SAMPLE_DUMP, MUS_ULTRATRACKER, MUS_YAMAHA_SY85, MUS_YAMAHA_TX16W, MUS_DIGIPLAYER,
- MUS_COVOX, MUS_AVI, MUS_OMF, MUS_QUICKTIME, MUS_ASF, MUS_YAMAHA_SY99, MUS_KURZWEIL_2000,
- MUS_AIFF, MUS_PAF, MUS_CSL, MUS_FILE_SAMP, MUS_PVF, MUS_SOUNDFORGE, MUS_TWINVQ, MUS_AKAI4,
- MUS_IMPULSETRACKER, MUS_KORG, MUS_NVF, MUS_MAUI, MUS_SDIF, MUS_OGG, MUS_FLAC, MUS_SPEEX, MUS_MPEG,
- MUS_SHORTEN, MUS_TTA, MUS_WAVPACK,
- MUS_NUM_HEADER_TYPES};
-
-#if defined(__GNUC__) && (!(defined(__cplusplus)))
- #define MUS_HEADER_TYPE_OK(n) ({ int _sndlib_h_0 = n; ((_sndlib_h_0 > MUS_UNSUPPORTED) && (_sndlib_h_0 <= MUS_MAUI)); })
-#else
- #define MUS_HEADER_TYPE_OK(n) (((n) > MUS_UNSUPPORTED) && ((n) <= MUS_MAUI))
-#endif
-
-enum {MUS_UNKNOWN, MUS_BSHORT, MUS_MULAW, MUS_BYTE, MUS_BFLOAT, MUS_BINT, MUS_ALAW, MUS_UBYTE, MUS_B24INT,
- MUS_BDOUBLE, MUS_LSHORT, MUS_LINT, MUS_LFLOAT, MUS_LDOUBLE, MUS_UBSHORT, MUS_ULSHORT, MUS_L24INT,
- MUS_BINTN, MUS_LINTN, MUS_BFLOAT_UNSCALED, MUS_LFLOAT_UNSCALED, MUS_BDOUBLE_UNSCALED, MUS_LDOUBLE_UNSCALED,
- MUS_NUM_DATA_FORMATS};
-
-/* MUS_LINTN and MUS_BINTN refer to 32 bit ints with 31 bits of "fraction" -- the data is "left justified" */
-/* "unscaled" means the float value is used directly (i.e. not as -1.0 to 1.0, but (probably) -32768.0 to 32768.0) */
-
-#if defined(__GNUC__) && (!(defined(__cplusplus)))
- #define MUS_DATA_FORMAT_OK(n) ({ int _sndlib_h_1 = n; ((_sndlib_h_1 > MUS_UNKNOWN) && (_sndlib_h_1 < MUS_NUM_DATA_FORMATS)); })
-#else
- #define MUS_DATA_FORMAT_OK(n) (((n) > MUS_UNKNOWN) && ((n) < MUS_NUM_DATA_FORMATS))
-#endif
-
-#if MUS_MAC_OSX
- #if MUS_LITTLE_ENDIAN
- #define MUS_AUDIO_COMPATIBLE_FORMAT MUS_LFLOAT
- #else
- #define MUS_AUDIO_COMPATIBLE_FORMAT MUS_BFLOAT
- #endif
-#else
- #if MUS_LITTLE_ENDIAN
- #define MUS_AUDIO_COMPATIBLE_FORMAT MUS_LSHORT
- #else
- #define MUS_AUDIO_COMPATIBLE_FORMAT MUS_BSHORT
- #endif
-#endif
-
-#define MUS_NIST_SHORTPACK 2
-#define MUS_AIFF_IMA_ADPCM 99
-
-#define MUS_AUDIO_PACK_SYSTEM(n) ((n) << 16)
-#define MUS_AUDIO_SYSTEM(n) (((n) >> 16) & 0xffff)
-#define MUS_AUDIO_DEVICE(n) ((n) & 0xffff)
-
-enum {MUS_AUDIO_DEFAULT, MUS_AUDIO_DUPLEX_DEFAULT, MUS_AUDIO_ADAT_IN, MUS_AUDIO_AES_IN, MUS_AUDIO_LINE_OUT,
- MUS_AUDIO_LINE_IN, MUS_AUDIO_MICROPHONE, MUS_AUDIO_SPEAKERS, MUS_AUDIO_DIGITAL_IN, MUS_AUDIO_DIGITAL_OUT,
- MUS_AUDIO_DAC_OUT, MUS_AUDIO_ADAT_OUT, MUS_AUDIO_AES_OUT, MUS_AUDIO_DAC_FILTER, MUS_AUDIO_MIXER,
- MUS_AUDIO_LINE1, MUS_AUDIO_LINE2, MUS_AUDIO_LINE3, MUS_AUDIO_AUX_INPUT, MUS_AUDIO_CD,
- MUS_AUDIO_AUX_OUTPUT, MUS_AUDIO_SPDIF_IN, MUS_AUDIO_SPDIF_OUT, MUS_AUDIO_AMP, MUS_AUDIO_SRATE,
- MUS_AUDIO_CHANNEL, MUS_AUDIO_FORMAT, MUS_AUDIO_IMIX, MUS_AUDIO_IGAIN, MUS_AUDIO_RECLEV,
- MUS_AUDIO_PCM, MUS_AUDIO_PCM2, MUS_AUDIO_OGAIN, MUS_AUDIO_LINE, MUS_AUDIO_SYNTH,
- MUS_AUDIO_BASS, MUS_AUDIO_TREBLE, MUS_AUDIO_PORT, MUS_AUDIO_SAMPLES_PER_CHANNEL,
- MUS_AUDIO_DIRECTION
-};
-/* Snd's recorder uses MUS_AUDIO_DIRECTION to find the size of this list */
-
-#if defined(__GNUC__) && (!(defined(__cplusplus)))
- #define MUS_AUDIO_DEVICE_OK(a) ({ int _sndlib_h_2 = a; ((_sndlib_h_2 >= MUS_AUDIO_DEFAULT) && (_sndlib_h_2 <= MUS_AUDIO_DIRECTION)); })
-#else
- #define MUS_AUDIO_DEVICE_OK(a) (((a) >= MUS_AUDIO_DEFAULT) && ((a) <= MUS_AUDIO_DIRECTION))
-#endif
-
-#define MUS_ERROR -1
-
-enum {MUS_NO_ERROR, MUS_NO_FREQUENCY, MUS_NO_PHASE, MUS_NO_GEN, MUS_NO_LENGTH,
- MUS_NO_FREE, MUS_NO_DESCRIBE, MUS_NO_DATA, MUS_NO_SCALER,
- MUS_MEMORY_ALLOCATION_FAILED, MUS_UNSTABLE_TWO_POLE_ERROR,
- MUS_CANT_OPEN_FILE, MUS_NO_SAMPLE_INPUT, MUS_NO_SAMPLE_OUTPUT,
- MUS_NO_SUCH_CHANNEL, MUS_NO_FILE_NAME_PROVIDED, MUS_NO_LOCATION, MUS_NO_CHANNEL,
- MUS_NO_SUCH_FFT_WINDOW, MUS_UNSUPPORTED_DATA_FORMAT, MUS_HEADER_READ_FAILED,
- MUS_UNSUPPORTED_HEADER_TYPE,
- MUS_FILE_DESCRIPTORS_NOT_INITIALIZED, MUS_NOT_A_SOUND_FILE, MUS_FILE_CLOSED, MUS_WRITE_ERROR,
- MUS_HEADER_WRITE_FAILED, MUS_CANT_OPEN_TEMP_FILE, MUS_INTERRUPTED, MUS_BAD_ENVELOPE,
-
- MUS_AUDIO_CHANNELS_NOT_AVAILABLE, MUS_AUDIO_SRATE_NOT_AVAILABLE, MUS_AUDIO_FORMAT_NOT_AVAILABLE,
- MUS_AUDIO_NO_INPUT_AVAILABLE, MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- MUS_AUDIO_NO_LINES_AVAILABLE, MUS_AUDIO_WRITE_ERROR, MUS_AUDIO_SIZE_NOT_AVAILABLE, MUS_AUDIO_DEVICE_NOT_AVAILABLE,
- MUS_AUDIO_CANT_CLOSE, MUS_AUDIO_CANT_OPEN, MUS_AUDIO_READ_ERROR, MUS_AUDIO_AMP_NOT_AVAILABLE,
- MUS_AUDIO_CANT_WRITE, MUS_AUDIO_CANT_READ, MUS_AUDIO_NO_READ_PERMISSION,
- MUS_CANT_CLOSE_FILE, MUS_ARG_OUT_OF_RANGE,
- MUS_MIDI_OPEN_ERROR, MUS_MIDI_READ_ERROR, MUS_MIDI_WRITE_ERROR, MUS_MIDI_CLOSE_ERROR, MUS_MIDI_INIT_ERROR, MUS_MIDI_MISC_ERROR,
-
- MUS_NO_CHANNELS, MUS_NO_HOP, MUS_NO_WIDTH, MUS_NO_FILE_NAME, MUS_NO_RAMP, MUS_NO_RUN,
- MUS_NO_INCREMENT, MUS_NO_OFFSET,
- MUS_NO_XCOEFF, MUS_NO_YCOEFF, MUS_NO_XCOEFFS, MUS_NO_YCOEFFS, MUS_NO_RESET,
- MUS_INITIAL_ERROR_TAG};
-
-/* keep this list in sync with mus_error_names in sound.c and snd-test.scm|rb */
-
-#if MUS_DEBUGGING
- #define CALLOC(a, b) mem_calloc((a), (b), c__FUNCTION__, __FILE__, __LINE__)
- #define MALLOC(a) mem_malloc((a), c__FUNCTION__, __FILE__, __LINE__)
-#ifndef __cplusplus
- #define FREE(a) a = mem_free(a, c__FUNCTION__, __FILE__, __LINE__)
-#else
- #define FREE(a) mem_free(a, c__FUNCTION__, __FILE__, __LINE__)
-#endif
- #define REALLOC(a, b) mem_realloc(a, (b), c__FUNCTION__, __FILE__, __LINE__)
-#else
- #define CALLOC(a, b) calloc((size_t)(a), (size_t)(b))
- #define MALLOC(a) malloc((size_t)(a))
- #define FREE(a) free(a)
- #define REALLOC(a, b) realloc(a, (size_t)(b))
-#endif
-
-#if MUS_WINDOZE
- #ifdef FOPEN
- #undef FOPEN
- #endif
- #if USE_SND
- #define OPEN(File, Flags, Mode) snd_open((File), (Flags), 0)
- #else
- #define OPEN(File, Flags, Mode) open((File), (Flags))
- #endif
-#else
- #if USE_SND
- #define OPEN(File, Flags, Mode) snd_open((File), (Flags), (Mode))
- #else
- #define OPEN(File, Flags, Mode) open((File), (Flags), (Mode))
- #endif
-#endif
-
-#if USE_SND
- #define FOPEN(File, Flags) snd_fopen((File), (Flags))
- #define CREAT(File, Flags) snd_creat((File), (Flags))
- #define REMOVE(OldF) snd_remove(OldF, IGNORE_CACHE)
- #define STRERROR(Err) snd_io_strerror()
- #define CLOSE(Fd, Name) snd_close(Fd, Name)
- #define FCLOSE(Fd, Name) snd_fclose(Fd, Name)
-#else
- #define FOPEN(File, Flags) fopen((File), (Flags))
- #define CREAT(File, Flags) creat((File), (Flags))
- #define REMOVE(OldF) remove(OldF)
- #define STRERROR(Err) strerror(Err)
- #define CLOSE(Fd, Name) close(Fd)
- #define FCLOSE(Fd, Name) fclose(Fd)
-#endif
-
-#ifndef S_setB
- #if HAVE_RUBY
- #define S_setB "set_"
- #endif
- #if HAVE_SCHEME
- #define S_setB "set! "
- #endif
- #if HAVE_FORTH
- #define S_setB "set-"
- #endif
- #if (!HAVE_EXTENSION_LANGUAGE)
- #define S_setB "set-"
- #endif
-#endif
-
-#define MUS_LOOP_INFO_SIZE 8
-
-#ifndef Float
- #define Float float
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* -------- sound.c -------- */
-
-#ifdef __GNUC__
- int mus_error(int error, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
- void mus_print(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
- char *mus_format(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
- void mus_snprintf(char *buffer, int buffer_len, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-#else
- int mus_error(int error, const char *format, ...);
- void mus_print(const char *format, ...);
- char *mus_format(const char *format, ...);
- void mus_snprintf(char *buffer, int buffer_len, const char *format, ...);
-#endif
-
-typedef void mus_error_handler_t(int type, char *msg);
-mus_error_handler_t *mus_error_set_handler (mus_error_handler_t *new_error_handler);
-int mus_make_error(char *error_name);
-const char *mus_error_type_to_string(int err);
-
-typedef void mus_print_handler_t(char *msg);
-mus_print_handler_t *mus_print_set_handler (mus_print_handler_t *new_print_handler);
-
-off_t mus_sound_samples(const char *arg);
-off_t mus_sound_frames(const char *arg);
-int mus_sound_datum_size(const char *arg);
-off_t mus_sound_data_location(const char *arg);
-int mus_sound_chans(const char *arg);
-int mus_sound_srate(const char *arg);
-int mus_sound_header_type(const char *arg);
-int mus_sound_data_format(const char *arg);
-int mus_sound_original_format(const char *arg);
-off_t mus_sound_comment_start(const char *arg);
-off_t mus_sound_comment_end(const char *arg);
-off_t mus_sound_length(const char *arg);
-int mus_sound_fact_samples(const char *arg);
-time_t mus_sound_write_date(const char *arg);
-int mus_sound_type_specifier(const char *arg);
-int mus_sound_block_align(const char *arg);
-int mus_sound_bits_per_sample(const char *arg);
-
-int mus_sound_set_chans(const char *arg, int val);
-int mus_sound_set_srate(const char *arg, int val);
-int mus_sound_set_header_type(const char *arg, int val);
-int mus_sound_set_data_format(const char *arg, int val);
-int mus_sound_set_data_location(const char *arg, off_t val);
-int mus_sound_set_samples(const char *arg, off_t val);
-
-const char *mus_header_type_name(int type);
-const char *mus_data_format_name(int format);
-char *mus_header_type_to_string(int type);
-char *mus_data_format_to_string(int format);
-const char *mus_data_format_short_name(int format);
-char *mus_sound_comment(const char *name);
-int mus_bytes_per_sample(int format);
-float mus_sound_duration(const char *arg);
-int mus_sound_initialize(void);
-int mus_sample_bits(void);
-int mus_sound_override_header(const char *arg, int srate, int chans, int format, int type, off_t location, off_t size);
-int mus_sound_forget(const char *name);
-int mus_sound_prune(void);
-void mus_sound_report_cache(FILE *fp);
-int *mus_sound_loop_info(const char *arg);
-void mus_sound_set_loop_info(const char *arg, int *loop);
-
-int mus_sound_open_input(const char *arg);
-int mus_sound_open_output(const char *arg, int srate, int chans, int data_format, int header_type, const char *comment);
-int mus_sound_reopen_output(const char *arg, int chans, int format, int type, off_t data_loc);
-int mus_sound_close_input(int fd);
-int mus_sound_close_output(int fd, off_t bytes_of_data);
-#define mus_sound_seek_frame(Ifd, Frm) mus_file_seek_frame(Ifd, Frm)
-#define mus_sound_read(Fd, Beg, End, Chans, Bufs) mus_file_read(Fd, Beg, End, Chans, Bufs)
-#define mus_sound_write(Fd, Beg, End, Chans, Bufs) mus_file_write(Fd, Beg, End, Chans, Bufs)
-
-off_t mus_sound_maxamps(const char *ifile, int chans, mus_sample_t *vals, off_t *times);
-int mus_sound_set_maxamps(const char *ifile, int chans, mus_sample_t *vals, off_t *times);
-bool mus_sound_maxamp_exists(const char *ifile);
-int mus_file_to_array(const char *filename, int chan, int start, int samples, mus_sample_t *array);
-int mus_array_to_file(const char *filename, mus_sample_t *ddata, int len, int srate, int channels);
-char *mus_array_to_file_with_error(const char *filename, mus_sample_t *ddata, int len, int srate, int channels);
-int mus_file_to_float_array(const char *filename, int chan, off_t start, int samples, Float *array);
-int mus_float_array_to_file(const char *filename, Float *ddata, int len, int srate, int channels);
-
-
-
-/* -------- audio.c -------- */
-
-#if (HAVE_OSS || HAVE_ALSA || HAVE_JACK)
- #define ALSA_API 0
- #define OSS_API 1
- #define JACK_API 2
-#endif
-
-void mus_audio_describe(void);
-char *mus_audio_report(void);
-int mus_audio_open_output(int dev, int srate, int chans, int format, int size);
-int mus_audio_open_input(int dev, int srate, int chans, int format, int size);
-int mus_audio_write(int line, char *buf, int bytes);
-int mus_audio_close(int line);
-int mus_audio_read(int line, char *buf, int bytes);
-
-int mus_audio_write_buffers(int line, int frames, int chans, mus_sample_t **bufs, int output_format, bool clipped);
-int mus_audio_read_buffers(int line, int frames, int chans, mus_sample_t **bufs, int input_format);
-
-int mus_audio_mixer_read(int dev, int field, int chan, float *val);
-int mus_audio_mixer_write(int dev, int field, int chan, float *val);
-int mus_audio_initialize(void);
-
-#if HAVE_OSS || HAVE_ALSA
- int mus_audio_reinitialize(void); /* 29-Aug-01 for CLM/Snd bugfix? */
- char *mus_alsa_playback_device(void);
- char *mus_alsa_set_playback_device(const char *name);
- char *mus_alsa_capture_device(void);
- char *mus_alsa_set_capture_device(const char *name);
- char *mus_alsa_device(void);
- char *mus_alsa_set_device(const char *name);
- int mus_alsa_buffer_size(void);
- int mus_alsa_set_buffer_size(int size);
- int mus_alsa_buffers(void);
- int mus_alsa_set_buffers(int num);
- bool mus_alsa_squelch_warning(void);
- bool mus_alsa_set_squelch_warning(bool val);
- int mus_audio_api(void);
- void mus_oss_set_buffers(int num, int size);
-#endif
-
-int mus_audio_systems(void);
-char *mus_audio_system_name(int sys);
-char *mus_audio_moniker(void);
-int mus_audio_compatible_format(int dev);
-
-#if MUS_SUN
- void mus_sun_set_outputs(int speakers, int headphones, int line_out);
-#endif
-
-#if MUS_NETBSD
- void mus_netbsd_set_outputs(int speakers, int headphones, int line_out);
-#endif
-
-#if (!HAVE_STRERROR)
- char *strerror(int errnum);
-#endif
-
-
-
-/* -------- io.c -------- */
-
-int mus_file_open_descriptors(int tfd, const char *arg, int df, int ds, off_t dl, int dc, int dt);
-int mus_file_open_read(const char *arg);
-bool mus_file_probe(const char *arg);
-int mus_file_open_write(const char *arg);
-int mus_file_create(const char *arg);
-int mus_file_reopen_write(const char *arg);
- int mus_file_close(int fd);
-off_t mus_file_seek_frame(int tfd, off_t frame);
-int mus_file_read(int fd, int beg, int end, int chans, mus_sample_t **bufs);
-int mus_file_read_chans(int fd, int beg, int end, int chans, mus_sample_t **bufs, mus_sample_t **cm);
-int mus_file_write(int tfd, int beg, int end, int chans, mus_sample_t **bufs);
-int mus_file_read_any(int tfd, int beg, int chans, int nints, mus_sample_t **bufs, mus_sample_t **cm);
-int mus_file_read_file(int tfd, int beg, int chans, int nints, mus_sample_t **bufs);
-int mus_file_read_buffer(int charbuf_data_format, int beg, int chans, int nints, mus_sample_t **bufs, char *charbuf);
-int mus_file_write_file(int tfd, int beg, int end, int chans, mus_sample_t **bufs);
-int mus_file_write_buffer(int charbuf_data_format, int beg, int end, int chans, mus_sample_t **bufs, char *charbuf, bool clipped);
-char *mus_expand_filename(const char *name);
-char *mus_getcwd(void);
-
-bool mus_clipping(void);
-bool mus_set_clipping(bool new_value);
-bool mus_file_clipping(int tfd);
-int mus_file_set_clipping(int tfd, bool clipped);
-
-int mus_file_set_header_type(int tfd, int type);
-int mus_file_header_type(int tfd);
-char *mus_file_fd_name(int tfd);
-int mus_file_set_chans(int tfd, int chans);
-
-Float mus_file_prescaler(int tfd);
-Float mus_file_set_prescaler(int tfd, Float val);
-Float mus_prescaler(void);
-Float mus_set_prescaler(Float new_value);
-
-void mus_bint_to_char(unsigned char *j, int x);
-int mus_char_to_bint(const unsigned char *inp);
-void mus_lint_to_char(unsigned char *j, int x);
-int mus_char_to_lint(const unsigned char *inp);
-int mus_char_to_uninterpreted_int(const unsigned char *inp);
-void mus_bfloat_to_char(unsigned char *j, float x);
-float mus_char_to_bfloat(const unsigned char *inp);
-void mus_lfloat_to_char(unsigned char *j, float x);
-float mus_char_to_lfloat(const unsigned char *inp);
-void mus_bshort_to_char(unsigned char *j, short x);
-short mus_char_to_bshort(const unsigned char *inp);
-void mus_lshort_to_char(unsigned char *j, short x);
-short mus_char_to_lshort(const unsigned char *inp);
-void mus_ubshort_to_char(unsigned char *j, unsigned short x);
-unsigned short mus_char_to_ubshort(const unsigned char *inp);
-void mus_ulshort_to_char(unsigned char *j, unsigned short x);
-unsigned short mus_char_to_ulshort(const unsigned char *inp);
-double mus_char_to_ldouble(const unsigned char *inp);
-double mus_char_to_bdouble(const unsigned char *inp);
-void mus_bdouble_to_char(unsigned char *j, double x);
-void mus_ldouble_to_char(unsigned char *j, double x);
-unsigned int mus_char_to_ubint(const unsigned char *inp);
-unsigned int mus_char_to_ulint(const unsigned char *inp);
-
-int mus_iclamp(int lo, int val, int hi);
-off_t mus_oclamp(off_t lo, off_t val, off_t hi);
-Float mus_fclamp(Float lo, Float val, Float hi);
-
-/* for CLM */
-/* these are needed to clear a saved lisp image to the just-initialized state */
-void mus_reset_io_c(void);
-void mus_reset_headers_c(void);
-void mus_reset_audio_c(void);
-
-
-
-/* -------- headers.c -------- */
-
-off_t mus_header_samples(void);
-off_t mus_header_data_location(void);
-int mus_header_chans(void);
-int mus_header_srate(void);
-int mus_header_type(void);
-int mus_header_format(void);
-off_t mus_header_comment_start(void);
-off_t mus_header_comment_end(void);
-int mus_header_type_specifier(void);
-int mus_header_bits_per_sample(void);
-int mus_header_fact_samples(void);
-int mus_header_block_align(void);
-int mus_header_loop_mode(int which);
-int mus_header_loop_start(int which);
-int mus_header_loop_end(int which);
-int mus_header_mark_position(int id);
-int mus_header_base_note(void);
-int mus_header_base_detune(void);
-void mus_header_set_raw_defaults(int sr, int chn, int frm);
-void mus_header_raw_defaults(int *sr, int *chn, int *frm);
-off_t mus_header_true_length(void);
-int mus_header_original_format(void);
-off_t mus_samples_to_bytes(int format, off_t size);
-off_t mus_bytes_to_samples(int format, off_t size);
-int mus_header_write_next_header(int chan, int srate, int chans, int loc, int siz, int format, const char *comment, int len);
-int mus_header_read(const char *name);
-int mus_header_write(const char *name, int type, int srate, int chans, off_t loc, off_t size_in_samples, int format, const char *comment, int len);
-off_t mus_header_aux_comment_start(int n);
-off_t mus_header_aux_comment_end(int n);
-int mus_header_initialize(void);
-bool mus_header_writable(int type, int format);
-void mus_header_set_aiff_loop_info(int *data);
-int mus_header_sf2_entries(void);
-char *mus_header_sf2_name(int n);
-int mus_header_sf2_start(int n);
-int mus_header_sf2_end(int n);
-int mus_header_sf2_loop_start(int n);
-int mus_header_sf2_loop_end(int n);
-const char *mus_header_original_format_name(int format, int type);
-bool mus_header_no_header(const char *name);
-
-char *mus_header_riff_aux_comment(const char *name, off_t *starts, off_t *ends);
-char *mus_header_aiff_aux_comment(const char *name, off_t *starts, off_t *ends);
-
-int mus_header_change_chans(const char *filename, int type, int new_chans);
-int mus_header_change_srate(const char *filename, int type, int new_srate);
-int mus_header_change_type(const char *filename, int new_type, int new_format);
-int mus_header_change_format(const char *filename, int type, int new_format);
-int mus_header_change_location(const char *filename, int type, off_t new_location);
-int mus_header_change_comment(const char *filename, int type, char *new_comment);
-int mus_header_change_data_size(const char *filename, int type, off_t bytes);
-
-typedef void mus_header_write_hook_t(const char *filename);
-mus_header_write_hook_t *mus_header_write_set_hook(mus_header_write_hook_t *new_hook);
-
-
-/* -------- midi.c -------- */
-int mus_midi_open_read(const char *name);
-int mus_midi_open_write(const char *name);
-int mus_midi_close(int line);
-int mus_midi_read(int line, unsigned char *buffer, int bytes);
-int mus_midi_write(int line, unsigned char *buffer, int bytes);
-char *mus_midi_device_name(int sysdev);
-char *mus_midi_describe(void);
-#if HAVE_EXTENSION_LANGUAGE
- void mus_midi_init(void);
-#endif
-
-
-#if MUS_DEBUGGING
- /* snd-utils.c (only used in conjunction with Snd's memory tracking functions) */
- void *mem_calloc(int len, int size, const char *func, const char *file, int line);
- void *mem_malloc(int len, const char *func, const char *file, int line);
- void *mem_free(void *ptr, const char *func, const char *file, int line);
- void *mem_realloc(void *ptr, int size, const char *func, const char *file, int line);
-#endif
-
-#if (!HAVE_STRDUP)
-char *strdup(const char *str);
-#endif
-#if (!HAVE_FILENO)
-int fileno(FILE *fp);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/third_party/resample/sndlib-20/audio.c b/third_party/resample/sndlib-20/audio.c
deleted file mode 100644
index 32649bb3..00000000
--- a/third_party/resample/sndlib-20/audio.c
+++ /dev/null
@@ -1,9867 +0,0 @@
-/* Audio hardware handlers (SGI, OSS, ALSA, Sun, Windows, Mac OSX, Jack, ESD, HPUX, NetBSD) */
-
-/*
- * layout of this file:
- * error handlers
- * SGI new and old audio library
- * OSS (with Sam 9407 support)
- * ALSA
- * Sun (has switches for OpenBSD, but they're untested)
- * Windows 95/98
- * OSX
- * ESD
- * JACK
- * HPUX
- * NetBSD
- * audio describers
- */
-
-/*
- * void mus_audio_describe(void) describes the audio hardware state.
- * char *mus_audio_report(void) returns the same information as a string.
- *
- * int mus_audio_open_output(int dev, int srate, int chans, int format, int size)
- * int mus_audio_open_input(int dev, int srate, int chans, int format, int size)
- * int mus_audio_write(int line, char *buf, int bytes)
- * int mus_audio_close(int line)
- * int mus_audio_read(int line, char *buf, int bytes)
- *
- * int mus_audio_mixer_read(int dev, int field, int chan, float *val)
- * int mus_audio_mixer_write(int dev, int field, int chan, float *val)
- * int mus_audio_initialize(void) does whatever is needed to get set up
- * int mus_audio_systems(void) returns number of separate complete audio systems (soundcards essentially)
- * AUDIO_SYSTEM(n) selects the nth card (counting from 0), AUDIO_SYSTEM(0) is always the default
- * char *mus_audio_system_name(int system) returns some user-recognizable (?) name for the given card (don't free)
- * char *mus_audio_moniker(void) returns some brief description of the overall audio setup (don't free return string).
- */
-
-/* error handling is tricky here -- higher levels are using many calls as probes, so
- * the "error" is a sign of non-existence, not a true error. So, for nearly all
- * cases, I'll use mus_print, not mus_error.
- */
-
-#include <mus-config.h>
-
-#if USE_SND && MUS_MAC_OSX && USE_MOTIF
- #undef USE_MOTIF
- #define USE_NO_GUI 1
- /* Xt's Boolean (/usr/include/X11/Intrinsic.h = char) collides with MacTypes.h Boolean, (actually,
- * unsigned char in /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreFoundation.framework/Versions/A/Headers/CFBase.h)
- * but we want snd.h for other stuff, so, if Motif is in use, don't load its headers at this time
- * perhaps we could use the -funsigned-char switch in gcc
- */
-#endif
-
-#if USE_SND && MUS_MAC_OSX && HAVE_RUBY
- /* if using Ruby, OpenTransport.h T_* definitions collide with Ruby's -- it isn't needed here, so... */
- #define REDEFINE_HAVE_RUBY 1
- #undef HAVE_RUBY
-#endif
-
-#if USE_SND
- #include "snd.h"
-#else
- #define PRINT_BUFFER_SIZE 512
- #define LABEL_BUFFER_SIZE 64
-#endif
-
-#if USE_SND && MUS_MAC_OSX
- #define USE_MOTIF 1
- #undef USE_NO_GUI
- #if REDEFINE_HAVE_RUBY
- #define HAVE_RUBY 1
- #endif
-#endif
-
-#include <math.h>
-#include <stdio.h>
-#if HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#include <errno.h>
-#include <stdlib.h>
-#if (defined(HAVE_LIBC_H) && (!defined(HAVE_UNISTD_H)))
- #include <libc.h>
-#else
- #if (!(defined(_MSC_VER)))
- #include <unistd.h>
- #endif
-#endif
-#if HAVE_STRING_H
- #include <string.h>
-#endif
-
-#if HAVE_SAM_9407
- #include <sys/sam9407.h>
-#endif
-
-#ifdef MUS_MAC_OSX
-#include <CoreServices/CoreServices.h>
-#include <CoreAudio/CoreAudio.h>
-/* these pull in stdbool.h apparently, so they have to precede sndlib.h */
-#endif
-
-#include "_sndlib.h"
-#include "sndlib-strings.h"
-
-#if (!HAVE_STRERROR)
-char *strerror(int errnum)
-{
- char *strerrbuf;
- strerrbuf = (char *)CALLOC(LABEL_BUFFER_SIZE, sizeof(char));
- mus_snprintf(strerrbuf, LABEL_BUFFER_SIZE, "io err %d", errnum);
- return(strerrbuf);
-}
-#endif
-
-#define MUS_STANDARD_ERROR(Error_Type, Error_Message) \
- mus_print("%s\n [%s[%d] %s]", Error_Message, __FILE__, __LINE__, c__FUNCTION__)
-
-#define MUS_STANDARD_IO_ERROR(Error_Type, IO_Func, IO_Name) \
- mus_print("%s %s: %s\n [%s[%d] %s]", IO_Func, IO_Name, strerror(errno), __FILE__, __LINE__, c__FUNCTION__)
-
-
-static char *version_name = NULL;
-static bool audio_initialized = false;
-
-static const char *mus_audio_device_names[] = {
- S_mus_audio_default, S_mus_audio_duplex_default, S_mus_audio_adat_in, S_mus_audio_aes_in, S_mus_audio_line_out,
- S_mus_audio_line_in, S_mus_audio_microphone, S_mus_audio_speakers, S_mus_audio_digital_in, S_mus_audio_digital_out,
- S_mus_audio_dac_out, S_mus_audio_adat_out, S_mus_audio_aes_out, S_mus_audio_dac_filter, S_mus_audio_mixer,
- S_mus_audio_line1, S_mus_audio_line2, S_mus_audio_line3, S_mus_audio_aux_input, S_mus_audio_cd,
- S_mus_audio_aux_output, S_mus_audio_spdif_in, S_mus_audio_spdif_out, S_mus_audio_amp, S_mus_audio_srate,
- S_mus_audio_channel, S_mus_audio_format, S_mus_audio_imix, S_mus_audio_igain, S_mus_audio_reclev,
- S_mus_audio_pcm, S_mus_audio_pcm2, S_mus_audio_ogain, S_mus_audio_line, S_mus_audio_synth,
- S_mus_audio_bass, S_mus_audio_treble, S_mus_audio_port, S_mus_audio_samples_per_channel,
- S_mus_audio_direction
-};
-
-static const char *mus_audio_device_name(int dev)
-{
- if (MUS_AUDIO_DEVICE_OK(dev))
- return(mus_audio_device_names[dev]);
- return("invalid device");
-}
-
-#if (!HAVE_OSS) || (HAVE_ALSA)
-static const char *mus_audio_format_names[] = {
- "unknown", S_mus_bshort, S_mus_mulaw, S_mus_byte, S_mus_bfloat, S_mus_bint, S_mus_alaw, S_mus_ubyte, S_mus_b24int,
- S_mus_bdouble, S_mus_lshort, S_mus_lint, S_mus_lfloat, S_mus_ldouble, S_mus_ubshort, S_mus_ulshort, S_mus_l24int,
- S_mus_bintn, S_mus_lintn
-};
-
-static const char *mus_audio_format_name(int fr)
-{
- if (MUS_DATA_FORMAT_OK(fr))
- return(mus_audio_format_names[fr]);
- return("invalid format");
-}
-#endif
-
-static char *audio_strbuf = NULL; /* previous name "strbuf" collides with Mac OSX global! */
-static void pprint(char *str);
-
-int device_channels(int dev);
-int device_gains(int dev);
-
-int device_channels(int dev)
-{
- float val[4];
-#if USE_SND && MUS_DEBUGGING
- XEN res;
- res = XEN_EVAL_C_STRING("(if (defined? 'debugging-device-channels) debugging-device-channels 0)");
- if (XEN_INTEGER_P(res))
- {
- int chans;
- chans = XEN_TO_C_INT(res);
- if (chans > 0) return(chans);
- }
-#endif
- mus_audio_mixer_read(dev, MUS_AUDIO_CHANNEL, 0, val);
- return((int)val[0]);
-}
-
-int device_gains(int ur_dev)
-{
- float val[4];
- int err;
- int dev;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- /* to get hardware gains, read device amp_field and error = none */
- if ((dev == MUS_AUDIO_DAC_FILTER) || (dev == MUS_AUDIO_MIXER))
- {
- err = mus_audio_mixer_read(ur_dev, MUS_AUDIO_CHANNEL, 0, val);
-#ifdef HAVE_ALSA
- if (err != MUS_NO_ERROR) return(0);
-#endif
- return((int)val[0]);
- }
- err = mus_audio_mixer_read(ur_dev, MUS_AUDIO_AMP, 0, val);
- if (err != MUS_NO_ERROR) return(0);
- return(device_channels(ur_dev));
-}
-
-
-
-/* ------------------------------- SGI ----------------------------------------- */
-
-#ifdef MUS_SGI
-#define AUDIO_OK
-
-#include <audio.h>
-
-int mus_audio_systems(void) {return(1);} /* I think more than 1 is possible, but don't have a case to test with */
-
-char *mus_audio_system_name(int system) {return("SGI");}
-
-char *mus_audio_moniker(void)
-{
-#ifdef AL_RESOURCE
- return("New SGI audio");
-#else
- return("Old SGI audio");
-#endif
-}
-
-#ifndef AL_RESOURCE
-static char *alGetErrorString(int err)
-{
- switch (err)
- {
- case AL_BAD_NOT_IMPLEMENTED: return("not implemented yet"); break;
- case AL_BAD_PORT: return("tried to use an invalid port"); break;
- case AL_BAD_CONFIG: return("tried to use an invalid configuration"); break;
- case AL_BAD_DEVICE: return("tried to use an invalid device"); break;
- case AL_BAD_DEVICE_ACCESS: return("unable to access the device"); break;
- case AL_BAD_DIRECTION: return("invalid direction given for port"); break;
- case AL_BAD_OUT_OF_MEM: return("operation has run out of memory"); break;
- case AL_BAD_NO_PORTS: return("not able to allocate a port"); break;
- case AL_BAD_WIDTH: return("invalid sample width given"); break;
- case AL_BAD_ILLEGAL_STATE: return("an invalid state has occurred"); break;
- case AL_BAD_QSIZE: return("attempt to set an invalid queue size"); break;
- case AL_BAD_FILLPOINT: return("attempt to set an invalid fillpoint"); break;
- case AL_BAD_BUFFER_NULL: return("null buffer pointer"); break;
- case AL_BAD_COUNT_NEG: return("negative count"); break;
- case AL_BAD_PVBUFFER: return("param/val buffer doesn't make sense"); break;
- case AL_BAD_BUFFERLENGTH_NEG: return("negative buffer length"); break;
- case AL_BAD_BUFFERLENGTH_ODD: return("odd length parameter/value buffer"); break;
- case AL_BAD_CHANNELS: return("invalid channel specifier"); break;
- case AL_BAD_PARAM: return("invalid parameter"); break;
- case AL_BAD_SAMPFMT: return("attempt to set invalid sample format"); break;
- case AL_BAD_RATE: return("invalid sample rate token"); break;
- case AL_BAD_TRANSFER_SIZE: return("invalid size for sample read/write"); break;
- case AL_BAD_FLOATMAX: return("invalid size for floatmax"); break;
- case AL_BAD_PORTSTYLE: return("invalid port style"); break;
- default: return("");
- }
-}
-#endif
-
-static char *sgi_err_buf = NULL;
-static mus_print_handler_t *old_handler = NULL;
-
-static void sgi_mus_print(char *msg)
-{
- int oserr = oserror();
- if (oserr)
- {
- if (sgi_err_buf == NULL) sgi_err_buf = (char *)CALLOC(PRINT_BUFFER_SIZE, sizeof(char));
- mus_snprintf(sgi_err_buf, PRINT_BUFFER_SIZE, "%s [%s]", msg, alGetErrorString(oserr));
- (*old_handler)(sgi_err_buf);
- }
- else (*old_handler)(msg);
-}
-
-static void start_sgi_print(void)
-{
- if (old_handler != sgi_mus_print)
- old_handler = mus_print_set_handler(sgi_mus_print);
-}
-
-static void end_sgi_print(void)
-{
- if (old_handler != sgi_mus_print)
- mus_print_set_handler(old_handler);
- else mus_print_set_handler(NULL);
-}
-
-
-#if AL_RESOURCE
- #define al_free(Line) alFreeConfig(config[Line])
- #define al_newconfig() alNewConfig()
- #define al_setsampfmt(Line, Format) alSetSampFmt(Line, Format)
- #define al_setchannels(Line, Chans) alSetChannels(Line, Chans)
- #define al_setwidth(Line, Width) alSetWidth(Line, Width)
- #define al_setqueuesize(Line, Size) alSetQueueSize(Line, Size)
- #define al_openport(Name, Flag, Line) alOpenPort(Name, Flag, Line)
- #define al_getfilled(Port) alGetFilled(Port)
- #define al_closeport(Port) alClosePort(Port)
- #define al_freeconfig(Config) alFreeConfig(Config)
-#else
- #define al_free(Line) ALfreeconfig(config[Line]);
- #define al_newconfig() ALnewconfig()
- #define al_setsampfmt(Line, Format) ALsetsampfmt(Line, Format)
- #define al_setchannels(Line, Chans) ALsetchannels(Line, Chans)
- #define al_setwidth(Line, Width) ALsetwidth(Line, Width)
- #define al_setqueuesize(Line, Size) ALsetqueuesize(Line, Size)
- #define al_openport(Name, Flag, Line) ALopenport(Name, Flag, Line)
- #define al_getfilled(Port) ALgetfilled(Port)
- #define al_closeport(Port) ALcloseport(Port)
- #define al_freeconfig(Config) ALfreeconfig(Config)
-#endif
-
-
-#define RETURN_ERROR_EXIT(Error_Type, Audio_Line, Ur_Error_Message) \
- do { \
- char *Error_Message; Error_Message = Ur_Error_Message; \
- if (Audio_Line != -1) al_free(Audio_Line); \
- if (Error_Message) \
- { \
- MUS_STANDARD_ERROR(Error_Type, Error_Message); FREE(Error_Message); \
- } \
- else MUS_STANDARD_ERROR(Error_Type, mus_error_type_to_string(Error_Type)); \
- end_sgi_print(); \
- return(MUS_ERROR); \
- } while (false)
-
-
-#ifdef AL_RESOURCE
-
-static int check_queue_size(int size, int chans)
-{
- if (size > chans * 1024)
- return(size);
- else return(chans * 1024);
-}
-
-#else
-
-#define STEREO_QUEUE_MIN_SIZE 1024
-#define STEREO_QUEUE_MIN_CHOICE 1024
-/* docs say 510 or 512, but they die with "File size limit exceeded" %$@#!(& */
-#define MONO_QUEUE_MIN_SIZE 1019
-#define MONO_QUEUE_MIN_CHOICE 1024
-#define STEREO_QUEUE_MAX_SIZE 131069
-#define STEREO_QUEUE_MAX_CHOICE 65536
-#define MONO_QUEUE_MAX_SIZE 262139
-#define MONO_QUEUE_MAX_CHOICE 131072
-/* if these limits are not followed, the damned thing dumps core and dies */
-
-static int check_queue_size(int size, int chans)
-{
- if ((chans == 1) && (size > MONO_QUEUE_MAX_SIZE)) return(MONO_QUEUE_MAX_CHOICE);
- if ((chans == 1) && (size < MONO_QUEUE_MIN_SIZE)) return(MONO_QUEUE_MIN_CHOICE);
- if ((chans > 1) && (size > STEREO_QUEUE_MAX_SIZE)) return(STEREO_QUEUE_MAX_CHOICE);
- if ((chans > 1) && (size < STEREO_QUEUE_MIN_SIZE)) return(STEREO_QUEUE_MIN_CHOICE);
- return(size);
-}
-
-static void check_quad(int device, int channels)
-{
- long sr[2];
- /* if quad, make sure we are set up for it, else make sure we aren't (perhaps the latter is unnecessary) */
- /* in 4 channel mode, stereo mic and line-in are 4 inputs, headphones/speakers and stereo line-out are the 4 outputs */
- sr[0] = AL_CHANNEL_MODE;
- ALgetparams(device, sr, 2);
- if ((channels == 4) && (sr[1] != AL_4CHANNEL))
- {
- sr[1] = AL_4CHANNEL;
- ALsetparams(device, sr, 2);
- }
- else
- {
- if ((channels != 4) && (sr[1] != AL_STEREO))
- {
- sr[1] = AL_STEREO;
- ALsetparams(device, sr, 2);
- }
- }
-}
-#endif
-
-#define IO_LINES 8
-static ALconfig *config = NULL;
-static ALport *port = NULL;
-static int *line_in_use = NULL;
-static int *channels = NULL;
-static long *device = NULL;
-static int *datum_size = NULL;
-static int *line_out = NULL;
-
-int mus_audio_initialize(void)
-{
- if (!audio_initialized)
- {
- audio_initialized = true;
- config = (ALconfig *)CALLOC(IO_LINES, sizeof(ALconfig));
- port = (ALport *)CALLOC(IO_LINES, sizeof(ALport));
- line_in_use = (int *)CALLOC(IO_LINES, sizeof(int));
- channels = (int *)CALLOC(IO_LINES, sizeof(int));
- device = (long *)CALLOC(IO_LINES, sizeof(long));
- datum_size = (int *)CALLOC(IO_LINES, sizeof(int));
- line_out = (int *)CALLOC(IO_LINES, sizeof(int));
- }
- return(MUS_NO_ERROR);
-}
-
-#ifdef AL_RESOURCE
-static int to_al_interface_or_device(int dev, int which)
-{
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DUPLEX_DEFAULT: return(AL_DEFAULT_OUTPUT); break;
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_SPEAKERS: return(alGetResourceByName(AL_SYSTEM, "Analog Out", which)); break;
- case MUS_AUDIO_MICROPHONE: return(alGetResourceByName(AL_SYSTEM, "Microphone", which)); break;
- case MUS_AUDIO_ADAT_IN: return(alGetResourceByName(AL_SYSTEM, "ADAT In", which)); break;
- case MUS_AUDIO_AES_IN: return(alGetResourceByName(AL_SYSTEM, "AES In", which)); break;
- case MUS_AUDIO_ADAT_OUT: return(alGetResourceByName(AL_SYSTEM, "ADAT Out", which)); break;
- case MUS_AUDIO_DIGITAL_OUT:
- case MUS_AUDIO_AES_OUT: return(alGetResourceByName(AL_SYSTEM, "AES Out", which)); break;
- case MUS_AUDIO_LINE_IN: return(alGetResourceByName(AL_SYSTEM, "Line In", which)); break;
- case MUS_AUDIO_LINE_OUT: return(alGetResourceByName(AL_SYSTEM, "Line Out2", which)); break; /* ?? */
- /* case MUS_AUDIO_DIGITAL_IN: return(alGetResourceByName(AL_SYSTEM, "DAC2 In", which)); break; */ /* this is analog in ?? */
- }
- return(MUS_ERROR);
-}
-
-static int to_al_device(int dev)
-{
- return(to_al_interface_or_device(dev, AL_DEVICE_TYPE));
-}
-
-static int to_al_interface(int dev)
-{
- return(to_al_interface_or_device(dev, AL_INTERFACE_TYPE));
-}
-#endif
-
-#include <stdio.h>
-
-/* just a placeholder for now */
-int find_audio_output(int chans)
-{
-#ifdef AL_RESOURCE
- ALvalue x[32];
- ALpv y;
- int n, i;
- y.param = AL_INTERFACE;
- y.value.i = AL_DIGITAL_IF_TYPE;
- n = alQueryValues(AL_SYSTEM, AL_DEFAULT_OUTPUT, x, 32, &y, 1);
- for (i = 0; i < n; i++)
- {
- y.param = AL_CHANNELS;
- alGetParams(x[i].i, &y, 1);
- if (chans <= y.value.i) return(x[i].i);
- }
-#endif
- return(MUS_ERROR);
-}
-
-static int to_sgi_format(int frm)
-{
- switch (frm)
- {
- case MUS_BYTE:
- case MUS_BSHORT:
- case MUS_B24INT: return(AL_SAMPFMT_TWOSCOMP); break;
- case MUS_BFLOAT: return(AL_SAMPFMT_FLOAT); break;
- case MUS_BDOUBLE: return(AL_SAMPFMT_DOUBLE); break;
- }
- return(MUS_ERROR);
-}
-
-int mus_audio_open_output(int ur_dev, int srate, int chans, int format, int requested_size)
-{
-#ifdef AL_RESOURCE
- ALpv z[2];
-#endif
- long sr[2];
- int i, line, size, width, sgi_format, dev;
- start_sgi_print();
- dev = MUS_AUDIO_DEVICE(ur_dev);
- line = -1;
- for (i = 0; i < IO_LINES; i++)
- if (line_in_use[i] == 0)
- {
- line = i;
- break;
- }
- if (line == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_NO_LINES_AVAILABLE, line,
- "no free audio lines?");
- channels[line] = chans;
- line_out[line] = 1;
-
- if (requested_size == 0)
- size = 1024 * chans;
- else size = check_queue_size(requested_size, chans);
- /* if (chans > 2) size = 65536; */ /* for temp adat code */
-
- datum_size[line] = mus_bytes_per_sample(format);
- if (datum_size[line] == 3)
- width = AL_SAMPLE_24;
- else
- {
- if (datum_size[line] == 1)
- width = AL_SAMPLE_8;
- else width = AL_SAMPLE_16;
- }
- sgi_format = to_sgi_format(format);
- if (sgi_format == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %d (%s) not supported by SGI",
- format,
- mus_audio_format_name(format)));
-#ifdef AL_RESOURCE
- if (dev == MUS_AUDIO_DEFAULT)
- device[line] = AL_DEFAULT_OUTPUT;
- else device[line] = to_al_device(dev);
- if (!(device[line]))
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, -1,
- mus_format("device %d (%s) not available",
- dev,
- mus_audio_device_name(dev)));
-#if 0
- if (device_channels(dev) < chans) /* look for some device that can play this file */
- device[line] = find_audio_output(chans);
- if (device[line] == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, -1,
- mus_format("can't find %d channel device",
- chans));
-#endif
- if ((chans == 4) && (dev == MUS_AUDIO_DAC_OUT))
- { /* kludge around a bug in the new audio library */
- sr[0] = AL_CHANNEL_MODE;
- sr[1] = AL_4CHANNEL;
- ALsetparams(AL_DEFAULT_DEVICE, sr, 2);
- }
- z[0].param = AL_RATE;
- z[0].value.ll = alDoubleToFixed((double)srate);
- z[1].param = AL_MASTER_CLOCK;
- /* z[1].value.i = AL_CRYSTAL_MCLK_TYPE; */
- z[1].value.i = AL_MCLK_TYPE; /* was AL_CRYSTAL_MCLK_TYPE -- digital I/O perhaps needs AL_VARIABLE_MCLK_TYPE */
- if (alSetParams(device[line], z, 2) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, -1,
- mus_format("can't set srate of %s to %d",
- mus_audio_device_name(dev),
- srate));
-#else
- device[line] = AL_DEFAULT_DEVICE;
- check_quad(device[line], chans);
- sr[0] = AL_OUTPUT_RATE;
- sr[1] = srate;
- if (ALsetparams(device[line], sr, 2) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, -1,
- mus_format("can't set srate of %s to %d",
- mus_audio_device_name(dev),
- srate));
-#endif
-
- config[line] = al_newconfig();
- if (!(config[line]))
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, -1,
- "can't allocate audio configuration?");
- if ((al_setsampfmt(config[line], sgi_format) == -1) ||
- (al_setwidth(config[line], width) == -1)) /* this is a no-op in the float and double cases */
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, line,
- mus_format("audio format %d (%s, SGI: %d) not available on device %d (%s)",
- format, mus_audio_format_name(format), sgi_format,
- dev,
- mus_audio_device_name(dev)));
- if (al_setchannels(config[line], chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, line,
- mus_format("can't get %d channels on device %d (%s)",
- chans, dev, mus_audio_device_name(dev)));
-
- /* set queue size probably needs a check first for legal queue sizes given the current desired device */
- /* in new AL, I'm assuming above (check_queue_size) that it needs at least 1024 per chan */
- if (al_setqueuesize(config[line], size) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SIZE_NOT_AVAILABLE, line,
- mus_format("can't get queue size %d on device %d (%s) (chans: %d, requested_size: %d)",
- size, dev,
- mus_audio_device_name(dev),
- chans, requested_size));
-
-#ifdef AL_RESOURCE
- if (alSetDevice(config[line], device[line]) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, line,
- mus_format("can't get device %d (%s)",
- dev,
- mus_audio_device_name(dev)));
-#endif
-
- port[line] = al_openport("dac", "w", config[line]);
- if (!(port[line]))
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, line,
- mus_format("can't open output port on device %d (%s)",
- dev,
- mus_audio_device_name(dev)));
- line_in_use[line] = 1;
- end_sgi_print();
- return(line);
-}
-
-int mus_audio_write(int line, char *buf, int bytes)
-{
- start_sgi_print();
-#ifdef AL_RESOURCE
- if (alWriteFrames(port[line], (short *)buf, bytes / (channels[line] * datum_size[line])))
-#else
- if (ALwritesamps(port[line], (short *)buf, bytes / datum_size[line]))
-#endif
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- "write error");
- end_sgi_print();
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_close(int line)
-{
- int err;
- start_sgi_print();
- if (line_in_use[line])
- {
- if (line_out[line])
- while (al_getfilled(port[line]) > 0)
- sginap(1);
- err = ((al_closeport(port[line])) ||
- (al_freeconfig(config[line])));
- line_in_use[line] = 0;
- if (err)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_CLOSE, -1,
- mus_format("can't close audio port %p (line %d)",
- port[line], line));
- }
- end_sgi_print();
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_open_input(int ur_dev, int srate, int chans, int format, int requested_size)
-{
- int dev;
-#ifdef AL_RESOURCE
- ALpv pv;
- ALpv x[2];
-#else
- long sr[2];
- int resind;
-#endif
- int i, line, sgi_format;
- start_sgi_print();
- dev = MUS_AUDIO_DEVICE(ur_dev);
- line = -1;
- for (i = 0; i < IO_LINES; i++)
- if (line_in_use[i] == 0)
- {
- line = i;
- break;
- }
- if (line == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_NO_LINES_AVAILABLE, -1,
- "no free audio lines?");
- channels[line] = chans;
- line_out[line] = 0;
- datum_size[line] = mus_bytes_per_sample(format);
-#ifdef AL_RESOURCE
- if (dev == MUS_AUDIO_DEFAULT)
- device[line] = AL_DEFAULT_INPUT;
- else
- {
- int itf;
- device[line] = to_al_device(dev);
- itf = to_al_interface(dev);
- if (itf)
- {
- pv.param = AL_INTERFACE;
- pv.value.i = itf;
- if (alSetParams(device[line], &pv, 1) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, -1,
- mus_format("can't set up device %d (%s)",
- dev,
- mus_audio_device_name(dev)));
- }
- }
- if (!(device[line]))
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, -1,
- mus_format("can't get input device %d (%s)",
- dev, mus_audio_device_name(dev)));
- x[0].param = AL_RATE;
- x[0].value.ll = alDoubleToFixed((double)srate);
- x[1].param = AL_MASTER_CLOCK;
- x[1].value.i = AL_MCLK_TYPE; /* AL_CRYSTAL_MCLK_TYPE; */
- if (alSetParams(device[line], x, 2) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, -1,
- mus_format("can't set srate of %s to %d",
- mus_audio_device_name(dev),
- srate));
-#else
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_MICROPHONE: resind = AL_INPUT_MIC; break;
- case MUS_AUDIO_LINE_IN: resind = AL_INPUT_LINE; break;
- case MUS_AUDIO_DIGITAL_IN: resind = AL_INPUT_DIGITAL; break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, -1,
- mus_format("audio input device %d (%s) not available",
- dev,
- mus_audio_device_name(dev)));
- break;
- }
- device[line] = AL_DEFAULT_DEVICE;
- sr[0] = AL_INPUT_SOURCE;
- sr[1] = resind;
- if (ALsetparams(device[line], sr, 2) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, -1,
- mus_format("can't set up input device %d (%s)",
- dev,
- mus_audio_device_name(dev)));
- check_quad(device[line], chans);
- sr[0] = AL_INPUT_RATE;
- sr[1] = srate;
- if (ALsetparams(device[line], sr, 2) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, -1,
- mus_format("can't set srate of %s to %d",
- mus_audio_device_name(dev),
- srate));
-#endif
-
- config[line] = al_newconfig();
- if (!(config[line]))
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, -1,
- "can't allocate audio configuration?");
- sgi_format = to_sgi_format(format);
- if (sgi_format == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %d (%s) not supported by SGI",
- format,
- mus_audio_format_name(format)));
- if ((al_setsampfmt(config[line], sgi_format) == -1) ||
- (al_setwidth(config[line], (datum_size[line] == 2) ? AL_SAMPLE_16 : AL_SAMPLE_8) == -1))
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, line,
- mus_format("audio format %d (%s, SGI: %d) not available on device %d (%s)",
- format,
- mus_audio_format_name(format), sgi_format,
- dev,
- mus_audio_device_name(dev)));
- if (al_setchannels(config[line], chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, line,
- mus_format("can't get %d channels on device %d (%s)",
- chans, dev,
- mus_audio_device_name(dev)));
-
-#ifdef AL_RESOURCE
- if (alSetDevice(config[line], device[line]) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, line,
- mus_format("can't get device %d (%s)",
- dev,
- mus_audio_device_name(dev)));
-#endif
-
- port[line] = al_openport("adc", "r", config[line]);
- if (!(port[line]))
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, line,
- mus_format("can't open input port on device %d (%s)",
- dev,
- mus_audio_device_name(dev)));
- line_in_use[line] = 1;
- end_sgi_print();
- return(line);
-}
-
-int mus_audio_read(int line, char *buf, int bytes)
-{
- start_sgi_print();
-#ifdef AL_RESOURCE
- if (alReadFrames(port[line], (short *)buf, bytes / (channels[line] * datum_size[line])))
-#else
- if (ALreadsamps(port[line], (short *)buf, bytes / datum_size[line]))
-#endif
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- "read error");
- end_sgi_print();
- return(MUS_NO_ERROR);
-}
-
-
-#ifdef AL_RESOURCE
-/* borrowed from /usr/share/src/dmedia/audio/printdevs.c with modifications */
-
-#define MAX_CHANNELS 8
-
-static float dB_to_linear(float val)
-{
- if (val == 0.0) return(1.0);
- return(pow(10.0, val / 20.0));
-}
-
-static float dB_to_normalized(float val, float lo, float hi)
-{
- float linlo;
- if (hi <= lo) return(1.0);
- linlo = dB_to_linear(lo);
- return((dB_to_linear(val) - linlo) / (dB_to_linear(hi) - linlo));
-}
-
-static float normalized_to_dB(float val_norm, float lo_dB, float hi_dB)
-{
- if (hi_dB <= lo_dB) return(0.0);
- return(lo_dB + (hi_dB - lo_dB) * val_norm);
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- ALpv x[4];
- ALparamInfo pinf;
- ALfixed g[MAX_CHANNELS];
- int rv = 0, i, dev;
- start_sgi_print();
- dev = MUS_AUDIO_DEVICE(ur_dev);
- if (field != MUS_AUDIO_PORT)
- {
- rv = to_al_device(dev);
- if (!rv)
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, -1,
- mus_format("can't read %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- }
- switch (field)
- {
- case MUS_AUDIO_PORT:
- /* in this case, chan == length of incoming val array. Number of devices is returned as val[0],
- * and the rest of the available area (if needed) is filled with the device ids.
- */
- i = 0;
- if (alGetResourceByName(AL_SYSTEM, "Microphone", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_MICROPHONE; i++;}
- if (alGetResourceByName(AL_SYSTEM, "Analog Out", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_DAC_OUT; i++;}
- if (alGetResourceByName(AL_SYSTEM, "ADAT In", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_ADAT_IN; i++;}
- if (alGetResourceByName(AL_SYSTEM, "AES In", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_AES_IN; i++;}
- if (alGetResourceByName(AL_SYSTEM, "ADAT Out", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_ADAT_OUT; i++;}
- if (alGetResourceByName(AL_SYSTEM, "AES Out", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_AES_OUT; i++;}
- if (alGetResourceByName(AL_SYSTEM, "Line In", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_LINE_IN; i++;}
- /* if (alGetResourceByName(AL_SYSTEM, "DAC2 In", AL_DEVICE_TYPE) != 0) {if ((i + 1) < chan) val[i + 1] = MUS_AUDIO_DIGITAL_IN; i++;} */
- val[0] = i;
- break;
- case MUS_AUDIO_FORMAT:
- val[0] = 1;
- if (chan > 1) val[1] = MUS_BSHORT;
- break;
- case MUS_AUDIO_CHANNEL:
- x[0].param = AL_CHANNELS;
- if (alGetParams(rv, x, 1) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("can't read channel setting of %s",
- mus_audio_device_name(dev)));
- val[0] = (float)(x[0].value.i);
- break;
- case MUS_AUDIO_SRATE:
- x[0].param = AL_RATE;
- if (alGetParams(rv, x, 1) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("can't read srate setting of %s",
- mus_audio_device_name(dev)));
- val[0] = (float)(x[0].value.i);
- break;
- case MUS_AUDIO_AMP:
- if (alGetParamInfo(rv, AL_GAIN, &pinf) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("can't read gain settings of %s",
- mus_audio_device_name(dev)));
- if (pinf.min.ll == pinf.max.ll)
- RETURN_ERROR_EXIT(MUS_AUDIO_AMP_NOT_AVAILABLE, -1,
- mus_format("%s's gain apparently can't be set",
- mus_audio_device_name(dev)));
- /* this ridiculous thing is in dB with completely arbitrary min and max values */
- x[0].param = AL_GAIN;
- x[0].value.ptr = g;
- x[0].sizeIn = MAX_CHANNELS;
- alGetParams(rv, x, 1);
- if (x[0].sizeOut <= chan)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, -1,
- mus_format("can't read gain settings of %s channel %d",
- mus_audio_device_name(dev), chan));
- val[0] = dB_to_normalized(alFixedToDouble(g[chan]),
- alFixedToDouble(pinf.min.ll),
- alFixedToDouble(pinf.max.ll));
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, -1,
- mus_format("can't read %s setting of %s",
- mus_audio_device_name(field),
- mus_audio_device_name(dev)));
- break;
- }
- end_sgi_print();
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- /* each field coming in assumes 0.0 to 1.0 as the range */
- ALpv x[4];
- ALparamInfo pinf;
- ALfixed g[MAX_CHANNELS];
- int rv, dev;
- start_sgi_print();
- dev = MUS_AUDIO_DEVICE(ur_dev);
- rv = to_al_device(dev);
- if (!rv) RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, -1,
- mus_format("can't write %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- switch (field)
- {
- case MUS_AUDIO_SRATE:
- x[0].param = AL_RATE;
- x[0].value.i = (int)val[0];
- x[1].param = AL_MASTER_CLOCK;
- x[1].value.i = AL_CRYSTAL_MCLK_TYPE;
- alSetParams(rv, x, 2);
- break;
- case MUS_AUDIO_AMP:
- /* need to change normalized linear value into dB between (dB) lo and hi */
- if (alGetParamInfo(rv, AL_GAIN, &pinf) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("can't write gain settings of %s",
- mus_audio_device_name(dev)));
- /* I think we need to read all channels here, change the one we care about, then write all channels */
- x[0].param = AL_GAIN;
- x[0].value.ptr = g;
- x[0].sizeIn = MAX_CHANNELS;
- alGetParams(rv, x, 1);
- if (x[0].sizeOut <= chan)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, -1,
- mus_format("can't write gain settings of %s channel %d",
- mus_audio_device_name(dev),
- chan));
- g[chan] = alDoubleToFixed(normalized_to_dB(val[0],
- alFixedToDouble(pinf.min.ll),
- alFixedToDouble(pinf.max.ll)));
- if (alSetParams(rv, x, 1) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("can't write gain settings of %s",
- mus_audio_device_name(dev)));
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, -1,
- mus_format("can't write %s setting of %s",
- mus_audio_device_name(field),
- mus_audio_device_name(dev)));
- break;
- }
- end_sgi_print();
- return(MUS_NO_ERROR);
-}
-
-#define STRING_SIZE 32
-static void dump_resources(ALvalue *x, int rv)
-{
- ALpv y[4];
- ALparamInfo pinf;
- ALfixed g[MAX_CHANNELS];
- char dn[STRING_SIZE];
- char dl[STRING_SIZE];
- int i, k;
- ALvalue z[16];
- int nres;
- for (i = 0; i < rv; i++)
- {
- y[0].param = AL_LABEL;
- y[0].value.ptr = dl;
- y[0].sizeIn = STRING_SIZE;
- y[1].param = AL_NAME;
- y[1].value.ptr = dn;
- y[1].sizeIn = STRING_SIZE;
- y[2].param = AL_CHANNELS;
- y[3].param = AL_RATE;
- alGetParams(x[i].i, y, 5);
- if (alIsSubtype(AL_DEVICE_TYPE, x[i].i))
- {
- alGetParamInfo(x[i].i, AL_GAIN, &pinf);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "\nDevice: %s (%s), srate: %d, chans: %d",
- dn, dl,
- y[3].value.i,
- y[2].value.i);
- pprint(audio_strbuf);
- if (pinf.min.ll != pinf.max.ll)
- {
- ALpv yy;
- yy.param = AL_GAIN;
- yy.value.ptr = g;
- yy.sizeIn = MAX_CHANNELS;
- alGetParams(x[i].i, &yy, 1);
- pprint(" amps:[");
- for (k = 0; k < yy.sizeOut; k++)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%.2f",
- dB_to_normalized(alFixedToDouble(g[k]),
- alFixedToDouble(pinf.min.ll),
- alFixedToDouble(pinf.max.ll)));
- pprint(audio_strbuf);
- if (k < (yy.sizeOut - 1)) pprint(" ");
- }
- pprint("]");
- }
- pprint("\n");
- if ((nres= alQueryValues(x[i].i, AL_INTERFACE, z, 16, 0, 0)) >= 0)
- dump_resources(z, nres);
- else mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "query failed: %s\n", alGetErrorString(oserror()));
- pprint(audio_strbuf);
- }
- else
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s (%s), chans: %d\n", dn, dl, y[2].value.i);
- pprint(audio_strbuf);
- }
- }
-}
-
-static void describe_audio_state_1(void)
-{
- int rv;
- ALvalue x[16];
- pprint("Devices and Interfaces on this system:\n");
- rv= alQueryValues(AL_SYSTEM, AL_DEVICES, x, 16, 0, 0);
- if (rv > 0)
- dump_resources(x, rv);
-}
-
-
-#else
-
-/* old audio library */
-
-#define MAX_VOLUME 255
-
-static int decode_field(int dev, int field, int chan)
-{
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_SPEAKERS:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- return((chan == 0) ? AL_LEFT_SPEAKER_GAIN : AL_RIGHT_SPEAKER_GAIN);
- break;
- case MUS_AUDIO_SRATE:
- return(AL_OUTPUT_RATE);
- break;
- }
- break;
- case MUS_AUDIO_LINE_OUT:
- switch (field)
- {
- case MUS_AUDIO_SRATE:
- return(AL_OUTPUT_RATE); /* ? */
- break;
- }
- break;
- case MUS_AUDIO_DIGITAL_OUT:
- if (field == MUS_AUDIO_SRATE)
- return(AL_OUTPUT_RATE);
- break;
- case MUS_AUDIO_DIGITAL_IN:
- if (field == MUS_AUDIO_SRATE)
- return(AL_INPUT_RATE);
- break;
- case MUS_AUDIO_LINE_IN:
- if (field == MUS_AUDIO_AMP)
- return((chan == 0) ? AL_LEFT_INPUT_ATTEN : AL_RIGHT_INPUT_ATTEN);
- else
- if (field == MUS_AUDIO_SRATE)
- return(AL_INPUT_RATE);
- break;
- case MUS_AUDIO_MICROPHONE:
- if (field == MUS_AUDIO_AMP)
- return((chan == 0) ? AL_LEFT2_INPUT_ATTEN : AL_RIGHT2_INPUT_ATTEN);
- else
- if (field == MUS_AUDIO_SRATE)
- return(AL_INPUT_RATE);
- break;
- }
- return(MUS_ERROR);
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- long pb[4];
- long fld;
- int dev, err = MUS_NO_ERROR;
- start_sgi_print();
- dev = MUS_AUDIO_DEVICE(ur_dev);
- switch (field)
- {
- case MUS_AUDIO_CHANNEL:
- val[0] = 4;
- break;
- case MUS_AUDIO_FORMAT:
- val[0] = 1;
- if (chan > 1) val[1] = MUS_BSHORT;
- break;
- case MUS_AUDIO_PORT:
- /* how to tell which machine we're on? */
- val[0] = 4;
- if (chan > 1) val[1] = MUS_AUDIO_LINE_IN;
- if (chan > 2) val[2] = MUS_AUDIO_MICROPHONE;
- if (chan > 3) val[3] = MUS_AUDIO_DIGITAL_IN;
- if (chan > 4) val[4] = MUS_AUDIO_DAC_OUT;
- /* does this order work for digital input as well? (i.e. does it replace the microphone)? */
- break;
- case MUS_AUDIO_AMP:
- fld = decode_field(dev, field, chan);
- if (fld != MUS_ERROR)
- {
- pb[0] = fld;
- if (ALgetparams(AL_DEFAULT_DEVICE, pb, 2))
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("can't read gain settings of %s",
- mus_audio_device_name(dev)));
- if ((fld == AL_LEFT_SPEAKER_GAIN) ||
- (fld == AL_RIGHT_SPEAKER_GAIN))
- val[0] = ((float)pb[1]) / ((float)MAX_VOLUME);
- else val[0] = 1.0 - ((float)pb[1]) / ((float)MAX_VOLUME);
- }
- else err = MUS_ERROR;
- break;
- case MUS_AUDIO_SRATE:
- fld = decode_field(dev, field, chan);
- if (fld != MUS_ERROR)
- {
- pb[0] = fld;
- if (ALgetparams(AL_DEFAULT_DEVICE, pb, 2))
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("can't read srate setting of %s",
- mus_audio_device_name(dev)));
- val[0] = pb[1];
- }
- else err = MUS_ERROR;
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- if (err == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, -1,
- mus_format("can't read %s setting of %s",
- mus_audio_device_name(field),
- mus_audio_device_name(dev)));
- end_sgi_print();
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- long pb[4];
- long fld;
- int dev, err = MUS_NO_ERROR;
- start_sgi_print();
- dev = MUS_AUDIO_DEVICE(ur_dev);
- switch (field)
- {
- case MUS_AUDIO_PORT:
- if (dev == MUS_AUDIO_DEFAULT)
- {
- pb[0] = AL_CHANNEL_MODE;
- pb[1] = ((chan == MUS_AUDIO_DIGITAL_IN) ? AL_STEREO : AL_4CHANNEL);
- pb[2] = AL_INPUT_SOURCE;
- pb[3] = ((chan == MUS_AUDIO_DIGITAL_IN) ? AL_INPUT_DIGITAL : AL_INPUT_MIC);
- if (ALsetparams(AL_DEFAULT_DEVICE, pb, 4))
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("can't set mode and source of %s",
- mus_audio_device_name(dev)));
- }
- else err = MUS_ERROR;
- break;
- case MUS_AUDIO_CHANNEL:
- if (dev == MUS_AUDIO_MICROPHONE)
- {
- pb[0] = AL_MIC_MODE;
- pb[1] = ((chan == 2) ? AL_STEREO : AL_MONO);
- if (ALsetparams(AL_DEFAULT_DEVICE, pb, 2))
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("can't set microphone to be %s",
- (chan == 2) ? "stereo" : "mono"));
- }
- else
- {
- if (dev == MUS_AUDIO_DEFAULT)
- {
- pb[0] = AL_CHANNEL_MODE;
- pb[1] = ((chan == 4) ? AL_4CHANNEL : AL_STEREO);
- if (ALsetparams(AL_DEFAULT_DEVICE, pb, 2))
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("can't set default device to be %s",
- (chan == 4) ? "quad" : "stereo"));
- }
- else err = MUS_ERROR;
- }
- break;
- case MUS_AUDIO_AMP:
- fld = decode_field(dev, field, chan);
- if (fld != -1)
- {
- pb[0] = fld;
- if ((fld == AL_LEFT_SPEAKER_GAIN) ||
- (fld == AL_RIGHT_SPEAKER_GAIN))
- pb[1] = val[0] * MAX_VOLUME;
- else pb[1] = (1.0 - val[0]) * MAX_VOLUME;
- if (ALsetparams(AL_DEFAULT_DEVICE, pb, 2))
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("can't set gain of %s",
- mus_audio_device_name(dev)));
- }
- else err = MUS_ERROR;
- break;
- case MUS_AUDIO_SRATE:
- fld = decode_field(dev, field, chan);
- if (fld != -1)
- {
- pb[0] = fld;
- pb[1] = val[0];
- if (ALsetparams(AL_DEFAULT_DEVICE, pb, 2))
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1, NULL);
- if (fld == AL_INPUT_RATE)
- {
- pb[0] = AL_OUTPUT_RATE;
- pb[1] = val[0];
- if (ALsetparams(AL_DEFAULT_DEVICE, pb, 2))
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("can't set srate of %s",
- mus_audio_device_name(dev)));
- }
- }
- else err = MUS_ERROR;
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- if (err == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, -1,
- mus_format("can't write %s setting of %s",
- mus_audio_device_name(field),
- mus_audio_device_name(dev)));
- end_sgi_print();
- return(MUS_NO_ERROR);
-}
-
-static void describe_audio_state_1(void)
-{
- float amps[1];
- int err;
- err = mus_audio_mixer_read(MUS_AUDIO_SPEAKERS, MUS_AUDIO_SRATE, 0, amps);
- if (err == MUS_NO_ERROR)
- {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "srate: %.2f\n", amps[0]); pprint(audio_strbuf);}
- else {fprintf(stdout, "err: %d!\n", err); fflush(stdout);}
- err = mus_audio_mixer_read(MUS_AUDIO_SPEAKERS, MUS_AUDIO_AMP, 0, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "speakers: %.2f", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_SPEAKERS, MUS_AUDIO_AMP, 1, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.2f\n", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_LINE_IN, MUS_AUDIO_AMP, 0, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "line in: %.2f", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_LINE_IN, MUS_AUDIO_AMP, 1, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.2f\n", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_MICROPHONE, MUS_AUDIO_AMP, 0, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "microphone: %.2f", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_MICROPHONE, MUS_AUDIO_AMP, 1, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.2f\n", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_LINE_OUT, MUS_AUDIO_AMP, 0, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "line out: %.2f", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_LINE_OUT, MUS_AUDIO_AMP, 1, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.2f\n", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_DIGITAL_OUT, MUS_AUDIO_AMP, 0, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "digital out: %.2f", amps[0]); pprint(audio_strbuf);}
- err = mus_audio_mixer_read(MUS_AUDIO_DIGITAL_OUT, MUS_AUDIO_AMP, 1, amps);
- if (err == MUS_NO_ERROR) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.2f\n", amps[0]); pprint(audio_strbuf);}
-}
-
-#endif
-/* new or old AL */
-
-#endif
-/* SGI */
-
-
-
-/* ------------------------------- OSS ----------------------------------------- */
-
-#if (HAVE_OSS || HAVE_ALSA || HAVE_JACK)
-/* actually it's not impossible that someday we'll have ALSA but not OSS... */
-#define AUDIO_OK
-
-#include <sys/ioctl.h>
-
-/* the system version of the soundcard header file may have no relation to the current OSS actually loaded */
-/* sys/soundcard.h is usually just a pointer to linux/soundcard.h */
-
-#if (MUS_HAVE_USR_LIB_OSS)
- #include "/usr/lib/oss/include/sys/soundcard.h"
-#else
- #if (MUS_HAVE_USR_LOCAL_LIB_OSS)
- #include "/usr/local/lib/oss/include/sys/soundcard.h"
- #else
- #if (MUS_HAVE_OPT_OSS)
- #include "/opt/oss/include/sys/soundcard.h"
- #else
- #if (MUS_HAVE_VAR_LIB_OSS)
- #include "/var/lib/oss/include/sys/soundcard.h"
- #else
- #if defined(HAVE_SYS_SOUNDCARD_H) || defined(MUS_LINUX)
- #include <sys/soundcard.h>
- #else
- #if defined(HAVE_MACHINE_SOUNDCARD_H)
- #include <machine/soundcard.h>
- #else
- #include <soundcard.h>
- #endif
- #endif
- #endif
- #endif
- #endif
-#endif
-
-#if ((SOUND_VERSION > 360) && (defined(OSS_SYSINFO)))
- #define NEW_OSS 1
-#endif
-
-#define DAC_NAME "/dev/dsp"
-#define MIXER_NAME "/dev/mixer"
-#define SYNTH_NAME "/dev/music"
-/* some programs use /dev/audio */
-
-/* there can be more than one sound card installed, and a card can be handled through
- * more than one /dev/dsp device, so we can't use a global dac device here.
- * The caller has to keep track of the various cards (via AUDIO_SYSTEM) --
- * I toyed with embedding all that in mus_audio_open_output and mus_audio_write, but
- * decided it's better to keep them explicit -- the caller may want entirely
- * different (non-synchronous) streams going to the various cards. This same
- * code (AUDIO_SYSTEM(n)->devn) should work in Windoze (see below), and
- * might work on the Mac and SGI -- something for a rainy day...
- */
-
-#define RETURN_ERROR_EXIT(Message_Type, Audio_Line, Ur_Message) \
- do { \
- char *Message; Message = Ur_Message; \
- if (Audio_Line != -1) \
- linux_audio_close(Audio_Line); \
- if ((Message) && (strlen(Message) > 0)) \
- { \
- mus_print("%s\n [%s[%d] %s]", \
- Message, \
- __FILE__, __LINE__, c__FUNCTION__); \
- FREE(Message); \
- } \
- else mus_print("%s\n [%s[%d] %s]", \
- mus_error_type_to_string(Message_Type), \
- __FILE__, __LINE__, c__FUNCTION__); \
- return(MUS_ERROR); \
- } while (false)
-
-static int FRAGMENTS = 4;
-static int FRAGMENT_SIZE = 12;
-static bool fragments_locked = false;
-
-/* defaults here are FRAGMENTS 16 and FRAGMENT_SIZE 12; these values however
- * cause about a .5 second delay, which is not acceptable in "real-time" situations.
- *
- * this changed 22-May-01: these are causing more trouble than they're worth
- */
-
-static void oss_mus_oss_set_buffers(int num, int size) {FRAGMENTS = num; FRAGMENT_SIZE = size; fragments_locked = true;}
-
-#define MAX_SOUNDCARDS 8
-#define MAX_DSPS 8
-#define MAX_MIXERS 8
-/* there can be (apparently) any number of mixers and dsps per soundcard, but 8 is enough! */
-
-static int *audio_fd = NULL;
-static int *audio_open_ctr = NULL;
-static int *audio_dsp = NULL;
-static int *audio_mixer = NULL;
-static int *audio_mode = NULL;
-typedef enum {NORMAL_CARD, SONORUS_STUDIO, RME_HAMMERFALL, SAM9407_DSP, DELTA_66} audio_card_t;
-/* the Sonorus Studi/o card is a special case in all regards */
-static audio_card_t *audio_type = NULL;
-
-static int sound_cards = 0;
-static int new_oss_running = 0;
-static char *dev_name = NULL;
-
-static int oss_mus_audio_systems(void)
-{
- return(sound_cards);
-}
-
-static char *mixer_name(int sys)
-{
-#if HAVE_SAM_9407
- if((sys < sound_cards) && (audio_type[sys] == SAM9407_DSP))
- {
- mus_snprintf(dev_name, LABEL_BUFFER_SIZE, "/dev/sam%d_mixer", audio_mixer[sys]);
- return(dev_name);
- }
-#endif
- if (sys < sound_cards)
- {
- if (audio_mixer[sys] == -2)
- return(MIXER_NAME);
- /* if we have /dev/dsp (not /dev/dsp0), I assume the corresponding mixer is /dev/mixer (not /dev/mixer0) */
- /* but in sam9407 driver, there is no /dev/mixer, and everything goes through /dev/dsp */
- else
- {
- if (audio_mixer[sys] == -3)
- return(DAC_NAME);
- else
- {
- mus_snprintf(dev_name, LABEL_BUFFER_SIZE, "%s%d", MIXER_NAME, audio_mixer[sys]);
- return(dev_name);
- }
- }
- }
- return(DAC_NAME);
-}
-
-static char *oss_mus_audio_system_name(int system)
-{
-#if HAVE_SAM_9407
- if((system < sound_cards) && (audio_type[system] == SAM9407_DSP))
- {
- int fd;
- fd = open(mixer_name(system), O_RDONLY, 0);
- if(fd != -1)
- {
- static SamDriverInfo driverInfo;
- if(ioctl(fd, SAM_IOC_DRIVER_INFO, &driverInfo) >= 0)
- {
- close(fd);
- return(driverInfo.hardware);
- }
- close(fd);
- }
- return("sam9407");
- }
-#endif
-#ifdef NEW_OSS
- static mixer_info mixinfo;
- int status, ignored, fd;
- fd = open(mixer_name(system), O_RDONLY, 0);
- if (fd != -1)
- {
- status = ioctl(fd, OSS_GETVERSION, &ignored);
- if (status == 0)
- {
- status = ioctl(fd, SOUND_MIXER_INFO, &mixinfo);
- if (status == 0)
- {
- close(fd);
- return(mixinfo.name);
- }
- }
- close(fd);
- }
-#endif
- return("OSS");
-}
-
-#if HAVE_SAM_9407
-static char *oss_mus_audio_moniker(void) {return("Sam 9407");}
-#else
-static char *oss_mus_audio_moniker(void)
-{
- char version[LABEL_BUFFER_SIZE];
- if (version_name == NULL) version_name = (char *)CALLOC(LABEL_BUFFER_SIZE, sizeof(char));
- if (SOUND_VERSION < 361)
- {
- mus_snprintf(version, LABEL_BUFFER_SIZE, "%d", SOUND_VERSION);
- mus_snprintf(version_name, LABEL_BUFFER_SIZE, "OSS %c.%c.%c", version[0], version[1], version[2]);
- }
- else
- mus_snprintf(version_name, LABEL_BUFFER_SIZE, "OSS %x.%x.%x",
- (SOUND_VERSION >> 16) & 0xff,
- (SOUND_VERSION >> 8) & 0xff,
- SOUND_VERSION & 0xff);
- return(version_name);
-}
-#endif
-
-static char *dac_name(int sys, int offset)
-{
-#if HAVE_SAM_9407
- if ((sys < sound_cards) && (audio_type[sys] == SAM9407_DSP))
- {
- mus_snprintf(dev_name, LABEL_BUFFER_SIZE, "/dev/sam%d_dsp", audio_dsp[sys]);
- return(dev_name);
- }
-#endif
- if ((sys < sound_cards) && (audio_mixer[sys] >= -1))
- {
- mus_snprintf(dev_name, LABEL_BUFFER_SIZE, "%s%d", DAC_NAME, audio_dsp[sys] + offset);
- return(dev_name);
- }
- return(DAC_NAME);
-}
-
-#define MIXER_SIZE SOUND_MIXER_NRDEVICES
-static int **mixer_state = NULL;
-static int *init_srate = NULL, *init_chans = NULL, *init_format = NULL;
-
-static int oss_mus_audio_initialize(void)
-{
- /* here we need to set up the map of /dev/dsp and /dev/mixer to a given system */
- /* since this info is not passed to us by OSS, we have to work at it... */
- /* for the time being, I'll ignore auxiliary dsp and mixer ports (each is a special case) */
- int i, fd = -1, md, err = 0;
- char dname[LABEL_BUFFER_SIZE];
- int amp, old_mixer_amp, old_dsp_amp, new_mixer_amp, responsive_field;
- int devmask;
-#ifdef NEW_OSS
- int status, ignored;
- oss_sysinfo sysinfo;
- static mixer_info mixinfo;
- int sysinfo_ok = 0;
-#endif
- int num_mixers, num_dsps, nmix, ndsp;
- if (!audio_initialized)
- {
- audio_initialized = true;
- audio_fd = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- audio_open_ctr = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- audio_dsp = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- audio_mixer = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- audio_type = (audio_card_t *)CALLOC(MAX_SOUNDCARDS, sizeof(audio_card_t));
- audio_mode = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- dev_name = (char *)CALLOC(LABEL_BUFFER_SIZE, sizeof(char));
- init_srate = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- init_chans = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- init_format = (int *)CALLOC(MAX_SOUNDCARDS, sizeof(int));
- mixer_state = (int **)CALLOC(MAX_SOUNDCARDS, sizeof(int *));
- for (i = 0; i < MAX_SOUNDCARDS; i++) mixer_state[i] = (int *)CALLOC(MIXER_SIZE, sizeof(int));
- for (i = 0; i < MAX_SOUNDCARDS; i++)
- {
- audio_fd[i] = -1;
- audio_open_ctr[i] = 0;
- audio_dsp[i] = -1;
- audio_mixer[i] = -1;
- audio_type[i] = NORMAL_CARD;
- }
-#if HAVE_SAM_9407
- {
- SamApiInfo apiInfo;
- SamDriverInfo driverInfo;
- for (i = 0; i < MAX_SOUNDCARDS; i++)
- {
- mus_snprintf(dname, LABEL_BUFFER_SIZE, "/dev/sam%d_mixer", i);
- fd = open(dname, O_WRONLY);
- if (fd < 0)
- break;
- if ((ioctl(fd, SAM_IOC_API_INFO, &apiInfo) < 0) ||
- (apiInfo.apiClass!=SAM_API_CLASS_VANILLA) ||
- (ioctl(fd, SAM_IOC_DRIVER_INFO, &driverInfo) < 0) ||
- (!driverInfo.haveAudio))
- {
- close(fd);
- continue;
- }
- audio_type[sound_cards] = SAM9407_DSP;
- audio_dsp[sound_cards] = i;
- audio_mixer[sound_cards] = i;
- sound_cards++;
- close(fd);
- }
- if(sound_cards > 0)
- return(0);
- }
-#endif
-
- num_mixers = MAX_MIXERS;
- num_dsps = MAX_DSPS;
-#ifdef NEW_OSS
- fd = open(DAC_NAME, O_WRONLY | O_NONBLOCK, 0);
- if (fd == -1) fd = open(SYNTH_NAME, O_RDONLY | O_NONBLOCK, 0);
- if (fd == -1) fd = open(MIXER_NAME, O_RDONLY | O_NONBLOCK, 0);
- if (fd != -1)
- {
- status = ioctl(fd, OSS_GETVERSION, &ignored);
- new_oss_running = (status == 0);
- if (new_oss_running)
- {
- status = ioctl(fd, OSS_SYSINFO, &sysinfo);
- sysinfo_ok = (status == 0);
- }
- if ((new_oss_running) && (sysinfo_ok))
- {
- num_mixers = sysinfo.nummixers;
- num_dsps = sysinfo.numaudios;
- }
- close(fd);
- }
-#endif
-
- /* need to get which /dev/dsp lines match which /dev/mixer lines,
- * find out how many separate systems (soundcards) are available,
- * fill the audio_dsp and audio_mixer arrays with the system-related numbers,
- * since we have no way to tell from OSS info which mixers/dsps are the
- * main ones, we'll do some messing aound to try to deduce this info.
- * for example, SB uses two dsp ports and two mixers per card, whereas
- * Ensoniq uses 2 dsps and 1 mixer.
- *
- * the data we are gathering here:
- * int audio_dsp[MAX_SOUNDCARDS] -> main_dsp_port[MUS_AUDIO_PACK_SYSTEM(n)] (-1 => no such system dsp)
- * int audio_mixer[MAX_SOUNDCARDS] -> main_mixer_port[MUS_AUDIO_PACK_SYSTEM(n)]
- * int sound_cards = 0 -> usable systems
- * all auxiliary ports are currently ignored (SB equalizer, etc)
- */
- sound_cards = 0;
- ndsp = 0;
- nmix = 0;
- while ((nmix < num_mixers) &&
- (ndsp < num_dsps))
- {
- /* for each mixer, find associated main dsp (assumed to be first in /dev/dsp ordering) */
- /* if mixer's dsp overlaps or we run out of dsps first, ignore it (aux mixer) */
- /* our by-guess-or-by-gosh method here is to try to open the mixer.
- * if that fails, quit (if very first, try at least to get the dsp setup)
- * find volume field, if none, go on, else read current volume
- * open next unchecked dsp, try to set volume, read current, if different we found a match -- set and go on.
- * if no change, move to next dsp and try again, if no more dsps, quit (checking for null case as before)
- */
- mus_snprintf(dname, LABEL_BUFFER_SIZE, "%s%d", MIXER_NAME, nmix);
- md = open(dname, O_RDWR, 0);
- if (md == -1)
- {
- if (errno == EBUSY)
- {
- mus_print("%s is busy: can't access it [%s[%d] %s]",
- dname,
- __FILE__, __LINE__, c__FUNCTION__);
- nmix++;
- continue;
- }
- else break;
- }
- mus_snprintf(dname, LABEL_BUFFER_SIZE, "%s%d", DAC_NAME, ndsp);
- fd = open(dname, O_RDWR | O_NONBLOCK, 0);
- if (fd == -1) fd = open(dname, O_RDONLY | O_NONBLOCK, 0);
- if (fd == -1) fd = open(dname, O_WRONLY | O_NONBLOCK, 0); /* some output devices need this */
- if (fd == -1)
- {
- close(md);
- if (errno == EBUSY) /* in linux /usr/include/asm/errno.h */
- {
- fprintf(stderr, "%s is busy: can't access it\n", dname);
- ndsp++;
- continue;
- }
- else
- {
- if ((errno != ENXIO) && (errno != ENODEV))
- fprintf(stderr, "%s: %s! ", dname, strerror(errno));
- break;
- }
- }
-#ifdef NEW_OSS
- /* can't change volume yet of Sonorus, so the method above won't work --
- * try to catch this case via the mixer's name
- */
- status = ioctl(md, SOUND_MIXER_INFO, &mixinfo);
- if ((status == 0) &&
- (mixinfo.name) &&
- (*(mixinfo.name)) &&
- (strlen(mixinfo.name) > 6))
- {
- if (strncmp("STUDI/O", mixinfo.name, 7) == 0)
- {
- /* a special case in every regard */
- audio_type[sound_cards] = SONORUS_STUDIO;
- audio_mixer[sound_cards] = nmix;
- nmix++;
- audio_dsp[sound_cards] = ndsp;
- if (num_dsps >= 21)
- {
- ndsp += 21;
- audio_mode[sound_cards] = 1;
- }
- else
- {
- ndsp += 9;
- audio_mode[sound_cards] = 0;
- }
- sound_cards++;
- close(fd);
- close(md);
- continue;
- }
- else
- {
- if (strncmp("RME Digi96", mixinfo.name, 10) == 0)
- {
- audio_type[sound_cards] = RME_HAMMERFALL;
- audio_mixer[sound_cards] = nmix;
- nmix++;
- audio_dsp[sound_cards] = ndsp;
- sound_cards++;
- close(fd);
- close(md);
- continue;
- }
- else
- {
- if (strncmp("M Audio Delta", mixinfo.name, 13) == 0)
- {
- audio_type[sound_cards] = DELTA_66;
- audio_mixer[sound_cards] = nmix;
- nmix++;
- ndsp += 6; /* just a guess */
- audio_dsp[sound_cards] = ndsp;
- sound_cards++;
- close(fd);
- close(md);
- continue;
- }
- }
- }
- }
-#endif
- err = ioctl(md, SOUND_MIXER_READ_DEVMASK, &devmask);
- responsive_field = SOUND_MIXER_VOLUME;
- for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
- if ((1 << i) & devmask)
- {
- responsive_field = i;
- break;
- }
- if (!err)
- {
- err = ioctl(md, MIXER_READ(responsive_field), &old_mixer_amp);
- if (!err)
- {
- err = ioctl(fd, MIXER_READ(responsive_field), &old_dsp_amp);
- if ((!err) && (old_dsp_amp == old_mixer_amp))
- {
- if (old_mixer_amp == 0) amp = 50; else amp = 0; /* 0..100 */
- err = ioctl(fd, MIXER_WRITE(responsive_field), &amp);
- if (!err)
- {
- err = ioctl(md, MIXER_READ(responsive_field), &new_mixer_amp);
- if (!err)
- {
- if (new_mixer_amp == amp)
- {
- /* found one! */
- audio_dsp[sound_cards] = ndsp; ndsp++;
- audio_mixer[sound_cards] = nmix; nmix++;
- audio_type[sound_cards] = NORMAL_CARD;
- sound_cards++;
- }
- else ndsp++;
- err = ioctl(fd, MIXER_WRITE(responsive_field), &old_dsp_amp);
- }
- else nmix++;
- }
- else ndsp++;
- }
- else ndsp++;
- }
- else nmix++;
- }
- else nmix++;
- close(fd);
- close(md);
- }
- if (sound_cards == 0)
- {
- fd = open(DAC_NAME, O_WRONLY | O_NONBLOCK, 0);
- if (fd != -1)
- {
- sound_cards = 1;
- audio_dsp[0] = 0;
- audio_type[0] = NORMAL_CARD;
- audio_mixer[0] = -2; /* hmmm -- need a way to see /dev/dsp as lonely outpost */
- close(fd);
- fd = open(MIXER_NAME, O_RDONLY | O_NONBLOCK, 0);
- if (fd == -1)
- audio_mixer[0] = -3;
- else close(fd);
- }
- }
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_reinitialize(void)
-{
- /* an experiment */
- audio_initialized = false;
- return(mus_audio_initialize());
-}
-
-static int linux_audio_open(const char *pathname, int flags, mode_t mode, int system)
-{
- /* sometimes this is simply searching for a device (so failure is not a mus_error) */
- if (audio_fd[system] == -1)
- {
- audio_fd[system] = open(pathname, flags, mode);
- audio_open_ctr[system] = 0;
- }
- else audio_open_ctr[system]++;
- return(audio_fd[system]);
-}
-
-static int linux_audio_open_with_error(const char *pathname, int flags, mode_t mode, int system)
-{
- int fd;
- fd = linux_audio_open(pathname, flags, mode, system);
- if (fd == -1)
- MUS_STANDARD_IO_ERROR(MUS_AUDIO_CANT_OPEN,
- ((mode == O_RDONLY) ? "open read" :
- (mode == O_WRONLY) ? "open write" : "open read/write"),
- pathname);
- return(fd);
-}
-
-static int find_system(int line)
-{
- int i;
- for (i = 0; i < sound_cards; i++)
- if (line == audio_fd[i])
- return(i);
- return(MUS_ERROR);
-}
-
-static int linux_audio_close(int fd)
-{
- if (fd != -1)
- {
- int err = 0, sys;
- sys = find_system(fd);
- if (sys != -1)
- {
- if (audio_open_ctr[sys] > 0)
- audio_open_ctr[sys]--;
- else
- {
- err = close(fd);
- audio_open_ctr[sys] = 0;
- audio_fd[sys] = -1;
- }
- }
- else err = close(fd);
- if (err) RETURN_ERROR_EXIT(MUS_AUDIO_CANT_CLOSE, -1,
- mus_format("close %d failed: %s",
- fd, strerror(errno)));
- }
- /* is this an error? */
- return(MUS_NO_ERROR);
-}
-
-static int to_oss_format(int snd_format)
-{
- switch (snd_format)
- {
- case MUS_BYTE: return(AFMT_S8); break;
- case MUS_BSHORT: return(AFMT_S16_BE); break;
- case MUS_UBYTE: return(AFMT_U8); break;
- case MUS_MULAW: return(AFMT_MU_LAW); break;
- case MUS_ALAW: return(AFMT_A_LAW); break;
- case MUS_LSHORT: return(AFMT_S16_LE); break;
- case MUS_UBSHORT: return(AFMT_U16_BE); break;
- case MUS_ULSHORT: return(AFMT_U16_LE); break;
-#ifdef NEW_OSS
- case MUS_LINT: return(AFMT_S32_LE); break;
- case MUS_BINT: return(AFMT_S32_BE); break;
-#endif
- }
- return(MUS_ERROR);
-}
-
-static char sonorus_buf[LABEL_BUFFER_SIZE];
-static char *sonorus_name(int sys, int offset)
-{
- mus_snprintf(sonorus_buf, LABEL_BUFFER_SIZE, "/dev/dsp%d", offset + audio_dsp[sys]);
- return(sonorus_buf);
-}
-
-static bool fragment_set_failed = false;
-
-static int oss_mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size)
-{
- /* ur_dev is in general MUS_AUDIO_PACK_SYSTEM(n) | MUS_AUDIO_DEVICE */
- int oss_format, buffer_info, audio_out = -1, sys, dev;
- char *dev_name;
-#ifndef NEW_OSS
- int stereo;
-#endif
- sys = MUS_AUDIO_SYSTEM(ur_dev);
- dev = MUS_AUDIO_DEVICE(ur_dev);
- oss_format = to_oss_format(format);
- if (oss_format == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %d (%s) not available",
- format,
- mus_data_format_name(format)));
- if (audio_type[sys] == SONORUS_STUDIO)
- {
- /* in this case the output devices are parcelled out to the /dev/dsp locs */
- /* dev/dsp0 is always stereo */
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- if (chans > 2)
- audio_out = open(sonorus_name(sys, 1), O_WRONLY, 0);
- else audio_out = open(sonorus_name(sys, 0), O_WRONLY, 0);
- /* probably should write to both outputs */
- if (audio_out == -1) audio_out = open("/dev/dsp", O_WRONLY, 0);
- break;
- case MUS_AUDIO_SPEAKERS:
- audio_out = open(sonorus_name(sys, 0), O_WRONLY, 0);
- if (audio_out == -1) audio_out = open("/dev/dsp", O_WRONLY, 0);
- break;
- case MUS_AUDIO_ADAT_OUT: case MUS_AUDIO_SPDIF_OUT:
- audio_out = open(sonorus_name(sys, 1), O_WRONLY, 0);
- break;
- case MUS_AUDIO_AES_OUT:
- audio_out = open(sonorus_name(sys, 9), O_WRONLY, 0);
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, audio_out,
- mus_format("Sonorus device %d (%s) not available",
- dev,
- mus_audio_device_name(dev)));
- break;
- }
- if (audio_out == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, audio_out,
- mus_format("can't open Sonorus output device %d (%s): %s",
- dev,
- mus_audio_device_name(dev), strerror(errno)));
-#ifdef NEW_OSS
- if (ioctl(audio_out, SNDCTL_DSP_CHANNELS, &chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_out,
- mus_format("can't get %d channels for Sonorus device %d (%s)",
- chans, dev,
- mus_audio_device_name(dev)));
-#endif
- return(audio_out);
- }
-
-#if HAVE_SAM_9407
- if (audio_type[sys] == SAM9407_DSP)
- {
- char dname[LABEL_BUFFER_SIZE];
- mus_snprintf(dname, LABEL_BUFFER_SIZE, "/dev/sam%d_dsp", audio_dsp[sys]);
- audio_out = open(dname, O_WRONLY);
- if(audio_out == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, audio_out,
- mus_format("can't open %s: %s",
- dname,
- strerror(errno)));
- if ((ioctl(audio_out, SNDCTL_DSP_SETFMT, &oss_format) == -1) ||
- (oss_format != to_oss_format(format)))
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_out,
- mus_format("can't set %s format to %d (%s)",
- dname, format,
- mus_data_format_name(format)));
- if (ioctl(audio_out, SNDCTL_DSP_CHANNELS, &chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_out,
- mus_format("can't get %d channels on %s",
- chans, dname));
- if (ioctl(audio_out, SNDCTL_DSP_SPEED, &srate) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, audio_out,
- mus_format("can't set srate to %d on %s",
- srate, dname));
- FRAGMENT_SIZE = 14;
- buffer_info = (FRAGMENTS << 16) | (FRAGMENT_SIZE);
- ioctl(audio_out, SNDCTL_DSP_SETFRAGMENT, &buffer_info);
- return(audio_out);
- }
-#endif
-
- if (dev == MUS_AUDIO_DEFAULT)
- audio_out = linux_audio_open_with_error(dev_name = dac_name(sys, 0),
- O_WRONLY, 0, sys);
- else audio_out = linux_audio_open_with_error(dev_name = dac_name(sys, (dev == MUS_AUDIO_AUX_OUTPUT) ? 1 : 0),
- O_RDWR, 0, sys);
- if (audio_out == -1) return(MUS_ERROR);
-
- /* ioctl(audio_out, SNDCTL_DSP_RESET, 0); */ /* causes clicks */
- if ((fragments_locked) &&
- (!(fragment_set_failed)) &&
- ((dev == MUS_AUDIO_DUPLEX_DEFAULT) ||
- (size != 0))) /* only set if user has previously called set_oss_buffers */
- {
- buffer_info = (FRAGMENTS << 16) | (FRAGMENT_SIZE);
- if (ioctl(audio_out, SNDCTL_DSP_SETFRAGMENT, &buffer_info) == -1)
- {
- /* older Linuces (or OSS's?) refuse to handle the fragment reset if O_RDWR used --
- * someone at OSS forgot to update the version number when this was fixed, so
- * I have no way to get around this except to try and retry...
- */
- linux_audio_close(audio_out);
- audio_out = linux_audio_open_with_error(dev_name = dac_name(sys, (dev == MUS_AUDIO_AUX_OUTPUT) ? 1 : 0),
- O_WRONLY, 0, sys);
- if (audio_out == -1) return(MUS_ERROR);
- buffer_info = (FRAGMENTS << 16) | (FRAGMENT_SIZE);
- if (ioctl(audio_out, SNDCTL_DSP_SETFRAGMENT, &buffer_info) == -1)
- {
- char *tmp;
- fprintf(stderr, tmp = mus_format("can't set %s fragments to: %d x %d",
- dev_name, FRAGMENTS, FRAGMENT_SIZE)); /* not an error if ALSA OSS-emulation */
- fragment_set_failed = true;
- FREE(tmp);
- }
- }
- }
- if ((ioctl(audio_out, SNDCTL_DSP_SETFMT, &oss_format) == -1) ||
- (oss_format != to_oss_format(format)))
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_out,
- mus_format("data format %d (%s) not available on %s",
- format,
- mus_data_format_name(format),
- dev_name));
-#ifdef NEW_OSS
- if (ioctl(audio_out, SNDCTL_DSP_CHANNELS, &chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_out,
- mus_format("can't get %d channels on %s",
- chans, dev_name));
-#else
- if (chans == 2) stereo = 1; else stereo = 0;
- if ((ioctl(audio_out, SNDCTL_DSP_STEREO, &stereo) == -1) ||
- ((chans == 2) && (stereo == 0)))
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_out,
- mus_format("can't get %d channels on %s",
- chans, dev_name));
-#endif
- if (ioctl(audio_out, SNDCTL_DSP_SPEED, &srate) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, audio_out,
- mus_format("can't set srate of %s to %d",
- dev_name, srate));
- /* http://www.4front-tech.com/pguide/audio.html says this order has to be followed */
- return(audio_out);
-}
-
-static int oss_mus_audio_write(int line, char *buf, int bytes)
-{
- int err;
- if (line < 0) return(-1);
- errno = 0;
- err = write(line, buf, bytes);
- if (err != bytes)
- {
- if (errno != 0)
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("write error: %s", strerror(errno)));
- else RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("wrote %d bytes of requested %d", err, bytes));
- }
- return(MUS_NO_ERROR);
-}
-
-static int oss_mus_audio_close(int line)
-{
- return(linux_audio_close(line));
-}
-
-static int oss_mus_audio_read(int line, char *buf, int bytes)
-{
- int err;
- if (line < 0) return(-1);
- errno = 0;
- err = read(line, buf, bytes);
- if (err != bytes)
- {
- if (errno != 0)
- RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("read error: %s", strerror(errno)));
- else RETURN_ERROR_EXIT(MUS_AUDIO_READ_ERROR, -1,
- mus_format("read %d bytes of requested %d", err, bytes));
- }
- return(MUS_NO_ERROR);
-}
-
-static char *oss_unsrc(int srcbit)
-{
- if (srcbit == 0)
- return(strdup("none"));
- else
- {
- bool need_and = false;
- char *buf;
- buf = (char *)CALLOC(PRINT_BUFFER_SIZE, sizeof(char));
- if (srcbit & SOUND_MASK_MIC) {need_and = true; strcat(buf, "mic");}
- if (srcbit & SOUND_MASK_LINE) {if (need_and) strcat(buf, " and "); need_and = true; strcat(buf, "line in");}
- if (srcbit & SOUND_MASK_LINE1) {if (need_and) strcat(buf, " and "); need_and = true; strcat(buf, "line1");}
- if (srcbit & SOUND_MASK_LINE2) {if (need_and) strcat(buf, " and "); need_and = true; strcat(buf, "line2");}
- if (srcbit & SOUND_MASK_LINE3) {if (need_and) strcat(buf, " and "); need_and = true; strcat(buf, "line3");}
- if (srcbit & SOUND_MASK_CD) {if (need_and) strcat(buf, " and "); need_and = true; strcat(buf, "cd");}
- return(buf);
- }
-}
-
-static int oss_mus_audio_open_input(int ur_dev, int srate, int chans, int format, int requested_size)
-{
- /* dev can be MUS_AUDIO_DEFAULT or MUS_AUDIO_DUPLEX_DEFAULT as well as the obvious others */
- int audio_fd = -1, oss_format, buffer_info, sys, dev, srcbit, cursrc, err;
- bool adat_mode = false;
- char *dev_name;
-#ifndef NEW_OSS
- int stereo;
-#endif
- sys = MUS_AUDIO_SYSTEM(ur_dev);
- dev = MUS_AUDIO_DEVICE(ur_dev);
- oss_format = to_oss_format(format);
- if (oss_format == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %d (%s) not available",
- format,
- mus_data_format_name(format)));
- if (audio_type[sys] == SONORUS_STUDIO)
- {
- adat_mode = (audio_mode[sys] == 1);
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- if (adat_mode)
- audio_fd = open(dev_name = sonorus_name(sys, 11), O_RDONLY, 0);
- else audio_fd = open(dev_name = sonorus_name(sys, 5), O_RDONLY, 0);
- break;
- case MUS_AUDIO_ADAT_IN:
- audio_fd = open(dev_name = sonorus_name(sys, 11), O_RDONLY, 0);
- break;
- case MUS_AUDIO_AES_IN:
- audio_fd = open(dev_name = sonorus_name(sys, 20), O_RDONLY, 0);
- break;
- case MUS_AUDIO_SPDIF_IN:
- audio_fd = open(dev_name = sonorus_name(sys, 5), O_RDONLY, 0);
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, -1,
- mus_format("no %s device on Sonorus?",
- mus_audio_device_name(dev)));
- break;
- }
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_NO_INPUT_AVAILABLE, -1,
- mus_format("can't open %s (Sonorus device %s): %s",
- dev_name,
- mus_audio_device_name(dev),
- strerror(errno)));
-#ifdef NEW_OSS
- if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_fd,
- mus_format("can't get %d channels on %s (Sonorus device %s)",
- chans, dev_name,
- mus_audio_device_name(dev)));
-#endif
- return(audio_fd);
- }
-
-#if HAVE_SAM_9407
- if (audio_type[sys] == SAM9407_DSP)
- {
- char dname[LABEL_BUFFER_SIZE];
- mus_snprintf(dname, LABEL_BUFFER_SIZE, "/dev/sam%d_dsp", audio_dsp[sys]);
- audio_fd = open(dname, O_RDONLY);
- if(audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, audio_fd,
- mus_format("can't open input %s: %s",
- dname,
- strerror(errno)));
- if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &oss_format) == -1) ||
- (oss_format != to_oss_format(format)))
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_fd,
- mus_format("can't set %s format to %d (%s)",
- dname, format,
- mus_data_format_name(format)));
- if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_fd,
- mus_format("can't get %d channels on %s",
- chans, dname));
- if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &srate) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, audio_fd,
- mus_format("can't set srate to %d on %s",
- srate, dname));
- FRAGMENT_SIZE = 14;
- buffer_info = (FRAGMENTS << 16) | (FRAGMENT_SIZE);
- ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &buffer_info);
- return(audio_fd);
- }
-#endif
-
- if (((dev == MUS_AUDIO_DEFAULT) || (dev == MUS_AUDIO_DUPLEX_DEFAULT)) && (sys == 0))
- audio_fd = linux_audio_open(dev_name = dac_name(sys, 0),
- O_RDWR, 0, sys);
- else audio_fd = linux_audio_open(dev_name = dac_name(sys, (dev == MUS_AUDIO_AUX_INPUT) ? 1 : 0),
- O_RDONLY, 0, sys);
- if (audio_fd == -1)
- {
- if (dev == MUS_AUDIO_DUPLEX_DEFAULT)
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, -1,
- mus_format("can't open %s (device %s): %s",
- dev_name, mus_audio_device_name(dev), strerror(errno)));
- if ((audio_fd = linux_audio_open(dev_name = dac_name(sys, (dev == MUS_AUDIO_AUX_INPUT) ? 1 : 0),
- O_RDONLY, 0, sys)) == -1)
- {
- if ((errno == EACCES) || (errno == ENOENT))
- RETURN_ERROR_EXIT(MUS_AUDIO_NO_READ_PERMISSION, -1,
- mus_format("can't open %s (device %s): %s\n to get input in Linux, we need read permission on /dev/dsp",
- dev_name,
- mus_audio_device_name(dev),
- strerror(errno)));
- else RETURN_ERROR_EXIT(MUS_AUDIO_NO_INPUT_AVAILABLE, -1,
- mus_format("can't open %s (device %s): %s",
- dev_name,
- mus_audio_device_name(dev),
- strerror(errno)));
- }
- }
-#ifdef SNDCTL_DSP_SETDUPLEX
- else
- ioctl(audio_fd, SNDCTL_DSP_SETDUPLEX, &err); /* not always a no-op! */
-#endif
- if (audio_type[sys] == RME_HAMMERFALL) return(audio_fd);
- if (audio_type[sys] == DELTA_66) return(audio_fd);
- /* need to make sure the desired recording source is active -- does this actually have any effect? */
- switch (dev)
- {
- case MUS_AUDIO_MICROPHONE: srcbit = SOUND_MASK_MIC; break;
- case MUS_AUDIO_LINE_IN: srcbit = SOUND_MASK_LINE; break;
- case MUS_AUDIO_LINE1: srcbit = SOUND_MASK_LINE1; break;
- case MUS_AUDIO_LINE2: srcbit = SOUND_MASK_LINE2; break;
- case MUS_AUDIO_LINE3: srcbit = SOUND_MASK_LINE3; break; /* also digital1..3 */
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_DEFAULT: srcbit = SOUND_MASK_LINE | SOUND_MASK_MIC; break;
- case MUS_AUDIO_CD: srcbit = SOUND_MASK_CD; break;
- default: srcbit = 0; break;
- /* other possibilities: synth, radio, phonein but these apparently bypass the mixer (no gains?) */
- }
- ioctl(audio_fd, MIXER_READ(SOUND_MIXER_RECSRC), &cursrc);
- srcbit = (srcbit | cursrc);
- ioctl(audio_fd, MIXER_WRITE(SOUND_MIXER_RECSRC), &srcbit);
- ioctl(audio_fd, MIXER_READ(SOUND_MIXER_RECSRC), &cursrc);
- if (cursrc != srcbit)
- {
- char *str1, *str2;
- str1 = oss_unsrc(srcbit);
- str2 = oss_unsrc(cursrc);
- mus_print("weird: tried to set recorder source to %s, but got %s?", str1, str2);
- FREE(str1);
- FREE(str2);
- }
- if ((fragments_locked) && (requested_size != 0))
- {
- buffer_info = (FRAGMENTS << 16) | (FRAGMENT_SIZE);
- ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &buffer_info);
- }
- if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &oss_format) == -1) ||
- (oss_format != to_oss_format(format)))
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_fd,
- mus_format("can't set %s format to %d (%s)",
- dev_name, format,
- mus_data_format_name(format)));
-#ifdef NEW_OSS
- if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &chans) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_fd,
- mus_format("can't get %d channels on %s",
- chans, dev_name));
-#else
- if (chans == 2) stereo = 1; else stereo = 0;
- if ((ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) == -1) ||
- ((chans == 2) && (stereo == 0)))
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_fd,
- mus_format("can't get %d channels on %s (%s)",
- chans, dev_name,
- mus_audio_device_name(dev)));
-#endif
- if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &srate) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, audio_fd,
- mus_format("can't set srate to %d on %s (%s)",
- srate, dev_name,
- mus_audio_device_name(dev)));
- return(audio_fd);
-}
-
-
-static int oss_mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- int fd, amp, channels, err = MUS_NO_ERROR, devmask, stereodevs, ind, formats, sys, dev, srate;
- char *dev_name = NULL;
- sys = MUS_AUDIO_SYSTEM(ur_dev);
- dev = MUS_AUDIO_DEVICE(ur_dev);
- if (audio_type[sys] == SONORUS_STUDIO)
- {
- bool adat_mode = false;
- adat_mode = (audio_mode[sys] == 1);
- if (dev == MUS_AUDIO_MIXER) val[0] = 0; /* no mixer */
- else
- {
- if (field == MUS_AUDIO_PORT)
- {
- if (adat_mode)
- {
- val[0] = 5;
- val[1] = MUS_AUDIO_ADAT_IN;
- val[2] = MUS_AUDIO_ADAT_OUT;
- val[3] = MUS_AUDIO_SPEAKERS;
- val[4] = MUS_AUDIO_AES_IN;
- val[5] = MUS_AUDIO_AES_OUT;
- }
- else
- {
- val[0] = 3;
- val[1] = MUS_AUDIO_SPDIF_IN;
- val[2] = MUS_AUDIO_SPDIF_OUT;
- val[3] = MUS_AUDIO_SPEAKERS;
- }
- }
- else
- {
- if (field == MUS_AUDIO_FORMAT)
- {
- val[0] = 1;
- val[1] = MUS_LSHORT;
- }
- else
- {
- if (field == MUS_AUDIO_CHANNEL)
- {
- switch (dev)
- {
- case MUS_AUDIO_SPEAKERS:
- channels = 2;
- break;
- case MUS_AUDIO_ADAT_IN: case MUS_AUDIO_ADAT_OUT:
- channels = 8;
- break;
- case MUS_AUDIO_AES_IN: case MUS_AUDIO_AES_OUT:
- channels = 2;
- break;
- case MUS_AUDIO_SPDIF_IN: case MUS_AUDIO_SPDIF_OUT:
- channels = 4;
- break;
- case MUS_AUDIO_DEFAULT:
- if (adat_mode)
- channels = 8;
- else channels = 4;
- break;
- default:
- channels = 0;
- break;
- }
- val[0] = channels;
- }
- else
- {
- if (field == MUS_AUDIO_SRATE)
- {
- val[0] = 44100;
- }
- }
- }
- }
- }
- return(MUS_NO_ERROR);
- }
-
-#if HAVE_SAM_9407
- if (audio_type[sys] == SAM9407_DSP)
- {
- switch(field)
- {
- case MUS_AUDIO_PORT:
- val[0] = 2;
- val[1] = MUS_AUDIO_SPEAKERS;
- val[2] = MUS_AUDIO_LINE_IN;
- break;
- case MUS_AUDIO_FORMAT:
- val[0] = 1;
- val[1] = MUS_LSHORT;
- break;
- case MUS_AUDIO_CHANNEL:
- val[0] = 2;
- break;
- case MUS_AUDIO_AMP:
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, -1,
- mus_format("can't read %s's gains in Sam9407",
- mus_audio_device_name(dev)));
- break;
- case MUS_AUDIO_SRATE:
- val[0] = 44100;
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, -1,
- mus_format("can't read %s's %s in Sam9407",
- mus_audio_device_name(dev),
- mus_audio_device_name(field)));
- break;
- }
- return(MUS_NO_ERROR);
- }
-#endif
-
- if (audio_type[sys] == RME_HAMMERFALL)
- {
- if (dev == MUS_AUDIO_MIXER) val[0] = 0; /* no mixer */
- else
- {
- if (field == MUS_AUDIO_PORT)
- {
- val[0] = 5;
- val[1] = MUS_AUDIO_ADAT_IN;
- val[2] = MUS_AUDIO_ADAT_OUT;
- val[3] = MUS_AUDIO_SPEAKERS;
- val[4] = MUS_AUDIO_AES_IN;
- val[5] = MUS_AUDIO_AES_OUT;
- }
- else
- {
- if (field == MUS_AUDIO_FORMAT)
- {
- val[0] = 1;
- val[1] = MUS_LSHORT;
- }
- else
- {
- if (field == MUS_AUDIO_CHANNEL)
- {
- switch (dev)
- {
- case MUS_AUDIO_SPEAKERS:
- channels = 2;
- break;
- case MUS_AUDIO_ADAT_IN: case MUS_AUDIO_ADAT_OUT:
- channels = 8;
- break;
- case MUS_AUDIO_AES_IN: case MUS_AUDIO_AES_OUT:
- channels = 2;
- break;
- case MUS_AUDIO_SPDIF_IN: case MUS_AUDIO_SPDIF_OUT:
- channels = 4;
- break;
- case MUS_AUDIO_DEFAULT:
- channels = 8;
- break;
- default:
- channels = 0;
- break;
- }
- val[0] = channels;
- }
- else
- {
- if (field == MUS_AUDIO_SRATE)
- {
- val[0] = 44100;
- }
- }
- }
- }
- }
- return(MUS_NO_ERROR);
- }
-
- fd = linux_audio_open(dev_name = mixer_name(sys), O_RDONLY | O_NONBLOCK, 0, sys);
- if (fd == -1)
- {
- fd = linux_audio_open(DAC_NAME, O_RDONLY, 0, sys);
- if (fd == -1)
- {
- fd = linux_audio_open(DAC_NAME, O_WRONLY, 0, sys);
- if (fd == -1)
- {
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, -1,
- mus_format("can't open input %s or %s: %s",
- dev_name, DAC_NAME,
- strerror(errno)));
- return(MUS_ERROR);
- }
- else dev_name = DAC_NAME;
- }
- else dev_name = DAC_NAME;
- }
- if (ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask))
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE, fd,
- mus_format("can't read device info from %s",
- dev_name));
- err = 0;
- if ((dev == MUS_AUDIO_MIXER) ||
- (dev == MUS_AUDIO_DAC_FILTER)) /* these give access to all the on-board analog input gain controls */
- {
- amp = 0;
- ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask);
- switch (field)
- {
- /* also DIGITAL1..3 PHONEIN PHONEOUT VIDEO RADIO MONITOR */
- /* the digital lines should get their own panes in the recorder */
- /* not clear whether the phone et al lines are routed to the ADC */
- /* also, I've never seen a card with any of these devices */
- case MUS_AUDIO_IMIX: if (SOUND_MASK_IMIX & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_IMIX), &amp); break;
- case MUS_AUDIO_IGAIN: if (SOUND_MASK_IGAIN & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_IGAIN), &amp); break;
- case MUS_AUDIO_RECLEV: if (SOUND_MASK_RECLEV & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_RECLEV), &amp); break;
- case MUS_AUDIO_PCM: if (SOUND_MASK_PCM & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_PCM), &amp); break;
- case MUS_AUDIO_PCM2: if (SOUND_MASK_ALTPCM & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_ALTPCM), &amp); break;
- case MUS_AUDIO_OGAIN: if (SOUND_MASK_OGAIN & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_OGAIN), &amp); break;
- case MUS_AUDIO_LINE: if (SOUND_MASK_LINE & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE), &amp); break;
- case MUS_AUDIO_MICROPHONE: if (SOUND_MASK_MIC & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_MIC), &amp); break;
- case MUS_AUDIO_LINE1: if (SOUND_MASK_LINE1 & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE1), &amp); break;
- case MUS_AUDIO_LINE2: if (SOUND_MASK_LINE2 & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE2), &amp); break;
- case MUS_AUDIO_LINE3: if (SOUND_MASK_LINE3 & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE3), &amp); break;
- case MUS_AUDIO_SYNTH: if (SOUND_MASK_SYNTH & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_SYNTH), &amp); break;
- case MUS_AUDIO_BASS: if (SOUND_MASK_BASS & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_BASS), &amp); break;
- case MUS_AUDIO_TREBLE: if (SOUND_MASK_TREBLE & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_TREBLE), &amp); break;
- case MUS_AUDIO_CD: if (SOUND_MASK_CD & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_CD), &amp); break;
- case MUS_AUDIO_CHANNEL:
- if (dev == MUS_AUDIO_MIXER)
- {
- channels = 0;
- ioctl(fd, SOUND_MIXER_READ_STEREODEVS, &stereodevs);
- if (SOUND_MASK_IMIX & devmask) {if (SOUND_MASK_IMIX & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_IGAIN & devmask) {if (SOUND_MASK_IGAIN & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_RECLEV & devmask) {if (SOUND_MASK_RECLEV & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_PCM & devmask) {if (SOUND_MASK_PCM & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_ALTPCM & devmask) {if (SOUND_MASK_ALTPCM & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_OGAIN & devmask) {if (SOUND_MASK_OGAIN & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_LINE & devmask) {if (SOUND_MASK_LINE & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_MIC & devmask) {if (SOUND_MASK_MIC & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_LINE1 & devmask) {if (SOUND_MASK_LINE1 & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_LINE2 & devmask) {if (SOUND_MASK_LINE2 & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_LINE3 & devmask) {if (SOUND_MASK_LINE3 & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_SYNTH & devmask) {if (SOUND_MASK_SYNTH & stereodevs) channels += 2; else channels += 1;}
- if (SOUND_MASK_CD & devmask) {if (SOUND_MASK_CD & stereodevs) channels += 2; else channels += 1;}
- }
- else
- if (SOUND_MASK_TREBLE & devmask) channels = 2; else channels = 0;
- val[0] = channels;
- linux_audio_close(fd);
- return(MUS_NO_ERROR);
- break;
- case MUS_AUDIO_FORMAT: /* this is asking for configuration info -- we return an array with per-"device" channels */
- ioctl(fd, SOUND_MIXER_READ_STEREODEVS, &stereodevs);
- for (ind = 0; ind <= MUS_AUDIO_SYNTH; ind++) {if (chan > ind) val[ind] = 0;}
- if (SOUND_MASK_IMIX & devmask) {if (chan > MUS_AUDIO_IMIX) val[MUS_AUDIO_IMIX] = ((SOUND_MASK_IMIX & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_IGAIN & devmask) {if (chan > MUS_AUDIO_IGAIN) val[MUS_AUDIO_IGAIN] = ((SOUND_MASK_IGAIN & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_RECLEV & devmask) {if (chan > MUS_AUDIO_RECLEV) val[MUS_AUDIO_RECLEV] = ((SOUND_MASK_RECLEV & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_PCM & devmask) {if (chan > MUS_AUDIO_PCM) val[MUS_AUDIO_PCM] = ((SOUND_MASK_PCM & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_ALTPCM & devmask) {if (chan > MUS_AUDIO_PCM2) val[MUS_AUDIO_PCM2] = ((SOUND_MASK_ALTPCM & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_OGAIN & devmask) {if (chan > MUS_AUDIO_OGAIN) val[MUS_AUDIO_OGAIN] = ((SOUND_MASK_OGAIN & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_LINE & devmask) {if (chan > MUS_AUDIO_LINE) val[MUS_AUDIO_LINE] = ((SOUND_MASK_LINE & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_MIC & devmask) {if (chan > MUS_AUDIO_MICROPHONE) val[MUS_AUDIO_MICROPHONE] = ((SOUND_MASK_MIC & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_LINE1 & devmask) {if (chan > MUS_AUDIO_LINE1) val[MUS_AUDIO_LINE1] = ((SOUND_MASK_LINE1 & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_LINE2 & devmask) {if (chan > MUS_AUDIO_LINE2) val[MUS_AUDIO_LINE2] = ((SOUND_MASK_LINE2 & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_LINE3 & devmask) {if (chan > MUS_AUDIO_LINE3) val[MUS_AUDIO_LINE3] = ((SOUND_MASK_LINE3 & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_SYNTH & devmask) {if (chan > MUS_AUDIO_SYNTH) val[MUS_AUDIO_SYNTH] = ((SOUND_MASK_SYNTH & stereodevs) ? 2 : 1);}
- if (SOUND_MASK_CD & devmask) {if (chan > MUS_AUDIO_CD) val[MUS_AUDIO_CD] = ((SOUND_MASK_CD & stereodevs) ? 2 : 1);}
- linux_audio_close(fd);
- return(MUS_NO_ERROR);
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, fd,
- mus_format("can't read %s's (%s) %s",
- mus_audio_device_name(dev), dev_name,
- mus_audio_device_name(field)));
- break;
- }
- if (chan == 0)
- val[0] = ((float)(amp & 0xff)) * 0.01;
- else val[0] = (((float)((amp & 0xff00) >> 8)) * 0.01);
- }
- else
- {
- switch (field)
- {
- case MUS_AUDIO_PORT:
- ind = 1;
- val[1] = MUS_AUDIO_MIXER;
- if ((SOUND_MASK_MIC | SOUND_MASK_LINE | SOUND_MASK_CD) & devmask) {ind++; if (chan > ind) val[ind] = MUS_AUDIO_LINE_IN;}
- /* problem here is that microphone and line_in are mixed before the ADC */
- if (SOUND_MASK_SPEAKER & devmask) {ind++; if (chan > ind) val[ind] = MUS_AUDIO_SPEAKERS;}
- if (SOUND_MASK_VOLUME & devmask) {ind++; if (chan > ind) val[ind] = MUS_AUDIO_DAC_OUT;}
- if (SOUND_MASK_TREBLE & devmask) {ind++; if (chan > ind) val[ind] = MUS_AUDIO_DAC_FILTER;}
- /* DIGITAL1..3 as RECSRC(?) => MUS_AUDIO_DIGITAL_IN */
- val[0] = ind;
- break;
-#if 1
- case MUS_AUDIO_FORMAT:
- linux_audio_close(fd);
- fd = open(dac_name(sys, 0), O_WRONLY, 0);
- if (fd == -1) fd = open(DAC_NAME, O_WRONLY, 0);
- if (fd == -1)
- {
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, -1,
- mus_format("can't open %s: %s",
- DAC_NAME, strerror(errno)));
- return(MUS_ERROR);
- }
- ioctl(fd, SOUND_PCM_GETFMTS, &formats);
-#else
- case MUS_AUDIO_FORMAT:
- ioctl(fd, SOUND_PCM_GETFMTS, &formats);
- /* this returns -1 and garbage?? */
-
- /* from Steven Schultz:
- I did discover why, in audio.c the SOUND_PCM_GETFMTS ioctl was failing.
- That ioctl call can only be made against the /dev/dsp device and _not_
- the /dev/mixer device. With that change things starting working real
- nice.
- */
-#endif
- ind = 0;
- if (formats & (to_oss_format(MUS_BYTE))) {ind++; if (chan > ind) val[ind] = MUS_BYTE;}
- if (formats & (to_oss_format(MUS_BSHORT))) {ind++; if (chan > ind) val[ind] = MUS_BSHORT;}
- if (formats & (to_oss_format(MUS_UBYTE))) {ind++; if (chan > ind) val[ind] = MUS_UBYTE;}
- if (formats & (to_oss_format(MUS_MULAW))) {ind++; if (chan > ind) val[ind] = MUS_MULAW;}
- if (formats & (to_oss_format(MUS_ALAW))) {ind++; if (chan > ind) val[ind] = MUS_ALAW;}
- if (formats & (to_oss_format(MUS_LSHORT))) {ind++; if (chan > ind) val[ind] = MUS_LSHORT;}
- if (formats & (to_oss_format(MUS_UBSHORT))) {ind++; if (chan > ind) val[ind] = MUS_UBSHORT;}
- if (formats & (to_oss_format(MUS_ULSHORT))) {ind++; if (chan > ind) val[ind] = MUS_ULSHORT;}
- val[0] = ind;
- break;
- case MUS_AUDIO_CHANNEL:
- channels = 0;
- ioctl(fd, SOUND_MIXER_READ_STEREODEVS, &stereodevs);
- switch (dev)
- {
- case MUS_AUDIO_MICROPHONE: if (SOUND_MASK_MIC & devmask) {if (SOUND_MASK_MIC & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_SPEAKERS: if (SOUND_MASK_SPEAKER & devmask) {if (SOUND_MASK_SPEAKER & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_LINE_IN: if (SOUND_MASK_LINE & devmask) {if (SOUND_MASK_LINE & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_LINE1: if (SOUND_MASK_LINE1 & devmask) {if (SOUND_MASK_LINE1 & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_LINE2: if (SOUND_MASK_LINE2 & devmask) {if (SOUND_MASK_LINE2 & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_LINE3: if (SOUND_MASK_LINE3 & devmask) {if (SOUND_MASK_LINE3 & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_DAC_OUT: if (SOUND_MASK_VOLUME & devmask) {if (SOUND_MASK_VOLUME & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_DEFAULT: if (SOUND_MASK_VOLUME & devmask) {if (SOUND_MASK_VOLUME & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_CD: if (SOUND_MASK_CD & devmask) {if (SOUND_MASK_CD & stereodevs) channels = 2; else channels = 1;} break;
- case MUS_AUDIO_DUPLEX_DEFAULT:
- err = ioctl(fd, SNDCTL_DSP_GETCAPS, &ind);
- if (err != -1)
- channels = (ind & DSP_CAP_DUPLEX);
- else channels = 0;
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, fd,
- mus_format("can't read channel info from %s (%s)",
- mus_audio_device_name(dev), dev_name));
- break;
- }
- val[0] = channels;
- break;
- case MUS_AUDIO_AMP:
- amp = 0;
- switch (dev)
- {
- case MUS_AUDIO_MICROPHONE: if (SOUND_MASK_MIC & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_MIC), &amp); break;
- case MUS_AUDIO_SPEAKERS: if (SOUND_MASK_SPEAKER & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_SPEAKER), &amp); break;
- case MUS_AUDIO_LINE_IN: if (SOUND_MASK_LINE & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE), &amp); break;
- case MUS_AUDIO_LINE1: if (SOUND_MASK_LINE1 & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE1), &amp); break;
- case MUS_AUDIO_LINE2: if (SOUND_MASK_LINE2 & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE2), &amp); break;
- case MUS_AUDIO_LINE3: if (SOUND_MASK_LINE3 & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_LINE3), &amp); break;
- case MUS_AUDIO_DAC_OUT: if (SOUND_MASK_VOLUME & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_VOLUME), &amp); break;
- case MUS_AUDIO_DEFAULT: if (SOUND_MASK_VOLUME & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_VOLUME), &amp); break;
- case MUS_AUDIO_CD: if (SOUND_MASK_CD & devmask) err = ioctl(fd, MIXER_READ(SOUND_MIXER_CD), &amp); break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, fd,
- mus_format("can't get gain info for %s (%s)",
- mus_audio_device_name(dev), dev_name));
- break;
- }
- if (err)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, fd,
- mus_format("can't read %s's (%s) amp info",
- mus_audio_device_name(dev), dev_name));
- if (chan == 0)
- val[0] = ((float)(amp & 0xff)) * 0.01;
- else val[0] = (((float)((amp & 0xff00) >> 8)) * 0.01);
- break;
- case MUS_AUDIO_SRATE:
- srate = (int)(val[0]);
- if (ioctl(fd, SNDCTL_DSP_SPEED, &srate) == -1)
- {
- linux_audio_close(fd);
- /* see comment from Steven Schultz above */
- fd = open(dac_name(sys, 0), O_WRONLY, 0);
- if (fd == -1) fd = open(DAC_NAME, O_WRONLY, 0);
- if (ioctl(fd, SNDCTL_DSP_SPEED, &srate) == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, fd,
- mus_format("can't get %s's (%s) srate",
- mus_audio_device_name(dev), dev_name));
- }
- val[0] = (float)srate;
- break;
- case MUS_AUDIO_DIRECTION:
- switch (dev)
- {
- case MUS_AUDIO_DIGITAL_OUT: case MUS_AUDIO_LINE_OUT: case MUS_AUDIO_DEFAULT: case MUS_AUDIO_ADAT_OUT:
- case MUS_AUDIO_AES_OUT: case MUS_AUDIO_SPDIF_OUT: case MUS_AUDIO_SPEAKERS: case MUS_AUDIO_MIXER:
- case MUS_AUDIO_DAC_FILTER: case MUS_AUDIO_AUX_OUTPUT: case MUS_AUDIO_DAC_OUT:
- val[0] = 0.0;
- break;
- default:
- val[0] = 1.0;
- break;
- }
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, fd,
- mus_format("can't get %s's (%s) %s",
- mus_audio_device_name(dev), dev_name,
- mus_audio_device_name(field)));
- break;
- }
- }
- return(linux_audio_close(fd));
-}
-
-static int oss_mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- int fd, err = MUS_NO_ERROR, devmask, vol, sys, dev;
- char *dev_name;
- float amp[1];
- sys = MUS_AUDIO_SYSTEM(ur_dev);
- dev = MUS_AUDIO_DEVICE(ur_dev);
-
-#if HAVE_SAM_9407
- if (audio_type[sys] == SAM9407_DSP) return(MUS_NO_ERROR); /* XXX */
-#endif
-
- if (audio_type[sys] == SONORUS_STUDIO) return(MUS_NO_ERROR); /* there are apparently volume controls, but they're not accessible yet */
- if (audio_type[sys] == RME_HAMMERFALL) return(MUS_NO_ERROR);
- if (audio_type[sys] == DELTA_66) return(MUS_NO_ERROR);
-
- fd = linux_audio_open(dev_name = mixer_name(sys), O_RDWR | O_NONBLOCK, 0, sys);
- if (fd == -1)
- {
- fd = linux_audio_open_with_error(dev_name = DAC_NAME, O_WRONLY, 0, sys);
- if (fd == -1) return(MUS_ERROR);
- }
- if ((dev == MUS_AUDIO_MIXER) ||
- (dev == MUS_AUDIO_DAC_FILTER)) /* these give access to all the on-board analog input gain controls */
- {
- if (mus_audio_mixer_read(ur_dev, field, (chan == 0) ? 1 : 0, amp))
- {
- linux_audio_close(fd);
- return(MUS_ERROR);
- }
- if (val[0] >= 0.99) val[0] = 0.99;
- if (val[0] < 0.0) val[0] = 0.0;
- if (amp[0] >= 0.99) amp[0] = 0.99;
- if (chan == 0)
- vol = (((int)(amp[0] * 100)) << 8) + ((int)(val[0] * 100));
- else vol = (((int)(val[0] * 100)) << 8) + ((int)(amp[0] * 100));
- ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask);
- switch (field)
- {
- case MUS_AUDIO_IMIX: if (SOUND_MASK_IMIX & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_IMIX), &vol); break;
- case MUS_AUDIO_IGAIN: if (SOUND_MASK_IGAIN & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_IGAIN), &vol); break;
- case MUS_AUDIO_RECLEV: if (SOUND_MASK_RECLEV & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_RECLEV), &vol); break;
- case MUS_AUDIO_PCM: if (SOUND_MASK_PCM & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_PCM), &vol); break;
- case MUS_AUDIO_PCM2: if (SOUND_MASK_ALTPCM & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_ALTPCM), &vol); break;
- case MUS_AUDIO_OGAIN: if (SOUND_MASK_OGAIN & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_OGAIN), &vol); break;
- case MUS_AUDIO_LINE: if (SOUND_MASK_LINE & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE), &vol); break;
- case MUS_AUDIO_MICROPHONE: if (SOUND_MASK_MIC & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &vol); break;
- case MUS_AUDIO_LINE1: if (SOUND_MASK_LINE1 & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE1), &vol); break;
- case MUS_AUDIO_LINE2: if (SOUND_MASK_LINE2 & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE2), &vol); break;
- case MUS_AUDIO_LINE3: if (SOUND_MASK_LINE3 & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE3), &vol); break;
- case MUS_AUDIO_SYNTH: if (SOUND_MASK_SYNTH & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_SYNTH), &vol); break;
- case MUS_AUDIO_BASS: if (SOUND_MASK_BASS & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_BASS), &vol); break;
- case MUS_AUDIO_TREBLE: if (SOUND_MASK_TREBLE & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_TREBLE), &vol); break;
- case MUS_AUDIO_CD: if (SOUND_MASK_CD & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_CD), &vol); break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, fd,
- mus_format("can't write %s's (%s) %s field",
- mus_audio_device_name(dev), dev_name,
- mus_audio_device_name(field)));
- break;
- }
- }
- else
- {
- switch (field)
- {
- case MUS_AUDIO_AMP:
- /* need to read both channel amps, then change the one we're concerned with */
- mus_audio_mixer_read(ur_dev, field, (chan == 0) ? 1 : 0, amp);
- if (val[0] >= 0.99) val[0] = 0.99;
- if (val[0] < 0.0) val[0] = 0.0;
- if (amp[0] >= 0.99) amp[0] = 0.99;
- if (chan == 0)
- vol = (((int)(amp[0] * 100)) << 8) + ((int)(val[0] * 100));
- else vol = (((int)(val[0] * 100)) << 8) + ((int)(amp[0] * 100));
- ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask);
- switch (dev)
- {
- case MUS_AUDIO_MICROPHONE: if (SOUND_MASK_MIC & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &vol); break;
- case MUS_AUDIO_SPEAKERS: if (SOUND_MASK_SPEAKER & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_SPEAKER), &vol); break;
- case MUS_AUDIO_LINE_IN: if (SOUND_MASK_LINE & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE), &vol); break;
- case MUS_AUDIO_LINE1: if (SOUND_MASK_LINE1 & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE1), &vol); break;
- case MUS_AUDIO_LINE2: if (SOUND_MASK_LINE2 & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE2), &vol); break;
- case MUS_AUDIO_LINE3: if (SOUND_MASK_LINE3 & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_LINE3), &vol); break;
- case MUS_AUDIO_DAC_OUT: if (SOUND_MASK_VOLUME & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &vol); break;
- case MUS_AUDIO_DEFAULT: if (SOUND_MASK_VOLUME & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &vol); break;
- case MUS_AUDIO_CD: if (SOUND_MASK_CD & devmask) err = ioctl(fd, MIXER_WRITE(SOUND_MIXER_CD), &vol); break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, fd,
- mus_format("device %d (%s) not available on %s",
- dev, mus_audio_device_name(dev), dev_name));
- }
- break;
- case MUS_AUDIO_SRATE:
- vol = (int)val[0];
- linux_audio_close(fd);
- /* see comment from Steven Schultz above */
- fd = open(dac_name(sys, 0), O_WRONLY | O_NONBLOCK, 0);
- if (fd == -1)
- {
- fd = open(DAC_NAME, O_WRONLY | O_NONBLOCK, 0);
- if (fd == -1) return(-1);
- }
- err = ioctl(fd, SNDCTL_DSP_SPEED, &vol);
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, fd,
- mus_format("can't write %s's (%s) %s field",
- mus_audio_device_name(dev), dev_name,
- mus_audio_device_name(field)));
- break;
- /* case MUS_AUDIO_FORMAT: to force 16-bit input or give up */
- /* case MUS_AUDIO_CHANNEL: to open as stereo if possible?? */
- /* case MUS_AUDIO_PORT: to open digital out? */
- }
- }
- if (err)
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, fd,
- mus_format("possible write problem for %s's (%s) %s field",
- mus_audio_device_name(dev), dev_name,
- mus_audio_device_name(field)));
- return(linux_audio_close(fd));
-}
-
-static char *synth_names[] =
- {"",
- "Adlib", "SoundBlaster", "ProAudio Spectrum", "Gravis UltraSound", "MPU 401",
- "SoundBlaster 16", "SoundBlaster 16 MIDI", "6850 UART", "Gravis UltraSound 16", "Microsoft",
- "Personal sound system", "Ensoniq Soundscape", "Personal sound system + MPU", "Personal/Microsoft",
- "Mediatrix Pro", "MAD16", "MAD16 + MPU", "CS4232", "CS4232 + MPU", "Maui",
- "Pseudo-MSS", "Gravis Ultrasound PnP", "UART 401"};
-
-static char *synth_name(int i)
-{
-#ifdef SNDCARD_UART401
- if ((i > 0) && (i <= SNDCARD_UART401))
-#else
- if ((i > 0) && (i <= 26))
-#endif
- return(synth_names[i]);
- return("unknown");
-}
-
-static char *device_types[] = {"FM", "Sampling", "MIDI"};
-
-static char *device_type(int i)
-{
- if ((i >= 0) && (i <= 2))
- return(device_types[i]);
- return("unknown");
-}
-
-static void yes_no(int condition)
-{
- if (condition)
- pprint(" yes ");
- else pprint(" no ");
-}
-
-static int set_dsp(int fd, int channels, int bits, int *rate)
-{
- int val;
- val = channels;
- ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &val);
- if (val != channels) return(MUS_ERROR);
- val = bits;
- ioctl(fd, SOUND_PCM_WRITE_BITS, &val);
- if (val != bits) return(MUS_ERROR);
- ioctl(fd, SOUND_PCM_WRITE_RATE, rate);
- return(MUS_NO_ERROR);
-}
-
-static void oss_describe_audio_state_1(void)
-{
- /* this code taken largely from "Linux Multimedia Guide" by Jeff Tranter, O'Reilly & Associates, Inc 1996 */
- /* it is explicitly released under the GPL, so I think I can use it here without elaborate disguises */
- int fd;
- int status = 0, level, i, recsrc, devmask, recmask, stereodevs, caps;
- int numdevs = 0, rate = 0, channels = 0, bits = 0, blocksize = 0, formats = 0, deffmt = 0, min_rate = 0, max_rate = 0;
- struct synth_info sinfo;
- struct midi_info minfo;
- const char *sound_device_names[] = SOUND_DEVICE_LABELS;
- char dsp_name[LABEL_BUFFER_SIZE];
- char version[LABEL_BUFFER_SIZE];
- int dsp_num = 0;
-#ifdef NEW_OSS
- mixer_info mixinfo;
- oss_sysinfo sysinfo;
-#endif
-
- if (sound_cards <= 0) mus_audio_initialize();
- memset((void *)dsp_name, 0, LABEL_BUFFER_SIZE);
- memset((void *)version, 0, LABEL_BUFFER_SIZE);
-
-#ifdef NEW_OSS
- fd = open(DAC_NAME, O_WRONLY, 0);
- if (fd == -1) fd = open(SYNTH_NAME, O_RDONLY, 0);
- if (fd == -1) fd = open(MIXER_NAME, O_RDONLY, 0);
- if (fd != -1)
- {
- status = ioctl(fd, OSS_GETVERSION, &level);
- new_oss_running = (status == 0);
- status = ioctl(fd, OSS_SYSINFO, &sysinfo);
- close(fd);
- }
-#endif
-
- if (new_oss_running)
- {
-#ifdef NEW_OSS
- if (status == 0)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "OSS version: %s\n", sysinfo.version);
- pprint(audio_strbuf);
- }
- else
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "OSS version: %x.%x.%x\n", (level >> 16) & 0xff, (level >> 8) & 0xff, level & 0xff);
- pprint(audio_strbuf);
- }
-#else
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "OSS version: %x.%x.%x\n", (level >> 16) & 0xff, (level >> 8) & 0xff, level & 0xff);
- pprint(audio_strbuf);
-#endif
- }
- else
- {
- /* refers to the version upon compilation */
- mus_snprintf(version, LABEL_BUFFER_SIZE, "%d", SOUND_VERSION);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "OSS version: %c.%c.%c\n", version[0], version[1], version[2]);
- pprint(audio_strbuf);
- }
-
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%d card%s found", sound_cards, (sound_cards != 1) ? "s" : ""); pprint(audio_strbuf);
- if (sound_cards > 1)
- {
- pprint(": ");
- for (i = 0; i < sound_cards; i++)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "/dev/dsp%d with /dev/mixer%d%s",
- audio_dsp[i],
- audio_mixer[i],
- (i < (sound_cards - 1)) ? ", " : "");
- pprint(audio_strbuf);
- }
- }
- pprint("\n\n");
-
- fd = open(SYNTH_NAME, O_RDWR, 0);
- if (fd == -1) fd = open(SYNTH_NAME, O_RDONLY, 0);
- if (fd == -1)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s: %s\n", SYNTH_NAME, strerror(errno)); pprint(audio_strbuf);
- pprint("no synth found\n");
- }
- else
- {
- status = ioctl(fd, SNDCTL_SEQ_NRSYNTHS, &numdevs);
- if (status == -1)
- {
- close(fd); fd = -1;
- pprint("no sequencer?");
- }
- else
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "/dev/sequencer: %d device%s installed\n", numdevs, (numdevs == 1) ? "" : "s");
- pprint(audio_strbuf);
- for (i = 0; i < numdevs; i++)
- {
- sinfo.device = i;
- status = ioctl(fd, SNDCTL_SYNTH_INFO, &sinfo);
- if (status != -1)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " device: %d: %s, %s, %d voices\n", i, sinfo.name, device_type(sinfo.synth_type), sinfo.nr_voices);
- pprint(audio_strbuf);
- }
- }
- status = ioctl(fd, SNDCTL_SEQ_NRMIDIS, &numdevs);
- if (status == -1)
- {
- close(fd); fd = -1;
- pprint("no midi");
- }
- else
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %d midi device%s installed\n", numdevs, (numdevs == 1) ? "" : "s");
- pprint(audio_strbuf);
- for (i = 0; i < numdevs; i++)
- {
- minfo.device = i;
- status = ioctl(fd, SNDCTL_MIDI_INFO, &minfo);
- if (status != -1)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " device %d: %s, %s\n", i, minfo.name, synth_name(minfo.dev_type));
- pprint(audio_strbuf);
- }
- }
- }
- }
- }
- if (fd != -1) close(fd);
- pprint("--------------------------------\n");
-
-MIXER_INFO:
- mus_snprintf(dsp_name, LABEL_BUFFER_SIZE, "%s%d", MIXER_NAME, dsp_num);
- fd = linux_audio_open(dsp_name, O_RDWR, 0, 0);
- if (fd == -1)
- {
- /* maybe output only */
- fd = linux_audio_open(dsp_name, O_WRONLY, 0, 0);
- if (fd == -1)
- {
- if (dsp_num == 0)
- {
- mus_snprintf(dsp_name, LABEL_BUFFER_SIZE, "%s", DAC_NAME);
- fd = linux_audio_open(DAC_NAME, O_RDWR, 0, 0);
- if (fd == -1)
- {
- /* maybe output only */
- fd = linux_audio_open(DAC_NAME, O_WRONLY, 0, 0);
- if (fd == -1)
- {
- pprint("no audio device found\n");
- return;
- }
- }
- }
- else goto AUDIO_INFO; /* no /dev/mixern */
- }
- else pprint("no audio input enabled\n");
- }
- if (fd == -1) goto AUDIO_INFO;
-
-#ifdef NEW_OSS
- if (new_oss_running) status = ioctl(fd, SOUND_MIXER_INFO, &mixinfo);
-#endif
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s", dsp_name);
- pprint(audio_strbuf);
-#ifdef NEW_OSS
- if ((new_oss_running) && (status == 0))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " (%s", mixinfo.name);
- pprint(audio_strbuf);
- for (i = 0; i < sound_cards; i++)
- {
- if ((audio_mixer[i] == dsp_num) && (audio_type[i] == SONORUS_STUDIO))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " in mode %d", audio_mode[i]);
- pprint(audio_strbuf);
- break;
- }
- }
- pprint(")");
- }
-#endif
- status = ioctl(fd, SOUND_MIXER_READ_RECSRC, &recsrc);
- if (status == -1)
- {
- linux_audio_close(fd);
- fd = -1;
- pprint(" no recsrc\n");
- }
- else
- {
- status = ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask);
- if ((status == -1) || (devmask == 0))
- {
- linux_audio_close(fd);
- fd = -1;
- if (status == -1) pprint(" no devmask\n"); else pprint(" (no reported devices)");
- }
- else
- {
- status = ioctl(fd, SOUND_MIXER_READ_RECMASK, &recmask);
- if (status == -1)
- {
- pprint(" no recmask\n");
- recmask = 0;
- }
- status = ioctl(fd, SOUND_MIXER_READ_STEREODEVS, &stereodevs);
- if (status == -1)
- {
- pprint(" no stereodevs\n");
- stereodevs = 0;
- }
- status = ioctl(fd, SOUND_MIXER_READ_CAPS, &caps);
- if (status == -1)
- {
- pprint(" no caps\n");
- caps = 0;
- }
- pprint(":\n\n"
- " mixer recording active stereo current\n"
- " channel source source device level\n"
- " -------- -------- -------- -------- -------- \n");
- for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
- {
- if ((1<<i) & devmask)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %-10s", sound_device_names[i]);
- pprint(audio_strbuf);
- yes_no((1 << i) & recmask);
- yes_no((1 << i) & recsrc);
- yes_no((1 << i) & stereodevs);
- status = ioctl(fd, MIXER_READ(i), &level);
- if (status != -1)
- {
- if ((1<<i) & stereodevs)
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.2f %.2f", (float)(level & 0xff) * 0.01, (float)((level & 0xff00) >> 8) * 0.01);
- else mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.2f", (float)(level & 0xff) * 0.01);
- /* can't use %% here because subsequent fprintf in pprint evaluates the %! #$@$! */
- pprint(audio_strbuf);
- }
- pprint("\n");
- }
- }
- pprint("--------------------------------\n");
- }
- }
-
-AUDIO_INFO:
- if (fd != -1) {linux_audio_close(fd); fd = -1;}
- mus_snprintf(dsp_name, LABEL_BUFFER_SIZE, "%s%d", DAC_NAME, dsp_num);
- fd = linux_audio_open(dsp_name, O_RDWR, 0, 0);
- if ((fd == -1) && (dsp_num == 0)) fd = linux_audio_open(DAC_NAME, O_WRONLY, 0, 0);
- if (fd == -1) return;
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s:\n\n", dsp_name); pprint(audio_strbuf);
- if ((ioctl(fd, SOUND_PCM_READ_RATE, &rate) != -1) &&
- (ioctl(fd, SOUND_PCM_READ_CHANNELS, &channels) != -1) &&
- (ioctl(fd, SOUND_PCM_READ_BITS, &bits) != -1) &&
- (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &blocksize) != -1))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- " defaults:\n sampling rate: %d, chans: %d, sample size: %d bits, block size: %d bytes",
- rate, channels, bits, blocksize);
- pprint(audio_strbuf);
-
-#ifdef SNDCTL_DSP_GETOSPACE
- {
- audio_buf_info abi;
- ioctl(fd, SNDCTL_DSP_GETOSPACE, &abi);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " (%d fragments)\n", abi.fragments);
- pprint(audio_strbuf);
- }
-#else
- pprint("\n");
-#endif
-
- deffmt = AFMT_QUERY;
- if ((ioctl(fd, SOUND_PCM_SETFMT, &deffmt) != -1) &&
- (ioctl(fd, SOUND_PCM_GETFMTS, &formats) != -1))
- {
- pprint(" supported formats:\n");
- if (formats & AFMT_MU_LAW) {pprint(" mulaw"); if (deffmt == AFMT_MU_LAW) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_A_LAW) {pprint(" alaw"); if (deffmt == AFMT_A_LAW) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_IMA_ADPCM) {pprint(" adpcm"); if (deffmt == AFMT_IMA_ADPCM) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_U8) {pprint(" unsigned byte"); if (deffmt == AFMT_U8) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_S16_LE) {pprint(" signed little-endian short"); if (deffmt == AFMT_S16_LE) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_S16_BE) {pprint(" signed big-endian short"); if (deffmt == AFMT_S16_BE) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_S8) {pprint(" signed byte"); if (deffmt == AFMT_S8) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_U16_LE) {pprint(" unsigned little-endian short"); if (deffmt == AFMT_U16_LE) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_U16_BE) {pprint(" unsigned big-endian short"); if (deffmt == AFMT_U16_BE) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_MPEG) {pprint(" mpeg 2"); if (deffmt == AFMT_MPEG) pprint(" (default)"); pprint("\n");}
-#ifdef NEW_OSS
- if (formats & AFMT_S32_LE) {pprint(" signed little-endian int"); if (deffmt == AFMT_S32_LE) pprint(" (default)"); pprint("\n");}
- if (formats & AFMT_S32_BE) {pprint(" signed big-endian int"); if (deffmt == AFMT_S32_BE) pprint(" (default)"); pprint("\n");}
-#endif
- status = ioctl(fd, SNDCTL_DSP_GETCAPS, &caps);
- if (status != -1)
- {
- if (caps & DSP_CAP_DUPLEX) pprint(" full duplex\n");
- pprint(" sample srate\n channels size min max\n");
- for (channels = 1; channels <= 2; channels++)
- {
- for (bits = 8; bits <= 16; bits += 8)
- {
- min_rate = 1;
- if (set_dsp(fd, channels, bits, &min_rate) == -1) continue;
- max_rate = 100000;
- if (set_dsp(fd, channels, bits, &max_rate) == -1) continue;
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %4d %8d %8d %8d\n", channels, bits, min_rate, max_rate);
- pprint(audio_strbuf);
- }
- }
- }
- }
- }
- pprint("--------------------------------\n");
- linux_audio_close(fd);
- fd = -1;
- dsp_num++;
- if (dsp_num < 16)
- {
- mus_snprintf(dsp_name, LABEL_BUFFER_SIZE, "%s%d", MIXER_NAME, dsp_num);
- goto MIXER_INFO;
- }
-}
-
-/* ------------------------------- ALSA, OSS, Jack ----------------------------------- */
-/* API being used */
-
-static int api = ALSA_API;
-int mus_audio_api(void) {return(api);}
-
-/* hopefully first call to sndlib will be this... */
-static int probe_api(void);
-static int (*vect_mus_audio_initialize)(void);
-
-/* FIXME: add a suitable default for all other vectors
- so that a call happening before mus_audio_initialize
- can be detected */
-/* I don't think this is necessary -- documentation discusses this
- * (mus_sound_initialize calls mus_audio_initialize)
- */
-
-/* vectors for the rest of the sndlib api */
-static void (*vect_mus_oss_set_buffers)(int num, int size);
-static int (*vect_mus_audio_systems)(void);
-static char* (*vect_mus_audio_system_name)(int system);
-static char* (*vect_mus_audio_moniker)(void);
-static int (*vect_mus_audio_open_output)(int ur_dev, int srate, int chans, int format, int size);
-static int (*vect_mus_audio_open_input)(int ur_dev, int srate, int chans, int format, int requested_size);
-static int (*vect_mus_audio_write)(int id, char *buf, int bytes);
-static int (*vect_mus_audio_read)(int id, char *buf, int bytes);
-static int (*vect_mus_audio_close)(int id);
-static int (*vect_mus_audio_mixer_read)(int ur_dev, int field, int chan, float *val);
-static int (*vect_mus_audio_mixer_write)(int ur_dev, int field, int chan, float *val);
-static void (*vect_describe_audio_state_1)(void);
-
-/* vectors for the rest of the sndlib api */
-int mus_audio_initialize(void)
-{
- return(probe_api());
-}
-
-void mus_oss_set_buffers(int num, int size)
-{
- vect_mus_oss_set_buffers(num, size);
-}
-
-int mus_audio_systems(void)
-{
- return(vect_mus_audio_systems());
-}
-
-char* mus_audio_system_name(int system)
-{
- return(vect_mus_audio_system_name(system));
-}
-
-#if HAVE_ALSA
-static char* alsa_mus_audio_moniker(void);
-#endif
-
-char* mus_audio_moniker(void)
-{
-#if (HAVE_OSS && HAVE_ALSA)
- char *both_names;
- both_names = (char *)CALLOC(PRINT_BUFFER_SIZE, sizeof(char));
- /* need to be careful here since these use the same constant buffer */
- strcpy(both_names, oss_mus_audio_moniker());
- strcat(both_names, ", ");
- strcat(both_names, alsa_mus_audio_moniker());
- return(both_names); /* tiny memory leak ... */
-#else
- return(vect_mus_audio_moniker());
-#endif
-}
-
-int mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size)
-{
- return(vect_mus_audio_open_output(ur_dev, srate, chans, format, size));
-}
-
-int mus_audio_open_input(int ur_dev, int srate, int chans, int format, int requested_size)
-{
- return(vect_mus_audio_open_input(ur_dev, srate, chans, format, requested_size));
-}
-
-int mus_audio_write(int id, char *buf, int bytes)
-{
- return(vect_mus_audio_write(id, buf, bytes));
-}
-
-int mus_audio_read(int id, char *buf, int bytes)
-{
- return(vect_mus_audio_read(id, buf, bytes));
-}
-
-int mus_audio_close(int id)
-{
- return(vect_mus_audio_close(id));
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- return(vect_mus_audio_mixer_read(ur_dev, field, chan, val));
-}
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- return(vect_mus_audio_mixer_write(ur_dev, field, chan, val));
-}
-
-static void describe_audio_state_1(void)
-{
- vect_describe_audio_state_1();
-}
-
-#if HAVE_JACK
- static int jack_mus_audio_initialize(void);
-#endif
-
-#if (!HAVE_ALSA)
-static int probe_api(void)
-{
-#if HAVE_JACK
- {
- int jackprobe = jack_mus_audio_initialize();
- if (jackprobe == MUS_ERROR)
- {
-#endif
- /* go for the oss api */
- api = OSS_API;
- vect_mus_audio_initialize = oss_mus_audio_initialize;
- vect_mus_oss_set_buffers = oss_mus_oss_set_buffers;
- vect_mus_audio_systems = oss_mus_audio_systems;
- vect_mus_audio_system_name = oss_mus_audio_system_name;
- vect_mus_audio_moniker = oss_mus_audio_moniker;
- vect_mus_audio_open_output = oss_mus_audio_open_output;
- vect_mus_audio_open_input = oss_mus_audio_open_input;
- vect_mus_audio_write = oss_mus_audio_write;
- vect_mus_audio_read = oss_mus_audio_read;
- vect_mus_audio_close = oss_mus_audio_close;
- vect_mus_audio_mixer_read = oss_mus_audio_mixer_read;
- vect_mus_audio_mixer_write = oss_mus_audio_mixer_write;
- vect_describe_audio_state_1 = oss_describe_audio_state_1;
- return(vect_mus_audio_initialize());
-#if HAVE_JACK
- }
- return(jackprobe);
- }
-#endif
-}
-#endif
-
-#endif
-
-
-/* ------------------------------- ALSA ----------------------------------------- */
-/*
- * added HAVE_NEW_ALSA, and changed various calls to reflect the new calling sequences (all under HAVE_NEW_ALSA)
- * also scheme/ruby tie-ins, and other such changes. Changed the names of the environment variables to use MUS, not SNDLIB.
- * reformatted and reorganized to be like the rest of the code
- * changed default device to "default"
- * -- Bill 3-Feb-06
- *
- * error handling (mus_error) changed by Bill 14-Nov-02
- * 0.5 support removed by Bill 24-Mar-02
- *
- * changed for 0.9.x api by Fernando Lopez-Lezcano <nando@ccrma.stanford.edu>
- *
- * sndlib "exports" only one soundcard with two directions (if they are available),
- * and only deals with the alsa library pcm's. It does not scan for available
- * cards and devices at the hardware level. Which device it uses can be defined by:
- *
- * - setting variables in the environment (searched for in the following order):
- * MUS_ALSA_PLAYBACK_DEVICE
- * defines the name of the playback device
- * MUS_ALSA_CAPTURE_DEVICE
- * defines the name of the capture device
- * MUS_ALSA_DEVICE
- * defines the name of the playback and capture device
- * use the first two if the playback and capture devices are different or the
- * third if they are the same.
- * - if no variables are found in the environment sndlib tries to probe for a
- * default device named "sndlib" (in alsa 0.9 devices are configured in
- * /usr/share/alsa/alsa.conf or in ~/.asoundrc)
- * - if "sndlib" is not a valid device "hw:0,0" was used [but now it looks for "default"] (which by default should
- * point to the first device of the first card
- *
- * Some default settings are controllable through the environment as well:
- * MUS_ALSA_BUFFER_SIZE = size of each buffer in frames
- * MUS_ALSA_BUFFERS = number of buffers
- *
- * changed 18-Sep-00 by Bill: new error handling: old mus_audio_error folded into
- * mus_error; mus_error itself should be used only for "real" errors -- things
- * that can cause a throw (a kind of global jump elsewhere); use mus_print for informational
- * stuff -- in Snd, mus_print will also save everything printed in the error dialog.
- * In a few cases, I tried to fix the code to unwind before mus_error, and in others
- * I've changed mus_error to mus_print, but some of these may be mistaken.
- * Look for ?? below for areas where I'm not sure I rewrote code correctly.
- *
- * changed for 0.6.x api by Paul Barton-Davis, pbd@op.net
- *
- * changed for 0.5.x api by Fernando Lopez-Lezcano, nando@ccrma.stanford.edu
- * 04-10-2000:
- * based on original 0.4.x code by Paul Barton-Davis (not much left of it :-)
- * also Bill's code and Jaroslav Kysela (aplay.c and friends)
- *
- * Changes:
- * 04/25/2000: finished major rework, snd-dac now automatically decides which
- * device or devices it uses for playback. Multiple device use is
- * for now restricted to only two at most (more changes in Bill's
- * needed to be able to support more). Four channel playback in
- * Ensoniq AudioPCI and relatives possible (with proper settings
- * of the mixer) as well as using two separate cards.
- * 04/11/2000: added reporting of alsa sound formats
-*/
-
-#if HAVE_ALSA
-
-#if (!HAVE_OSS)
-#define AUDIO_OK
-#endif
-
-#include <sys/ioctl.h>
-
-#if (!HAVE_NEW_ALSA)
- #define ALSA_PCM_OLD_HW_PARAMS_API
- #define ALSA_PCM_OLD_SW_PARAMS_API
-#endif
-
-#if HAVE_ALSA_ASOUNDLIB_H
- #include <alsa/asoundlib.h>
-#else
- #include <sys/asoundlib.h>
-#endif
-
-#if SND_LIB_VERSION < ((0<<16)|(6<<8)|(0))
- #error ALSA version is too old -- audio.c needs 0.9 or later
-#endif
-
-/* prototypes for the alsa sndlib functions */
-static int alsa_mus_audio_initialize(void);
-static void alsa_mus_oss_set_buffers(int num, int size);
-static int alsa_mus_audio_systems(void);
-static char* alsa_mus_audio_system_name(int system);
-static int alsa_mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size);
-static int alsa_mus_audio_open_input(int ur_dev, int srate, int chans, int format, int requested_size);
-static int alsa_mus_audio_write(int id, char *buf, int bytes);
-static int alsa_mus_audio_read(int id, char *buf, int bytes);
-static int alsa_mus_audio_close(int id);
-static int alsa_mus_audio_mixer_read(int ur_dev, int field, int chan, float *val);
-static int alsa_mus_audio_mixer_write(int ur_dev, int field, int chan, float *val);
-static void alsa_describe_audio_state_1(void);
-
-/* decide which api to activate */
-
-static int probe_api(void)
-{
-#if HAVE_JACK
- int jackprobe;
- jackprobe = jack_mus_audio_initialize();
- if (jackprobe == MUS_ERROR)
- {
-#endif
- int card = -1;
- if ((snd_card_next(&card) >= 0) && (card >= 0))
- {
- /* the alsa library has detected one or more cards */
- api = ALSA_API;
- vect_mus_audio_initialize = alsa_mus_audio_initialize;
- vect_mus_oss_set_buffers = alsa_mus_oss_set_buffers;
- vect_mus_audio_systems = alsa_mus_audio_systems;
- vect_mus_audio_system_name = alsa_mus_audio_system_name;
- vect_mus_audio_moniker = alsa_mus_audio_moniker;
- vect_mus_audio_open_output = alsa_mus_audio_open_output;
- vect_mus_audio_open_input = alsa_mus_audio_open_input;
- vect_mus_audio_write = alsa_mus_audio_write;
- vect_mus_audio_read = alsa_mus_audio_read;
- vect_mus_audio_close = alsa_mus_audio_close;
- vect_mus_audio_mixer_read = alsa_mus_audio_mixer_read;
- vect_mus_audio_mixer_write = alsa_mus_audio_mixer_write;
- vect_describe_audio_state_1 = alsa_describe_audio_state_1;
- }
- else
- {
- /* go for the oss api */
- api = OSS_API;
- vect_mus_audio_initialize = oss_mus_audio_initialize;
- vect_mus_oss_set_buffers = oss_mus_oss_set_buffers;
- vect_mus_audio_systems = oss_mus_audio_systems;
- vect_mus_audio_system_name = oss_mus_audio_system_name;
- vect_mus_audio_moniker = oss_mus_audio_moniker;
- vect_mus_audio_open_output = oss_mus_audio_open_output;
- vect_mus_audio_open_input = oss_mus_audio_open_input;
- vect_mus_audio_write = oss_mus_audio_write;
- vect_mus_audio_read = oss_mus_audio_read;
- vect_mus_audio_close = oss_mus_audio_close;
- vect_mus_audio_mixer_read = oss_mus_audio_mixer_read;
- vect_mus_audio_mixer_write = oss_mus_audio_mixer_write;
- vect_describe_audio_state_1 = oss_describe_audio_state_1;
- }
- /* will the _real_ mus_audio_initialize please stand up? */
- return(vect_mus_audio_initialize());
-#if HAVE_JACK
- }
- return(jackprobe);
-#endif
-}
-
-/* convert a sndlib sample format to an alsa sample format */
-
-static snd_pcm_format_t to_alsa_format(int snd_format)
-{
- switch (snd_format)
- {
- case MUS_BYTE: return(SND_PCM_FORMAT_S8);
- case MUS_UBYTE: return(SND_PCM_FORMAT_U8);
- case MUS_MULAW: return(SND_PCM_FORMAT_MU_LAW);
- case MUS_ALAW: return(SND_PCM_FORMAT_A_LAW);
- case MUS_BSHORT: return(SND_PCM_FORMAT_S16_BE);
- case MUS_LSHORT: return(SND_PCM_FORMAT_S16_LE);
- case MUS_UBSHORT: return(SND_PCM_FORMAT_U16_BE);
- case MUS_ULSHORT: return(SND_PCM_FORMAT_U16_LE);
- case MUS_B24INT: return(SND_PCM_FORMAT_S24_BE);
- case MUS_L24INT: return(SND_PCM_FORMAT_S24_LE);
- case MUS_BINT: return(SND_PCM_FORMAT_S32_BE);
- case MUS_LINT: return(SND_PCM_FORMAT_S32_LE);
- case MUS_BINTN: return(SND_PCM_FORMAT_S32_BE);
- case MUS_LINTN: return(SND_PCM_FORMAT_S32_LE);
- case MUS_BFLOAT: return(SND_PCM_FORMAT_FLOAT_BE);
- case MUS_LFLOAT: return(SND_PCM_FORMAT_FLOAT_LE);
- case MUS_BDOUBLE: return(SND_PCM_FORMAT_FLOAT64_BE);
- case MUS_LDOUBLE: return(SND_PCM_FORMAT_FLOAT64_LE);
- }
- return((snd_pcm_format_t)MUS_ERROR);
-}
-
-/* FIXME: this is not taking yet into account the
- * number of bits that a given alsa format is actually
- * using...
- */
-
-static int to_mus_format(int alsa_format)
-{
- /* alsa format definitions from asoundlib.h (0.9 cvs 6/27/2001) */
- switch (alsa_format)
- {
- case SND_PCM_FORMAT_S8: return(MUS_BYTE);
- case SND_PCM_FORMAT_U8: return(MUS_UBYTE);
- case SND_PCM_FORMAT_S16_LE: return(MUS_LSHORT);
- case SND_PCM_FORMAT_S16_BE: return(MUS_BSHORT);
- case SND_PCM_FORMAT_U16_LE: return(MUS_ULSHORT);
- case SND_PCM_FORMAT_U16_BE: return(MUS_UBSHORT);
- case SND_PCM_FORMAT_S24_LE: return(MUS_L24INT);
- case SND_PCM_FORMAT_S24_BE: return(MUS_B24INT);
- case SND_PCM_FORMAT_S32_LE: return(MUS_LINTN); /* 32bit normalized plays 24bit and 16bit files with same amplitude bound (for 24 bit cards) */
- case SND_PCM_FORMAT_S32_BE: return(MUS_BINTN);
- case SND_PCM_FORMAT_FLOAT_LE: return(MUS_LFLOAT);
- case SND_PCM_FORMAT_FLOAT_BE: return(MUS_BFLOAT);
- case SND_PCM_FORMAT_FLOAT64_LE: return(MUS_LDOUBLE);
- case SND_PCM_FORMAT_FLOAT64_BE: return(MUS_BDOUBLE);
- case SND_PCM_FORMAT_MU_LAW: return(MUS_MULAW);
- case SND_PCM_FORMAT_A_LAW: return(MUS_ALAW);
- /* formats with no translation in snd */
- case SND_PCM_FORMAT_U24_LE:
- case SND_PCM_FORMAT_U24_BE:
- case SND_PCM_FORMAT_U32_LE:
- case SND_PCM_FORMAT_U32_BE:
- case SND_PCM_FORMAT_IEC958_SUBFRAME_LE:
- case SND_PCM_FORMAT_IEC958_SUBFRAME_BE:
- case SND_PCM_FORMAT_IMA_ADPCM:
- case SND_PCM_FORMAT_MPEG:
- case SND_PCM_FORMAT_GSM:
- case SND_PCM_FORMAT_SPECIAL:
- default:
- return(MUS_ERROR);
- }
-}
-
-/* convert a sndlib device into an alsa device number and channel
- * [has to be coordinated with following function!]
- */
-
-/* very simplistic approach, device mapping should also depend
- * on which card we're dealing with, digital i/o devices should
- * be identified as such and so on
- */
-
-/* NOTE: in the Delta1010 digital i/o is just a pair of channels
- * in the 10 channel playback frame or 12 channel capture frame,
- * how do we specify that???
- */
-
-static int to_alsa_device(int dev, int *adev, snd_pcm_stream_t *achan)
-{
- switch(dev)
- {
- /* default values are a problem because the concept does
- * not imply a direction (playback or capture). This works
- * fine as long as both directions of a device are symetric,
- * the Midiman 1010, for example, has 10 channel frames for
- * playback and 12 channel frames for capture and breaks
- * the recorder (probes the default, defaults to output,
- * uses the values for input).
- */
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_LINE_OUT:
- /* analog output */
- (*adev) = 0;
- (*achan) = SND_PCM_STREAM_PLAYBACK;
- break;
- case MUS_AUDIO_AUX_OUTPUT:
- /* extra analog output */
- (*adev) = 1;
- (*achan) = SND_PCM_STREAM_PLAYBACK;
- break;
- case MUS_AUDIO_DAC_OUT:
- /* analog outputs */
- (*adev) = 2;
- (*achan) = SND_PCM_STREAM_PLAYBACK;
- break;
- case MUS_AUDIO_MICROPHONE:
- case MUS_AUDIO_LINE_IN:
- /* analog input */
- (*adev) = 0;
- (*achan) = SND_PCM_STREAM_CAPTURE;
- break;
- case MUS_AUDIO_AUX_INPUT:
- /* extra analog input */
- (*adev) = 1;
- (*achan) = SND_PCM_STREAM_CAPTURE;
- break;
- case MUS_AUDIO_DIGITAL_OUT:
- case MUS_AUDIO_SPDIF_OUT:
- case MUS_AUDIO_AES_OUT:
- case MUS_AUDIO_ADAT_OUT:
- case MUS_AUDIO_DIGITAL_IN:
- case MUS_AUDIO_SPDIF_IN:
- case MUS_AUDIO_AES_IN:
- case MUS_AUDIO_ADAT_IN:
- case MUS_AUDIO_SPEAKERS:
- case MUS_AUDIO_DAC_FILTER:
- case MUS_AUDIO_MIXER:
- case MUS_AUDIO_LINE1:
- case MUS_AUDIO_LINE2:
- case MUS_AUDIO_LINE3:
- case MUS_AUDIO_CD:
- default:
- return(MUS_ERROR);
- break;
- }
- return(0);
-}
-
-/* convert an alsa device into a sndlib device
- * [has to be coordinated with previous function!]
- *
- * naming here is pretty much arbitrary. We have to have
- * a bidirectional mapping between sndlib devices and
- * alsa devices and that's just not possible (I think).
- * This stopgap mapping ignores digital input and output
- * devices - how to differentiate them in alsa?
- */
-
-static int to_sndlib_device(int dev, int channel)
-{
- switch (channel)
- {
- case SND_PCM_STREAM_PLAYBACK:
- switch (dev)
- {
- /* works only for the first three outputs */
- case 0: return(MUS_AUDIO_LINE_OUT);
- case 1: return(MUS_AUDIO_AUX_OUTPUT);
- case 2: return(MUS_AUDIO_DAC_OUT);
- default:
- return(MUS_ERROR);
- }
- case SND_PCM_STREAM_CAPTURE:
- switch (dev)
- {
- case 0: return(MUS_AUDIO_LINE_IN);
- case 1: return(MUS_AUDIO_AUX_INPUT);
- default:
- return(MUS_ERROR);
- }
- break;
- }
- return(MUS_ERROR);
-}
-
-
-static int alsa_mus_error(int type, char *message)
-{
- if (message)
- {
- mus_print(message);
- FREE(message);
- }
- return(MUS_ERROR);
-}
-
-#if 0
-static void alsa_dump_hardware_params(snd_pcm_hw_params_t *params, const char *msg)
-{
- snd_output_t *out;
- snd_output_stdio_attach(&out, stderr, 0);
- fprintf(stderr, "%s\n", msg);
- snd_pcm_hw_params_dump(params, out);
-}
-
-static void alsa_dump_software_params(snd_pcm_sw_params_t *params, const char *msg)
-{
- snd_output_t *out;
- snd_output_stdio_attach(&out, stderr, 0);
- fprintf(stderr, "%s\n", msg);
- snd_pcm_sw_params_dump(params, out);
-}
-#endif
-
-
-/* dump current hardware and software configuration */
-
-static void alsa_dump_configuration(char *name, snd_pcm_hw_params_t *hw_params, snd_pcm_sw_params_t *sw_params)
-{
- int err;
- char *str;
- size_t len;
- snd_output_t *buf;
-
-#if (SND_LIB_MAJOR == 0) || ((SND_LIB_MAJOR == 1) && (SND_LIB_MINOR == 0) && (SND_LIB_SUBMINOR < 8))
- return; /* avoid Alsa bug */
-#endif
-
- err = snd_output_buffer_open(&buf);
- if (err < 0)
- {
- mus_print("could not open dump buffer: %s", snd_strerror(err));
- }
- else
- {
- if (hw_params)
- {
- snd_output_puts(buf, "hw_params status of ");
- snd_output_puts(buf, name);
- snd_output_puts(buf, "\n");
- err = snd_pcm_hw_params_dump(hw_params, buf);
- if (err < 0)
- mus_print("snd_pcm_hw_params_dump: %s", snd_strerror(err));
- }
- if (sw_params)
- {
- snd_output_puts(buf, "sw_params status of ");
- snd_output_puts(buf, name);
- snd_output_puts(buf, "\n");
- err = snd_pcm_sw_params_dump(sw_params, buf);
- if (err < 0)
- mus_print("snd_pcm_hw_params_dump: %s", snd_strerror(err));
- }
- snd_output_putc(buf, '\0');
- len = snd_output_buffer_string(buf, &str);
- if (len > 1)
- mus_print("status of %s\n%s", name, str);
- snd_output_close(buf);
- }
-}
-
-/* get hardware params for a pcm */
-
-static snd_pcm_hw_params_t *alsa_get_hardware_params(const char *name, snd_pcm_stream_t stream, int mode)
-{
- int err;
- snd_pcm_t *handle;
- if ((err = snd_pcm_open(&handle, name, stream, mode | SND_PCM_NONBLOCK)) != 0)
- {
- alsa_mus_error(MUS_AUDIO_CANT_OPEN,
- mus_format("open pcm %s for stream %d: %s",
- name, stream, snd_strerror(err)));
- return(NULL);
- }
- else
- {
- snd_pcm_hw_params_t *params;
- params = (snd_pcm_hw_params_t *)calloc(1, snd_pcm_hw_params_sizeof());
- if (params == NULL)
- {
- snd_pcm_close(handle);
- alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("could not allocate memory for hardware params"));
- }
- else
- {
- err = snd_pcm_hw_params_any(handle, params);
- if (err < 0)
- {
- snd_pcm_close(handle);
- alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("snd_pcm_hw_params_any: pcm %s, stream %d, error: %s",
- name, stream, snd_strerror(err)));
- }
- else
- {
- snd_pcm_close(handle);
- return(params);
- }
- }
- }
- return(NULL);
-}
-
-/* allocate software params structure */
-
-static snd_pcm_sw_params_t *alsa_get_software_params(void)
-{
- snd_pcm_sw_params_t *params = NULL;
- params = (snd_pcm_sw_params_t *)calloc(1, snd_pcm_sw_params_sizeof());
- if (params == NULL)
- {
- alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("could not allocate memory for software params"));
- }
- return(params);
-}
-
-/* probe a device name against the list of available pcm devices */
-
-#ifndef SND_CONFIG_GET_ID_ARGS
- #define SND_CONFIG_GET_ID_ARGS 1
-#endif
-
-static bool alsa_probe_device_name(const char *name)
-{
- snd_config_t *conf;
- snd_config_iterator_t pos, next;
- int err;
-
- err = snd_config_update();
- if (err < 0)
- {
- mus_print("snd_config_update: %s", snd_strerror(err));
- return(false);
- }
-
- err = snd_config_search(snd_config, "pcm", &conf);
- if (err < 0)
- {
- mus_print("snd_config_search: %s", snd_strerror(err));
- return(false);
- }
-
- snd_config_for_each(pos, next, conf)
- {
- snd_config_t *c = snd_config_iterator_entry(pos);
-#if (SND_CONFIG_GET_ID_ARGS == 2)
- const char *id;
- int err = snd_config_get_id(c, &id);
- if (err == 0) {
- int result = strncmp(name, id, strlen(id));
- if (result == 0 &&
- (name[strlen(id)] == '\0' || name[strlen(id)] == ':'))
- {
- return(true);
- }
- }
-#else
- const char *id = snd_config_get_id(c);
- int result = strncmp(name, id, strlen(id));
- if (result == 0 &&
- (name[strlen(id)] == '\0' || name[strlen(id)] == ':'))
- {
- return(true);
- }
-#endif
- }
- return(false);
-}
-
-/* check a device name against the list of available pcm devices */
-
-static int alsa_check_device_name(const char *name)
-{
- if (!alsa_probe_device_name(name))
- {
- return(alsa_mus_error(MUS_AUDIO_CANT_READ,
- mus_format("alsa could not find device \"%s\" in configuration",
- name)));
- }
- return(MUS_NO_ERROR);
-}
-
-
-/* set scheduling priority to SCHED_FIFO
- * this will only work if the program that uses sndlib is run as root or is suid root
- */
-
-/* whether we want to trace calls
- *
- * set to "1" to print function trace information in the
- * snd error window
- */
-
-static int alsa_trace = 0;
-
-/* this should go away as it is oss specific */
-
-static int fragment_size = 512;
-static int fragments = 4;
-
-static void alsa_mus_oss_set_buffers(int num, int size)
-{
- fragments = num;
- fragment_size = size;
-#if MUS_DEBUGGING
- mus_print("set_oss_buffers: %d fragments or size %d", num, size);
-#endif
-}
-
-/* total number of soundcards in our setup, set by initialize_audio */
-
-/* static int sound_cards = 0; */
-
-/* return the number of cards that are available */
-
-static int alsa_mus_audio_systems(void)
-{
- return(sound_cards);
-}
-
-/* return the type of driver we're dealing with */
-
-static char *alsa_mus_audio_moniker(void)
-{
- if (version_name == NULL) version_name = (char *)CALLOC(LABEL_BUFFER_SIZE, sizeof(char));
- mus_snprintf(version_name, LABEL_BUFFER_SIZE, "ALSA %s", SND_LIB_VERSION_STR);
- return(version_name);
-}
-
-/* handles for both directions of the virtual device */
-
-static snd_pcm_t *handles[2] = {NULL, NULL};
-
-/* hardware and software parameter sctructure pointers */
-
-static snd_pcm_hw_params_t *alsa_hw_params[2] = {NULL, NULL}; /* avoid bogus free */
-static snd_pcm_sw_params_t *alsa_sw_params[2] = {NULL, NULL};
-
-/* some defaults */
-
-static int alsa_open_mode = SND_PCM_ASYNC;
-static int alsa_buffers = 3;
-/* size of buffer in number of samples per channel,
- * at 44100 approximately 5.9mSecs
- */
-static int alsa_samples_per_channel = 1024;
-static snd_pcm_access_t alsa_interleave = SND_PCM_ACCESS_RW_INTERLEAVED;
-static int alsa_max_capture_channels = 32;
-
-/* first default name for pcm configuration */
-
-static char *alsa_sndlib_device_name = "sndlib";
-
-/* second default for playback and capture: hardware pcm, first card, first device */
-/* pcms used by sndlib, playback and capture */
-
-static char *alsa_playback_device_name = NULL;
-static char *alsa_capture_device_name = NULL;
-
-
-/* -------- tie these names into scheme/ruby -------- */
-
-static int alsa_get_max_buffers(void)
-{
- unsigned int max_periods = 0, max_rec_periods = 0;
- int dir = 0;
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_periods_max(alsa_hw_params[SND_PCM_STREAM_PLAYBACK], &max_periods, &dir);
-#else
- max_periods = snd_pcm_hw_params_get_periods_max(alsa_hw_params[SND_PCM_STREAM_PLAYBACK], &dir);
-#endif
- if (alsa_hw_params[SND_PCM_STREAM_CAPTURE])
- {
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_periods_max(alsa_hw_params[SND_PCM_STREAM_CAPTURE], &max_rec_periods, &dir);
-#else
- max_rec_periods = snd_pcm_hw_params_get_periods_max(alsa_hw_params[SND_PCM_STREAM_CAPTURE], &dir);
-#endif
- if (max_periods > max_rec_periods)
- max_periods = max_rec_periods;
- }
- return(max_periods);
-}
-
-static int alsa_get_min_buffers(void)
-{
- unsigned int min_periods = 0, min_rec_periods = 0;
- int dir = 0;
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_periods_min(alsa_hw_params[SND_PCM_STREAM_PLAYBACK], &min_periods, &dir);
-#else
- min_periods = snd_pcm_hw_params_get_periods_min(alsa_hw_params[SND_PCM_STREAM_PLAYBACK], &dir);
-#endif
- if (alsa_hw_params[SND_PCM_STREAM_CAPTURE])
- {
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_periods_min(alsa_hw_params[SND_PCM_STREAM_CAPTURE], &min_rec_periods, &dir);
-#else
- min_rec_periods = snd_pcm_hw_params_get_periods_min(alsa_hw_params[SND_PCM_STREAM_CAPTURE], &dir);
-#endif
- if (min_periods < min_rec_periods)
- min_periods = min_rec_periods;
- }
- return(min_periods);
-}
-
-static int alsa_clamp_buffers(int bufs)
-{
- int minb, maxb;
- minb = alsa_get_min_buffers();
- maxb = alsa_get_max_buffers();
- if (bufs > maxb)
- bufs = maxb;
- if (bufs < minb)
- bufs = minb;
- return(bufs);
-}
-
-static snd_pcm_uframes_t alsa_get_min_buffer_size(void)
-{
- snd_pcm_uframes_t min_buffer_size = 0, min_rec_buffer_size = 0;
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_buffer_size_min(alsa_hw_params[SND_PCM_STREAM_PLAYBACK], &min_buffer_size);
-#else
- min_buffer_size = snd_pcm_hw_params_get_buffer_size_min(alsa_hw_params[SND_PCM_STREAM_PLAYBACK]);
-#endif
- if (alsa_hw_params[SND_PCM_STREAM_CAPTURE])
- {
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_buffer_size_min(alsa_hw_params[SND_PCM_STREAM_CAPTURE], &min_rec_buffer_size);
-#else
- min_rec_buffer_size = snd_pcm_hw_params_get_buffer_size_min(alsa_hw_params[SND_PCM_STREAM_CAPTURE]);
-#endif
-
- if (min_buffer_size < min_rec_buffer_size)
- min_buffer_size = min_rec_buffer_size;
- }
- return(min_buffer_size);
-}
-
-static snd_pcm_uframes_t alsa_get_max_buffer_size(void)
-{
- snd_pcm_uframes_t max_buffer_size = 0, max_rec_buffer_size = 0;
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_buffer_size_max(alsa_hw_params[SND_PCM_STREAM_PLAYBACK], &max_buffer_size);
-#else
- max_buffer_size = snd_pcm_hw_params_get_buffer_size_max(alsa_hw_params[SND_PCM_STREAM_PLAYBACK]);
-#endif
- if (alsa_hw_params[SND_PCM_STREAM_CAPTURE])
- {
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_buffer_size_max(alsa_hw_params[SND_PCM_STREAM_CAPTURE], &max_rec_buffer_size);
-#else
- max_rec_buffer_size = snd_pcm_hw_params_get_buffer_size_max(alsa_hw_params[SND_PCM_STREAM_CAPTURE]);
-#endif
- if (max_buffer_size > max_rec_buffer_size)
- max_buffer_size = max_rec_buffer_size;
- }
- return(max_buffer_size);
-}
-
-static int alsa_clamp_buffer_size(int buf_size)
-{
- int minb, maxb;
- minb = alsa_get_min_buffer_size();
- maxb = alsa_get_max_buffer_size();
- if (buf_size > maxb)
- buf_size = maxb;
- if (buf_size < minb)
- buf_size = minb;
- return(buf_size);
-}
-
-static bool alsa_set_playback_parameters(void)
-{
- /* playback stream parameters */
- if (alsa_hw_params[SND_PCM_STREAM_PLAYBACK]) free(alsa_hw_params[SND_PCM_STREAM_PLAYBACK]);
- alsa_hw_params[SND_PCM_STREAM_PLAYBACK] = alsa_get_hardware_params(alsa_playback_device_name, SND_PCM_STREAM_PLAYBACK, alsa_open_mode);
- if (alsa_hw_params[SND_PCM_STREAM_PLAYBACK])
- {
- snd_pcm_uframes_t size;
- int old_buffers;
- old_buffers = alsa_buffers;
- if (alsa_sw_params[SND_PCM_STREAM_PLAYBACK]) free(alsa_sw_params[SND_PCM_STREAM_PLAYBACK]);
- alsa_sw_params[SND_PCM_STREAM_PLAYBACK] = alsa_get_software_params();
- sound_cards = 1;
- alsa_buffers = alsa_clamp_buffers(alsa_buffers);
- if (alsa_buffers <= 0)
- {
- alsa_buffers = old_buffers;
- return(false);
- }
- size = alsa_clamp_buffer_size(alsa_samples_per_channel * alsa_buffers);
- if (size <= 0) return(false);
- alsa_samples_per_channel = size / alsa_buffers;
- }
- return(alsa_hw_params[SND_PCM_STREAM_PLAYBACK] && alsa_sw_params[SND_PCM_STREAM_PLAYBACK]);
-}
-
-static bool alsa_set_capture_parameters(void)
-{
- /* capture stream parameters */
- if (alsa_hw_params[SND_PCM_STREAM_CAPTURE]) free(alsa_hw_params[SND_PCM_STREAM_CAPTURE]);
- alsa_hw_params[SND_PCM_STREAM_CAPTURE] = alsa_get_hardware_params(alsa_capture_device_name, SND_PCM_STREAM_CAPTURE, alsa_open_mode);
- if (alsa_hw_params[SND_PCM_STREAM_CAPTURE])
- {
- snd_pcm_uframes_t size;
- int old_buffers;
- old_buffers = alsa_buffers;
- if (alsa_sw_params[SND_PCM_STREAM_CAPTURE]) free(alsa_sw_params[SND_PCM_STREAM_CAPTURE]);
- alsa_sw_params[SND_PCM_STREAM_CAPTURE] = alsa_get_software_params();
- sound_cards = 1;
- alsa_buffers = alsa_clamp_buffers(alsa_buffers);
- if (alsa_buffers <= 0)
- {
- alsa_buffers = old_buffers;
- return(false);
- }
- size = alsa_clamp_buffer_size(alsa_samples_per_channel * alsa_buffers);
- if (size <= 0) return(false);
- alsa_samples_per_channel = size / alsa_buffers;
- }
- return(alsa_hw_params[SND_PCM_STREAM_CAPTURE] && alsa_sw_params[SND_PCM_STREAM_CAPTURE]);
-}
-
-
-char *mus_alsa_playback_device(void) {return(alsa_playback_device_name);}
-char *mus_alsa_set_playback_device(const char *name)
-{
- if (alsa_check_device_name(name) == MUS_NO_ERROR)
- {
- char *old_name = alsa_playback_device_name;
- alsa_playback_device_name = strdup(name);
- if (!alsa_set_playback_parameters())
- {
- alsa_playback_device_name = old_name; /* try to back out of the mistake */
- alsa_set_playback_parameters();
- }
- }
- return(alsa_playback_device_name);
-}
-
-char *mus_alsa_capture_device(void) {return(alsa_capture_device_name);}
-char *mus_alsa_set_capture_device(const char *name)
-{
- if (alsa_check_device_name(name) == MUS_NO_ERROR)
- {
- char *old_name = alsa_capture_device_name;
- alsa_capture_device_name = strdup(name);
- if (!alsa_set_capture_parameters())
- {
- alsa_capture_device_name = old_name;
- alsa_set_capture_parameters();
- }
- }
- return(alsa_capture_device_name);
-}
-
-char *mus_alsa_device(void) {return(alsa_sndlib_device_name);}
-char *mus_alsa_set_device(const char *name)
-{
- if (alsa_check_device_name(name) == MUS_NO_ERROR)
- {
- alsa_sndlib_device_name = strdup(name);
- mus_alsa_set_playback_device(name);
- mus_alsa_set_capture_device(name);
- }
- return(alsa_sndlib_device_name);
-}
-
-int mus_alsa_buffer_size(void) {return(alsa_samples_per_channel);}
-int mus_alsa_set_buffer_size(int size)
-{
- snd_pcm_uframes_t bsize;
- if (alsa_buffers == 0) alsa_buffers = 1;
- if (size > 0)
- {
- bsize = alsa_clamp_buffer_size(size * alsa_buffers);
- alsa_samples_per_channel = bsize / alsa_buffers;
- }
- return(alsa_samples_per_channel);
-}
-
-int mus_alsa_buffers(void) {return(alsa_buffers);}
-int mus_alsa_set_buffers(int num)
-{
- snd_pcm_uframes_t size;
- if (num > 0)
- {
- alsa_buffers = alsa_clamp_buffers(num);
- if (alsa_buffers > 0)
- {
- size = alsa_clamp_buffer_size(alsa_samples_per_channel * alsa_buffers);
- alsa_samples_per_channel = size / alsa_buffers;
- }
- }
- return(alsa_buffers);
-}
-
-static bool alsa_squelch_warning = false;
-bool mus_alsa_squelch_warning(void) {return(alsa_squelch_warning);}
-bool mus_alsa_set_squelch_warning(bool val)
-{
- alsa_squelch_warning = val;
- return(val);
-}
-
-
-
-
-/* return the name of a given system */
-
-static char *alsa_mus_audio_system_name(int system)
-{
- return(alsa_playback_device_name);
-}
-
-/* get a device name from the environment */
-
-static char *alsa_get_device_from_env(const char *name)
-{
- char *string = getenv(name);
- if (string)
- if (alsa_check_device_name(string) == MUS_NO_ERROR)
- return(string);
- return(NULL);
-}
-
-/* get an integer from the environment */
-
-static int alsa_get_int_from_env(const char *name, int *value, int min, int max)
-{
- char *string = getenv(name);
- if (string)
- {
- char *end;
- long int result = strtol(string, &end, 10);
- if (((min != -1) && (max != -1)) &&
- (result < min || result > max))
- {
- return(alsa_mus_error(MUS_AUDIO_CANT_READ,
- mus_format("%s ignored: out of range, value=%d, min=%d, max=%d",
- name, (int)result, min, max)));
- }
- else
- {
- if (errno == ERANGE)
- {
- return(alsa_mus_error(MUS_AUDIO_CANT_READ,
- mus_format("%s ignored: strlol conversion out of range",
- name)));
- }
- else
- {
- if ((*string != '\0') && (*end == '\0'))
- {
- *value = (int)result;
- return(MUS_NO_ERROR);
- }
- else
- {
- return(alsa_mus_error(MUS_AUDIO_CANT_READ,
- mus_format("%s ignored: value is \"%s\", not an integer",
- name, string)));
- }
- }
- }
- }
- return(MUS_ERROR);
-}
-
-/* initialize the audio subsystem */
-
-/* define environment variable names */
-#define MUS_ALSA_PLAYBACK_DEVICE_ENV_NAME "MUS_ALSA_PLAYBACK_DEVICE"
-#define MUS_ALSA_CAPTURE_DEVICE_ENV_NAME "MUS_ALSA_CAPTURE_DEVICE"
-#define MUS_ALSA_DEVICE_ENV_NAME "MUS_ALSA_DEVICE"
-#define MUS_ALSA_BUFFERS_ENV_NAME "MUS_ALSA_BUFFERS"
-#define MUS_ALSA_BUFFER_SIZE_ENV_NAME "MUS_ALSA_BUFFER_SIZE"
-#define MUS_ALSA_TRACE_ENV_NAME "MUS_ALSA_TRACE"
-
-static int alsa_mus_audio_initialize(void)
-{
- char *name = NULL;
- char *pname;
- char *cname;
- int value = 0, alsa_buffer_size = 0;
-
- if (audio_initialized)
- return(0);
-
- sound_cards = 0;
-
- /* get trace flag from environment */
- if (alsa_get_int_from_env(MUS_ALSA_TRACE_ENV_NAME, &value, 0, 1) == MUS_NO_ERROR)
- alsa_trace = value;
-
- /* try to get device names from environment */
- pname = alsa_get_device_from_env(MUS_ALSA_PLAYBACK_DEVICE_ENV_NAME);
- if ((pname) && (alsa_probe_device_name(pname)))
- alsa_playback_device_name = pname;
-
- cname = alsa_get_device_from_env(MUS_ALSA_CAPTURE_DEVICE_ENV_NAME);
- if ((cname) && (alsa_probe_device_name(cname)))
- alsa_capture_device_name = cname;
-
- name = alsa_get_device_from_env(MUS_ALSA_DEVICE_ENV_NAME);
- if ((name) && (alsa_probe_device_name(name)))
- {
- if (!alsa_playback_device_name)
- alsa_playback_device_name = name;
-
- if (!alsa_capture_device_name)
- alsa_capture_device_name = name;
-
- alsa_sndlib_device_name = name;
- }
-
- /* now check that we have a plausible name */
- if (!alsa_probe_device_name(alsa_sndlib_device_name))
- {
- alsa_sndlib_device_name = "default";
- if (!alsa_probe_device_name(alsa_sndlib_device_name))
- {
- alsa_sndlib_device_name = "plughw:0";
- if (!alsa_probe_device_name(alsa_sndlib_device_name))
- alsa_sndlib_device_name = "hw:0";
- }
- }
-
- /* if no device name set yet, try for special sndlib name first */
- if (!alsa_playback_device_name)
- {
- if (alsa_probe_device_name(alsa_sndlib_device_name))
- alsa_playback_device_name = alsa_sndlib_device_name;
- else alsa_playback_device_name = "hw:0";
- }
-
- if (!alsa_capture_device_name)
- {
- if (alsa_probe_device_name(alsa_sndlib_device_name))
- alsa_capture_device_name = alsa_sndlib_device_name;
- else alsa_capture_device_name = "hw:0";
- }
-
- alsa_get_int_from_env(MUS_ALSA_BUFFERS_ENV_NAME, &alsa_buffers, -1, -1);
- alsa_get_int_from_env(MUS_ALSA_BUFFER_SIZE_ENV_NAME, &alsa_buffer_size, -1, -1);
-
- if ((alsa_buffer_size > 0) && (alsa_buffers > 0))
- alsa_samples_per_channel = alsa_buffer_size / alsa_buffers;
-
- if (!alsa_set_playback_parameters())
- {
- /* somehow we got a device that passed muster with alsa_probe_device_name, but doesn't return hw params! */
- alsa_playback_device_name = "plughw:0";
- if (!alsa_set_playback_parameters())
- {
- alsa_playback_device_name = "hw:0";
- if (!alsa_set_playback_parameters())
- return(MUS_ERROR);
- }
- }
-
- if (!alsa_set_capture_parameters())
- {
- alsa_capture_device_name = "plughw:0";
- if (!alsa_set_capture_parameters())
- {
- alsa_capture_device_name = "hw:0";
- if (!alsa_set_capture_parameters())
- return(MUS_ERROR);
- }
- }
-
- if ((!alsa_hw_params[SND_PCM_STREAM_CAPTURE]) ||
- (!alsa_hw_params[SND_PCM_STREAM_PLAYBACK]))
- return(MUS_ERROR);
-
- audio_initialized = true;
- return(0);
-}
-
-/* open an input or output stream */
-
-static int alsa_audio_open(int ur_dev, int srate, int chans, int format, int size)
-{
- int card, device, alsa_device;
- snd_pcm_format_t alsa_format;
- snd_pcm_stream_t alsa_stream;
- char *alsa_name;
- int frames, periods;
- int err;
- unsigned int r;
- snd_pcm_t *handle;
- snd_pcm_hw_params_t *hw_params = NULL;
- snd_pcm_sw_params_t *sw_params = NULL;
-
- if ((!audio_initialized) &&
- (mus_audio_initialize() != MUS_NO_ERROR))
- return(MUS_ERROR);
- if (chans <= 0) return(MUS_ERROR);
-
- if (alsa_trace)
- mus_print("%s: %x rate=%d, chans=%d, format=%d:%s, size=%d",
- c__FUNCTION__, ur_dev, srate, chans, format,
- mus_audio_format_name(format), size);
-
- card = MUS_AUDIO_SYSTEM(ur_dev);
- device = MUS_AUDIO_DEVICE(ur_dev);
-
- if ((err = to_alsa_device(device, &alsa_device, &alsa_stream)) < 0)
- {
- return(alsa_mus_error(MUS_AUDIO_DEVICE_NOT_AVAILABLE,
- mus_format("%s: cannot translate device %s<%d> to alsa",
- snd_strerror(err), mus_audio_device_name(device), device)));
- }
- if ((alsa_format = to_alsa_format(format)) == (snd_pcm_format_t)MUS_ERROR)
- {
- return(alsa_mus_error(MUS_AUDIO_FORMAT_NOT_AVAILABLE,
- mus_format("could not change %s<%d> to alsa format",
- mus_audio_format_name(format), format)));
- }
-
- alsa_name = (alsa_stream == SND_PCM_STREAM_PLAYBACK) ? alsa_playback_device_name : alsa_capture_device_name;
- if ((err = snd_pcm_open(&handle, alsa_name, alsa_stream, alsa_open_mode)) != 0)
- {
- snd_pcm_close(handle);
- return(alsa_mus_error(MUS_AUDIO_CANT_OPEN,
- mus_format("open pcm %s (%s) stream %s: %s",
- mus_audio_device_name(device), alsa_name, snd_pcm_stream_name(alsa_stream),
- snd_strerror(err))));
- }
- handles[alsa_stream] = handle;
- hw_params = alsa_hw_params[alsa_stream];
- sw_params = alsa_sw_params[alsa_stream];
- if ((err = snd_pcm_hw_params_any(handle, hw_params)) < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: no parameter configurations available for %s",
- snd_strerror(err), alsa_name)));
- }
-
- err = snd_pcm_hw_params_set_access(handle, hw_params, alsa_interleave);
- if (err < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: %s: access type %s not available",
- snd_strerror(err), alsa_name, snd_pcm_access_name(alsa_interleave))));
- }
-
- periods = alsa_buffers;
- err = snd_pcm_hw_params_set_periods(handle, hw_params, periods, 0);
- if (err < 0)
- {
- unsigned int minp, maxp;
- int dir;
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_periods_min(hw_params, &minp, &dir);
- snd_pcm_hw_params_get_periods_max(hw_params, &maxp, &dir);
-#else
- minp = snd_pcm_hw_params_get_periods_min(hw_params, &dir);
- maxp = snd_pcm_hw_params_get_periods_max(hw_params, &dir);
-#endif
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: %s: cannot set number of periods to %d, min is %d, max is %d",
- snd_strerror(err), alsa_name, periods, (int)minp, (int)maxp)));
- }
-
- frames = size / chans / mus_bytes_per_sample(format);
-
- err = snd_pcm_hw_params_set_buffer_size(handle, hw_params, frames * periods);
- if (err < 0)
- {
- snd_pcm_uframes_t minp, maxp;
-#if HAVE_NEW_ALSA
- snd_pcm_hw_params_get_buffer_size_min(hw_params, &minp);
- snd_pcm_hw_params_get_buffer_size_max(hw_params, &maxp);
-#else
- minp = snd_pcm_hw_params_get_buffer_size_min(hw_params);
- maxp = snd_pcm_hw_params_get_buffer_size_max(hw_params);
-#endif
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: %s: cannot set buffer size to %d periods of %d frames; \
-total requested buffer size is %d frames, minimum allowed is %d, maximum is %d",
- snd_strerror(err), alsa_name, periods, frames, periods * frames, (int)minp, (int)maxp)));
- }
-
- err = snd_pcm_hw_params_set_format(handle, hw_params, alsa_format);
- if (err < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: %s: cannot set format to %s",
- snd_strerror(err), alsa_name, snd_pcm_format_name(alsa_format))));
- }
-
- err = snd_pcm_hw_params_set_channels(handle, hw_params, chans);
- if (err < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: %s: cannot set channels to %d",
- snd_strerror(err), alsa_name, chans)));
- }
-#if HAVE_NEW_ALSA
- {
- unsigned int new_rate;
- new_rate = srate;
- r = snd_pcm_hw_params_set_rate_near(handle, hw_params, &new_rate, 0);
- if (r < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: %s: cannot set sampling rate near %d",
- snd_strerror(r), alsa_name, srate)));
- }
- else
- {
- if ((new_rate != srate) && (!alsa_squelch_warning))
- {
- mus_print("%s: could not set rate to exactly %d, set to %d instead",
- alsa_name, srate, new_rate);
- }
- }
- }
-#else
- r = snd_pcm_hw_params_set_rate_near(handle, hw_params, srate, 0);
- if (r < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: %s: cannot set sampling rate near %d",
- snd_strerror(r), alsa_name, srate)));
- }
- else
- {
- if (r != srate)
- {
- mus_print("%s: could not set rate to exactly %d, set to %d instead",
- alsa_name, srate, r);
- }
- }
-#endif
-
- err = snd_pcm_hw_params(handle, hw_params);
- if (err < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: cannot set hardware parameters for %s",
- snd_strerror(err), alsa_name)));
- }
-
- snd_pcm_sw_params_current(handle, sw_params);
- err = snd_pcm_sw_params(handle, sw_params);
- if (err < 0)
- {
- snd_pcm_close(handle);
- handles[alsa_stream] = NULL;
- alsa_dump_configuration(alsa_name, hw_params, sw_params);
- return(alsa_mus_error(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("%s: cannot set software parameters for %s",
- snd_strerror(err), alsa_name)));
- }
-
- /* for now the id for the stream is the direction identifier, that is
- not a problem because we only advertise one card with two devices */
- return(alsa_stream);
-}
-
-/* sndlib support for opening output devices */
-
-static int alsa_mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size)
-{
- return(alsa_audio_open(ur_dev, srate, chans, format, size));
-}
-
-/* sndlib support for opening input devices */
-
-static int alsa_mus_audio_open_input(int ur_dev, int srate, int chans, int format, int size)
-{
- return(alsa_audio_open(ur_dev, srate, chans, format, size));
-}
-
-/* sndlib support for closing a device */
-
-/* to force it to stop, snd_pcm_drop */
-
-static bool xrun_warned = false;
-
-static int alsa_mus_audio_close(int id)
-{
- int err = 0;
- xrun_warned = false;
- if (alsa_trace) mus_print( "%s: %d", c__FUNCTION__, id);
- if (handles[id])
- {
- err = snd_pcm_drain(handles[id]);
- if (err != 0)
- mus_print("snd_pcm_drain: %s", snd_strerror(err));
-
- err = snd_pcm_close(handles[id]);
- if (err != 0)
- return(alsa_mus_error(MUS_AUDIO_CANT_CLOSE,
- mus_format("snd_pcm_close: %s",
- snd_strerror(err))));
- handles[id] = NULL;
- }
- return(MUS_NO_ERROR);
-}
-
-/* recover from underruns or overruns */
-
-static int recover_from_xrun(int id)
-{
- int err;
- snd_pcm_status_t *status;
- snd_pcm_state_t state;
- snd_pcm_status_alloca(&status);
- err = snd_pcm_status(handles[id], status);
- if (err < 0)
- {
- mus_print("%s: snd_pcm_status: %s", c__FUNCTION__, snd_strerror(err));
- return(MUS_ERROR);
- }
- state = snd_pcm_status_get_state(status);
- if (state == SND_PCM_STATE_XRUN)
- {
- if (!xrun_warned)
- {
- xrun_warned = true;
- mus_print("[under|over]run detected");
- }
- err = snd_pcm_prepare(handles[id]);
- if (err < 0)
- mus_print("snd_pcm_prepare: %s", snd_strerror(err));
- else return(MUS_NO_ERROR);
- }
- else mus_print("%s: error, current state is %s", c__FUNCTION__, snd_pcm_state_name(state));
- return(MUS_ERROR);
-}
-
-/* sndlib support for writing a buffer to an output device */
-
-static int alsa_mus_audio_write(int id, char *buf, int bytes)
-{
- snd_pcm_sframes_t status;
- ssize_t frames;
- frames = snd_pcm_bytes_to_frames(handles[id], bytes);
-#if MUS_DEBUGGING
- if ((frames <= 0) || (frames > bytes))
- {
- /* pcm->frame_bits not correct? */
- mus_print("audio write %d frames (%d bytes)?", bytes, frames);
- abort();
- return(MUS_ERROR);
- }
-#endif
- status = snd_pcm_writei(handles[id], buf, frames);
- if ((status == -EAGAIN) ||
- ((status >= 0) && (status < frames)))
- snd_pcm_wait(handles[id], 1000);
- else
- {
- if (status == -EPIPE)
- return(recover_from_xrun(id));
- else
- {
- if (status < 0)
- {
- mus_print("snd_pcm_writei: %s", snd_strerror(status));
- return(MUS_ERROR);
- }
- }
- }
- return(MUS_NO_ERROR);
-}
-
-/* sndlib support for reading a buffer from an input device */
-
-static int alsa_mus_audio_read(int id, char *buf, int bytes)
-{
- snd_pcm_sframes_t status;
- ssize_t frames;
- frames = snd_pcm_bytes_to_frames(handles[id], bytes);
-#if MUS_DEBUGGING
- if ((frames <= 0) || (frames > bytes))
- {
- mus_print("audio read %d frames (%d bytes)?", frames, bytes);
- abort();
- return(MUS_ERROR);
- }
-#endif
- status = snd_pcm_readi(handles[id], buf, frames);
- if ((status == -EAGAIN) ||
- ((status >= 0) && (status < frames)))
- snd_pcm_wait(handles[id], 1000);
- else
- {
- if (status == -EPIPE)
- return(recover_from_xrun(id));
- else
- {
- if (status < 0)
- {
- mus_print("snd_pcm_readi: %s", snd_strerror(status));
- return(MUS_ERROR);
- }
- }
- }
- return(MUS_NO_ERROR);
-}
-
-/* read state of the audio hardware */
-
-static int alsa_mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- int card;
- int device;
- int alsa_device;
- snd_pcm_stream_t alsa_stream;
- int f, err;
-
- if ((!audio_initialized) &&
- (mus_audio_initialize() != MUS_NO_ERROR))
- return(MUS_ERROR);
-
- card = MUS_AUDIO_SYSTEM(ur_dev);
- device = MUS_AUDIO_DEVICE(ur_dev);
- if (alsa_trace)
- mus_print( "%s: card=%d, dev=%s<%d>, field=%s<%d>, chan=%d",
- c__FUNCTION__, card, mus_audio_device_name(device), device,
- mus_audio_device_name(field), field,
- chan);
- /* for now do not implement mixer interface */
- if (device == MUS_AUDIO_MIXER)
- {
- val[0] = 0;
- return(MUS_NO_ERROR);
- }
- /* MUS_AUDIO_PORT probes for devices and should not depend on the
- * device which was used in the ur_dev argument, we process this
- * before trying to map the device to an alsa device */
-
- if (field == MUS_AUDIO_PORT)
- {
- /* under 0.9 we only advertise at most two devices, one for playback
- and another one for capture */
- /* int dev; */
- int i = 1;
- if (alsa_hw_params[SND_PCM_STREAM_PLAYBACK])
- val[i++] = (float)to_sndlib_device(0, SND_PCM_STREAM_PLAYBACK);
-
- if (alsa_hw_params[SND_PCM_STREAM_CAPTURE])
- val[i++] = (float)to_sndlib_device(0, SND_PCM_STREAM_CAPTURE);
-
- val[0]=(float)(i - 1);
- return(MUS_NO_ERROR);
- }
- /* map the mus device to an alsa device and channel */
- if ((err = to_alsa_device(device, &alsa_device, &alsa_stream)) < 0)
- {
- /* FIXME: snd-dac still probes some non-existing devices, specifically
- * MUS_AUDIO_DAC_FILTER, do not report error till that's fixed */
- if (alsa_trace)
- {
- mus_print("%s: cannot translate device %s<%d> to alsa, field=%s<%d>",
- snd_strerror(err),
- mus_audio_device_name(device), device,
- mus_audio_device_name(field), field);
- }
- return(MUS_ERROR);
- }
- if (alsa_trace) mus_print("%s: adev=%d, achan=%d", c__FUNCTION__, alsa_device, alsa_stream);
- switch (field)
- {
- case MUS_AUDIO_AMP:
- /* amplitude value */
- val[0] = 1.0;
- break;
- case MUS_AUDIO_SAMPLES_PER_CHANNEL:
- /* samples per channel */
- if (card > 0 || alsa_device > 0)
- return(alsa_mus_error(MUS_AUDIO_CANT_READ, NULL));
- else
- {
- val[0] = (float)alsa_samples_per_channel;
- if (chan > 1)
- {
-#if HAVE_NEW_ALSA
- snd_pcm_uframes_t tmp = 0;
- snd_pcm_hw_params_get_buffer_size_min(alsa_hw_params[alsa_stream], &tmp);
- val[1] = (float)tmp;
- snd_pcm_hw_params_get_buffer_size_max(alsa_hw_params[alsa_stream], &tmp);
- val[2] = (float)tmp;
-#else
- val[1] = (float)snd_pcm_hw_params_get_buffer_size_min(alsa_hw_params[alsa_stream]);
- val[2] = (float)snd_pcm_hw_params_get_buffer_size_max(alsa_hw_params[alsa_stream]);
-#endif
- }
- }
- break;
- case MUS_AUDIO_CHANNEL:
- /* number of channels */
- if (card > 0 || alsa_device > 0)
- return(alsa_mus_error(MUS_AUDIO_CANT_READ, NULL));
- else
- {
-
- if ((alsa_stream == SND_PCM_STREAM_CAPTURE) &&
- (alsa_capture_device_name) &&
- (strcmp(alsa_capture_device_name, "default") == 0))
- {
- val[0] = 2;
- }
- else
- {
-
-#if HAVE_NEW_ALSA
- unsigned int max_channels = 0;
- snd_pcm_hw_params_get_channels_max(alsa_hw_params[alsa_stream], &max_channels);
-#else
- int max_channels = snd_pcm_hw_params_get_channels_max(alsa_hw_params[alsa_stream]);
-#endif
- if ((alsa_stream == SND_PCM_STREAM_CAPTURE) &&
- (max_channels > alsa_max_capture_channels))
- {
- /* limit number of capture channels to a reasonable maximum, if the user
- specifies a plug pcm as the capture pcm then the returned number of channels
- would be MAXINT (or whatever the name is for a really big number). At this
- point there is no support in the alsa api to distinguish between default
- parameters or those that have been set by a user on purpose, of for querying
- the hardware pcm device that is hidden by the plug device to see what is the
- real number of channels for the device we are dealing with. We could also try
- to flag this as an error to the user and exit the program */
- max_channels = alsa_max_capture_channels;
- }
- val[0] = (float)max_channels;
- if (chan > 1)
- {
-#if HAVE_NEW_ALSA
- unsigned int tmp = 0;
- snd_pcm_hw_params_get_channels_min(alsa_hw_params[alsa_stream], &tmp);
- val[1] = (float)tmp;
-#else
- val[1] = (float)snd_pcm_hw_params_get_channels_min(alsa_hw_params[alsa_stream]);
-#endif
- val[2] = (float)max_channels;
- }
- }
- }
- break;
- case MUS_AUDIO_SRATE:
- /* supported sample rates */
- if (card > 0 || alsa_device > 0)
- return(alsa_mus_error(MUS_AUDIO_CANT_READ, NULL));
- else
- {
- int dir = 0;
- val[0] = 44100;
- if (chan > 1)
- {
-#if HAVE_NEW_ALSA
- unsigned int tmp;
- snd_pcm_hw_params_get_rate_min(alsa_hw_params[alsa_stream], &tmp, &dir);
- val[1] = (float)tmp;
- snd_pcm_hw_params_get_rate_max(alsa_hw_params[alsa_stream], &tmp, &dir);
- val[2] = (float)tmp;
-#else
- val[1] = (float)snd_pcm_hw_params_get_rate_min(alsa_hw_params[alsa_stream], &dir);
- val[2] = (float)snd_pcm_hw_params_get_rate_max(alsa_hw_params[alsa_stream], &dir);
-#endif
- }
- }
- break;
- case MUS_AUDIO_FORMAT:
- /* supported formats */
- if (card > 0 || alsa_device > 0)
- return(alsa_mus_error(MUS_AUDIO_CANT_READ, NULL));
- else
- {
- int format;
- snd_pcm_format_mask_t *mask;
- snd_pcm_format_mask_alloca(&mask);
- snd_pcm_hw_params_get_format_mask(alsa_hw_params[alsa_stream], mask);
- for (format = 0, f = 1; format < SND_PCM_FORMAT_LAST; format++)
- {
- err = snd_pcm_format_mask_test(mask, (snd_pcm_format_t)format);
- if (err > 0)
- {
- if ((f < chan) &&
- (to_mus_format(format)!=MUS_ERROR))
- val[f++] = (float)to_mus_format(format);
- }
- }
- val[0] = f - 1;
- }
- break;
- case MUS_AUDIO_DIRECTION:
- /* direction of this device */
- if (card > 0 || alsa_device > 0)
- return(alsa_mus_error(MUS_AUDIO_CANT_READ, NULL));
- else
- {
- /* 0-->playback, 1-->capture */
- val[0] = (float)alsa_stream;
- }
- break;
- default:
- return(alsa_mus_error(MUS_AUDIO_CANT_READ, NULL));
- break;
- }
- return(MUS_NO_ERROR);
-}
-
-static int alsa_mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- return(MUS_NO_ERROR);
-}
-
-static void alsa_describe_audio_state_1(void)
-{
- int err;
- char *str;
- size_t len;
- snd_config_t *conf;
- snd_output_t *buf = NULL;
-#if (SND_LIB_MAJOR == 0) || ((SND_LIB_MAJOR == 1) && (SND_LIB_MINOR == 0) && (SND_LIB_SUBMINOR < 8))
- return; /* avoid Alsa bug */
-#endif
- err = snd_config_update();
- if (err < 0)
- {
- mus_print("snd_config_update: %s", snd_strerror(err));
- return;
- }
- err = snd_output_buffer_open(&buf);
- if (err < 0)
- mus_print("could not open dump buffer: %s", snd_strerror(err));
- else
- {
- err = snd_config_search(snd_config, "pcm", &conf);
- if (err < 0)
- {
- mus_print("snd_config_search: could not find at least one pcm: %s", snd_strerror(err));
- return;
- }
- snd_output_puts(buf, "PCM list:\n");
- snd_config_save(conf, buf);
- snd_output_putc(buf, '\0');
- len = snd_output_buffer_string(buf, &str);
- if (len > 1)
- pprint(str);
- snd_output_close(buf);
- }
-}
-
-#endif /* HAVE_ALSA */
-
-
-/* -------------------------------- SUN -------------------------------- */
-/*
- * Thanks to Seppo Ingalsuo for several bugfixes.
- * record case improved after perusal of Snack 1.6/src/jkAudio_sun.c
- */
-
-/* apparently input other than 8000 is 16-bit, 8000 is (?) mulaw */
-
-#if (defined(MUS_SUN) || defined(MUS_OPENBSD)) && (!(defined(AUDIO_OK)))
-#define AUDIO_OK
-
-#include <sys/types.h>
-#include <stropts.h>
-#include <sys/filio.h>
-
-#ifdef SUNOS
-#include <sun/audioio.h>
-#else
-#include <sys/audioio.h>
-#endif
-#if HAVE_SYS_MIXER_H
-#include <sys/mixer.h>
-#endif
-
-int mus_audio_initialize(void) {return(MUS_NO_ERROR);}
-int mus_audio_systems(void) {return(1);}
-char *mus_audio_system_name(int system) {return("Sun");}
-
-static int sun_default_outputs = (AUDIO_HEADPHONE | AUDIO_LINE_OUT | AUDIO_SPEAKER);
-
-void mus_sun_set_outputs(int speakers, int headphones, int line_out)
-{
- sun_default_outputs = 0;
- if (speakers) sun_default_outputs |= AUDIO_SPEAKER;
- if (headphones) sun_default_outputs |= AUDIO_HEADPHONE;
- if (line_out) sun_default_outputs |= AUDIO_LINE_OUT;
-}
-
-
-#ifdef MUS_OPENBSD
- #define DAC_NAME "/dev/sound"
-#else
- #define DAC_NAME "/dev/audio"
-#endif
-#define AUDIODEV_ENV "AUDIODEV"
-
-#define RETURN_ERROR_EXIT(Error_Type, Audio_Line, Ur_Error_Message) \
- do { char *Error_Message; Error_Message = Ur_Error_Message; \
- if (Audio_Line != -1) close(Audio_Line); \
- if (Error_Message) \
- {MUS_STANDARD_ERROR(Error_Type, Error_Message); FREE(Error_Message);} \
- else MUS_STANDARD_ERROR(Error_Type, mus_error_type_to_string(Error_Type)); \
- return(MUS_ERROR); \
- } while (false)
-
-char *mus_audio_moniker(void)
-{
-#ifndef AUDIO_DEV_AMD
- struct audio_device ad;
-#else
- int ad;
-#endif
- int audio_fd, err;
- char *dev_name;
- if (getenv(AUDIODEV_ENV) != NULL)
- dev_name = getenv(AUDIODEV_ENV);
- else dev_name = DAC_NAME;
- audio_fd = open(dev_name, O_RDONLY | O_NONBLOCK, 0);
- if (audio_fd == -1)
- {
- audio_fd = open("/dev/audioctl", O_RDONLY | O_NONBLOCK, 0);
- if (audio_fd == -1) return("sun probably");
- }
- err = ioctl(audio_fd, AUDIO_GETDEV, &ad);
- if (err == -1)
- {
- close(audio_fd);
- return("sun?");
- }
- mus_audio_close(audio_fd);
-#if HAVE_SYS_MIXER_H
- if (version_name == NULL) version_name = (char *)CALLOC(PRINT_BUFFER_SIZE, sizeof(char));
-#else
- if (version_name == NULL) version_name = (char *)CALLOC(LABEL_BUFFER_SIZE, sizeof(char));
-#endif
-#ifndef AUDIO_DEV_AMD
- #if HAVE_SYS_MIXER_H
- mus_snprintf(version_name, PRINT_BUFFER_SIZE,
- "audio: %s (%s), %s %s %s",
- ad.name, ad.version,
- MIXER_NAME, MIXER_VERSION, MIXER_CONFIGURATION);
- #else
- mus_snprintf(version_name, LABEL_BUFFER_SIZE, "audio: %s (%s)", ad.name, ad.version);
- #endif
-#else
- switch (ad)
- {
- case AUDIO_DEV_AMD: mus_snprintf(version_name, LABEL_BUFFER_SIZE, "audio: amd"); break;
- #ifdef AUDIO_DEV_CS4231
- case AUDIO_DEV_CS4231: mus_snprintf(version_name, LABEL_BUFFER_SIZE, "audio: cs4231"); break;
- #endif
- case AUDIO_DEV_SPEAKERBOX: mus_snprintf(version_name, LABEL_BUFFER_SIZE, "audio: speakerbox"); break;
- case AUDIO_DEV_CODEC: mus_snprintf(version_name, LABEL_BUFFER_SIZE, "audio: codec"); break;
- default: mus_snprintf(version_name, LABEL_BUFFER_SIZE, "audio: unknown"); break;
- }
-#endif
- return(version_name);
-}
-
-static int to_sun_format(int format)
-{
- switch (format)
- {
-#if MUS_LITTLE_ENDIAN
- case MUS_LSHORT: /* Solaris on Intel? */
-#else
- case MUS_BSHORT:
-#endif
-#ifdef MUS_OPENBSD
- return(AUDIO_ENCODING_PCM16);
-#else
- return(AUDIO_ENCODING_LINEAR);
-#endif
- break;
- case MUS_BYTE:
-#if defined(AUDIO_ENCODING_LINEAR8)
- return(AUDIO_ENCODING_LINEAR8); break;
-#else
- #ifdef MUS_OPENBSD
- return(AUDIO_ENCODING_PCM8);
- #else
- return(AUDIO_ENCODING_LINEAR);
- #endif
- break;
-#endif
- case MUS_MULAW: return(AUDIO_ENCODING_ULAW); break;
- case MUS_ALAW: return(AUDIO_ENCODING_ALAW); break;
- /* there's also AUDIO_ENCODING_DVI */
- }
- return(MUS_ERROR);
-}
-
-int mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size)
-{
- struct audio_info info;
- char *dev_name;
- int encode, bits, dev;
- int audio_fd, err;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- encode = to_sun_format(format);
- if (encode == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %d (%s) not available",
- format,
- mus_data_format_name(format)));
- if (getenv(AUDIODEV_ENV) != NULL)
- dev_name = getenv(AUDIODEV_ENV);
- else dev_name = DAC_NAME;
- if (dev != MUS_AUDIO_DUPLEX_DEFAULT)
- audio_fd = open(dev_name, O_WRONLY, 0);
- else audio_fd = open(dev_name, O_RDWR, 0);
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, -1,
- mus_format("can't open output %s: %s",
- dev_name, strerror(errno)));
- AUDIO_INITINFO(&info);
- if (dev == MUS_AUDIO_LINE_OUT)
- info.play.port = AUDIO_LINE_OUT;
- else
- {
- if (dev == MUS_AUDIO_SPEAKERS)
- /* OR may not be available */
- info.play.port = AUDIO_SPEAKER | (sun_default_outputs & AUDIO_HEADPHONE);
- else
- info.play.port = sun_default_outputs;
- }
- info.play.sample_rate = srate;
- info.play.channels = chans;
- bits = 8 * mus_bytes_per_sample(format);
- info.play.precision = bits;
- info.play.encoding = encode;
- err = ioctl(audio_fd, AUDIO_SETINFO, &info);
- if (err == -1)
- {
- ioctl(audio_fd, AUDIO_GETINFO, &info);
-
- if ((int)info.play.channels != chans)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_fd,
- mus_format("can't set output %s (%s) channels to %d",
- mus_audio_device_name(dev), dev_name, chans));
-
- if (((int)info.play.precision != bits) ||
- ((int)info.play.encoding != encode))
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_fd,
- mus_format("can't set output %s (%s) format to %d bits, %d encode (%s)",
- mus_audio_device_name(dev), dev_name,
- bits, encode,
- mus_data_format_name(format)));
-
- if ((int)info.play.sample_rate != srate)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_fd,
- mus_format("can't set output %s (%s) srate to %d",
- mus_audio_device_name(dev), dev_name, srate));
- }
- /* man audio sez the play.buffer_size field is not currently supported */
- /* but since the default buffer size is 8180! we need ioctl(audio_fd, I_SETSIG, ...) */
- ioctl(audio_fd, I_FLUSH, FLUSHR);
- return(audio_fd);
-}
-
-int mus_audio_write(int line, char *buf, int bytes)
-{
- if (write(line, buf, bytes) != bytes)
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("write error: %s", strerror(errno)));
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_close(int line)
-{
- write(line, (char *)NULL, 0);
- close(line);
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_read(int line, char *buf, int bytes)
-{
- int total = 0;
- char *curbuf;
- /* ioctl(line, AUDIO_DRAIN, NULL) */
- /* this seems to return 8-12 bytes fewer than requested -- perverse! */
- /* should I buffer data internally? */
-
- /* apparently we need to loop here ... */
- curbuf = buf;
- while (total < bytes)
- {
- int bytes_available;
- ioctl(line, FIONREAD, &bytes_available);
- if (bytes_available > 0)
- {
- int bytes_read;
- if ((total + bytes_available) > bytes) bytes_available = bytes - total;
- bytes_read = read(line, curbuf, bytes_available);
- if (bytes_read > 0)
- {
- total += bytes_read;
- curbuf = (char *)(buf + total);
- }
- /* else return anyway?? */
- }
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_open_input(int ur_dev, int srate, int chans, int format, int size)
-{
- struct audio_info info;
- int indev, encode, bits, dev, audio_fd, err;
- char *dev_name;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- encode = to_sun_format(format);
- bits = 8 * mus_bytes_per_sample(format);
- if (encode == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %d bits, %d encode (%s) not available",
- bits, encode,
- mus_data_format_name(format)));
- if (getenv(AUDIODEV_ENV) != NULL)
- dev_name = getenv(AUDIODEV_ENV);
- else dev_name = DAC_NAME;
- if (dev != MUS_AUDIO_DUPLEX_DEFAULT)
- audio_fd = open(dev_name, O_RDONLY, 0);
- else audio_fd = open(dev_name, O_RDWR, 0);
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, -1,
- mus_format("can't open input %s: %s",
- dev_name, strerror(errno)));
- AUDIO_INITINFO(&info);
- /* ioctl(audio_fd, AUDIO_GETINFO, &info); */
- info.record.sample_rate = srate;
- info.record.channels = chans;
- err = ioctl(audio_fd, AUDIO_SETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, audio_fd,
- mus_format("can't set srate %d and chans %d for input %s (%s)",
- srate, chans,
- dev_name,
- mus_audio_device_name(dev)));
- ioctl(audio_fd, AUDIO_GETINFO, &info);
- if (info.record.sample_rate != (unsigned int)srate)
- mus_print("%s[%d]: sampling rate: %d != %d\n",
- __FILE__, __LINE__,
- info.record.sample_rate, srate);
- if (info.record.channels != (unsigned int)chans)
- mus_print("%s[%d]: channels: %d != %d\n",
- __FILE__, __LINE__,
- info.record.channels, chans);
-
- info.record.precision = bits; /* was play, changed 10-Jul-03 thanks to Jürgen Keil */
- info.record.encoding = encode;
- err = ioctl(audio_fd, AUDIO_SETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, audio_fd,
- mus_format("can't set bits %d, encode %d (format %s) for input %s (%s)",
- bits, encode, mus_data_format_name(format),
- dev_name,
- mus_audio_device_name(dev)));
- ioctl(audio_fd, AUDIO_GETINFO, &info);
-
- /* these cannot be OR'd */
- if (dev == MUS_AUDIO_LINE_IN)
- indev = AUDIO_LINE_IN;
- else
- {
- if (dev == MUS_AUDIO_CD)
- indev = AUDIO_INTERNAL_CD_IN;
- else indev = AUDIO_MICROPHONE;
- }
- info.record.port = indev;
- err = ioctl(audio_fd, AUDIO_SETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't set record.port to %d for %s (%s)",
- indev, dev_name,
- mus_audio_device_name(dev)));
- err = ioctl(audio_fd, AUDIO_GETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't getinfo on input %s (%s, line: %d)",
- dev_name,
- mus_audio_device_name(dev), audio_fd));
- else
- {
- if ((int)info.record.port != indev)
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, audio_fd,
- mus_format("confusion in record.port: %d != %d (%s: %s)",
- (int)info.record.port, indev,
- dev_name,
- mus_audio_device_name(dev)));
- if ((int)info.record.channels != chans)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_fd,
- mus_format("confusion in record.channels: %d != %d (%s: %s)",
- (int)info.record.channels, chans,
- dev_name,
- mus_audio_device_name(dev)));
- if (((int)info.record.precision != bits) ||
- ((int)info.record.encoding != encode))
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_fd,
- mus_format("confusion in record.precision|encoding: %d != %d or %d != %d (%s: %s)",
- (int)info.record.precision, bits,
- (int)info.record.encoding, encode,
- dev_name,
- mus_audio_device_name(dev)));
- }
- /* this may be a bad idea */
- info.record.buffer_size = size;
- err = ioctl(audio_fd, AUDIO_SETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't set buffer size to %d on input %s (%s)",
- size,
- dev_name,
- mus_audio_device_name(dev)));
- return(audio_fd);
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
-#ifndef AUDIO_DEV_AMD
- struct audio_device ad;
-#else
- int ad;
-#endif
- int audio_fd, err;
- struct audio_info info;
- int dev, port;
- char *dev_name;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- AUDIO_INITINFO(&info);
- if (getenv(AUDIODEV_ENV) != NULL)
- dev_name = getenv(AUDIODEV_ENV);
- else dev_name = DAC_NAME;
- audio_fd = open(dev_name, O_RDONLY | O_NONBLOCK, 0);
- if (audio_fd == -1)
- {
- audio_fd = open("/dev/audioctl", O_RDONLY | O_NONBLOCK);
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, -1,
- mus_format("can't open %s or /dev/audioctl: %s",
- dev_name, strerror(errno)));
- else dev_name = "/dev/audioctl";
- }
- err = ioctl(audio_fd, AUDIO_GETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't get %s (%s) info",
- dev_name,
- mus_audio_device_name(dev)));
- if (field == MUS_AUDIO_PORT)
- {
- /* info.play|record have a field avail_ports */
- port = 1;
- if ((chan > port) &&
- (info.record.avail_ports & AUDIO_MICROPHONE))
- {
- val[port] = MUS_AUDIO_MICROPHONE;
- port++;
- }
- if ((chan > port) &&
- (info.record.avail_ports & AUDIO_LINE_IN))
- {
- val[port] = MUS_AUDIO_LINE_IN;
- port++;
- }
-#ifndef AUDIO_DEV_AMD
- if ((chan > port) &&
- (info.record.avail_ports & AUDIO_INTERNAL_CD_IN))
- {
- /* this field lies -- there is no such port available on the Ultra */
- err = ioctl(audio_fd, AUDIO_GETDEV, &ad);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't get device info on %s (%s)",
- dev_name,
- mus_audio_device_name(dev)));
- if (((ad.version) && (strcmp(ad.version, "a") == 0)) || /* is it a SparcStation? */
- ((ad.name) && (strcmp(ad.name, "SUNW,CS4231") == 0)))
- {
- val[port] = MUS_AUDIO_CD;
- port++;
- }
- }
-#endif
- if ((chan > port) &&
- (info.play.avail_ports & AUDIO_SPEAKER))
- {
- val[port] = MUS_AUDIO_SPEAKERS;
- port++;
- }
- if ((chan > port) &&
- (info.play.avail_ports & AUDIO_LINE_OUT))
- {
- val[port] = MUS_AUDIO_LINE_OUT;
- port++;
- }
- if ((chan > port) &&
- (info.play.avail_ports & AUDIO_HEADPHONE))
- {
- val[port] = MUS_AUDIO_DAC_OUT;
- port++;
- }
- val[0] = port - 1;
- }
- else
- {
- if (field == MUS_AUDIO_FORMAT) /* this actually depends on the audio device */
- {
- err = ioctl(audio_fd, AUDIO_GETDEV, &ad); /* SUNW, dbri|am79c30|CS4231|sbpro|sb16 */
- /* Jurgen Keil's drivers use SUNW,CS4231, but the "real" names are:
- "TOOLS,sbpci" SoundBlaster PCI card
- "TOOLS,EMU10Kx" SoundBlaster Live! or Audigy
- "TOOLS,i810" Intel i8xx audio (and compatible)
- "TOOLS,via686" VIA 686 audio
- "TOOLS,via8233" VIA 8233 (and compatible)
- */
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't get data format info for %s (%s)",
- dev_name,
- mus_audio_device_name(dev)));
- port = 1;
- if ((ad.name) &&
- (strcmp(ad.name, "SUNW,audio810") == 0))
- {
- val[0] = 1;
- val[1] = MUS_MULAW;
- }
- else
- {
-#ifndef AUDIO_DEV_AMD
- if ((ad.name) &&
- (strcmp(ad.name, "SUNW, am79c30") != 0))
-#else
- if (ad == AUDIO_DEV_AMD)
-#endif
- {
- if (chan > port) val[port++] = MUS_BSHORT;
- }
-#ifndef AUDIO_DEV_AMD
- if ((ad.name) &&
- (strcmp(ad.name, "SUNW, sbpro") != 0) &&
- (strcmp(ad.name, "SUNW, sb16") != 0))
- {
- if (chan > port) val[port++] = MUS_ALAW;
- }
-#endif
- if (chan > port) val[port++] = MUS_MULAW;
-#if MUS_LITTLE_ENDIAN
- if (chan > port) val[port++] = MUS_LSHORT;
-#endif
- val[0] = port - 1;
- }
- }
- else
- {
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_SPEAKERS:
- case MUS_AUDIO_LINE_OUT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- /* who knows how this really works? documentation is incomplete, actual behavior seems to be: */
- if (chan == 0)
- {
- if (info.play.balance <= (AUDIO_RIGHT_BALANCE / 2))
- val[0] = info.play.gain / (float)(AUDIO_MAX_GAIN);
- else val[0] = info.play.gain * (AUDIO_RIGHT_BALANCE - info.play.balance) / (float)(AUDIO_MAX_GAIN * (AUDIO_RIGHT_BALANCE / 2));
- }
- else
- {
- if (info.play.balance >= (AUDIO_RIGHT_BALANCE / 2))
- val[0] = info.play.gain / (float)(AUDIO_MAX_GAIN);
- else val[0] = info.play.gain * info.play.balance / (float)(AUDIO_MAX_GAIN * (AUDIO_RIGHT_BALANCE / 2));
- }
- break;
- case MUS_AUDIO_CHANNEL:
- val[0] = 2;
- break;
- /* appears to depend on data format (mulaw is mono) */
- case MUS_AUDIO_SRATE:
- val[0] = (float)info.play.sample_rate;
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't read %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- break;
- }
- break;
- case MUS_AUDIO_MICROPHONE:
- case MUS_AUDIO_LINE_IN:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_CD:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- if (chan == 0)
- {
- if (info.record.balance <= (AUDIO_RIGHT_BALANCE / 2))
- val[0] = info.record.gain / (float)(AUDIO_MAX_GAIN);
- else val[0] = info.record.gain * (AUDIO_RIGHT_BALANCE - info.record.balance) / (float)(AUDIO_MAX_GAIN * (AUDIO_RIGHT_BALANCE / 2));
- }
- else
- {
- if (info.record.balance >= (AUDIO_RIGHT_BALANCE / 2))
- val[0] = info.record.gain / (float)(AUDIO_MAX_GAIN);
- else val[0] = info.record.gain * info.record.balance / (float)(AUDIO_MAX_GAIN * (AUDIO_RIGHT_BALANCE / 2));
- }
- break;
-
- case MUS_AUDIO_CHANNEL:
- val[0] = 1;
- break;
- case MUS_AUDIO_SRATE:
- val[0] = (float)(info.record.sample_rate);
- break;
- case MUS_AUDIO_IGAIN:
- val[0] = (float)(info.monitor_gain) / (float)AUDIO_MAX_GAIN;
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't read %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- break;
- }
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't read %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- break;
- }
- }
- }
- return(mus_audio_close(audio_fd));
-}
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- struct audio_info info;
- int dev, balance, gain;
- float ratio, lc, rc;
- int audio_fd, err;
- char *dev_name;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- AUDIO_INITINFO(&info);
- if (getenv(AUDIODEV_ENV) != NULL)
- dev_name = getenv(AUDIODEV_ENV);
- else dev_name = DAC_NAME;
- audio_fd = open(dev_name, O_RDWR | O_NONBLOCK, 0);
- if (audio_fd == -1)
- {
- audio_fd = open("/dev/audioctl", O_RDWR | O_NONBLOCK);
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, -1,
- mus_format("can't write fields of %s (or /dev/audioctl) (%s): %s",
- dev_name,
- mus_audio_device_name(dev),
- strerror(errno)));
- else dev_name = "/dev/audioctl";
- }
- err = ioctl(audio_fd, AUDIO_GETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't get %s (%s) info",
- dev_name,
- mus_audio_device_name(dev)));
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_SPEAKERS:
- case MUS_AUDIO_LINE_OUT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- balance = info.play.balance;
- gain = info.play.gain;
- if (balance <= (AUDIO_RIGHT_BALANCE / 2))
- {
- lc = gain;
- rc = gain * balance / (float)(AUDIO_RIGHT_BALANCE / 2);
- }
- else
- {
- lc = gain * (AUDIO_RIGHT_BALANCE - balance) / (float)(AUDIO_RIGHT_BALANCE / 2);
- rc = gain;
- }
- if (chan == 0)
- lc = AUDIO_MAX_GAIN * val[0];
- else rc = AUDIO_MAX_GAIN * val[0];
- if ((rc + lc) == 0)
- info.play.gain = 0;
- else
- {
- ratio = (float)rc / (float)(rc + lc);
- info.play.balance = (unsigned char)(AUDIO_RIGHT_BALANCE * ratio);
- if (rc > lc)
- info.play.gain = (int)rc;
- else info.play.gain = (int)lc;
- }
- break;
- case MUS_AUDIO_CHANNEL:
- info.play.channels = (int)val[0];
- break;
- /* amd device only mono */
- case MUS_AUDIO_SRATE:
- info.play.sample_rate = (int)val[0];
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't write %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- break;
- }
- break;
- case MUS_AUDIO_MICROPHONE:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- info.record.gain = (int)(AUDIO_MAX_GAIN * val[0]);
- info.record.balance = 0;
- break;
- case MUS_AUDIO_CHANNEL:
- info.record.channels = (int)val[0];
- break;
- case MUS_AUDIO_SRATE:
- info.record.sample_rate = (int)val[0];
- break;
- case MUS_AUDIO_IGAIN:
- info.monitor_gain = (int)(AUDIO_MAX_GAIN * val[0]);
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't write %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- break;
- }
- break;
- case MUS_AUDIO_LINE_IN:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_CD:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- balance = info.record.balance;
- gain = info.record.gain;
- lc = gain * (float)(AUDIO_RIGHT_BALANCE - balance) / (float)AUDIO_RIGHT_BALANCE;
- rc = gain - lc;
- if (chan == 0)
- lc = AUDIO_MAX_GAIN * val[0];
- else rc = AUDIO_MAX_GAIN * val[0];
- gain = (int)(rc + lc);
- if (gain == 0)
- info.record.gain = 0;
- else
- {
- info.record.balance = (unsigned char)(AUDIO_RIGHT_BALANCE * ((float)rc / (float)(rc + lc)));
- if (rc > lc)
- info.record.gain = (int)rc;
- else info.record.gain = (int)lc;
- }
- break;
- case MUS_AUDIO_CHANNEL:
- info.record.channels = (int)val[0];
- break;
- case MUS_AUDIO_SRATE:
- info.record.sample_rate = (int)val[0];
- break;
- case MUS_AUDIO_IGAIN:
- info.monitor_gain = (int)(AUDIO_MAX_GAIN * val[0]);
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't write %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- break;
- }
- break;
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't write %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- break;
- }
- err = ioctl(audio_fd, AUDIO_SETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't write %s field %d (%s) after explicit set",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- return(mus_audio_close(audio_fd));
-}
-
-/* pause can be implemented with play.pause and record.pause */
-
-static char *sun_format_name(int format)
-{
- switch (format)
- {
-#ifdef AUDIO_ENCODING_ALAW
- case AUDIO_ENCODING_ALAW: return("alaw"); break;
-#endif
-#ifdef AUDIO_ENCODING_ULAW
- case AUDIO_ENCODING_ULAW: return("ulaw"); break;
-#endif
-#ifdef AUDIO_ENCODING_DVI
- case AUDIO_ENCODING_DVI: return("dvi adpcm"); break;
-#endif
-#ifdef AUDIO_ENCODING_LINEAR8
- case AUDIO_ENCODING_LINEAR8: return("linear"); break;
-#else
- #ifdef AUDIO_ENCODING_PCM8
- case AUDIO_ENCODING_PCM8: return("linear"); break;
- #endif
-#endif
-#ifdef AUDIO_ENCODING_LINEAR
- case AUDIO_ENCODING_LINEAR: return("linear"); break;
-#else
- #ifdef AUDIO_ENCODING_PCM16
- case AUDIO_ENCODING_PCM16: return("linear"); break;
- #endif
-#endif
-#ifdef AUDIO_ENCODING_NONE
- case AUDIO_ENCODING_NONE: return("not audio"); break; /* dbri interface configured for something else */
-#endif
- }
- return("unknown");
-}
-
-static char *sun_in_device_name(int dev)
-{
- if (dev == AUDIO_MICROPHONE) return("microphone");
- if (dev == AUDIO_LINE_IN) return("line in");
- if (dev == AUDIO_INTERNAL_CD_IN) return("cd");
- if (dev == (AUDIO_MICROPHONE | AUDIO_LINE_IN)) return("microphone + line in");
- if (dev == (AUDIO_MICROPHONE | AUDIO_LINE_IN | AUDIO_INTERNAL_CD_IN)) return("microphone + line in + cd");
- if (dev == (AUDIO_MICROPHONE | AUDIO_INTERNAL_CD_IN)) return("microphone + cd");
- if (dev == (AUDIO_LINE_IN | AUDIO_INTERNAL_CD_IN)) return("line in + cd");
- return("unknown");
-}
-
-static char *sun_out_device_name(int dev)
-{
- if (dev == AUDIO_SPEAKER) return("speakers");
- if (dev == AUDIO_LINE_OUT) return("line out");
- if (dev == AUDIO_HEADPHONE) return("headphones");
- if (dev == (AUDIO_SPEAKER | AUDIO_LINE_OUT)) return("speakers + line out");
- if (dev == (AUDIO_SPEAKER | AUDIO_LINE_OUT | AUDIO_HEADPHONE)) return("speakers + line out + headphones");
- if (dev == (AUDIO_SPEAKER | AUDIO_HEADPHONE)) return("speakers + headphones");
- if (dev == (AUDIO_LINE_OUT | AUDIO_HEADPHONE)) return("line out + headphones");
- return("unknown");
-}
-
-static char *sun_vol_name = NULL;
-static char *sun_volume_name(float vol, int balance, int chans)
-{
- if (sun_vol_name == NULL) sun_vol_name = (char *)CALLOC(LABEL_BUFFER_SIZE, sizeof(char));
- if (chans != 2)
- mus_snprintf(sun_vol_name, LABEL_BUFFER_SIZE, "%.3f", vol);
- else
- {
- mus_snprintf(sun_vol_name, LABEL_BUFFER_SIZE, "%.3f %.3f",
- vol * (float)(AUDIO_RIGHT_BALANCE - balance) / (float)AUDIO_RIGHT_BALANCE,
- vol * (float)balance / (float)AUDIO_RIGHT_BALANCE);
- }
- return(sun_vol_name);
-}
-
-static void describe_audio_state_1(void)
-{
- struct audio_info info;
-#ifndef AUDIO_DEV_AMD
- struct audio_device ad;
-#else
- int ad;
-#endif
- int audio_fd, err;
- char *dev_name;
- AUDIO_INITINFO(&info);
- if (getenv(AUDIODEV_ENV) != NULL)
- dev_name = getenv(AUDIODEV_ENV);
- else dev_name = DAC_NAME;
- audio_fd = open(dev_name, O_RDONLY | O_NONBLOCK, 0);
- if (audio_fd == -1)
- audio_fd = open("/dev/audioctl", O_RDONLY | O_NONBLOCK, 0);
- if (audio_fd == -1) return;
- err = ioctl(audio_fd, AUDIO_GETINFO, &info);
- if (err == -1) return;
- err = ioctl(audio_fd, AUDIO_GETDEV, &ad);
- if (err == -1) return;
- pprint(mus_audio_moniker());
- pprint("\n");
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "output: %s\n srate: %d, vol: %s, chans: %d, format %d-bit %s\n",
- sun_out_device_name(info.play.port),
- info.play.sample_rate,
- sun_volume_name((float)info.play.gain / (float)AUDIO_MAX_GAIN, info.play.balance, 2),
- info.play.channels,
- info.play.precision,
- sun_format_name(info.play.encoding));
- pprint(audio_strbuf);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "input: %s\n srate: %d, vol: %s, chans: %d, format %d-bit %s\n",
- sun_in_device_name(info.record.port),
- info.record.sample_rate,
- sun_volume_name((float)info.record.gain / (float)AUDIO_MAX_GAIN, info.record.balance, 2),
- info.record.channels,
- info.record.precision,
- sun_format_name(info.record.encoding));
- pprint(audio_strbuf);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "input->output vol: %.3f\n", (float)info.monitor_gain / (float)AUDIO_MAX_GAIN);
- pprint(audio_strbuf);
- if (info.play.pause) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "Playback is paused\n"); pprint(audio_strbuf);}
- if (info.record.pause) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "Recording is paused\n"); pprint(audio_strbuf);}
- if (info.output_muted) {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "Output is muted\n"); pprint(audio_strbuf);}
-#ifdef AUDIO_HWFEATURE_DUPLEX
- if (info.hw_features == AUDIO_HWFEATURE_DUPLEX)
- {mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "Simultaneous play and record supported\n"); pprint(audio_strbuf);}
-#endif
-#if HAVE_SYS_MIXER_H
- {
- int i, num = 0, choice;
- #define LARGE_NUMBER 100
- am_sample_rates_t *sr = NULL;
- for (choice = 0; choice < 2; choice++)
- {
- for (num = 4; num < LARGE_NUMBER; num += 2)
- {
- sr = (am_sample_rates_t *)
- malloc(AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(num));
- sr->num_samp_rates = num;
- sr->type = (choice == 0) ? AUDIO_PLAY : AUDIO_RECORD;
- err = ioctl(audio_fd, AUDIO_MIXER_GET_SAMPLE_RATES, sr);
- if ((int)(sr->num_samp_rates) <= num) break;
- free(sr);
- sr = NULL;
- }
- if (sr)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s srates:", (choice == 0) ? "play" : "record");
- pprint(audio_strbuf);
- if (sr->type == MIXER_SR_LIMITS)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %d to %d", sr->samp_rates[0], sr->samp_rates[sr->num_samp_rates - 1]);
- pprint(audio_strbuf);
- }
- else
- {
- for (i = 0; i < (int)(sr->num_samp_rates); i++)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %d", sr->samp_rates[i]);
- pprint(audio_strbuf);
- }
- }
- pprint("\n");
- }
- free(sr);
- sr = NULL;
- }
- }
-#endif
- mus_audio_close(audio_fd);
-}
-
-#endif
-
-
-
-/* ------------------------------- WINDOZE ----------------------------------------- */
-
-#if defined(MUS_WINDOZE) && (!(defined(__CYGWIN__)))
-#define AUDIO_OK
-
-#include <windows.h>
-#include <mmsystem.h>
-
-#define BUFFER_FILLED 1
-#define BUFFER_EMPTY 2
-
-#define OUTPUT_LINE 1
-#define INPUT_LINE 2
-
-#define SOUND_UNREADY 0
-#define SOUND_INITIALIZED 1
-#define SOUND_RUNNING 2
-
-static int buffer_size = 1024;
-static int db_state[2];
-static int sound_state = 0;
-static int current_chans = 1;
-static int current_datum_size = 2;
-static int current_buf = 0;
-WAVEHDR wh[2];
-HWAVEOUT fd;
-HWAVEIN record_fd;
-WAVEHDR rec_wh;
-static int rec_state = SOUND_UNREADY;
-
-static MMRESULT win_in_err = 0, win_out_err = 0;
-static char errstr[128], getstr[128];
-
-static char *win_err_buf = NULL;
-static mus_print_handler_t *old_handler;
-
-static void win_mus_print(char *msg)
-{
- if ((win_in_err == 0) && (win_out_err == 0))
- (*old_handler)(msg);
- else
- {
- if (win_in_err)
- waveInGetErrorText(win_in_err, getstr, PRINT_BUFFER_SIZE);
- else waveOutGetErrorText(win_out_err, getstr, PRINT_BUFFER_SIZE);
- mus_snprintf(errstr, PRINT_BUFFER_SIZE, "%s [%s]", msg, getstr);
- (*old_handler)(errstr);
- }
-}
-
-static void start_win_print(void)
-{
- if (old_handler != win_mus_print)
- old_handler = mus_print_set_handler(win_mus_print);
-}
-
-static void end_win_print(void)
-{
- if (old_handler == win_mus_print)
- mus_print_set_handler(NULL);
- else mus_print_set_handler(old_handler);
-}
-
-#define RETURN_ERROR_EXIT(Error_Type, Ur_Error_Message) \
- do { char *Error_Message; Error_Message = Ur_Error_Message; \
- if (Error_Message) \
- {MUS_STANDARD_ERROR(Error_Type, Error_Message); FREE(Error_Message);} \
- else MUS_STANDARD_ERROR(Error_Type, mus_error_type_to_string(Error_Type)); \
- end_win_print(); \
- return(MUS_ERROR); \
- } while (false)
-
-int mus_audio_systems(void)
-{
- /* this number is available -- see below (user mixer number as in linux)->mixerGetNumDevs */
- return(1);
-}
-char *mus_audio_system_name(int system) {return("Windoze");}
-
-DWORD CALLBACK next_buffer(HWAVEOUT w, UINT msg, DWORD user_data, DWORD p1, DWORD p2)
-{
- if (msg == WOM_DONE)
- {
- db_state[current_buf] = BUFFER_EMPTY;
- }
- return(0);
-}
-
-int mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size)
-{
- WAVEFORMATEX wf;
- int dev;
- start_win_print();
- dev = MUS_AUDIO_DEVICE(ur_dev);
- wf.nChannels = chans;
- current_chans = chans;
- wf.wFormatTag = WAVE_FORMAT_PCM;
- wf.cbSize = 0;
- if (format == MUS_UBYTE)
- {
- wf.wBitsPerSample = 8;
- current_datum_size = 1;
- }
- else
- {
- wf.wBitsPerSample = 16;
- current_datum_size = 2;
- }
- wf.nSamplesPerSec = srate;
- wf.nBlockAlign = chans * current_datum_size;
- wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec;
- win_out_err = waveOutOpen(&fd, WAVE_MAPPER, &wf, (DWORD)next_buffer, 0, CALLBACK_FUNCTION); /* 0 here = user_data above, other case = WAVE_FORMAT_QUERY */
- if (win_out_err)
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE,
- mus_format("can't open %d (%s)",
- dev,
- mus_audio_device_name(dev)));
- waveOutPause(fd);
- if (size <= 0)
- buffer_size = 1024;
- else buffer_size = size;
- wh[0].dwBufferLength = buffer_size * current_datum_size;
- wh[0].dwFlags = 0;
- wh[0].dwLoops = 0;
- wh[0].lpData = (char *)CALLOC(wh[0].dwBufferLength, sizeof(char));
- if ((wh[0].lpData) == 0)
- {
- waveOutClose(fd);
- RETURN_ERROR_EXIT(MUS_AUDIO_SIZE_NOT_AVAILABLE,
- mus_format("can't allocate buffer size %d for output %d (%s)",
- buffer_size, dev,
- mus_audio_device_name(dev)));
- }
- win_out_err = waveOutPrepareHeader(fd, &(wh[0]), sizeof(WAVEHDR));
- if (win_out_err)
- {
- FREE(wh[0].lpData);
- waveOutClose(fd);
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("can't setup output 'header' for %d (%s)",
- dev,
- mus_audio_device_name(dev)));
- }
- db_state[0] = BUFFER_EMPTY;
- wh[1].dwBufferLength = buffer_size * current_datum_size;
- wh[1].dwFlags = 0;
- wh[1].dwLoops = 0;
- wh[1].lpData = (char *)CALLOC(wh[0].dwBufferLength, sizeof(char));
- if ((wh[1].lpData) == 0)
- {
- FREE(wh[0].lpData);
- waveOutClose(fd);
- RETURN_ERROR_EXIT(MUS_AUDIO_SIZE_NOT_AVAILABLE,
- mus_format("can't allocate buffer size %d for output %d (%s)",
- buffer_size, dev,
- mus_audio_device_name(dev)));
- }
- win_out_err = waveOutPrepareHeader(fd, &(wh[1]), sizeof(WAVEHDR));
- if (win_out_err)
- {
- waveOutUnprepareHeader(fd, &(wh[0]), sizeof(WAVEHDR));
- FREE(wh[0].lpData);
- FREE(wh[1].lpData);
- waveOutClose(fd);
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("can't setup output 'header' for %d (%s)",
- dev,
- mus_audio_device_name(dev)));
- }
- db_state[1] = BUFFER_EMPTY;
- sound_state = SOUND_INITIALIZED;
- current_buf = 0;
- end_win_print();
- return(OUTPUT_LINE);
-}
-
-static MMRESULT fill_buffer(int dbi, char *inbuf, int instart, int bytes)
-{
- int i, j;
- win_out_err = 0;
- if (sound_state == SOUND_UNREADY) return(0);
- for (i = instart, j = 0; j < bytes; j++, i++)
- wh[dbi].lpData[j] = inbuf[i];
- wh[dbi].dwBufferLength = bytes;
- db_state[dbi] = BUFFER_FILLED;
- if ((sound_state == SOUND_INITIALIZED) &&
- (dbi == 1))
- {
- sound_state = SOUND_RUNNING;
- win_out_err = waveOutRestart(fd);
- }
- return(win_out_err);
-}
-
-static void wait_for_empty_buffer(int buf)
-{
- while (db_state[buf] != BUFFER_EMPTY)
- {
- Sleep(1); /* in millisecs, so even this may be too much if buf = 256 bytes */
- }
-}
-
-int mus_audio_write(int line, char *buf, int bytes)
-{
- int lim, leftover, start;
- start_win_print();
- if (line != OUTPUT_LINE)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE,
- mus_format("write error: line %d != %d?",
- line, OUTPUT_LINE));
- win_out_err = 0;
- leftover = bytes;
- start = 0;
- if (sound_state == SOUND_UNREADY)
- {
- end_win_print();
- return(MUS_NO_ERROR);
- }
- while (leftover > 0)
- {
- lim = leftover;
- if (lim > buffer_size) lim = buffer_size;
- leftover -= lim;
- wait_for_empty_buffer(current_buf);
- win_out_err = fill_buffer(current_buf, buf, start, lim);
- if (win_out_err)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE,
- mus_format("write error on %d",
- line));
- win_out_err = waveOutWrite(fd, &wh[current_buf], sizeof(WAVEHDR));
- if (win_out_err)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE,
- mus_format("write error on %d",
- line));
- start += lim;
- current_buf++;
- if (current_buf > 1) current_buf = 0;
- }
- return(MUS_NO_ERROR);
-}
-
-static float unlog(unsigned short val)
-{
- /* 1.0 linear is 0xffff, rest is said to be "logarithmic", whatever that really means here */
- if (val == 0) return(0.0);
- return((float)val / 65536.0);
- /* return(pow(2.0, amp) - 1.0); */ /* doc seems to be bogus */
-}
-
-#define SRATE_11025_BITS (WAVE_FORMAT_1S16 | WAVE_FORMAT_1S08 | WAVE_FORMAT_1M16 | WAVE_FORMAT_1M08)
-#define SRATE_22050_BITS (WAVE_FORMAT_2S16 | WAVE_FORMAT_2S08 | WAVE_FORMAT_2M16 | WAVE_FORMAT_2M08)
-#define SRATE_44100_BITS (WAVE_FORMAT_4S16 | WAVE_FORMAT_4S08 | WAVE_FORMAT_4M16 | WAVE_FORMAT_4M08)
-#define SHORT_SAMPLE_BITS (WAVE_FORMAT_1S16 | WAVE_FORMAT_1M16 | WAVE_FORMAT_2S16 | WAVE_FORMAT_2M16 | WAVE_FORMAT_4S16 | WAVE_FORMAT_4M16)
-#define BYTE_SAMPLE_BITS (WAVE_FORMAT_1S08 | WAVE_FORMAT_1M08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_2M08 | WAVE_FORMAT_4S08 | WAVE_FORMAT_4M08)
-
-static char *mixer_status_name(int status)
-{
- switch (status)
- {
- case MIXERLINE_LINEF_ACTIVE: return(", (active)"); break;
- case MIXERLINE_LINEF_DISCONNECTED: return(", (disconnected)"); break;
- case MIXERLINE_LINEF_SOURCE: return(", (source)"); break;
- default: return(""); break;
- }
-}
-
-static char *mixer_target_name(int type)
-{
- switch (type)
- {
- case MIXERLINE_TARGETTYPE_UNDEFINED: return("undefined"); break;
- case MIXERLINE_TARGETTYPE_WAVEOUT: return("output"); break;
- case MIXERLINE_TARGETTYPE_WAVEIN: return("input"); break;
- case MIXERLINE_TARGETTYPE_MIDIOUT: return("midi output"); break;
- case MIXERLINE_TARGETTYPE_MIDIIN: return("midi input"); break;
- case MIXERLINE_TARGETTYPE_AUX: return("aux"); break;
- default: return(""); break;
- }
-}
-
-static char *mixer_component_name(int type)
-{
- switch (type)
- {
- case MIXERLINE_COMPONENTTYPE_DST_UNDEFINED: return("undefined"); break;
- case MIXERLINE_COMPONENTTYPE_DST_DIGITAL: return("digital"); break;
- case MIXERLINE_COMPONENTTYPE_DST_LINE: return("line"); break;
- case MIXERLINE_COMPONENTTYPE_DST_MONITOR: return("monitor"); break;
- case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS: return("speakers"); break;
- case MIXERLINE_COMPONENTTYPE_DST_HEADPHONES: return("headphones"); break;
- case MIXERLINE_COMPONENTTYPE_DST_TELEPHONE: return("telephone"); break;
- case MIXERLINE_COMPONENTTYPE_DST_WAVEIN: return("wave in"); break;
- case MIXERLINE_COMPONENTTYPE_DST_VOICEIN: return("voice in"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED: return("undefined"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_DIGITAL: return("digital"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_LINE: return("line"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE: return("mic"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER: return("synth"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC: return("CD"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE: return("telephone"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER: return("speaker"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT: return("wave out"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY: return("aux"); break;
- case MIXERLINE_COMPONENTTYPE_SRC_ANALOG: return("analog"); break;
- default: return(""); break;
- }
-}
-
-#define MAX_DESCRIBE_CHANS 8
-#define MAX_DESCRIBE_CONTROLS 16
-/* these actually need to be big enough to handle whatever comes along, since we can't read partial states */
-/* or they need to be expanded as necessary */
-
-char *mus_audio_moniker(void) {return("MS audio");} /* version number of some sort? */
-
-static void describe_audio_state_1(void)
-{
- int devs, dev, srate, chans, format, need_comma, maker;
- MMRESULT err;
- unsigned long val, rate, pitch, version;
- WAVEOUTCAPS wocaps;
- WAVEINCAPS wicaps;
- AUXCAPS wacaps;
- HWAVEOUT hd;
- WAVEFORMATEX pwfx;
-#ifdef MIXERR_BASE
- MIXERCAPS wmcaps;
- MIXERLINE mixline;
- MIXERLINECONTROLS linecontrols;
- MIXERCONTROL mc[MAX_DESCRIBE_CONTROLS];
- MIXERCONTROLDETAILS controldetails;
- MIXERCONTROLDETAILS_LISTTEXT clist[MAX_DESCRIBE_CHANS];
- MIXERCONTROLDETAILS_BOOLEAN cbool[MAX_DESCRIBE_CHANS];
- MIXERCONTROLDETAILS_UNSIGNED cline[MAX_DESCRIBE_CHANS];
- MIXERCONTROLDETAILS_SIGNED csign[MAX_DESCRIBE_CHANS];
- HMIXER mfd;
- int control, controls, dest, dests, source, happy, dest_time, chan, mina, maxa, ctype;
-#endif
- need_comma = 1;
- chans = 1;
- devs = waveOutGetNumDevs();
- if (devs > 0)
- {
- pprint("Output:\n");
- for (dev = 0; dev < devs; dev++)
- {
- err = waveOutGetDevCaps(dev, &wocaps, sizeof(wocaps));
- if (!err)
- {
- version = wocaps.vDriverVersion;
- maker = wocaps.wMid;
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s: version %d.%d\n",
- wocaps.szPname, version >> 8, version & 0xff);
- pprint(audio_strbuf);
- if (wocaps.wChannels == 2) {chans = 2; pprint(" stereo");} else {chans = 1; pprint(" mono");}
- if (wocaps.dwFormats & SRATE_11025_BITS) {srate = 11025; if (need_comma) pprint(", "); pprint(" 11025"); need_comma = 1;}
- if (wocaps.dwFormats & SRATE_22050_BITS) {srate = 22050; if (need_comma) pprint(", "); pprint(" 22050"); need_comma = 1;}
- if (wocaps.dwFormats & SRATE_44100_BITS) {srate = 44100; if (need_comma) pprint(", "); pprint(" 44100"); need_comma = 1;}
- if (wocaps.dwFormats & BYTE_SAMPLE_BITS) {format = 8; if (need_comma) pprint(", "); pprint(" unsigned byte"); need_comma = 1;}
- if (wocaps.dwFormats & SHORT_SAMPLE_BITS) {format = 16; if (need_comma) pprint(", "); pprint(" little-endian short"); need_comma = 1;}
- if (need_comma) pprint("\n");
- need_comma = 0;
- pwfx.wFormatTag = WAVE_FORMAT_PCM;
- pwfx.nChannels = chans;
- pwfx.nSamplesPerSec = srate;
- pwfx.nAvgBytesPerSec = srate;
- pwfx.nBlockAlign = 1;
- pwfx.wBitsPerSample = format;
-
- err = waveOutOpen(&hd, dev, &pwfx, 0, 0, WAVE_FORMAT_QUERY);
-
- if (wocaps.dwSupport & WAVECAPS_VOLUME)
- {
- err = waveOutGetVolume(hd, &val);
- if (!err)
- {
- if (wocaps.dwSupport & WAVECAPS_LRVOLUME)
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- " vol: %.3f %.3f",
- unlog((unsigned short)(val >> 16)),
- unlog((unsigned short)(val & 0xffff)));
- else mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- " vol: %.3f",
- unlog((unsigned short)(val & 0xffff)));
- pprint(audio_strbuf);
- need_comma = 1;
- }
- }
- if (!err)
- {
- /* this is just to get the hd data for subsequent info */
- if (wocaps.dwSupport & WAVECAPS_PLAYBACKRATE)
- {
- err = waveOutGetPlaybackRate(hd, &rate);
- if (!err)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- "%s playback rate: %.3f",
- (need_comma ? ", " : ""),
- (float)rate / 65536.0);
- pprint(audio_strbuf);
- need_comma = 1;
- }
- }
- if (wocaps.dwSupport & WAVECAPS_PITCH)
- {
- err = waveOutGetPitch(hd, &pitch);
- if (!err)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- "%s pitch: %.3f",
- (need_comma ? ", " : ""),
- (float)pitch / 65536.0);
- pprint(audio_strbuf);
- need_comma = 1;
- }
- }
- waveOutClose(hd);
- }
- if (need_comma) {need_comma = 0; pprint("\n");}
- }
- }
- }
- devs = waveInGetNumDevs();
- if (devs > 0)
- {
- pprint("Input:\n");
- for (dev = 0; dev < devs; dev++)
- {
- err = waveInGetDevCaps(dev, &wicaps, sizeof(wicaps));
- if (!err)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s", wicaps.szPname);
- pprint(audio_strbuf);
- if ((wicaps.wMid != maker) || (version != wicaps.vDriverVersion))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, ": version %d.%d\n",
- (wicaps.vDriverVersion >> 8),
- wicaps.vDriverVersion & 0xff);
- pprint(audio_strbuf);
- }
- else pprint("\n");
- if (wicaps.wChannels == 2) pprint(" stereo"); else pprint(" mono");
- if (wicaps.dwFormats & SRATE_11025_BITS) {pprint(", 11025"); need_comma = 1;}
- if (wicaps.dwFormats & SRATE_22050_BITS) {if (need_comma) pprint(", "); pprint(" 22050"); need_comma = 1;}
- if (wicaps.dwFormats & SRATE_44100_BITS) {if (need_comma) pprint(", "); pprint(" 44100"); need_comma = 1;}
- if (wicaps.dwFormats & BYTE_SAMPLE_BITS) {if (need_comma) pprint(", "); pprint(" unsigned byte"); need_comma = 1;}
- if (wicaps.dwFormats & SHORT_SAMPLE_BITS) {if (need_comma) pprint(", "); pprint(" little-endian short");}
- pprint("\n");
- }
- }
- }
- devs = auxGetNumDevs();
- if (devs > 0)
- {
- pprint("Auxiliary:\n");
- for (dev = 0; dev < devs; dev++)
- {
- err = auxGetDevCaps(dev, &wacaps, sizeof(wacaps));
- if (!err)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s", wacaps.szPname);
- pprint(audio_strbuf);
- if ((wacaps.wMid != maker) || (version != wacaps.vDriverVersion))
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, ": version %d.%d%s",
- (wacaps.vDriverVersion >> 8), wacaps.vDriverVersion & 0xff,
- (wacaps.wTechnology & AUXCAPS_CDAUDIO) ? " (CD)" : "");
- else mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s\n", (wacaps.wTechnology & AUXCAPS_CDAUDIO) ? " (CD)" : "");
- pprint(audio_strbuf);
- if (wacaps.dwSupport & AUXCAPS_VOLUME)
- {
- err = auxGetVolume(dev, &val);
- if (!err)
- {
- if (wacaps.dwSupport & AUXCAPS_LRVOLUME)
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- " vol: %.3f %.3f\n",
- unlog((unsigned short)(val >> 16)),
- unlog((unsigned short)(val & 0xffff)));
- else mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- " vol: %.3f\n",
- unlog((unsigned short)(val & 0xffff)));
- pprint(audio_strbuf);
- }
- }
- }
- }
- }
-#ifdef MIXERR_BASE
- devs = mixerGetNumDevs();
- if (devs > 0)
- {
- pprint("Mixer:\n");
- for (dev = 0; dev < devs; dev++)
- {
- err = mixerGetDevCaps(dev, &wmcaps, sizeof(wmcaps));
- if (!err)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s", wmcaps.szPname);
- pprint(audio_strbuf);
- if ((wmcaps.wMid != maker) || (version != wmcaps.vDriverVersion))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- ": version %d.%d\n",
- (wmcaps.vDriverVersion >> 8),
- wmcaps.vDriverVersion & 0xff);
- pprint(audio_strbuf);
- }
- else pprint("\n");
- dests = wmcaps.cDestinations;
-
- err = mixerOpen(&mfd, dev, 0, 0, CALLBACK_NULL);
- if (!err)
- {
- dest = 0;
- source = 0;
- dest_time = 1;
- happy = 1;
- while (happy)
- {
- if (dest_time)
- {
- mixline.dwDestination = dest;
- mixline.cbStruct = sizeof(MIXERLINE);
- err = mixerGetLineInfo((HMIXEROBJ)mfd, &mixline, MIXER_GETLINEINFOF_DESTINATION);
- }
- else
- {
- mixline.dwSource = source;
- mixline.cbStruct = sizeof(MIXERLINE);
- err = mixerGetLineInfo((HMIXEROBJ)mfd, &mixline, MIXER_GETLINEINFOF_SOURCE);
- }
- if (!err)
- {
- if ((source == 0) && (!dest_time)) pprint(" Sources:\n");
- if ((dest == 0) && (dest_time)) pprint(" Destinations:\n");
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s: %s (%s), %d chan%s",
- mixline.szName,
- mixer_component_name(mixline.dwComponentType),
- mixer_target_name(mixline.Target.dwType),
-
- mixline.cChannels, ((mixline.cChannels != 1) ? "s" : ""));
- pprint(audio_strbuf);
- if (mixline.cConnections > 0)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, ", %d connection%s",
- mixline.cConnections, ((mixline.cConnections != 1) ? "s" : ""));
- pprint(audio_strbuf);
- }
- if (dest_time)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s\n", mixer_status_name(mixline.fdwLine));
- pprint(audio_strbuf);
- }
- else pprint("\n");
- if (mixline.cControls > 0)
- {
- linecontrols.cbStruct = sizeof(MIXERLINECONTROLS);
- linecontrols.dwLineID = mixline.dwLineID;
- linecontrols.dwControlID = MIXER_GETLINECONTROLSF_ONEBYID;
- if (mixline.cControls > MAX_DESCRIBE_CONTROLS)
- linecontrols.cControls = MAX_DESCRIBE_CONTROLS;
- else linecontrols.cControls = mixline.cControls;
- linecontrols.pamxctrl = mc;
- linecontrols.cbmxctrl = sizeof(MIXERCONTROL);
- err = mixerGetLineControls((HMIXEROBJ)mfd, &linecontrols, MIXER_GETLINECONTROLSF_ALL);
- if (!err)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE,
- " %d control%s:\n",
- linecontrols.cControls,
- (linecontrols.cControls != 1) ? "s" : "");
- pprint(audio_strbuf);
- controls = linecontrols.cControls;
- if (controls > MAX_DESCRIBE_CONTROLS) controls = MAX_DESCRIBE_CONTROLS;
- for (control = 0; control < controls; control++)
- {
-
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s", mc[control].szName);
- pprint(audio_strbuf);
- controldetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
- controldetails.dwControlID = mc[control].dwControlID;
-
- ctype = (mc[control].dwControlType);
- if ((ctype == MIXERCONTROL_CONTROLTYPE_EQUALIZER) ||
- (ctype == MIXERCONTROL_CONTROLTYPE_MUX) ||
- (ctype == MIXERCONTROL_CONTROLTYPE_MIXER) ||
- (ctype == MIXERCONTROL_CONTROLTYPE_SINGLESELECT) ||
- (ctype == MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT))
- {
- controldetails.cChannels = 1;
- controldetails.cMultipleItems = mc[control].cMultipleItems;
- controldetails.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT);
- controldetails.paDetails = clist;
- err = mixerGetControlDetails((HMIXEROBJ)mfd, &controldetails, MIXER_GETCONTROLDETAILSF_LISTTEXT);
- if (!err)
- {
- for (chan = 0; chan < mixline.cChannels; chan++)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " [%s]", clist[chan].szName);
- pprint(audio_strbuf);
- }
- }
- }
- if (mixline.cChannels > MAX_DESCRIBE_CHANS)
- controldetails.cChannels = MAX_DESCRIBE_CHANS;
- else controldetails.cChannels = mixline.cChannels;
- controldetails.cMultipleItems = 0;
- err = 0;
- switch (mc[control].dwControlType & MIXERCONTROL_CT_UNITS_MASK)
- {
- case MIXERCONTROL_CT_UNITS_BOOLEAN:
- controldetails.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
- controldetails.paDetails = cbool;
- break;
- case MIXERCONTROL_CT_UNITS_SIGNED: case MIXERCONTROL_CT_UNITS_DECIBELS:
- controldetails.cbDetails = sizeof(MIXERCONTROLDETAILS_SIGNED);
- controldetails.paDetails = csign;
- break;
- case MIXERCONTROL_CT_UNITS_UNSIGNED: case MIXERCONTROL_CT_UNITS_PERCENT:
- controldetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
- controldetails.paDetails = cline;
- break;
- default: err = 1; break;
- }
- if (err)
- pprint("\n");
- else
- {
- err = mixerGetControlDetails((HMIXEROBJ)mfd, &controldetails, MIXER_GETCONTROLDETAILSF_VALUE);
- if (!err)
- {
- chans = controldetails.cChannels;
- if (chans > MAX_DESCRIBE_CHANS) chans = MAX_DESCRIBE_CHANS;
- switch (mc[control].dwControlType & MIXERCONTROL_CT_UNITS_MASK)
- {
- case MIXERCONTROL_CT_UNITS_BOOLEAN:
- for (chan = 0; chan < chans; chan++)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s", (cbool[chan].fValue) ? " on" : " off");
- pprint(audio_strbuf);
- }
- break;
- case MIXERCONTROL_CT_UNITS_SIGNED: case MIXERCONTROL_CT_UNITS_DECIBELS:
- mina = mc[control].Bounds.lMinimum;
- maxa = mc[control].Bounds.lMaximum;
- if (maxa > mina)
- {
- for (chan = 0; chan < chans; chan++)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.3f",
- (float)(csign[chan].lValue - mina) / (float)(maxa - mina));
- pprint(audio_strbuf);
- }
- }
- break;
- case MIXERCONTROL_CT_UNITS_UNSIGNED: case MIXERCONTROL_CT_UNITS_PERCENT:
- mina = mc[control].Bounds.dwMinimum;
- maxa = mc[control].Bounds.dwMaximum;
- if (maxa > mina)
- {
- for (chan = 0; chan < chans; chan++)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %.3f",
- (float)(cline[chan].dwValue - mina) / (float)(maxa - mina));
- pprint(audio_strbuf);
- }
- }
- break;
- default: break;
- }
- pprint("\n");
- }
- else pprint("\n");
- }
- }
- }
- }
- }
- else if (!dest_time) happy = 0;
- if (dest_time) dest++; else source++;
- if (dest == dests) dest_time = 0;
- }
- }
- mixerClose(mfd);
- }
- }
- }
-#endif
-}
-
-int mus_audio_initialize(void)
-{
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_close(int line)
-{
- int i;
- win_out_err = 0;
- win_in_err = 0;
- if (line == OUTPUT_LINE)
- {
- /* fill with a few zeros, wait for empty flag */
- if (sound_state != SOUND_UNREADY)
- {
- wait_for_empty_buffer(current_buf);
- for (i = 0; i < 128; i++) wh[current_buf].lpData[i] = 0;
- wait_for_empty_buffer(current_buf);
- win_out_err = waveOutClose(fd);
- i = 0;
- while (win_out_err == WAVERR_STILLPLAYING)
- {
- Sleep(1);
- win_out_err = waveOutClose(fd);
- i++;
- if (i > 1024) break;
- }
- db_state[0] = BUFFER_EMPTY;
- db_state[1] = BUFFER_EMPTY;
- sound_state = SOUND_UNREADY;
- waveOutUnprepareHeader(fd, &(wh[0]), sizeof(WAVEHDR));
- waveOutUnprepareHeader(fd, &(wh[1]), sizeof(WAVEHDR));
- FREE(wh[0].lpData);
- FREE(wh[1].lpData);
- if (win_out_err)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_CLOSE,
- mus_format("close failed on %d",
- line));
- }
- }
- else
- {
- if (line == INPUT_LINE)
- {
- if (rec_state != SOUND_UNREADY)
- {
- waveInReset(record_fd);
- waveInClose(record_fd);
- waveInUnprepareHeader(record_fd, &rec_wh, sizeof(WAVEHDR));
- if (rec_wh.lpData)
- {
- FREE(rec_wh.lpData);
- rec_wh.lpData = NULL;
- }
- rec_state = SOUND_UNREADY;
- }
- }
- else
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_CLOSE,
- mus_format("can't close unrecognized line %d",
- line));
- }
- return(MUS_NO_ERROR);
-}
-
- /*
- * waveInAddBuffer sends buffer to get data
- * MM_WIM_DATA lParam->WAVEHDR dwBytesRecorded =>how much data actually in buffer
- */
-
-static int current_record_chans = 0, current_record_datum_size = 0;
-
-DWORD CALLBACK next_input_buffer(HWAVEIN w, UINT msg, DWORD user_data, DWORD p1, DWORD p2)
-{
- if (msg == WIM_DATA)
- {
- /* grab data */
- /* p1->dwBytesRecorded */
- }
- return(0);
-}
-
-int mus_audio_open_input(int ur_dev, int srate, int chans, int format, int size)
-{
- WAVEFORMATEX wf;
- int dev;
- win_in_err = 0;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- wf.nChannels = chans;
- current_record_chans = chans;
-
- wf.wFormatTag = WAVE_FORMAT_PCM;
- wf.cbSize = 0;
- if (format == MUS_UBYTE)
- {
- wf.wBitsPerSample = 8;
- current_record_datum_size = 1;
- }
- else
- {
- wf.wBitsPerSample = 16;
- current_record_datum_size = 2;
- }
- wf.nSamplesPerSec = srate;
- wf.nBlockAlign = chans * current_datum_size;
- wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec;
-
- rec_wh.dwBufferLength = size * current_record_datum_size;
- rec_wh.dwFlags = 0;
- rec_wh.dwLoops = 0;
- rec_wh.lpData = (char *)CALLOC(rec_wh.dwBufferLength, sizeof(char));
- if ((rec_wh.lpData) == 0)
- RETURN_ERROR_EXIT(MUS_AUDIO_SIZE_NOT_AVAILABLE,
- mus_format("can't allocated %d bytes for input buffer of %d (%s)",
- size, dev, mus_audio_device_name(dev)));
- win_in_err = waveInOpen(&record_fd, WAVE_MAPPER, &wf, (DWORD)next_input_buffer, 0, CALLBACK_FUNCTION);
- if (win_in_err)
- {
- FREE(rec_wh.lpData);
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE,
- mus_format("can't open input device %d (%s)",
- dev, mus_audio_device_name(dev)));
- }
- win_in_err = waveInPrepareHeader(record_fd, &(rec_wh), sizeof(WAVEHDR));
- if (win_in_err)
- {
- FREE(rec_wh.lpData);
- waveInClose(record_fd);
- RETURN_ERROR_EXIT(MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- mus_format("can't prepare input 'header' for %d (%s)",
- dev, mus_audio_device_name(dev)));
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_read(int line, char *buf, int bytes)
-{
- win_in_err = 0;
- return(MUS_ERROR);
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- int dev, sys;
- unsigned long lval;
- MMRESULT err;
- sys = MUS_AUDIO_SYSTEM(ur_dev);
- dev = MUS_AUDIO_DEVICE(ur_dev);
- if (field == MUS_AUDIO_AMP)
- {
- err = auxGetVolume(sys, &lval);
- if (!err)
- {
- if (chan == 0)
- val[0] = unlog((unsigned short)(lval >> 16));
- else val[0] = unlog((unsigned short)(lval & 0xffff));
- return(MUS_NO_ERROR);
- }
- }
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ,
- mus_format("can't read device %d (%s) field %s",
- dev, mus_audio_device_name(dev),
- mus_audio_device_name(field)));
-}
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- int dev, sys;
- unsigned long lval;
- MMRESULT err;
- sys = MUS_AUDIO_SYSTEM(ur_dev);
- dev = MUS_AUDIO_DEVICE(ur_dev);
- if (field == MUS_AUDIO_AMP)
- {
- err = auxGetVolume(sys, &lval);
- if (!err)
- {
- if (chan == 0)
- lval = (unsigned long)((lval & 0xffff) | (((unsigned short)(val[0] * 65535)) << 16));
- else lval = (unsigned long)((lval & 0xffff0000) | ((unsigned short)(val[0] * 65535)));
- err = auxSetVolume(sys, lval);
- if (err) return(MUS_NO_ERROR);
- }
- }
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE,
- mus_format("can't set device %d (%s) field %s",
- dev, mus_audio_device_name(dev),
- mus_audio_device_name(field)));
-}
-
-#endif
-
-
-
-/* ------------------------------- OSX ----------------------------------------- */
-
-/* this code based primarily on the CoreAudio headers and portaudio pa_mac_core.c,
- * and to a much lesser extent, coreaudio.pdf and the HAL/Daisy examples.
- */
-
-#ifdef MUS_MAC_OSX
-#define AUDIO_OK 1
-
-/*
-#include <CoreServices/CoreServices.h>
-#include <CoreAudio/CoreAudio.h>
-*/
-/* ./System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h */
-
-static char* osx_error(OSStatus err)
-{
- if (err == noErr) return("no error");
- switch (err)
- {
- case kAudioHardwareNoError: return("no error"); break;
- case kAudioHardwareUnspecifiedError: return("unspecified audio hardware error"); break;
- case kAudioHardwareNotRunningError: return("audio hardware not running"); break;
- case kAudioHardwareUnknownPropertyError: return("unknown property"); break;
- case kAudioHardwareBadPropertySizeError: return("bad property"); break;
- case kAudioHardwareBadDeviceError: return("bad device"); break;
- case kAudioHardwareBadStreamError: return("bad stream"); break;
- case kAudioHardwareIllegalOperationError: return("illegal operation"); break;
- case kAudioDeviceUnsupportedFormatError: return("unsupported format"); break;
- case kAudioDevicePermissionsError: return("device permissions error"); break;
- }
- return("unknown error");
-}
-
-char *device_name(AudioDeviceID deviceID, int input_case)
-{
- OSStatus err = noErr;
- UInt32 size = 0, msize = 0, trans = 0, trans_size = 0;
- char *name = NULL, *mfg = NULL, *full_name = NULL;
- err = AudioDeviceGetPropertyInfo(deviceID, 0, false, kAudioDevicePropertyDeviceName, &size, NULL);
- if (err == noErr) err = AudioDeviceGetPropertyInfo(deviceID, 0, false, kAudioDevicePropertyDeviceManufacturer, &msize, NULL);
- if (err == noErr)
- {
- name = (char *)MALLOC(size + 2);
- err = AudioDeviceGetProperty(deviceID, 0, input_case, kAudioDevicePropertyDeviceName, &size, name);
- mfg = (char *)MALLOC(msize + 2);
- err = AudioDeviceGetProperty(deviceID, 0, input_case, kAudioDevicePropertyDeviceManufacturer, &msize, mfg);
- full_name = (char *)MALLOC(size + msize + 4);
-#if HAVE_KAUDIODEVICEPROPERTYTRANSPORTTYPE
- trans_size = sizeof(UInt32);
- err = AudioDeviceGetProperty(deviceID, 0, input_case, kAudioDevicePropertyTransportType, &trans_size, &trans);
- if (err != noErr)
-#endif
- trans = 0;
- if (trans == 0)
- mus_snprintf(full_name, size + msize + 4, "\n %s: %s", mfg, name);
- else mus_snprintf(full_name, size + msize + 4, "\n %s: %s ('%c%c%c%c')",
- mfg, name,
- (char)((trans >> 24) & 0xff), (char)((trans >> 16) & 0xff), (char)((trans >> 8) & 0xff), (char)(trans & 0xff));
- FREE(name);
- FREE(mfg);
- }
- return(full_name);
-}
-
-static int max_chans_via_stream_configuration(AudioDeviceID device, bool input_case)
-{
- /* apparently MOTU 828 has to be different (this code from portaudio) */
- UInt32 size = 0;
- Boolean writable;
- OSStatus err = noErr;
- err = AudioDeviceGetPropertyInfo(device, 0, input_case, kAudioDevicePropertyStreamConfiguration, &size, &writable);
- if (err == noErr)
- {
- AudioBufferList *list;
- list = (AudioBufferList *)malloc(size);
- err = AudioDeviceGetProperty(device, 0, input_case, kAudioDevicePropertyStreamConfiguration, &size, list);
- if (err == noErr)
- {
- int chans = 0, i;
- for (i = 0; i < list->mNumberBuffers; i++)
- chans += list->mBuffers[i].mNumberChannels;
- free(list);
- return(chans);
- }
- }
- return(-1);
-}
-
-static void describe_audio_state_1(void)
-{
- OSStatus err = noErr;
- UInt32 num_devices = 0, msize = 0, size = 0, buffer_size = 0, mute = 0, alive = 0;
- Float32 vol;
- int i, j, k;
- pid_t hogger = 0;
- AudioDeviceID *devices = NULL;
- AudioDeviceID device, default_output, default_input;
- AudioStreamBasicDescription desc;
- AudioStreamBasicDescription *descs = NULL;
- int formats = 0, m;
- bool input_case = false;
- err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &msize, NULL);
- if (err != noErr)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "get property info error: %s\n", osx_error(err));
- pprint(audio_strbuf);
- return;
- }
- num_devices = msize / sizeof(AudioDeviceID);
- if (num_devices <= 0)
- {
- pprint("no audio devices found");
- return;
- }
- devices = (AudioDeviceID *)MALLOC(msize);
- size = sizeof(AudioDeviceID);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, &default_input);
- if (err != noErr) default_input = 55555555; /* unsigned int -- I want some value that won't happen! */
- size = sizeof(AudioDeviceID);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &default_output);
- if (err != noErr) default_output = 55555555;
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &msize, (void *)devices);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "found %d audio device%s",
- (int)num_devices, (num_devices != 1) ? "s" : "");
- pprint(audio_strbuf);
- for (m = 0; m < 2; m++)
- {
- for (i = 0; i < num_devices; i++)
- {
- device = devices[i];
- pprint(device_name(device, input_case));
- if (input_case)
- {
- if (device == default_input)
- pprint(" (default input)");
- else pprint(" (input)");
- }
- else
- {
- if (device == default_output)
- pprint(" (default output)");
- else pprint(" (output)");
- }
- size = sizeof(pid_t);
- err = AudioDeviceGetProperty(device, 0, input_case, kAudioDevicePropertyHogMode, &size, &hogger);
- if ((err == noErr) && (hogger >= 0))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " currently owned (exclusively) by process %d", (int)hogger);
- pprint(audio_strbuf);
- }
- size = sizeof(UInt32);
- err = AudioDeviceGetProperty(device, 0, input_case, kAudioDevicePropertyDeviceIsAlive, &size, &alive);
- if ((err == noErr) && (alive == 0))
- pprint(" disconnected?");
- size = sizeof(UInt32);
- err = AudioDeviceGetProperty(device, 0, input_case, kAudioDevicePropertyBufferSize, &size, &buffer_size);
- if (err != noErr) buffer_size = 0;
- size = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceGetProperty(device, 0, input_case, kAudioDevicePropertyStreamFormat, &size, &desc);
- if (err == noErr)
- {
- int config_chans;
- unsigned int trans;
- trans = (unsigned int)(desc.mFormatID);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "\n srate: %d, chans: %d",
- (int)(desc.mSampleRate),
- (int)(desc.mChannelsPerFrame));
- pprint(audio_strbuf);
- config_chans = max_chans_via_stream_configuration(device, input_case);
- if ((config_chans > 0) && (config_chans != (int)(desc.mChannelsPerFrame)))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " (or %d?)", config_chans);
- pprint(audio_strbuf);
- }
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, ", bits/sample: %d, format: %c%c%c%c",
- (int)(desc.mBitsPerChannel),
- (trans >> 24) & 0xff, (trans >> 16) & 0xff, (trans >> 8) & 0xff, trans & 0xff);
- pprint(audio_strbuf);
- if (buffer_size > 0)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, ", buf: %d", (int)buffer_size);
- pprint(audio_strbuf);
- }
- if ((int)(desc.mFormatFlags) != 0) /* assuming "PCM" here */
- {
- int flags;
- flags = ((int)(desc.mFormatFlags));
- pprint("\n flags: ");
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s%s%s%s%s%s",
- (flags & kLinearPCMFormatFlagIsFloat) ? "float " : "",
- (flags & kLinearPCMFormatFlagIsBigEndian) ? "big-endian " : "",
- (flags & kLinearPCMFormatFlagIsSignedInteger) ? "signed-int " : "",
- (flags & kLinearPCMFormatFlagIsPacked) ? "packed " : "",
- (flags & kLinearPCMFormatFlagIsAlignedHigh) ? "aligned-high " : "",
-#if HAVE_KLINEARPCMFORMATFLAGISNONINTERLEAVED
- (flags & kLinearPCMFormatFlagIsNonInterleaved) ? "non-interleaved " : ""
-#else
- ""
-#endif
- );
- pprint(audio_strbuf);
- }
-
- if ((int)(desc.mChannelsPerFrame) > 0)
- {
- pprint("\n vols:");
- for (j = 0; j <= (int)(desc.mChannelsPerFrame); j++)
- {
- size = sizeof(Float32);
- err = AudioDeviceGetProperty(device, j, input_case, kAudioDevicePropertyVolumeScalar, &size, &vol);
- if (err == noErr)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s%.3f",
- (j == 0) ? "master: " : "",
- vol);
- pprint(audio_strbuf);
- }
-
- if (j > 0)
- {
- size = sizeof(UInt32);
- err = AudioDeviceGetProperty(device, j, input_case, kAudioDevicePropertyMute, &size, &mute);
- if ((err == noErr) && (mute == 1))
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " (muted)");
- pprint(audio_strbuf);
- }
- }
- }
- }
- }
- size = 0;
- err = AudioDeviceGetPropertyInfo(device, 0, input_case, kAudioDevicePropertyStreamFormats, &size, NULL);
- formats = size / sizeof(AudioStreamBasicDescription);
- if (formats > 1)
- {
- descs = (AudioStreamBasicDescription *)CALLOC(formats, sizeof(AudioStreamBasicDescription));
- size = formats * sizeof(AudioStreamBasicDescription);
- err = AudioDeviceGetProperty(device, 0, input_case, kAudioDevicePropertyStreamFormats, &size, descs);
- if (err == noErr)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "\n This device supports %d formats: ", formats);
- pprint(audio_strbuf);
- for (k = 0; k < formats; k++)
- {
- unsigned int trans;
- trans = (unsigned int)(descs[k].mFormatID);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "\n srate: %d, chans: %d, bits/sample: %d, format: %c%c%c%c",
- (int)(descs[k].mSampleRate),
- (int)(descs[k].mChannelsPerFrame),
- (int)(descs[k].mBitsPerChannel),
- (trans >> 24) & 0xff, (trans >> 16) & 0xff, (trans >> 8) & 0xff, trans & 0xff);
- pprint(audio_strbuf);
- }
- }
- FREE(descs);
- }
- pprint("\n");
- }
- input_case = true;
- }
- if (devices) FREE(devices);
-}
-
-#define MAX_BUFS 4
-static char **bufs = NULL;
-static int in_buf = 0, out_buf = 0;
-
-static OSStatus writer(AudioDeviceID inDevice,
- const AudioTimeStamp *inNow,
- const AudioBufferList *InputData, const AudioTimeStamp *InputTime,
- AudioBufferList *OutputData, const AudioTimeStamp *OutputTime,
- void *appGlobals)
-{
- AudioBuffer abuf;
- char *aplbuf, *sndbuf;
- abuf = OutputData->mBuffers[0];
- aplbuf = (char *)(abuf.mData);
- sndbuf = bufs[out_buf];
- memmove((void *)aplbuf, (void *)sndbuf, abuf.mDataByteSize);
- out_buf++;
- if (out_buf >= MAX_BUFS) out_buf = 0;
- return(noErr);
-}
-
-static OSStatus reader(AudioDeviceID inDevice,
- const AudioTimeStamp *inNow,
- const AudioBufferList *InputData, const AudioTimeStamp *InputTime,
- AudioBufferList *OutputData, const AudioTimeStamp *OutputTime,
- void *appGlobals)
-{
- AudioBuffer abuf;
- char *aplbuf, *sndbuf;
- abuf = InputData->mBuffers[0];
- aplbuf = (char *)(abuf.mData);
- sndbuf = bufs[out_buf];
- memmove((void *)sndbuf, (void *)aplbuf, abuf.mDataByteSize);
- out_buf++;
- if (out_buf >= MAX_BUFS) out_buf = 0;
- return(noErr);
-}
-
-
-static AudioDeviceID device = kAudioDeviceUnknown;
-static bool writing = false, open_for_input = false;
-
-int mus_audio_close(int line)
-{
- OSStatus err = noErr;
- UInt32 sizeof_running;
- UInt32 running;
- if (open_for_input)
- {
- in_buf = 0;
- err = AudioDeviceStop(device, (AudioDeviceIOProc)reader);
- if (err == noErr)
- err = AudioDeviceRemoveIOProc(device, (AudioDeviceIOProc)reader);
- }
- else
- {
- if ((in_buf > 0) && (!writing))
- {
- /* short enough sound that we never got started? */
- err = AudioDeviceAddIOProc(device, (AudioDeviceIOProc)writer, NULL);
- if (err == noErr)
- err = AudioDeviceStart(device, (AudioDeviceIOProc)writer); /* writer will be called right away */
- if (err == noErr)
- writing = true;
- }
- if (writing)
- {
- /* send out waiting buffers */
- sizeof_running = sizeof(UInt32);
- while (in_buf == out_buf)
- {
- err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyDeviceIsRunning, &sizeof_running, &running);
- }
- while (in_buf != out_buf)
- {
- err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyDeviceIsRunning, &sizeof_running, &running);
- }
- in_buf = 0;
- err = AudioDeviceStop(device, (AudioDeviceIOProc)writer);
- if (err == noErr)
- err = AudioDeviceRemoveIOProc(device, (AudioDeviceIOProc)writer);
- writing = false;
- }
- }
- device = kAudioDeviceUnknown;
- if (err == noErr)
- return(MUS_NO_ERROR);
- return(MUS_ERROR);
-}
-
-typedef enum {CONVERT_NOT, CONVERT_COPY, CONVERT_SKIP, CONVERT_COPY_AND_SKIP, CONVERT_SKIP_N, CONVERT_COPY_AND_SKIP_N} audio_convert_t;
-static audio_convert_t conversion_choice = CONVERT_NOT;
-static float conversion_multiplier = 1.0;
-static int dac_out_chans, dac_out_srate;
-static int incoming_out_chans = 1, incoming_out_srate = 44100;
-static int fill_point = 0;
-static unsigned int bufsize = 0, current_bufsize = 0;
-
-/* I'm getting bogus buffer sizes from the audio conversion stuff from Apple,
- * and I think AudioConvert doesn't handle cases like 4->6 chans correctly
- * so, I'll just do the conversions myself -- there is little need here
- * for non-integer srate conversion anyway, and the rest is trivial.
- */
-
-int mus_audio_open_output(int dev, int srate, int chans, int format, int size)
-{
- OSStatus err = noErr;
- UInt32 sizeof_device, sizeof_format, sizeof_bufsize;
- AudioStreamBasicDescription device_desc;
- sizeof_device = sizeof(AudioDeviceID);
- sizeof_bufsize = sizeof(unsigned int);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &sizeof_device, (void *)(&device));
- bufsize = 4096;
- if (err == noErr)
- err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyBufferSize, &sizeof_bufsize, &bufsize);
- if (err != noErr)
- {
- fprintf(stderr,"open audio output err: %d %s\n", (int)err, osx_error(err));
- return(MUS_ERROR);
- }
- /* now check for srate/chan mismatches and so on */
- sizeof_format = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyStreamFormat, &sizeof_format, &device_desc);
- if (err != noErr)
- {
- fprintf(stderr,"open audio output (get device format) err: %d %s\n", (int)err, osx_error(err));
- return(MUS_ERROR);
- }
- /* current DAC state: device_desc.mChannelsPerFrame, (int)(device_desc.mSampleRate) */
- /* apparently get stream format can return noErr but chans == 0?? */
- if ((device_desc.mChannelsPerFrame != chans) ||
- ((int)(device_desc.mSampleRate) != srate))
- {
- /* try to match DAC settings to current sound */
- device_desc.mChannelsPerFrame = chans;
- device_desc.mSampleRate = srate;
- device_desc.mBytesPerPacket = chans * 4; /* assume 1 frame/packet and float32 data */
- device_desc.mBytesPerFrame = chans * 4;
- sizeof_format = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceSetProperty(device, 0, 0, false, kAudioDevicePropertyStreamFormat, sizeof_format, &device_desc);
-
- /* this error is bogus in some cases -- other audio systems just ignore it,
- * but in my case (a standard MacIntel with no special audio hardware), if I leave
- * this block out, the sound is played back at the wrong rate, and the volume
- * of outa is set to 0.0??
- */
-
- if (err != noErr)
- {
- /* it must have failed for some reason -- look for closest match available */
- /* if srate = 22050 try 44100, if chans = 1 try 2 */
- /* the "get closest match" business appears to be completely bogus... */
- device_desc.mChannelsPerFrame = (chans == 1) ? 2 : chans;
- device_desc.mSampleRate = (srate == 22050) ? 44100 : srate;
- device_desc.mBytesPerPacket = device_desc.mChannelsPerFrame * 4; /* assume 1 frame/packet and float32 data */
- device_desc.mBytesPerFrame = device_desc.mChannelsPerFrame * 4;
- sizeof_format = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceSetProperty(device, 0, 0, false, kAudioDevicePropertyStreamFormat, sizeof_format, &device_desc);
- if (err != noErr)
- {
- sizeof_format = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyStreamFormatMatch, &sizeof_format, &device_desc);
- if (err == noErr)
- {
- /* match suggests: device_desc.mChannelsPerFrame, (int)(device_desc.mSampleRate) */
- /* try to set DAC to reflect that match */
- /* a bug here in emagic 2|6 -- we can get 6 channel match, but then can't set it?? */
- sizeof_format = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceSetProperty(device, 0, 0, false, kAudioDevicePropertyStreamFormat, sizeof_format, &device_desc);
- if (err != noErr)
- {
- /* no luck -- get current DAC settings at least */
- sizeof_format = sizeof(AudioStreamBasicDescription);
- AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyStreamFormat, &sizeof_format, &device_desc);
- }
- }
- }
- else
- {
- /* nothing matches? -- get current DAC settings */
- sizeof_format = sizeof(AudioStreamBasicDescription);
- AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyStreamFormat, &sizeof_format, &device_desc);
- }
- }
- }
- /* now DAC claims it is ready for device_desc.mChannelsPerFrame, (int)(device_desc.mSampleRate) */
- dac_out_chans = device_desc.mChannelsPerFrame; /* use better variable names */
- dac_out_srate = (int)(device_desc.mSampleRate);
- open_for_input = false;
- if ((bufs == NULL) || (bufsize > current_bufsize))
- {
- int i;
- if (bufs)
- {
- for (i = 0; i < MAX_BUFS; i++) FREE(bufs[i]);
- FREE(bufs);
- }
- bufs = (char **)CALLOC(MAX_BUFS, sizeof(char *));
- for (i = 0; i < MAX_BUFS; i++)
- bufs[i] = (char *)CALLOC(bufsize, sizeof(char));
- current_bufsize = bufsize;
- }
- in_buf = 0;
- out_buf = 0;
- fill_point = 0;
- incoming_out_srate = srate;
- incoming_out_chans = chans;
- if (incoming_out_chans == dac_out_chans)
- {
- if (incoming_out_srate == dac_out_srate)
- {
- conversion_choice = CONVERT_NOT;
- conversion_multiplier = 1.0;
- }
- else
- {
- /* here we don't get very fancy -- assume dac/2=in */
- conversion_choice = CONVERT_COPY;
- conversion_multiplier = 2.0;
- }
- }
- else
- {
- if (incoming_out_srate == dac_out_srate)
- {
- if ((dac_out_chans == 2) && (incoming_out_chans == 1)) /* the usual case */
- {
- conversion_choice = CONVERT_SKIP;
- conversion_multiplier = 2.0;
- }
- else
- {
- conversion_choice = CONVERT_SKIP_N;
- conversion_multiplier = ((float)dac_out_chans / (float)incoming_out_chans);
- }
- }
- else
- {
- if ((dac_out_chans == 2) && (incoming_out_chans == 1)) /* the usual case */
- {
- conversion_choice = CONVERT_COPY_AND_SKIP;
- conversion_multiplier = 4.0;
- }
- else
- {
- conversion_choice = CONVERT_COPY_AND_SKIP_N;
- conversion_multiplier = ((float)dac_out_chans / (float)incoming_out_chans) * 2;
- }
- }
- }
- return(MUS_NO_ERROR);
-}
-
-static void convert_incoming(char *to_buf, int fill_point, int lim, char *buf)
-{
- int i, j, k, jc, kc, ic;
- switch (conversion_choice)
- {
- case CONVERT_NOT:
- /* no conversion needed */
- for (i = 0; i < lim; i++)
- to_buf[i + fill_point] = buf[i];
- break;
- case CONVERT_COPY:
- /* copy sample to mimic lower srate */
- for (i = 0, j = fill_point; i < lim; i += 8, j += 16)
- for (k = 0; k < 8; k++)
- {
- to_buf[j + k] = buf[i + k];
- to_buf[j + k + 8] = buf[i + k];
- }
- break;
- case CONVERT_SKIP:
- /* skip sample for empty chan */
- for (i = 0, j = fill_point; i < lim; i += 4, j += 8)
- for (k = 0; k < 4; k++)
- {
- to_buf[j + k] = buf[i + k];
- to_buf[j + k + 4] = 0;
- }
- break;
- case CONVERT_SKIP_N:
- /* copy incoming_out_chans then skip up to dac_out_chans */
- jc = dac_out_chans * 4;
- ic = incoming_out_chans * 4;
- for (i = 0, j = fill_point; i < lim; i += ic, j += jc)
- {
- for (k = 0; k < ic; k++) to_buf[j + k] = buf[i + k];
- for (k = ic; k < jc; k++) to_buf[j + k] = 0;
- }
- break;
- case CONVERT_COPY_AND_SKIP:
- for (i = 0, j = fill_point; i < lim; i += 4, j += 16)
- for (k = 0; k < 4; k++)
- {
- to_buf[j + k] = buf[i + k];
- to_buf[j + k + 4] = 0;
- to_buf[j + k + 8] = buf[i + k];
- to_buf[j + k + 12] = 0;
- }
- break;
- case CONVERT_COPY_AND_SKIP_N:
- /* copy for each active chan, skip rest */
- jc = dac_out_chans * 8;
- ic = incoming_out_chans * 4;
- kc = dac_out_chans * 4;
- for (i = 0, j = fill_point; i < lim; i += ic, j += jc)
- {
- for (k = 0; k < ic; k++)
- {
- to_buf[j + k] = buf[i + k];
- to_buf[j + k + kc] = buf[i + k];
- }
- for (k = ic; k < kc; k++)
- {
- to_buf[j + k] = 0;
- to_buf[j + k + kc] = 0;
- }
- }
- break;
- }
-}
-
-int mus_audio_write(int line, char *buf, int bytes)
-{
- OSStatus err = noErr;
- int lim, bp, out_bytes;
- UInt32 sizeof_running;
- UInt32 running;
- char *to_buf;
- to_buf = bufs[in_buf];
- out_bytes = (int)(bytes * conversion_multiplier);
- if ((fill_point + out_bytes) > bufsize)
- out_bytes = bufsize - fill_point;
- lim = (int)(out_bytes / conversion_multiplier);
- if (!writing)
- {
- convert_incoming(to_buf, fill_point, lim, buf);
- fill_point += out_bytes;
- if (fill_point >= bufsize)
- {
- in_buf++;
- fill_point = 0;
- if (in_buf == MAX_BUFS)
- {
- in_buf = 0;
- err = AudioDeviceAddIOProc(device, (AudioDeviceIOProc)writer, NULL);
- if (err == noErr)
- err = AudioDeviceStart(device, (AudioDeviceIOProc)writer); /* writer will be called right away */
- if (err == noErr)
- {
- writing = true;
- return(MUS_NO_ERROR);
- }
- else return(MUS_ERROR);
- }
- }
- return(MUS_NO_ERROR);
- }
- if ((fill_point == 0) && (in_buf == out_buf))
- {
- bp = out_buf;
- sizeof_running = sizeof(UInt32);
- while (bp == out_buf)
- {
- /* i.e. just kill time without hanging */
- err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyDeviceIsRunning, &sizeof_running, &running);
- /* usleep(10); */
- }
- }
- to_buf = bufs[in_buf];
- if (fill_point == 0) memset((void *)to_buf, 0, bufsize);
- convert_incoming(to_buf, fill_point, lim, buf);
- fill_point += out_bytes;
- if (fill_point >= bufsize)
- {
- in_buf++;
- fill_point = 0;
- if (in_buf >= MAX_BUFS) in_buf = 0;
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_open_input(int dev, int srate, int chans, int format, int size)
-{
- OSStatus err = noErr;
- UInt32 sizeof_device;
- UInt32 sizeof_bufsize;
- sizeof_device = sizeof(AudioDeviceID);
- sizeof_bufsize = sizeof(unsigned int);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &sizeof_device, (void *)(&device));
- bufsize = 4096;
- if (err == noErr)
- err = AudioDeviceGetProperty(device, 0, true, kAudioDevicePropertyBufferSize, &sizeof_bufsize, &bufsize);
- if (err != noErr)
- {
- fprintf(stderr,"open audio input err: %d %s\n", (int)err, osx_error(err));
- return(MUS_ERROR);
- }
- open_for_input = true;
- /* assume for now that recorder (higher level) will enforce match */
- if ((bufs == NULL) || (bufsize > current_bufsize))
- {
- int i;
- if (bufs)
- {
- for (i = 0; i < MAX_BUFS; i++) FREE(bufs[i]);
- FREE(bufs);
- }
- bufs = (char **)CALLOC(MAX_BUFS, sizeof(char *));
- for (i = 0; i < MAX_BUFS; i++)
- bufs[i] = (char *)CALLOC(bufsize, sizeof(char));
- current_bufsize = bufsize;
- }
- in_buf = 0;
- out_buf = 0;
- fill_point = 0;
- incoming_out_srate = srate;
- incoming_out_chans = chans;
- err = AudioDeviceAddIOProc(device, (AudioDeviceIOProc)reader, NULL);
- if (err == noErr)
- err = AudioDeviceStart(device, (AudioDeviceIOProc)reader);
- if (err != noErr)
- {
- fprintf(stderr,"add open audio input err: %d %s\n", (int)err, osx_error(err));
- return(MUS_ERROR);
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_read(int line, char *buf, int bytes)
-{
- OSStatus err = noErr;
- int bp;
- UInt32 sizeof_running;
- UInt32 running;
- char *to_buf;
- if (in_buf == out_buf)
- {
- bp = out_buf;
- sizeof_running = sizeof(UInt32);
- while (bp == out_buf)
- {
- err = AudioDeviceGetProperty(device, 0, true, kAudioDevicePropertyDeviceIsRunning, &sizeof_running, &running);
- if (err != noErr)
- fprintf(stderr,"wait err: %s ", osx_error(err));
- }
- }
- to_buf = bufs[in_buf];
- if (bytes <= bufsize)
- memmove((void *)buf, (void *)to_buf, bytes);
- else memmove((void *)buf, (void *)to_buf, bufsize);
- in_buf++;
- if (in_buf >= MAX_BUFS) in_buf = 0;
- return(MUS_ERROR);
-}
-
-static int max_chans(AudioDeviceID device, int input)
-{
- int maxc = 0, formats, k, config_chans;
- UInt32 size;
- OSStatus err;
- AudioStreamBasicDescription desc;
- AudioStreamBasicDescription *descs;
- size = sizeof(AudioStreamBasicDescription);
- err = AudioDeviceGetProperty(device, 0, input, kAudioDevicePropertyStreamFormat, &size, &desc);
- if (err == noErr)
- {
- maxc = (int)(desc.mChannelsPerFrame);
- size = 0;
- err = AudioDeviceGetPropertyInfo(device, 0, input, kAudioDevicePropertyStreamFormats, &size, NULL);
- formats = size / sizeof(AudioStreamBasicDescription);
- if (formats > 1)
- {
- descs = (AudioStreamBasicDescription *)CALLOC(formats, sizeof(AudioStreamBasicDescription));
- size = formats * sizeof(AudioStreamBasicDescription);
- err = AudioDeviceGetProperty(device, 0, input, kAudioDevicePropertyStreamFormats, &size, descs);
- if (err == noErr)
- for (k = 0; k < formats; k++)
- if ((int)(descs[k].mChannelsPerFrame) > maxc) maxc = (int)(descs[k].mChannelsPerFrame);
- FREE(descs);
- }
- }
- else fprintf(stderr, "read chans hit: %s\n", osx_error(err));
- config_chans = max_chans_via_stream_configuration(device, input);
- if (config_chans > maxc) return(config_chans);
- return(maxc);
-}
-
-int mus_audio_mixer_read(int dev1, int field, int chan, float *val)
-{
- AudioDeviceID dev = kAudioDeviceUnknown;
- OSStatus err = noErr;
- UInt32 size;
- Float32 amp;
- int i, curdev;
- bool in_case = false;
- switch (field)
- {
- case MUS_AUDIO_AMP:
- size = sizeof(AudioDeviceID);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &dev);
- size = sizeof(Float32);
- err = AudioDeviceGetProperty(dev, chan + 1, false, kAudioDevicePropertyVolumeScalar, &size, &amp);
- if (err == noErr)
- val[0] = (Float)amp;
- else val[0] = 0.0;
- break;
- case MUS_AUDIO_CHANNEL:
- curdev = MUS_AUDIO_DEVICE(dev1);
- size = sizeof(AudioDeviceID);
- in_case = ((curdev == MUS_AUDIO_MICROPHONE) || (curdev == MUS_AUDIO_LINE_IN));
- if (in_case)
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, &dev);
- else err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &dev);
- if (err != noErr) fprintf(stderr, "get default: %s\n", osx_error(err));
- val[0] = max_chans(dev, in_case);
- break;
- case MUS_AUDIO_SRATE:
- val[0] = 44100;
- break;
- case MUS_AUDIO_FORMAT:
- /* never actually used except perhaps play.scm */
- val[0] = 1.0;
-#if MUS_LITTLE_ENDIAN
- val[1] = MUS_LFLOAT;
-#else
- val[1] = MUS_BFLOAT;
-#endif
- break;
- case MUS_AUDIO_PORT:
- i = 0;
- if (1 < chan) val[1] = MUS_AUDIO_MICROPHONE;
- if (2 < chan) val[2] = MUS_AUDIO_DAC_OUT;
- val[0] = 2;
- break;
- case MUS_AUDIO_SAMPLES_PER_CHANNEL:
- /* bufsize / 16: mulaw 22050 mono -> float 44100 stereo => 16:1 expansion */
- {
- int bufsize = 4096;
- UInt32 sizeof_bufsize;
- sizeof_bufsize = sizeof(unsigned int);
- curdev = MUS_AUDIO_DEVICE(dev1);
- size = sizeof(AudioDeviceID);
- in_case = ((curdev == MUS_AUDIO_MICROPHONE) || (curdev == MUS_AUDIO_LINE_IN));
- if (in_case)
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, &dev);
- else err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &dev);
- if (err != noErr)
- fprintf(stderr, "get samps/chan: %s\n", osx_error(err));
- else
- {
- err = AudioDeviceGetProperty(dev, 0, true, kAudioDevicePropertyBufferSize, &sizeof_bufsize, &bufsize);
- if (err == noErr) val[0] = (float)(bufsize / 16);
- }
- }
- break;
- default:
- return(MUS_ERROR);
- break;
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_mixer_write(int dev1, int field, int chan, float *val)
-{
- AudioDeviceID dev = kAudioDeviceUnknown;
- OSStatus err = noErr;
- Boolean writable;
- UInt32 size;
- Float32 amp;
- switch (field)
- {
- case MUS_AUDIO_AMP:
- size = sizeof(AudioDeviceID);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, (void *)(&dev));
- err = AudioDeviceGetPropertyInfo(dev, chan + 1, false, kAudioDevicePropertyVolumeScalar, NULL, &writable); /* "false" -> output */
- amp = (Float32)(val[0]);
- if ((err == kAudioHardwareNoError) && (writable))
- err = AudioDeviceSetProperty(dev, NULL, chan + 1, false, kAudioDevicePropertyVolumeScalar, sizeof(Float32), &amp);
- break;
- default:
- return(MUS_ERROR);
- break;
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_initialize(void) {return(MUS_NO_ERROR);}
-int mus_audio_systems(void) {return(1);}
-char *mus_audio_system_name(int system) {return("Mac OSX");}
-
-char *mus_audio_moniker(void) {return("Mac OSX audio");}
-#endif
-
-
-
-/* -------------------------------- ESD -------------------------------- */
-
-/* ESD audio IO for Linux *
- * Nick Bailey <nick@bailey-family.org.uk> *
- * also n.bailey@elec.gla.ac.uk */
-
-/* ESD is pretty well undocumented, and I've not looked at snd before, *
- * but here goes... *
- * *
- * History: *
- * 14th Nov 2000: copied SUN drivers here and started to hack. NJB. *
- * */
-
-#ifdef MUS_ESD
-#define AUDIO_OK
-
-#include <esd.h>
-
-static int esd_play_sock = -1;
-static int esd_rec_sock = -1;
-static char esd_name[] = "Enlightened Sound Daemon";
-static int swap_end, resign; /* How to handle samples on write */
-
-int mus_audio_initialize(void) {return(MUS_NO_ERROR);}
-int mus_audio_systems(void) {return(1);}
-char *mus_audio_system_name(int system) {return esd_name;}
-static char our_name[LABEL_BUFFER_SIZE];
-char *mus_audio_moniker(void)
-{
-#ifdef MUS_ESD_VERSION
- #ifdef MUS_AUDIOFILE_VERSION
- mus_snprintf(our_name, LABEL_BUFFER_SIZE, "%s: %s (Audiofile %s)", esd_name, MUS_ESD_VERSION, MUS_AUDIOFILE_VERSION);
- #else
- mus_snprintf(our_name, LABEL_BUFFER_SIZE, "%s: %s", esd_name, MUS_ESD_VERSION);
- #endif
- return(our_name);
-#else
- return(esd_name);
-#endif
-}
-
-int mus_audio_api(void) {return(0);}
-
-#define RETURN_ERROR_EXIT(Error_Type, Audio_Line, Ur_Error_Message) \
- do { char *Error_Message; Error_Message = Ur_Error_Message; \
- if (esd_play_sock != -1) close(esd_play_sock); \
- if (esd_rec_sock != -1) close(esd_rec_sock); \
- if (Error_Message) \
- {MUS_STANDARD_ERROR(Error_Type, Error_Message); FREE(Error_Message);} \
- else MUS_STANDARD_ERROR(Error_Type, mus_error_type_to_string(Error_Type)); \
- return(MUS_ERROR); \
- } while (false)
-
-/* No we're laughing. snd think's its talking to a real piece of hardware
- so it'll only try to open it once. We can just use the socket numbers */
-
-/* REVOLTING HACK! to_esd_format is called from mus_audio_open, and
- /as a side effect/, sets a flag to tell the write routine whether
- or not to change the endienness of the audio sample data (afaik,
- esd can't do this for us). Same goes for signed-ness.
- If it gets called from elsewhere, it could be nasty. */
-
-static int to_esd_format(int snd_format)
-{
- /* Try this on the Macs: it may be esd expects Bigendian on those */
- switch (snd_format) { /* Only some are supported */
- case MUS_UBYTE: swap_end = 0; resign = 0; return ESD_BITS8;
- case MUS_LSHORT: swap_end = 0; resign = 0; return ESD_BITS16;
- case MUS_BSHORT: swap_end = 1; resign = 0; return ESD_BITS16;
- case MUS_ULSHORT: swap_end = 0; resign = 1; return ESD_BITS16;
- case MUS_UBSHORT: swap_end = 1; resign = 1; return ESD_BITS16;
- }
- return MUS_ERROR;
-}
-
-int mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size)
-{
- int esd_prop = ESD_STREAM;
- int esd_format;
-
- if ((esd_format = to_esd_format(format)) == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_out,
- mus_format("Can't handle format %d (%s) through esd",
- format, mus_data_format_name(format)));
- else
- esd_prop |= esd_format;
-
- if (chans < 1 || chans > 2)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_out,
- mus_format("Can't handle format %d channels through esd",
- format));
- else
- esd_prop |= chans == 1 ? ESD_MONO : ESD_STEREO;
-
- esd_play_sock = esd_play_stream(esd_prop, srate,
- NULL, "snd playback stream");
-
- if (esd_play_sock == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, audio_out,
- mus_format("Sonorus device %d (%s) not available",
- ur_dev, mus_audio_device_name(ur_dev)));
- else
- return esd_play_sock;
-}
-
-int mus_audio_write(int line, char *buf, int bytes)
-{
- int written;
- char *to = buf;
-
- /* Esd can't do endianness or signed/unsigned conversion,
- so it's our problem. We won't screw up the callers data */
-
- if (swap_end) {
- char *from = buf;
- char *p;
- int samps = bytes/2;
- p = to = (char *)alloca(bytes);
- while (samps--) {
- *p++ = *(from+1);
- *p++ = *(from);
- from += 2;
- }
- }
-
- /* Need to do something about sign correction here */
-
- do {
- written = write(line, to, bytes);
- if (written > 0) {
- bytes -= written;
- to += written;
- }
- else
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("write error: %s", strerror(errno)));
- } while (bytes > 0);
- return MUS_NO_ERROR;
-}
-
-int mus_audio_close(int line)
-{
- esd_close(line);
- if (esd_play_sock == line) esd_play_sock = -1;
- else if (esd_rec_sock == line) esd_rec_sock = -1;
- return MUS_NO_ERROR;
-}
-
-int mus_audio_read(int line, char *buf, int bytes)
-{
- int bytes_read;
-
- do {
- bytes_read = read(line, buf, bytes);
- if (bytes_read > 0) { /* 0 -> EOF; we'll regard that as an error */
- bytes -= bytes_read;
- buf += bytes_read;
- } else
- RETURN_ERROR_EXIT(MUS_AUDIO_WRITE_ERROR, -1,
- mus_format("read error: %s", strerror(errno)));
- } while (bytes > 0);
- return MUS_NO_ERROR;
-}
-
-int mus_audio_open_input(int ur_dev, int srate, int chans, int format, int size)
-{
- int esd_prop = ESD_STREAM;
- int esd_format;
-
- if ((esd_format = to_esd_format(format)) == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, audio_out,
- mus_format("Can't handle format %d (%s) through esd",
- format, mus_data_format_name(format)));
- else
- esd_prop |= esd_format;
-
- if (chans < 1 || chans > 2)
- RETURN_ERROR_EXIT(MUS_AUDIO_CHANNELS_NOT_AVAILABLE, audio_out,
- mus_format("Can't handle format %d channels through esd",
- chans));
- else
- esd_prop |= chans == 1 ? ESD_MONO : ESD_STEREO;
-
- esd_rec_sock = esd_play_stream(esd_prop, srate,
- NULL, "snd record stream");
-
- if (esd_rec_sock == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_DEVICE_NOT_AVAILABLE, audio_out,
- mus_format("Device %d (%s) not available",
- ur_dev, mus_audio_device_name(ur_dev)));
- else
- return esd_rec_sock;
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- /* Not really sure what to do here. Mixer is at the other end of the
- socket. Needs work. NJB */
-
- /* int card = MUS_AUDIO_SYSTEM(ur_dev); */
- int device = MUS_AUDIO_DEVICE(ur_dev);
-
- if (device == MUS_AUDIO_MIXER) {
- val[0] = 0.0;
- return MUS_NO_ERROR;
- }
-
- if (field == MUS_AUDIO_PORT) {
- val[0] = 1.0;
- return MUS_NO_ERROR;
- }
-
- switch (field) {
- case MUS_AUDIO_AMP:
- /* amplitude value */
- val[0] = 1.0;
- break;
- case MUS_AUDIO_SAMPLES_PER_CHANNEL:
- val[0] = 44100;
- break;
- case MUS_AUDIO_CHANNEL:
- /* number of channels */
- val[0] = 2.0;
- if (chan > 1) {
- val[1] = 1.0;
- val[2] = 2.0;
- }
- break;
- case MUS_AUDIO_SRATE:
- /* supported sample rates */
- val[0] = 44100;
- if (chan > 1) {
- val[1] = 8000;
- val[2] = 48000;
- }
- break;
- case MUS_AUDIO_FORMAT:
- /* supported formats (ugly...) */
- val[0] = 3.0;
- val[1] = MUS_UBYTE;
- val[2] = MUS_LSHORT;
- val[3] = MUS_BSHORT;
- break;
-
- case MUS_AUDIO_DIRECTION: /* Needs sorting. NJB */
- /* 0-->playback, 1-->capture */
- val[0] = 0;
- break;
-
- default:
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, -1, NULL);
- /* return(mus_error(MUS_AUDIO_CANT_READ, NULL)); */ /* Bill 14-Nov-02 -- avoid possibly uncaught throw */
- break;
- }
- return(MUS_NO_ERROR);
-}
-
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- /* Ditto */
- val[0] = 0.0;
- return MUS_NO_ERROR;
-}
-
-/* pause can be implemented with play.pause and record.pause */
-
-
-void describe_audio_state_1(void)
-{
- pprint("Enlightened Sound Daemon via socket connexion to default host");
-}
-
-#endif
-
-
-/* ------------------------------- JACK ----------------------------------------- */
-
-/* Kjetil S. Matheussen. k.s.matheussen@notam02.no */
-/* Based on code from ceres. */
-
-#if HAVE_JACK
-#define AUDIO_OK
-#include <jack/jack.h>
-#include <samplerate.h>
-#include <sys/mman.h>
-#include <signal.h>
-
-#if MUS_LITTLE_ENDIAN
-# define MUS_COMP_SHORT MUS_LSHORT
-# define MUS_COMP_FLOAT MUS_LFLOAT
-#else
-# define MUS_COMP_SHORT MUS_BSHORT
-# define MUS_COMP_FLOAT MUS_BFLOAT
-#endif
-
-#define SRC_QUALITY SRC_SINC_BEST_QUALITY
-
-/*************/
-/* Jack Part */
-/*************/
-
-#define SNDJACK_NUMINCHANNELS 4
-
-#define SNDJACK_MAXSNDS 20
-
-#define SNDJACK_BUFFERSIZE 32768
-
-typedef jack_default_audio_sample_t sample_t;
-typedef jack_nframes_t nframes_t;
-
-struct SndjackChannel{
- jack_port_t *port;
- sample_t *buffer;
-};
-
-static jack_client_t *sndjack_client = NULL;
-
-
-/*************************/
-/* Variables for reading */
-/*************************/
-static int sndjack_num_read_channels_allocated=0;
-static int sndjack_num_read_channels_inuse=0;
-static struct SndjackChannel *sndjack_read_channels=NULL;
-static pthread_cond_t sndjack_read_cond= PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t sndjack_read_mutex= PTHREAD_MUTEX_INITIALIZER;
-static int sj_r_buffersize=0;
-static int sj_r_writeplace=0;
-static int sj_r_readplace=0;
-static int sj_r_unread=0;
-static int sj_r_xrun=0;
-static int sj_r_totalxrun=0;
-
-/*************************/
-/* Variables for writing */
-/*************************/
-static pthread_cond_t sndjack_cond= PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t sndjack_mutex= PTHREAD_MUTEX_INITIALIZER;
-
-enum{SJ_STOPPED,SJ_RUNNING,SJ_ABOUTTOSTOP};
-
-// Variables for the ringbuffer:
-static int sj_writeplace=0;
-static int sj_readplace=0;
-static int sj_unread=0;
-static int sj_buffersize;
-static int sj_jackbuffersize; // number of frames sent to sndjack_process.
-static int sj_totalxrun=0;
-static int sj_xrun=0;
-static int sj_status=SJ_STOPPED;
-
-static int sndjack_num_channels_allocated=0;
-static int sndjack_num_channels_inuse=0;
-static struct SndjackChannel *sndjack_channels=NULL;
-static int sndjack_read_format;
-
-static SRC_STATE **sndjack_srcstates;
-static double sndjack_srcratio=1.0;
-
-static int jack_mus_watchdog_counter=0;
-
-
-#define SJ_MAX(a,b) (((a)>(b))?(a):(b))
-
-static void sndjack_read_process(jack_nframes_t nframes){
- int i,ch;
- sample_t *out[sndjack_num_channels_allocated];
-
- if(sndjack_num_read_channels_inuse==0) return;
-
- for(ch=0;ch<sndjack_num_read_channels_allocated;ch++){
- out[ch]=(sample_t*)jack_port_get_buffer(sndjack_read_channels[ch].port,nframes);
- }
-
- for(i=0;i<nframes;i++){
- if(sj_r_unread==sj_buffersize){
- sj_r_xrun+=nframes-i;
- goto exit;
- }
- for(ch=0;ch<sndjack_num_read_channels_inuse;ch++)
- sndjack_read_channels[ch].buffer[sj_r_writeplace]=out[ch][i];
- sj_r_unread++;
- sj_r_writeplace++;
- if(sj_r_writeplace==sj_r_buffersize)
- sj_r_writeplace=0;
- }
- exit:
- pthread_cond_broadcast(&sndjack_read_cond);
-}
-
-
-static void sndjack_write_process(jack_nframes_t nframes){
- int ch,i;
- sample_t *out[sndjack_num_channels_allocated];
-
- for(ch=0;ch<sndjack_num_channels_allocated;ch++){
- out[ch]=(sample_t*)jack_port_get_buffer(sndjack_channels[ch].port,nframes);
- }
-
- if(sj_status==SJ_STOPPED){
- for(ch=0;ch<sndjack_num_channels_allocated;ch++){
- memset(out[ch],0,nframes*sizeof(sample_t));
- }
- }else{
-
- // First null out unused channels, if any.
- if(sndjack_num_channels_inuse==1 && sndjack_num_channels_allocated>=2){
- for(ch=2;ch<sndjack_num_channels_allocated;ch++){
- memset(out[ch],0,nframes*sizeof(sample_t));
- }
- }else{
- for(ch=sndjack_num_channels_inuse;ch<sndjack_num_channels_allocated;ch++){
- memset(out[ch],0,nframes*sizeof(sample_t));
- }
- }
-
- for(i=0;i<nframes;i++){
- if(sj_unread==0){
- if(sj_status==SJ_RUNNING)
- sj_xrun+=nframes-i;
- for(;i<nframes;i++){
- for(ch=0;ch<sndjack_num_channels_inuse;ch++){
- out[ch][i]=0.0f;
- }
- }
- break;
- }
-
- if(sndjack_num_channels_inuse==1 && sndjack_num_channels_allocated>=2){
- for(ch=0;ch<2;ch++){
- out[ch][i]=sndjack_channels[0].buffer[sj_readplace];
- }
- }else{
- for(ch=0;ch<sndjack_num_channels_inuse;ch++){
- out[ch][i]=sndjack_channels[ch].buffer[sj_readplace];
- }
- }
- sj_unread--;
- sj_readplace++;
- if(sj_readplace==sj_buffersize)
- sj_readplace=0;
- }
-
- pthread_cond_broadcast(&sndjack_cond);
-
- if(sj_status==SJ_ABOUTTOSTOP && sj_unread==0)
- sj_status=SJ_STOPPED;
- }
-
-}
-
-
-
-static int sndjack_process(jack_nframes_t nframes, void *arg){
- sndjack_read_process(nframes);
- sndjack_write_process(nframes);
- return 0;
-}
-
-
-static int sndjack_read(void *buf,int bytes,int chs){
- int i,ch;
- int nframes=bytes /
- sndjack_read_format==MUS_COMP_FLOAT ? sizeof(float) :
- sndjack_read_format==MUS_COMP_SHORT ? sizeof(short) :
- 1;
- float *buf_f=buf;
- short *buf_s=buf;
- char *buf_c=buf;
-
- for(i=0;i<nframes;i++){
- while(sj_r_unread==0){
- pthread_cond_wait(&sndjack_read_cond,&sndjack_read_mutex);
- jack_mus_watchdog_counter++;
- }
-
- if(sj_r_xrun>0){
- sj_r_totalxrun+=sj_r_xrun;
- sj_r_xrun=0;
- return -1;
- }
- for(ch=0;ch<chs;ch++){
- switch(sndjack_read_format){
- case MUS_BYTE:
- buf_c[i*chs+ch]=sndjack_read_channels[ch].buffer[sj_r_readplace] * 127.9f;
- break;
- case MUS_COMP_SHORT:
- buf_s[i*chs+ch]=sndjack_read_channels[ch].buffer[sj_r_readplace] * 32767.9f;
- break;
- case MUS_COMP_FLOAT:
- buf_f[i*chs+ch]=sndjack_read_channels[ch].buffer[sj_r_readplace];
- break;
- }}
- sj_r_unread--;
- sj_r_readplace++;
- if(sj_r_readplace==sj_r_buffersize)
- sj_r_readplace=0;
- }
- return 0;
-}
-
-static void sndjack_write(sample_t **buf,int nframes,int latencyframes,int chs){
- int ch;
- int i;
-
- if(sj_xrun>0){
- if(sj_status==SJ_RUNNING){
- printf("Warning. %d frames delayed.\n",sj_xrun);
- sj_totalxrun+=sj_xrun;
- }
- sj_xrun=0;
- }
-
- for(i=0;i<nframes;i++){
- while(
- sj_status==SJ_RUNNING
- && (sj_unread==sj_buffersize
- || sj_unread >= SJ_MAX(sj_jackbuffersize*2, latencyframes))
- )
- {
- jack_mus_watchdog_counter++;
- pthread_cond_wait(&sndjack_cond,&sndjack_mutex);
- }
-
- for(ch=0;ch<chs;ch++)
- sndjack_channels[ch].buffer[sj_writeplace]=buf[ch][i];
-
- sj_unread++;
- sj_writeplace++;
- if(sj_writeplace==sj_buffersize)
- sj_writeplace=0;
- }
-
- if(sj_status==SJ_STOPPED)
- if(sj_unread>=sj_jackbuffersize)
- sj_status=SJ_RUNNING;
-}
-
-static int sndjack_buffersizecallback(jack_nframes_t nframes, void *arg){
- sj_jackbuffersize=nframes;
- return 0;
-}
-
-static int sndjack_getnumoutchannels(void){
- int lokke=0;
- const char **ports=jack_get_ports(sndjack_client,NULL,NULL,JackPortIsPhysical|JackPortIsInput);
- while(ports!=NULL && ports[lokke]!=NULL){
- lokke++;
- }
- if(lokke<2) return 2;
- return lokke;
-}
-
-static int sndjack_getnuminchannels(void){
- int lokke=0;
- const char **ports=jack_get_ports(sndjack_client,NULL,NULL,JackPortIsPhysical|JackPortIsOutput);
- while(ports!=NULL && ports[lokke]!=NULL){
- lokke++;
- }
- if(lokke<2) return 2;
- return lokke;
-}
-
-
-static int sndjack_init(void){
- int ch;
- int numch;
- int numch_read;
- int num=0;
-
- while(num<SNDJACK_MAXSNDS){
- char temp[500];
- sprintf(temp,"sndlib%d",num);
- if ((sndjack_client=jack_client_new(temp)) != 0) {
- break;
- }
- num++;
- }
-
- if(sndjack_client==NULL){
- /* printf("Unable to create new jack_client\n"); */
- return -1;
- }
-
- pthread_mutex_init(&sndjack_mutex,NULL);
- pthread_cond_init(&sndjack_cond,NULL);
- pthread_mutex_init(&sndjack_read_mutex,NULL);
- pthread_cond_init(&sndjack_read_cond,NULL);
-
- jack_set_process_callback(sndjack_client,sndjack_process,NULL);
-
- sndjack_num_channels_allocated = numch = sndjack_getnumoutchannels();
- numch_read=sndjack_getnuminchannels();
- sndjack_num_read_channels_allocated=SJ_MAX(SNDJACK_NUMINCHANNELS,numch_read);
-
- sndjack_channels=calloc(sizeof(struct SndjackChannel),numch);
- sndjack_read_channels=calloc(sizeof(struct SndjackChannel),sndjack_num_read_channels_allocated);
-
- for(ch=0;ch<numch;ch++){
- sndjack_channels[ch].buffer=calloc(sizeof(sample_t),SNDJACK_BUFFERSIZE);
- }
- for(ch=0;ch<sndjack_num_read_channels_allocated;ch++){
- sndjack_read_channels[ch].buffer=calloc(sizeof(sample_t),SNDJACK_BUFFERSIZE);
- }
- sj_buffersize=SNDJACK_BUFFERSIZE;
-
- for(ch=0;ch<numch;ch++){
- char temp[500];
- sprintf(temp,"out_%d",ch+1);
- if((sndjack_channels[ch].port=jack_port_register(
- sndjack_client,
- strdup(temp),
- JACK_DEFAULT_AUDIO_TYPE,
- JackPortIsOutput,
- 0
- ))==NULL)
- {
- fprintf(stderr,"Error. Could not register jack port.\n");
- goto failed_register;
- }
- }
-
- for(ch=0;ch<sndjack_num_read_channels_allocated;ch++){
- char temp[500];
- sprintf(temp,"in_%d",ch+1);
- if((sndjack_read_channels[ch].port=jack_port_register(
- sndjack_client,
- strdup(temp),
- JACK_DEFAULT_AUDIO_TYPE,
- JackPortIsInput,
- 0
- ))==NULL)
- {
- fprintf(stderr,"Error. Could not register jack port.\n");
- goto failed_register;
- }
- }
-
-
-
-
- sj_jackbuffersize=jack_get_buffer_size(sndjack_client);
- jack_set_buffer_size_callback(sndjack_client,sndjack_buffersizecallback,NULL);
-
- if (jack_activate (sndjack_client)) {
- fprintf (stderr, "Error. Cannot activate jack client.\n");
- goto failed_activate;
- }
-
- {
- const char **outportnames=jack_get_ports(sndjack_client,NULL,NULL,JackPortIsPhysical|JackPortIsInput);
- for(ch=0;outportnames && outportnames[ch]!=NULL && ch<numch;ch++){
- if (
- jack_connect(
- sndjack_client,
- jack_port_name(sndjack_channels[ch].port),
- outportnames[ch]
- )
- )
- {
- printf ("Warning. Cannot connect jack output port %d: \"%s\".\n",ch,outportnames[ch]);
- }
- }
- }
-
- {
- const char **inportnames=jack_get_ports(sndjack_client,NULL,NULL,JackPortIsPhysical|JackPortIsOutput);
- for(ch=0;inportnames && inportnames[ch]!=NULL && ch<numch;ch++){
- if (
- jack_connect(
- sndjack_client,
- inportnames[ch],
- jack_port_name(sndjack_read_channels[ch].port)
- )
- )
- {
- printf ("Warning. Cannot connect jack input port %d: \"%s\".\n",ch,inportnames[ch]);
- }
- }
- }
- return 0;
-
- // failed_connect:
- failed_activate:
- jack_deactivate(sndjack_client);
-
- failed_register:
- jack_client_close(sndjack_client);
- sndjack_client=NULL;
-
- return -1;
-}
-static void sndjack_cleanup(void){
- int ch;
- for(ch=0;ch<sndjack_num_channels_allocated;ch++){
- src_delete(sndjack_srcstates[ch]);
- }
- jack_deactivate(sndjack_client);
- jack_client_close(sndjack_client);
-
-}
-
-
-
-/***************/
-/* Sndlib Part */
-/***************/
-
-static int sndjack_format;
-static sample_t **sndjack_buffer;
-static sample_t *sndjack_srcbuffer;
-
-static int sndjack_dev;
-static int sndjack_read_dev;
-
-/* prototypes for the jack sndlib functions */
-static int jack_mus_audio_initialize(void);
-static void jack_mus_oss_set_buffers(int num, int size);
-static int jack_mus_audio_systems(void);
-static char* jack_mus_audio_system_name(int system);
-static char* jack_mus_audio_moniker(void);
-static int jack_mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size);
-static int jack_mus_audio_open_input(int ur_dev, int srate, int chans, int format, int requested_size);
-static int jack_mus_audio_write(int id, char *buf, int bytes);
-static int jack_mus_audio_read(int id, char *buf, int bytes);
-static int jack_mus_audio_close(int id);
-static int jack_mus_audio_mixer_read(int ur_dev, int field, int chan, float *val);
-static int jack_mus_audio_mixer_write(int ur_dev, int field, int chan, float *val);
-static void jack_describe_audio_state_1(void);
-
-
-static int jack_mus_audio_initialize(void) {
- int ch;
-
- if(audio_initialized){
- return MUS_NO_ERROR;
- }
-
- if(sndjack_init()!=0)
- return MUS_ERROR;
-
- sndjack_buffer=calloc(sizeof(sample_t*),sndjack_num_channels_allocated);
- for(ch=0;ch<sndjack_num_channels_allocated;ch++)
- sndjack_buffer[ch]=calloc(sizeof(sample_t),SNDJACK_BUFFERSIZE);
- sndjack_srcbuffer=calloc(sizeof(sample_t),SNDJACK_BUFFERSIZE);
-
- sndjack_srcstates=calloc(sizeof(SRC_STATE*),sndjack_num_channels_allocated);
- for(ch=0;ch<sndjack_num_channels_allocated;ch++){
- sndjack_srcstates[ch]=src_new(SRC_QUALITY,1,NULL);
- }
-
- atexit(sndjack_cleanup);
-
- api = JACK_API;
- vect_mus_audio_initialize = jack_mus_audio_initialize;
- vect_mus_oss_set_buffers = jack_mus_oss_set_buffers;
- vect_mus_audio_systems = jack_mus_audio_systems;
- vect_mus_audio_system_name = jack_mus_audio_system_name;
- vect_mus_audio_moniker = jack_mus_audio_moniker;
- vect_mus_audio_open_output = jack_mus_audio_open_output;
- vect_mus_audio_open_input = jack_mus_audio_open_input;
- vect_mus_audio_write = jack_mus_audio_write;
- vect_mus_audio_read = jack_mus_audio_read;
- vect_mus_audio_close = jack_mus_audio_close;
- vect_mus_audio_mixer_read = jack_mus_audio_mixer_read;
- vect_mus_audio_mixer_write = jack_mus_audio_mixer_write;
- vect_describe_audio_state_1 = jack_describe_audio_state_1;
-
- audio_initialized = true;
-
-#if 0
-
- /* Locking all future memory shouldn't be that necessary, and might even freeze the machine in certain situations. */
- /* So remove MCL_FUTURE from the mlockall call. (No. We can't do that. It can screw up code using the realtime extension. -Kjetil.*/
- munlockall();
- //mlockall(MCL_CURRENT);
-
- // Instead we just do this: (which is not enough, but maybe better than nothing)
- {
- mlock(sndjack_channels,sizeof(struct SndjackChannel)*sndjack_num_channels_allocated);
- mlock(sndjack_read_channels,sizeof(struct SndjackChannel)*sndjack_num_read_channels_allocated);
-
- for(ch=0;ch<numch;ch++){
- mlock(sndjack_channels[ch].buffer,sizeof(sample_t)*SNDJACK_BUFFERSIZE);
- }
- for(ch=0;ch<sndjack_num_read_channels_allocated;ch++){
- mlock(sndjack_read_channels[ch].buffer,sizeof(sample_t)*SNDJACK_BUFFERSIZE);
- }
- }
-#endif
-
- return MUS_NO_ERROR;
-}
-
-// ??
-static void jack_mus_oss_set_buffers(int num, int size){
-}
-
-static int jack_mus_isrunning=0;
-static pid_t jack_mus_player_pid;
-static pthread_t jack_mus_watchdog_thread;
-
-static void *jack_mus_audio_watchdog(void *arg){
- struct sched_param par;
-
- par.sched_priority = sched_get_priority_max(SCHED_RR);
- if(sched_setscheduler(0,SCHED_RR,&par)==-1){
- fprintf(stderr,"SNDLIB: Unable to set SCHED_RR realtime priority for the watchdog thread. No watchdog.\n");
- goto exit;
- }
-
- for(;;){
- int last=jack_mus_watchdog_counter;
- sleep(1);
-
- if(jack_mus_isrunning && jack_mus_watchdog_counter<last+10){
- struct sched_param par;
- fprintf(stderr,"SNDLIB: Setting player to non-realtime for 2 seconds.\n");
-
- par.sched_priority = 0;
- if(sched_setscheduler(jack_mus_player_pid,SCHED_OTHER,&par)==-1){
- fprintf(stderr,"SNDLIB: Unable to set non-realtime priority. Must kill player thread. Sorry!\n");
- while(1){
- kill(jack_mus_player_pid,SIGKILL);
- sleep(2);
- }
- }
-
- sleep(2);
-
- if(jack_mus_isrunning){
- par.sched_priority = sched_get_priority_min(SCHED_RR)+1;
- if(sched_setscheduler(jack_mus_player_pid,SCHED_RR,&par)==-1){
- fprintf(stderr,"SNDLIB: Could not set back to realtime priority...\n");
- }else
- fprintf(stderr,"SNDLIB: Play thread set back to realtime priority.\n");
- }
-
- }
- }
- exit:
- fprintf(stderr,"SNDLIB: Watchdog exiting\n");
- return NULL;
-}
-
-
-
-static void jack_mus_audio_set_realtime(void){
- struct sched_param par;
- static int watchdog_started=0;
-
- jack_mus_player_pid=getpid();
-
- if(watchdog_started==0){
- if(pthread_create(&jack_mus_watchdog_thread,NULL,jack_mus_audio_watchdog,NULL)!=0){
- fprintf(stderr,"Could not create watchdog. Not running realtime\n");
- return;
- }
- watchdog_started=1;
- }
-
- jack_mus_isrunning=1;
-
- par.sched_priority = sched_get_priority_min(SCHED_RR)+1;
- if(sched_setscheduler(0,SCHED_RR,&par)==-1){
- fprintf(stderr,"SNDLIB: Unable to set SCHED_RR realtime priority for the player thread.\n");
- }{
- //fprintf(stderr,"Set realtime priority\n");
- }
-}
-
-static void jack_mus_audio_set_non_realtime(void){
- struct sched_param par;
- par.sched_priority = 0;
- sched_setscheduler(0,SCHED_OTHER,&par);
- //fprintf(stderr,"Set non-realtime priority\n");
- jack_mus_isrunning=0;
-}
-
-int jack_mus_audio_open_output(int dev, int srate, int chans, int format, int size){
- if(sndjack_client==NULL){
- if(jack_mus_audio_initialize()==MUS_ERROR)
- return MUS_ERROR;
- }
-
- if(sndjack_num_channels_allocated<chans){
- printf("Error. Can not play back %d channels. (Only %d)\n",chans,sndjack_num_channels_allocated);
- return MUS_ERROR;
- }
-
- if(format!=MUS_BYTE && format!=MUS_COMP_SHORT && format!=MUS_COMP_FLOAT){
- printf("Error, unable to handle format %s.\n",mus_data_format_to_string(format));
- return MUS_ERROR;
- }
-
- while(sj_status!=SJ_STOPPED) usleep(5);
-
- sj_unread=0;
- sj_writeplace=0;
- sj_readplace=0;
-
-
- if(srate!=jack_get_sample_rate(sndjack_client)){
- int lokke;
- //printf("Warning, sample-rate differs between snd and jack. Sound will not be played correctly! %d/%d\n",srate,jack_get_sample_rate(sndjack_client));
- sndjack_srcratio=(double)jack_get_sample_rate(sndjack_client)/(double)srate;
- for(lokke=0;lokke<chans;lokke++){
- src_reset(sndjack_srcstates[lokke]);
- }
- }else{
- sndjack_srcratio=1.0;
- }
-
- sndjack_format=format;
- sndjack_num_channels_inuse=chans;
- sndjack_dev=dev;
-
- jack_mus_audio_set_realtime();
-
- return(MUS_NO_ERROR);
-}
-
-static int sndjack_from_byte(int ch,int chs,char *buf,float *out,int bytes){
- int i;
- int len=bytes/chs;
- if(len>SNDJACK_BUFFERSIZE) return -1;
-
- for(i=0;i<len;i++){
- out[i]=MUS_BYTE_TO_SAMPLE(buf[i*chs+ch]);
- }
- return len;
-}
-
-static int sndjack_from_short(int ch,int chs,short *buf,float *out,int bytes){
- int i;
- int len=bytes/(sizeof(short)*chs);
- if(len>SNDJACK_BUFFERSIZE) return -1;
-
- for(i=0;i<len;i++){
- out[i]=(float)buf[i*chs+ch]/32768.1f;
- }
- return len;
-}
-
-static int sndjack_from_float(int ch,int chs,float *buf,float *out,int bytes){
- int i;
- int len=bytes/(sizeof(float)*chs);
- if(len>SNDJACK_BUFFERSIZE) return -1;
-
- for(i=0;i<len;i++){
- out[i]=buf[i*chs+ch];
- }
- return len;
-}
-
-
-int jack_mus_audio_write(int line, char *buf, int bytes){
- int i;
- int ch;
- int outlen=0;
-
- for(ch=0;ch<sndjack_num_channels_inuse;ch++){
- int len = 0;
- float *buf2=sndjack_srcratio==1.0?sndjack_buffer[ch]:sndjack_srcbuffer;
-
- switch(sndjack_format){
- case MUS_BYTE:
- len=sndjack_from_byte(ch,sndjack_num_channels_inuse,buf,buf2,bytes);
- break;
- case MUS_COMP_SHORT:
- len=sndjack_from_short(ch,sndjack_num_channels_inuse,(short *)buf,buf2,bytes);
- break;
- case MUS_COMP_FLOAT:
- len=sndjack_from_float(ch,sndjack_num_channels_inuse,(float *)buf,buf2,bytes);
- break;
- }
- if(len<0){
- printf("Errur. Input buffer to large for mus_audio_write.\n");
- return MUS_ERROR;
- }
-
- if(sndjack_srcratio!=1.0){
- SRC_DATA src_data={
- buf2,sndjack_buffer[ch],
- len,SNDJACK_BUFFERSIZE,
- 0,0,
- 0,
- sndjack_srcratio
- };
- int res=src_process(sndjack_srcstates[ch],&src_data);
- if(res!=0){
- printf("Error while resampling. (%s)\n",src_strerror(res));
- return MUS_ERROR;
- }
- if(src_data.input_frames!=len){
- printf("Unsuccessfull resampling: Should have used %d bytes, used %d.",len,src_data.input_frames);
- return MUS_ERROR;
- }
- if(ch>0 && src_data.output_frames_gen!=outlen){
- printf("Error, src_process did not output the same number of frames as previous resampled channel (%d/%d).\n"
- "Please report this problem to k.s.matheussen@notam02.no. Thanks!\n",src_data.output_frames_gen,outlen);
- return MUS_ERROR;
- }
- outlen=src_data.output_frames_gen;
- }else{
- outlen=len;
- }
- }
-
-
- sndjack_write(sndjack_buffer,outlen,outlen*2,sndjack_num_channels_inuse);
-
- return MUS_NO_ERROR;
-}
-
-int jack_mus_audio_close(int line)
-{
- jack_mus_audio_set_non_realtime();
- if(line==sndjack_dev){
- sj_status=SJ_ABOUTTOSTOP;
- sndjack_num_channels_inuse=0;
- }
- return MUS_NO_ERROR;
- }
-
-int jack_mus_audio_mixer_read(int dev, int field, int chan, float *val)
-{
- //printf("dev: %d, field: %d, chan: %d\n",dev,field,chan);
-
- switch(field){
- case MUS_AUDIO_FORMAT:
- val[1]=MUS_COMP_FLOAT;
- val[0]=1;
- break;
- case MUS_AUDIO_PORT:
- val[0]=1;
- val[1]=MUS_AUDIO_DIGITAL_IN;
- break;
- case MUS_AUDIO_CHANNEL:
- val[0]=sndjack_num_read_channels_allocated;
- break;
- case MUS_AUDIO_AMP:
- val[0] = 1.0f;
- break;
- default:
- printf("Got unknown request with field %d %d\n",field, MUS_AUDIO_AMP);
- return MUS_ERROR;
- }
-
- return MUS_NO_ERROR;
-}
-
-int jack_mus_audio_mixer_write(int dev, int field, int chan, float *val){
- return(MUS_NO_ERROR);
-}
-
-int jack_mus_audio_open_input(int dev, int srate, int chans, int format, int size){
- if(sndjack_client==NULL){
- if(jack_mus_audio_initialize()==MUS_ERROR)
- return MUS_ERROR;
- }
-
- if(sndjack_num_read_channels_allocated<chans){
- printf("Error. Can not record %d channels. (Only %d)\n",chans,sndjack_num_read_channels_allocated);
- return MUS_ERROR;
- }
-
- printf("dev: %d\n" ,dev);
- if(format!=MUS_BYTE && format!=MUS_COMP_SHORT && format!=MUS_COMP_FLOAT){
- printf("Error, unable to handle format %s.\n",mus_data_format_to_string(format));
- return MUS_ERROR;
- }
-
- if(srate!=jack_get_sample_rate(sndjack_client)){
- printf("Warning, jacks samplerate is %d (and not %d), and the recording will use this samplerate too.\n",jack_get_sample_rate(sndjack_client),srate);
- }
-
- sndjack_read_format=format;
- sndjack_num_read_channels_inuse=chans;
- sndjack_read_dev=dev;
-
- return(MUS_NO_ERROR);
-}
-
-int jack_mus_audio_read(int line, char *buf, int bytes){
- if(sndjack_read(buf,bytes,sndjack_num_read_channels_inuse)==-1)
- return(MUS_ERROR);
- return MUS_NO_ERROR;
-}
-
-
-static void jack_describe_audio_state_1(void) {
- char temp[500];
-
- pprint("jack audio:\n");
- sprintf(temp,"\tNumber of output channels: %d\n",sndjack_num_channels_allocated);pprint(temp);
- sprintf(temp,"\tNumber of input channels: %d\n",sndjack_num_read_channels_allocated);pprint(temp);
- sprintf(temp,"\tSamplerate: %d\n",jack_get_sample_rate(sndjack_client));pprint(temp);
- sprintf(temp,"\tJack buffersize: %d\n",sj_jackbuffersize);pprint(temp);
- sprintf(temp,"\tSndjack buffersize: %d\n",SNDJACK_BUFFERSIZE);pprint(temp);
- sprintf(temp,"\tMax number of instances: %d\n",SNDJACK_MAXSNDS);pprint(temp);
- sprintf(temp,"\tTotal number of frames delayed: %d\n",sj_totalxrun);pprint(temp);
- sprintf(temp,"\tCurrent cpu-load: %f\n",jack_cpu_load(sndjack_client));pprint(temp);
- sprintf(temp,"\tIs running realtime: %s\n",jack_is_realtime(sndjack_client)==1?"yes":"no");pprint(temp);
- sprintf(temp,"\tResample quality (only used when needed): %s (%s)\n",src_get_name(SRC_QUALITY),src_get_description(SRC_QUALITY));pprint(temp);
- sprintf(temp,"\tIs able to handle the following audio formats: %s %s %s\n",mus_data_format_to_string(MUS_BYTE),mus_data_format_to_string(MUS_COMP_SHORT),mus_data_format_to_string(MUS_COMP_FLOAT));pprint(temp);
- sprintf(temp,"\tPrefered audio format: %s\n",mus_data_format_to_string(MUS_COMP_FLOAT));pprint(temp);
-}
-
-
-int jack_mus_audio_systems(void) {
- return(2);
-}
-
-char *jack_mus_audio_system_name(int system) {return("linux jack");}
-char *jack_mus_audio_moniker(void) {return("jack");}
-#endif
-
-
-
-/* ------------------------------- HPUX ----------------------------------------- */
-
-/* if this is basically the same as the Sun case with different macro names,
- * then it could perhaps be updated to match the new Sun version above --
- * Sun version changed 28-Jan-99
- */
-
-#if defined(MUS_HPUX) && (!(defined(AUDIO_OK)))
-#define AUDIO_OK
-#include <sys/audio.h>
-
-#define RETURN_ERROR_EXIT(Error_Type, Audio_Line, Ur_Error_Message) \
- do { char *Error_Message; Error_Message = Ur_Error_Message; \
- if (Audio_Line != -1) close(Audio_Line); \
- if (Error_Message) \
- {MUS_STANDARD_ERROR(Error_Type, Error_Message); FREE(Error_Message);} \
- else MUS_STANDARD_ERROR(Error_Type, mus_error_type_to_string(Error_Type)); \
- return(MUS_ERROR); \
- } while (false)
-
-char *mus_audio_moniker(void) {return("HPUX audio");}
-
-int mus_audio_open_output(int ur_dev, int srate, int chans, int format, int size)
-{
- int fd, i, dev;
- struct audio_describe desc;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- fd = open("/dev/audio", O_RDWR);
- if (fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, -1,
- mus_format("can't open /dev/audio for output: %s",
- strerror(errno)));
- ioctl(fd, AUDIO_SET_CHANNELS, chans);
- if (dev == MUS_AUDIO_SPEAKERS)
- ioctl(fd, AUDIO_SET_OUTPUT, AUDIO_OUT_SPEAKER);
- else
- if (dev == MUS_AUDIO_LINE_OUT)
- ioctl(fd, AUDIO_SET_OUTPUT, AUDIO_OUT_LINE);
- else ioctl(fd, AUDIO_SET_OUTPUT, AUDIO_OUT_HEADPHONE);
- if (format == MUS_BSHORT)
- ioctl(fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_LINEAR16BIT);
- else
- if (format == MUS_MULAW)
- ioctl(fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_ULAW);
- else
- if (format == MUS_ALAW)
- ioctl(fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_ALAW);
- else
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, fd,
- mus_format("can't set output format to %d (%s) for %d (%s)",
- format, mus_audio_format_name(format),
- dev,
- mus_audio_device_name(dev)));
- ioctl(fd, AUDIO_DESCRIBE, &desc);
- for(i = 0; i < desc.nrates; i++)
- if(srate == desc.sample_rate[i])
- break;
- if (i == desc.nrates)
- RETURN_ERROR_EXIT(SRATE_NOT_AVAILABLE, fd,
- mus_format("can't set srate to %d on %d (%s)",
- srate, dev,
- mus_audio_device_name(dev)));
- ioctl(fd, AUDIO_SET_SAMPLE_RATE, srate);
- return(fd);
-}
-
-int mus_audio_write(int line, char *buf, int bytes)
-{
- write(line, buf, bytes);
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_close(int line)
-{
- close(line);
- return(MUS_NO_ERROR);
-}
-
-static void describe_audio_state_1(void)
-{
- struct audio_describe desc;
- struct audio_gain gain;
- int mina, maxa, fd, tmp;
- int g[2];
- fd = open("/dev/audio", O_RDWR);
- if (fd == -1) return;
- ioctl(fd, AUDIO_GET_OUTPUT, &tmp);
- switch (tmp)
- {
- case AUDIO_OUT_SPEAKER: pprint("output: speakers\n"); break;
- case AUDIO_OUT_HEADPHONE: pprint("output: headphone\n"); break;
- case AUDIO_OUT_LINE: pprint("output: line out\n"); break;
- }
- ioctl(fd, AUDIO_GET_INPUT, &tmp);
- switch (tmp)
- {
- case AUDIO_IN_MIKE: pprint("input: mic\n"); break;
- case AUDIO_IN_LINE: pprint("input: line in\n"); break;
- }
- ioctl(fd, AUDIO_GET_DATA_FORMAT, &tmp);
- switch (tmp)
- {
- case AUDIO_FORMAT_LINEAR16BIT: pprint("format: 16-bit linear\n"); break;
- case AUDIO_FORMAT_ULAW: pprint("format: mulaw\n"); break;
- case AUDIO_FORMAT_ALAW: pprint("format: alaw\n"); break;
- }
- ioctl(fd, AUDIO_DESCRIBE, &desc);
- gain.channel_mask = (AUDIO_CHANNEL_LEFT | AUDIO_CHANNEL_RIGHT);
- ioctl(fd, AUDIO_GET_GAINS, &gain);
- close(fd);
- g[0] = gain.cgain[0].transmit_gain;
- g[1] = gain.cgain[1].transmit_gain;
- mina = desc.min_transmit_gain;
- maxa = desc.max_transmit_gain;
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "out vols: %.3f %.3f\n",
- (float)(g[0] - mina) / (float)(maxa - mina),
- (float)(g[1] - mina) / (float)(maxa - mina));
- pprint(audio_strbuf);
- g[0] = gain.cgain[0].receive_gain;
- g[1] = gain.cgain[1].receive_gain;
- mina = desc.min_receive_gain;
- maxa = desc.max_receive_gain;
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "in vols: %.3f %.3f\n",
- (float)(g[0] - mina) / (float)(maxa - mina),
- (float)(g[1] - mina) / (float)(maxa - mina));
- pprint(audio_strbuf);
- g[0] = gain.cgain[0].monitor_gain;
- g[1] = gain.cgain[1].monitor_gain;
- mina = desc.min_monitor_gain;
- maxa = desc.max_monitor_gain;
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "monitor vols: %.3f %.3f\n",
- (float)(g[0] - mina) / (float)(maxa - mina),
- (float)(g[1] - mina) / (float)(maxa - mina));
- pprint(audio_strbuf);
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- struct audio_describe desc;
- struct audio_gain gain;
- int audio_fd = -1, srate, g, maxa, mina, dev, err = MUS_NO_ERROR;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- if (field == MUS_AUDIO_PORT)
- {
- val[0] = 4;
- if (chan > 1) val[1] = MUS_AUDIO_MICROPHONE;
- if (chan > 2) val[2] = MUS_AUDIO_DAC_OUT;
- if (chan > 3) val[3] = MUS_AUDIO_LINE_OUT;
- if (chan > 4) val[4] = MUS_AUDIO_LINE_IN;
- }
- else
- {
- if (field == FORMAT_FIELD)
- {
- val[0] = 3;
- if (chan > 1) val[1] = MUS_BSHORT;
- if (chan > 2) val[2] = MUS_MULAW;
- if (chan > 3) val[3] = MUS_ALAW;
- }
- else
- {
- audio_fd = open("/dev/audio", O_RDWR);
- ioctl(audio_fd, AUDIO_DESCRIBE, &desc);
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_SPEAKERS:
- case MUS_AUDIO_LINE_OUT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- ioctl(audio_fd, AUDIO_GET_GAINS, &gain);
- if (chan == 0)
- g = gain.cgain[0].transmit_gain;
- else g = gain.cgain[1].transmit_gain;
- mina = desc.min_transmit_gain;
- maxa = desc.max_transmit_gain;
- val[0] = (float)(g - mina) / (float)(maxa - mina);
- break;
- case MUS_AUDIO_CHANNEL:
- val[0] = 2;
- break;
- case MUS_AUDIO_SRATE:
- ioctl(audio_fd, AUDIO_GET_SAMPLE_RATE, &srate);
- val[0] = srate;
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- break;
- case MUS_AUDIO_MICROPHONE:
- case MUS_AUDIO_LINE_IN:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- ioctl(audio_fd, AUDIO_GET_GAINS, &gain);
- if (chan == 0)
- g = gain.cgain[0].receive_gain;
- else g = gain.cgain[1].receive_gain;
- mina = desc.min_receive_gain;
- maxa = desc.max_receive_gain;
- val[0] = (float)(g - mina) / (float)(maxa - mina);
- break;
- case MUS_AUDIO_CHANNEL:
- val[0] = 2;
- break;
- case MUS_AUDIO_SRATE:
- ioctl(audio_fd, AUDIO_GET_SAMPLE_RATE, &srate);
- val[0] = srate;
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- }
- }
- if (err == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't read %s field of device %d (%s)",
- mus_audio_device_name(field),
- dev,
- mus_audio_device_name(dev)));
-
- if (audio_fd != -1) close(audio_fd);
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- struct audio_describe desc;
- struct audio_gain gain;
- int audio_fd = -1, srate, g, maxa, mina, dev, err = MUS_NO_ERROR;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- audio_fd = open("/dev/audio", O_RDWR);
- ioctl(audio_fd, AUDIO_DESCRIBE, &desc);
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_SPEAKERS:
- case MUS_AUDIO_LINE_OUT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- mina = desc.min_transmit_gain;
- maxa = desc.max_transmit_gain;
- ioctl(audio_fd, AUDIO_GET_GAINS, &gain);
- g = mina + val[0] * (maxa - mina);
- if (chan == 0)
- gain.cgain[0].transmit_gain = g;
- else gain.cgain[1].transmit_gain = g;
- ioctl(audio_fd, AUDIO_SET_GAINS, &gain);
- break;
- case MUS_AUDIO_SRATE:
- srate = val[0];
- ioctl(audio_fd, AUDIO_SET_SAMPLE_RATE, srate);
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- break;
- case MUS_AUDIO_MICROPHONE:
- case MUS_AUDIO_LINE_IN:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- mina = desc.min_receive_gain;
- maxa = desc.max_receive_gain;
- ioctl(audio_fd, AUDIO_GET_GAINS, &gain);
- g = mina + val[0] * (maxa - mina);
- if (chan == 0)
- gain.cgain[0].receive_gain = g;
- else gain.cgain[1].receive_gain = g;
- ioctl(audio_fd, AUDIO_SET_GAINS, &gain);
- break;
- case MUS_AUDIO_SRATE:
- srate = val[0];
- ioctl(audio_fd, AUDIO_SET_SAMPLE_RATE, srate);
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- break;
- default:
- err = MUS_ERROR;
- break;
- }
- if (err == MUS_ERROR)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't set %s field of device %d (%s)",
- mus_audio_device_name(field),
- dev,
- mus_audio_device_name(dev)));
-
- if (audio_fd != -1) close(audio_fd);
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_initialize(void) {return(MUS_NO_ERROR);}
-
-int mus_audio_systems(void) {return(1);}
-char *mus_audio_system_name(int system) {return("HPUX");}
-
-/* struct audio_status status_b;
- * ioctl(devAudio, AUDIO_GET_STATUS, &status_b)
- * not_busy = (status_b.transmit_status == AUDIO_DONE);
-*/
-
-int mus_audio_open_input(int ur_dev, int srate, int chans, int format, int size)
-{
- int fd, i, dev;
- struct audio_describe desc;
- dev = MUS_AUDIO_DEVICE(ur_dev);
- fd = open("/dev/audio", O_RDWR);
- if (fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, NULL,
- mus_format("can't open /dev/audio for input: %s",
- strerror(errno)));
- ioctl(fd, AUDIO_SET_CHANNELS, chans);
- if (dev == MUS_AUDIO_MICROPHONE)
- ioctl(fd, AUDIO_SET_INPUT, AUDIO_IN_MIKE);
- else ioctl(fd, AUDIO_SET_INPUT, AUDIO_IN_LINE);
- if (format == MUS_BSHORT)
- ioctl(fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_LINEAR16BIT);
- else
- if (format == MUS_MULAW)
- ioctl(fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_ULAW);
- else
- if (format == MUS_ALAW)
- ioctl(fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_ALAW);
- else
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, fd,
- mus_format("can't set input format to %d (%s) on %d (%s)",
- format, mus_audio_format_name(format),
- dev,
- mus_audio_device_name(dev)));
- ioctl(fd, AUDIO_DESCRIBE, &desc);
- for(i = 0; i < desc.nrates; i++)
- if(srate == desc.sample_rate[i])
- break;
- if (i == desc.nrates)
- RETURN_ERROR_EXIT(MUS_AUDIO_SRATE_NOT_AVAILABLE, fd,
- mus_format("can't set srate to %d on %d (%s)",
- srate, dev,
- mus_audio_device_name(dev)));
- ioctl(fd, AUDIO_SET_SAMPLE_RATE, srate);
- return(fd);
-}
-
-int mus_audio_read(int line, char *buf, int bytes)
-{
- read(line, buf, bytes);
- return(MUS_NO_ERROR);
-}
-
-#endif
-
-
-
-/* ------------------------------- NETBSD ----------------------------------------- */
-
-#if defined(MUS_NETBSD) && (!(defined(AUDIO_OK)))
-#define AUDIO_OK
-/* started from Xanim a long time ago..., bugfixes from Thomas Klausner 30-Jul-05, worked into better shape Aug-05 */
-#include <fcntl.h>
-#include <sys/audioio.h>
-#include <sys/ioctl.h>
-
-#define RETURN_ERROR_EXIT(Error_Type, Audio_Line, Ur_Error_Message) \
- do { char *Error_Message; Error_Message = Ur_Error_Message; \
- if (Audio_Line != -1) close(Audio_Line); \
- if (Error_Message) \
- {MUS_STANDARD_ERROR(Error_Type, Error_Message); FREE(Error_Message);} \
- else MUS_STANDARD_ERROR(Error_Type, mus_error_type_to_string(Error_Type)); \
- return(MUS_ERROR); \
- } while (false)
-
-static int bsd_format_to_sndlib(int encoding)
-{
- switch (encoding)
- {
- case AUDIO_ENCODING_ULAW: return(MUS_MULAW); break;
- case AUDIO_ENCODING_ALAW: return(MUS_ALAW); break;
- case AUDIO_ENCODING_LINEAR: return(MUS_BSHORT); break; /* "sun compatible" so probably big-endian? */
- case AUDIO_ENCODING_SLINEAR:
- case AUDIO_ENCODING_LINEAR8: return(MUS_BYTE); break;
- case AUDIO_ENCODING_SLINEAR_LE: return(MUS_LSHORT); break;
- case AUDIO_ENCODING_SLINEAR_BE: return(MUS_BSHORT); break;
- case AUDIO_ENCODING_ULINEAR_LE: return(MUS_ULSHORT); break;
- case AUDIO_ENCODING_ULINEAR_BE: return(MUS_UBSHORT); break;
- case AUDIO_ENCODING_ULINEAR: return(MUS_UBYTE); break;
- case AUDIO_ENCODING_NONE:
- case AUDIO_ENCODING_ADPCM:
- default: return(MUS_UNKNOWN); break;
- }
- return(MUS_UNKNOWN);
-}
-
-static int sndlib_format_to_bsd(int encoding)
-{
- switch (encoding)
- {
- case MUS_MULAW: return(AUDIO_ENCODING_ULAW); break;
- case MUS_ALAW: return(AUDIO_ENCODING_ALAW); break;
- case MUS_BYTE: return(AUDIO_ENCODING_SLINEAR); break;
- case MUS_LSHORT: return(AUDIO_ENCODING_SLINEAR_LE); break;
- case MUS_BSHORT: return(AUDIO_ENCODING_SLINEAR_BE); break;
- case MUS_ULSHORT: return(AUDIO_ENCODING_ULINEAR_LE); break;
- case MUS_UBSHORT: return(AUDIO_ENCODING_ULINEAR_BE); break;
- case MUS_UBYTE: return(AUDIO_ENCODING_ULINEAR); break;
- }
- return(AUDIO_ENCODING_NONE);
-}
-
-int mus_audio_initialize(void)
-{
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_systems(void)
-{
- return(1);
-}
-
-char *mus_audio_system_name(int system)
-{
- return("NetBSD");
-}
-
-char *mus_audio_moniker(void)
-{
- return("NetBSD audio");
-}
-
-static int cur_chans = 1, cur_srate = 22050;
-
-int mus_audio_write(int line, char *buf, int bytes)
-{
- /* trouble... AUDIO_WSEEK always returns 0, no way to tell that I'm about to
- * hit "hiwat", but when I do, it hangs. Can't use AUDIO_DRAIN --
- * it introduces interruptions. Not sure what to do...
- */
- int b = 0;
- b = write(line, buf, bytes);
- usleep(10000);
- if ((b != bytes) && (b > 0)) /* b <= 0 presumably some sort of error, and we want to avoid infinite recursion below */
- {
- /* hangs at close if we don't handle this somehow */
- if ((cur_chans == 1) || (cur_srate == 22050))
- sleep(1);
- else usleep(10000);
- mus_audio_write(line, (char *)(buf + b), bytes - b);
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_audio_close(int line)
-{
- usleep(100000);
- ioctl(line, AUDIO_FLUSH, 0);
- close(line);
- return(MUS_NO_ERROR);
-}
-
-static int netbsd_default_outputs = (AUDIO_HEADPHONE | AUDIO_LINE_OUT | AUDIO_SPEAKER);
-
-void mus_netbsd_set_outputs(int speakers, int headphones, int line_out)
-{
- netbsd_default_outputs = 0;
- if (speakers) netbsd_default_outputs |= AUDIO_SPEAKER;
- if (headphones) netbsd_default_outputs |= AUDIO_HEADPHONE;
- if (line_out) netbsd_default_outputs |= AUDIO_LINE_OUT;
-}
-
-int mus_audio_open_output(int dev, int srate, int chans, int format, int size)
-{
- int line, encode;
- audio_info_t a_info;
-
- line = open("/dev/sound", O_WRONLY | O_NDELAY); /* /dev/audio assumes mono 8-bit mulaw */
- if (line == -1)
- {
- if (errno == EBUSY)
- return(mus_error(MUS_AUDIO_CANT_OPEN, NULL));
- else return(mus_error(MUS_AUDIO_DEVICE_NOT_AVAILABLE, NULL));
- }
- AUDIO_INITINFO(&a_info);
-
- /* a_info.blocksize = size; */
- encode = sndlib_format_to_bsd(format);
- if (encode == AUDIO_ENCODING_NONE)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %d (%s) not available",
- format,
- mus_data_format_name(format)));
- a_info.play.encoding = encode;
- a_info.mode = AUMODE_PLAY | AUMODE_PLAY_ALL;
- a_info.play.precision = mus_bytes_per_sample(format) * 8;
- a_info.play.sample_rate = srate;
- if (dev == MUS_AUDIO_LINE_OUT)
- a_info.play.port = AUDIO_LINE_OUT;
- else
- {
- if (dev == MUS_AUDIO_SPEAKERS)
- a_info.play.port = AUDIO_SPEAKER | (netbsd_default_outputs & AUDIO_HEADPHONE);
- else a_info.play.port = netbsd_default_outputs;
- }
- a_info.play.channels = chans;
- ioctl(line, AUDIO_SETINFO, &a_info);
- /* actually doesn't set the "ports" field -- always 0 */
-
- ioctl(line, AUDIO_GETINFO, &a_info);
-
- if ((int)(a_info.play.sample_rate) != srate)
- mus_print("srate: %d -> %d\n", srate, a_info.play.sample_rate);
- if ((int)(a_info.play.encoding) != sndlib_format_to_bsd(format))
- mus_print("encoding: %d -> %d\n", sndlib_format_to_bsd(format), a_info.play.encoding);
- if ((int)(a_info.play.channels) != chans)
- mus_print("chans: %d -> %d\n", chans, a_info.play.channels);
-
- cur_chans = chans;
- cur_srate = srate;
-
- return(line);
-}
-
-int mus_audio_read(int line, char *buf, int bytes)
-{
- read(line, buf, bytes);
- return(MUS_NO_ERROR);
-}
-
-static void describe_audio_state_1(void)
-{
- audio_device_t dev;
- int i = 0, val, err = 0;
- int line;
- float amp;
- audio_info_t a_info;
- audio_encoding_t e_info;
-
- pprint("NetBSD ");
- line = open("/dev/sound", O_WRONLY | O_NDELAY);
- if (line == -1)
- return;
-
- pprint("/dev/sound:\n");
- err = ioctl(line, AUDIO_GETDEV, &dev);
- if (err == 0)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "%s: version: %s (%s)", dev.name, dev.version, dev.config);
- pprint(audio_strbuf);
- }
-
- err = ioctl(line, AUDIO_GETPROPS, &val);
- if (err == 0)
- {
- if (val & AUDIO_PROP_FULLDUPLEX)
- pprint(" full-duplex");
- else pprint(" half-duplex");
- }
- pprint("\n");
-
- err = ioctl(line, AUDIO_GETINFO, &a_info);
- if (err == 0)
- {
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " play: srate: %d, chans: %d, format: %s (%d bits), ",
- a_info.play.sample_rate,
- a_info.play.channels,
- mus_data_format_short_name(bsd_format_to_sndlib(a_info.play.encoding)),
- a_info.play.precision);
- pprint(audio_strbuf);
-
- amp = (float)(a_info.play.gain - AUDIO_MIN_GAIN) / (float)(AUDIO_MAX_GAIN - AUDIO_MIN_GAIN);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "volume: %.3f %.3f (gain: %d, balance: %d)\n",
- amp * (1.0 - ((float)(a_info.play.balance) / (float)(2 * AUDIO_MID_BALANCE))),
- amp * ((float)(a_info.play.balance) / (float)(2 * AUDIO_MID_BALANCE)),
- a_info.play.gain, a_info.play.balance);
- pprint(audio_strbuf);
-
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " record: srate: %d, chans: %d, format: %s (%d bits), ",
- a_info.record.sample_rate,
- a_info.record.channels,
- mus_data_format_short_name(bsd_format_to_sndlib(a_info.record.encoding)),
- a_info.record.precision);
- pprint(audio_strbuf);
-
- amp = (float)(a_info.record.gain - AUDIO_MIN_GAIN) / (float)(AUDIO_MAX_GAIN - AUDIO_MIN_GAIN);
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, "volume: %.3f %.3f (gain: %d, balance: %d)\n",
- amp * (1.0 - ((float)(a_info.record.balance) / (float)(2 * AUDIO_MID_BALANCE))),
- amp * ((float)(a_info.record.balance) / (float)(2 * AUDIO_MID_BALANCE)),
- a_info.record.gain, a_info.record.balance);
- pprint(audio_strbuf);
- }
-
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " available encodings:\n");
- pprint(audio_strbuf);
-
- for (i = 0; ; i++)
- {
- e_info.index = i;
- err = ioctl(line, AUDIO_GETENC, &e_info);
- if (err != 0) break;
- mus_snprintf(audio_strbuf, PRINT_BUFFER_SIZE, " %s (%s, bits: %d)\n",
- mus_data_format_short_name(bsd_format_to_sndlib(e_info.encoding)),
- e_info.name,
- e_info.precision);
- pprint(audio_strbuf);
- }
-
- close(line);
-
-#if 0
- /* I don't see anything useful in all this mixer data, so I'll omit it */
- fprintf(stderr,"/dev/mixer:\n");
- line = open("/dev/mixer", O_RDONLY | O_NDELAY);
- if (line == -1)
- return;
- val = ioctl(line, AUDIO_GETDEV, &dev);
- fprintf(stderr, "\n%d, name: %s, version: %s, config: %s\n",
- val, dev.name, dev.version, dev.config);
- for (i = 0; ; i++)
- {
- mdev.index = i;
- val = ioctl(line, AUDIO_MIXER_DEVINFO, &mdev);
- if (val != 0) break;
- fprintf(stderr,"%d: name: %s ", i, mdev.label.name);
- fprintf(stderr,"class: %d, type: %d, units: %s, chans: %d, delta: %d\n",
- mdev.mixer_class, mdev.type, mdev.un.v.units.name, mdev.un.v.num_channels, mdev.un.v.delta);
- mx.dev = i;
- ioctl(line, AUDIO_MIXER_READ, &mx);
- switch (mx.type)
- {
- case AUDIO_MIXER_CLASS:
- fprintf(stderr, "mixer read: class type?\n");
- break;
- case AUDIO_MIXER_ENUM:
- fprintf(stderr, "mixer read: enum: %d\n", mx.un.ord);
- break;
- case AUDIO_MIXER_SET:
- case AUDIO_MIXER_VALUE:
- {
- int j;
- ml = mx.un.value;
- fprintf(stderr, "mixer read: level: %d chans [", ml.num_channels);
- for (j = 0; j < ml.num_channels; j++)
- fprintf(stderr, "%d ", (int)(ml.level[j]));
- fprintf(stderr, "]\n");
- }
- break;
- default:
- fprintf(stderr, "mixer read: unknown type? %d\n", mx.type);
- break;
- }
- }
-#endif
-}
-
-int mus_audio_mixer_read(int ur_dev, int field, int chan, float *val)
-{
- int i, audio_fd, err, dev;
- audio_info_t info;
- bool ok = true;
-
- dev = MUS_AUDIO_DEVICE(ur_dev);
- AUDIO_INITINFO(&info);
- audio_fd = open("/dev/sound", O_RDONLY | O_NONBLOCK, 0);
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, -1,
- mus_format("can't open /dev/sound: %s",
- strerror(errno)));
- err = ioctl(audio_fd, AUDIO_GETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't get dac info"));
-
- if (field == MUS_AUDIO_PORT)
- {
- val[0] = 1;
- val[1] = MUS_AUDIO_MICROPHONE;
- }
- else
- {
- if (field == MUS_AUDIO_FORMAT)
- {
- audio_encoding_t e_info;
- for (i = 0; ; i++)
- {
- e_info.index = i;
- err = ioctl(audio_fd, AUDIO_GETENC, &e_info);
- if (err != 0) break;
- val[i + 1] = bsd_format_to_sndlib(e_info.encoding);
- }
- val[0] = i;
- }
- else
- {
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_SPEAKERS:
- case MUS_AUDIO_LINE_OUT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- {
- float amp;
- amp = (float)(info.play.gain - AUDIO_MIN_GAIN) / (float)(AUDIO_MAX_GAIN - AUDIO_MIN_GAIN);
- if (chan == 0)
- val[0] = amp * (1.0 - ((float)(info.play.balance) / (float)(2 * AUDIO_MID_BALANCE)));
- else val[0] = amp * ((float)(info.play.balance) / (float)(2 * AUDIO_MID_BALANCE));
- }
- break;
- case MUS_AUDIO_CHANNEL:
- val[0] = 2;
- break;
- case MUS_AUDIO_SRATE:
- val[0] = (float)info.play.sample_rate;
- break;
- default:
- ok = false;
- break;
- }
- break;
- case MUS_AUDIO_MICROPHONE:
- case MUS_AUDIO_LINE_IN:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_CD:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- {
- float amp;
- amp = (float)(info.record.gain - AUDIO_MIN_GAIN) / (float)(AUDIO_MAX_GAIN - AUDIO_MIN_GAIN);
- if (chan == 0)
- val[0] = amp * (1.0 - ((float)(info.record.balance) / (float)(2 * AUDIO_MID_BALANCE)));
- else val[0] = amp * ((float)(info.record.balance) / (float)(2 * AUDIO_MID_BALANCE));
- }
- break;
- case MUS_AUDIO_CHANNEL:
- val[0] = 1;
- break;
- case MUS_AUDIO_SRATE:
- val[0] = (float)(info.record.sample_rate);
- break;
- default:
- ok = false;
- break;
- }
- break;
- default:
- ok = false;
- break;
- }
- }
- }
- if (!ok)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't read %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- return(mus_audio_close(audio_fd));
-}
-
-int mus_audio_mixer_write(int ur_dev, int field, int chan, float *val)
-{
- audio_info_t info;
- int dev, audio_fd, err;
- bool ok = true;
-
- dev = MUS_AUDIO_DEVICE(ur_dev);
- AUDIO_INITINFO(&info);
-
- audio_fd = open("/dev/sound", O_RDWR | O_NONBLOCK, 0);
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, -1,
- mus_format("can't open /dev/sound: %s",
- strerror(errno)));
-
- err = ioctl(audio_fd, AUDIO_GETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_READ, audio_fd,
- mus_format("can't get /dev/sound info"));
-
- switch (dev)
- {
- case MUS_AUDIO_DEFAULT:
- case MUS_AUDIO_DAC_OUT:
- case MUS_AUDIO_SPEAKERS:
- case MUS_AUDIO_LINE_OUT:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- info.play.balance = AUDIO_MID_BALANCE;
- info.play.gain = AUDIO_MIN_GAIN + (int)((AUDIO_MAX_GAIN - AUDIO_MIN_GAIN) * val[0]);
- break;
- case MUS_AUDIO_CHANNEL:
- info.play.channels = (int)val[0];
- break;
- case MUS_AUDIO_SRATE:
- info.play.sample_rate = (int)val[0];
- break;
- default:
- ok = false;
- break;
- }
- break;
- case MUS_AUDIO_MICROPHONE:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- info.record.gain = AUDIO_MIN_GAIN + (int)((AUDIO_MAX_GAIN - AUDIO_MIN_GAIN) * val[0]);
- info.record.balance = AUDIO_MID_BALANCE;
- break;
- case MUS_AUDIO_CHANNEL:
- info.record.channels = (int)val[0];
- break;
- case MUS_AUDIO_SRATE:
- info.record.sample_rate = (int)val[0];
- break;
- default:
- ok = false;
- break;
- }
- break;
- case MUS_AUDIO_LINE_IN:
- case MUS_AUDIO_DUPLEX_DEFAULT:
- case MUS_AUDIO_CD:
- switch (field)
- {
- case MUS_AUDIO_AMP:
- info.record.balance = AUDIO_MID_BALANCE;
- info.record.gain = AUDIO_MIN_GAIN + (int)((AUDIO_MAX_GAIN - AUDIO_MIN_GAIN) * val[0]);
- break;
- case MUS_AUDIO_CHANNEL:
- info.record.channels = (int)val[0];
- break;
- case MUS_AUDIO_SRATE:
- info.record.sample_rate = (int)val[0];
- break;
- default:
- ok = false;
- break;
- }
- break;
- default:
- ok = false;
- break;
- }
- if (ok)
- ioctl(audio_fd, AUDIO_SETINFO, &info);
- else
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't write %s field %d (%s)",
- mus_audio_device_name(dev),
- field,
- mus_audio_device_name(field)));
- return(mus_audio_close(audio_fd));
-}
-
-int mus_audio_open_input(int ur_dev, int srate, int chans, int format, int size)
-{
- audio_info_t info;
- int encode, bits, dev, audio_fd, err;
-
- dev = MUS_AUDIO_DEVICE(ur_dev);
- encode = sndlib_format_to_bsd(format);
- bits = 8 * mus_bytes_per_sample(format);
- if (encode == AUDIO_ENCODING_NONE)
- RETURN_ERROR_EXIT(MUS_AUDIO_FORMAT_NOT_AVAILABLE, -1,
- mus_format("format %s not available for recording",
- mus_data_format_name(format)));
-
- if (dev != MUS_AUDIO_DUPLEX_DEFAULT)
- audio_fd = open("/dev/sound", O_RDONLY, 0);
- else audio_fd = open("/dev/sound", O_RDWR, 0);
- if (audio_fd == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_OPEN, -1,
- mus_format("can't open /dev/sound: %s",
- strerror(errno)));
-
- AUDIO_INITINFO(&info);
- info.record.sample_rate = srate;
- info.record.channels = chans;
- info.record.precision = bits;
- info.record.encoding = encode;
- info.record.port = AUDIO_MICROPHONE;
- err = ioctl(audio_fd, AUDIO_SETINFO, &info);
- if (err == -1)
- RETURN_ERROR_EXIT(MUS_AUDIO_CANT_WRITE, audio_fd,
- mus_format("can't set up for recording"));
- return(audio_fd);
-}
-
-#endif
-
-
-
-/* ------------------------------- STUBS ----------------------------------------- */
-
-#ifndef AUDIO_OK
-static void describe_audio_state_1(void) {pprint("audio stubbed out");}
-int mus_audio_open_output(int dev, int srate, int chans, int format, int size) {return(MUS_ERROR);}
-int mus_audio_open_input(int dev, int srate, int chans, int format, int size) {return(MUS_ERROR);}
-int mus_audio_write(int line, char *buf, int bytes) {return(MUS_ERROR);}
-int mus_audio_close(int line) {return(MUS_ERROR);}
-int mus_audio_read(int line, char *buf, int bytes) {return(MUS_ERROR);}
-int mus_audio_mixer_read(int dev, int field, int chan, float *val) {return(MUS_ERROR);}
-int mus_audio_mixer_write(int dev, int field, int chan, float *val) {return(MUS_ERROR);}
-int mus_audio_initialize(void) {return(MUS_ERROR);}
-int mus_audio_systems(void) {return(0);}
-char *mus_audio_system_name(int system) {return("none");}
-char *mus_audio_moniker(void) {return("no audio support");}
-#endif
-
-
-
-static char *save_it = NULL;
-static int print_it = 1;
-static int save_it_len = 0;
-static int save_it_loc = 0;
-
-static void pprint(char *str)
-{
- int i, len;
- if ((str) && (*str))
- {
- if ((print_it) || (!(save_it)))
- {
- mus_print(str);
- }
- else
- {
- len = strlen(str);
- if ((len + save_it_loc + 2) >= save_it_len)
- {
- save_it_len = (len + save_it_loc + 1024);
- save_it = (char *)REALLOC(save_it, save_it_len * sizeof(char));
- }
- for (i = 0; i < len; i++)
- save_it[save_it_loc++] = str[i];
- save_it[save_it_loc] = 0;
- }
- }
-}
-
-char *mus_audio_report(void)
-{
- mus_audio_initialize();
- if (!(save_it))
- {
- save_it_len = 1024;
- save_it = (char *)CALLOC(save_it_len, sizeof(char));
- }
- save_it_loc = 0;
- print_it = 0;
- if (!audio_strbuf) audio_strbuf = (char *)CALLOC(PRINT_BUFFER_SIZE, sizeof(char));
- describe_audio_state_1();
- return(save_it);
-}
-
-void mus_audio_describe(void)
-{
- mus_audio_initialize();
- print_it = 1;
- if (!audio_strbuf) audio_strbuf = (char *)CALLOC(PRINT_BUFFER_SIZE, sizeof(char));
- describe_audio_state_1();
-}
-
-/* for CLM */
-void mus_reset_audio_c(void)
-{
- audio_initialized = false;
- save_it = NULL;
- version_name = NULL;
-#ifdef MUS_SUN
- sun_vol_name = NULL;
-#endif
- save_it_len = 0;
- audio_strbuf = NULL;
-}
-
-
-int mus_audio_compatible_format(int dev)
-{
-#if HAVE_ALSA || HAVE_JACK
- int err, i;
- float val[32];
- int ival[32];
- err = mus_audio_mixer_read(dev, MUS_AUDIO_FORMAT, 32, val);
- if (err != MUS_ERROR)
- {
- for (i = 0; i <= (int)(val[0]); i++) ival[i] = (int)(val[i]);
- /* ^ this cast is vital! Memory clobbered otherwise in LinuxPPC */
- for (i = 1; i <= ival[0]; i++)
- if (ival[i] == MUS_AUDIO_COMPATIBLE_FORMAT)
- return(MUS_AUDIO_COMPATIBLE_FORMAT);
- for (i = 1; i <= ival[0]; i++)
- if ((ival[i] == MUS_BINT) || (ival[i] == MUS_LINT) ||
- (ival[i] == MUS_BFLOAT) || (ival[i] == MUS_LFLOAT) ||
- (ival[i] == MUS_BSHORT) || (ival[i] == MUS_LSHORT))
- return(ival[i]);
- for (i = 1; i <= ival[0]; i++)
- if ((ival[i] == MUS_MULAW) || (ival[i] == MUS_ALAW) ||
- (ival[i] == MUS_UBYTE) || (ival[i] == MUS_BYTE))
- return(ival[i]);
- return(ival[1]);
- }
-#endif
- return(MUS_AUDIO_COMPATIBLE_FORMAT);
-}
-
-
-/* next two added 17-Dec-02 for non-interleaved audio IO */
-static char *output_buffer = NULL;
-static int output_buffer_size = 0;
-
-int mus_audio_write_buffers(int port, int frames, int chans, mus_sample_t **bufs, int output_format, bool clipped)
-{
- int bytes;
- bytes = chans * frames * mus_bytes_per_sample(output_format);
- if (output_buffer_size < bytes)
- {
- if (output_buffer) free(output_buffer);
- output_buffer = (char *)malloc(bytes);
- output_buffer_size = bytes;
- }
- mus_file_write_buffer(output_format, 0, frames - 1, chans, bufs, output_buffer, clipped);
- return(mus_audio_write(port, output_buffer, bytes));
-}
-
-static char *input_buffer = NULL;
-static int input_buffer_size = 0;
-
-int mus_audio_read_buffers(int port, int frames, int chans, mus_sample_t **bufs, int input_format)
-{
- int bytes;
- bytes = chans * frames * mus_bytes_per_sample(input_format);
- if (input_buffer_size < bytes)
- {
- if (input_buffer) free(input_buffer);
- input_buffer = (char *)malloc(bytes);
- input_buffer_size = bytes;
- }
- mus_audio_read(port, input_buffer, bytes);
- return(mus_file_read_buffer(input_format, 0, chans, frames, bufs, input_buffer));
-}
diff --git a/third_party/resample/sndlib-20/configure b/third_party/resample/sndlib-20/configure
deleted file mode 100644
index 251a436e..00000000
--- a/third_party/resample/sndlib-20/configure
+++ /dev/null
@@ -1,13033 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.60 for sndlib 20.
-#
-# Report bugs to <bil@ccrma.stanford.edu>.
-#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-
-# PATH needs CR
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order. Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-as_nl='
-'
-IFS=" "" $as_nl"
-
-# Find who we are. Look in the path if we contain no directory separator.
-case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-IFS=$as_save_IFS
-
- ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
- as_myself=$0
-fi
-if test ! -f "$as_myself"; then
- echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
- { (exit 1); exit 1; }
-fi
-
-# Work around bugs in pre-3.0 UWIN ksh.
-for as_var in ENV MAIL MAILPATH
-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{
- s//\1/
- q
- }
- /^X\/\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\/\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
-
-# CDPATH.
-$as_unset CDPATH
-
-
-if test "x$CONFIG_SHELL" = x; then
- if (eval ":") 2>/dev/null; then
- as_have_required=yes
-else
- as_have_required=no
-fi
-
- if test $as_have_required = yes && (eval ":
-(as_func_return () {
- (exit \$1)
-}
-as_func_success () {
- as_func_return 0
-}
-as_func_failure () {
- as_func_return 1
-}
-as_func_ret_success () {
- return 0
-}
-as_func_ret_failure () {
- return 1
-}
-
-exitcode=0
-if as_func_success; then
- :
-else
- exitcode=1
- echo as_func_success failed.
-fi
-
-if as_func_failure; then
- exitcode=1
- echo as_func_failure succeeded.
-fi
-
-if as_func_ret_success; then
- :
-else
- exitcode=1
- echo as_func_ret_success failed.
-fi
-
-if as_func_ret_failure; then
- exitcode=1
- echo as_func_ret_failure succeeded.
-fi
-
-if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
- :
-else
- exitcode=1
- echo positional parameters were not saved.
-fi
-
-test \$exitcode = 0) || { (exit 1); exit 1; }
-
-(
- as_lineno_1=\$LINENO
- as_lineno_2=\$LINENO
- test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
- test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
-") 2> /dev/null; then
- :
-else
- as_candidate_shells=
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /usr/bin/posix$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- case $as_dir in
- /*)
- for as_base in sh bash ksh sh5; do
- as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
- done;;
- esac
-done
-IFS=$as_save_IFS
-
-
- for as_shell in $as_candidate_shells $SHELL; do
- # Try only shells that exist, to save several forks.
- if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
- { ("$as_shell") 2> /dev/null <<\_ASEOF
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-:
-_ASEOF
-}; then
- CONFIG_SHELL=$as_shell
- as_have_required=yes
- if { "$as_shell" 2> /dev/null <<\_ASEOF
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-:
-(as_func_return () {
- (exit $1)
-}
-as_func_success () {
- as_func_return 0
-}
-as_func_failure () {
- as_func_return 1
-}
-as_func_ret_success () {
- return 0
-}
-as_func_ret_failure () {
- return 1
-}
-
-exitcode=0
-if as_func_success; then
- :
-else
- exitcode=1
- echo as_func_success failed.
-fi
-
-if as_func_failure; then
- exitcode=1
- echo as_func_failure succeeded.
-fi
-
-if as_func_ret_success; then
- :
-else
- exitcode=1
- echo as_func_ret_success failed.
-fi
-
-if as_func_ret_failure; then
- exitcode=1
- echo as_func_ret_failure succeeded.
-fi
-
-if ( set x; as_func_ret_success y && test x = "$1" ); then
- :
-else
- exitcode=1
- echo positional parameters were not saved.
-fi
-
-test $exitcode = 0) || { (exit 1); exit 1; }
-
-(
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
-
-_ASEOF
-}; then
- break
-fi
-
-fi
-
- done
-
- if test "x$CONFIG_SHELL" != x; then
- for as_var in BASH_ENV ENV
- do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
- done
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
-fi
-
-
- if test $as_have_required = no; then
- echo This script requires a shell more modern than all the
- echo shells that I found on your system. Please install a
- echo modern shell, or manually run the script under such a
- echo shell if you do have one.
- { (exit 1); exit 1; }
-fi
-
-
-fi
-
-fi
-
-
-
-(eval "as_func_return () {
- (exit \$1)
-}
-as_func_success () {
- as_func_return 0
-}
-as_func_failure () {
- as_func_return 1
-}
-as_func_ret_success () {
- return 0
-}
-as_func_ret_failure () {
- return 1
-}
-
-exitcode=0
-if as_func_success; then
- :
-else
- exitcode=1
- echo as_func_success failed.
-fi
-
-if as_func_failure; then
- exitcode=1
- echo as_func_failure succeeded.
-fi
-
-if as_func_ret_success; then
- :
-else
- exitcode=1
- echo as_func_ret_success failed.
-fi
-
-if as_func_ret_failure; then
- exitcode=1
- echo as_func_ret_failure succeeded.
-fi
-
-if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
- :
-else
- exitcode=1
- echo positional parameters were not saved.
-fi
-
-test \$exitcode = 0") || {
- echo No shell found that supports shell functions.
- echo Please tell autoconf@gnu.org about your system,
- echo including any error possibly output before this
- echo message
-}
-
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line after each line using $LINENO; the second 'sed'
- # does the real work. The second script uses 'N' to pair each
- # line-number line with the line containing $LINENO, and appends
- # trailing '-' during substitution so that $LINENO is not a special
- # case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # scripts with optimization help from Paolo Bonzini. Blame Lee
- # E. McMahon (1931-1989) for sed's syntax. :-)
- sed -n '
- p
- /[$]LINENO/=
- ' <$as_myself |
- sed '
- s/[$]LINENO.*/&-/
- t lineno
- b
- :lineno
- N
- :loop
- s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
- t loop
- s/-\n.*//
- ' >$as_me.lineno &&
- chmod +x "$as_me.lineno" ||
- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensitive to this).
- . "./$as_me.lineno"
- # Exit status is that of the last command.
- exit
-}
-
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
- as_dirname=dirname
-else
- as_dirname=false
-fi
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in
--n*)
- case `echo 'x\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
- *) ECHO_C='\c';;
- esac;;
-*)
- ECHO_N='-n';;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
- rm -f conf$$.dir/conf$$.file
-else
- rm -f conf$$.dir
- mkdir conf$$.dir
-fi
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- as_ln_s='ln -s'
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-# Find out whether ``test -x'' works. Don't use a zero-byte file, as
-# systems may use methods other than mode bits to determine executability.
-cat >conf$$.file <<_ASEOF
-#! /bin/sh
-exit 0
-_ASEOF
-chmod +x conf$$.file
-if test -x conf$$.file >/dev/null 2>&1; then
- as_executable_p="test -x"
-else
- as_executable_p=:
-fi
-rm -f conf$$.file
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-
-exec 7<&0 </dev/null 6>&1
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_clean_files=
-ac_config_libobj_dir=.
-LIBOBJS=
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-# Identity of this package.
-PACKAGE_NAME='sndlib'
-PACKAGE_TARNAME='sndlib'
-PACKAGE_VERSION='20'
-PACKAGE_STRING='sndlib 20'
-PACKAGE_BUGREPORT='bil@ccrma.stanford.edu'
-
-ac_unique_file="io.c"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='SHELL
-PATH_SEPARATOR
-PACKAGE_NAME
-PACKAGE_TARNAME
-PACKAGE_VERSION
-PACKAGE_STRING
-PACKAGE_BUGREPORT
-exec_prefix
-prefix
-program_transform_name
-bindir
-sbindir
-libexecdir
-datarootdir
-datadir
-sysconfdir
-sharedstatedir
-localstatedir
-includedir
-oldincludedir
-docdir
-infodir
-htmldir
-dvidir
-pdfdir
-psdir
-libdir
-localedir
-mandir
-DEFS
-ECHO_C
-ECHO_N
-ECHO_T
-LIBS
-build_alias
-host_alias
-target_alias
-build
-build_cpu
-build_vendor
-build_os
-host
-host_cpu
-host_vendor
-host_os
-CC
-CFLAGS
-LDFLAGS
-CPPFLAGS
-ac_ct_CC
-EXEEXT
-OBJEXT
-CPP
-GREP
-EGREP
-SNDLIB_BITS
-INSTALL_PROGRAM
-INSTALL_SCRIPT
-INSTALL_DATA
-GSL_CONFIG
-GSL_LIBS
-GSL_CFLAGS
-GUILE_LIBS
-GUILE_CFLAGS
-GAUCHE_CONFIG
-FTH_VERSION
-FTH_CFLAGS
-FTH_LIBS
-FTH_HAVE_COMPLEX
-FTH_HAVE_RATIO
-FTH
-XM_LIBS
-AUDIO_LIB
-LDSO_FLAGS
-SO_FLAGS
-SO_INSTALL
-A_INSTALL
-SO_LD
-A_LD
-A_LD_FLAGS
-LD_FLAGS
-SNDLIB_VERSION
-SNDLIB_LANGUAGE
-SNDLIB_MODULES
-AUDIO_CHOICE
-LIBOBJS
-LTLIBOBJS'
-ac_subst_files=''
- ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-CPPFLAGS
-CPP'
-
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-# (The list follows the same order as the GNU Coding Standards.)
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datarootdir='${prefix}/share'
-datadir='${datarootdir}'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
-infodir='${datarootdir}/info'
-htmldir='${docdir}'
-dvidir='${docdir}'
-pdfdir='${docdir}'
-psdir='${docdir}'
-libdir='${exec_prefix}/lib'
-localedir='${datarootdir}/locale'
-mandir='${datarootdir}/man'
-
-ac_prev=
-ac_dashdash=
-for ac_option
-do
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval $ac_prev=\$ac_option
- ac_prev=
- continue
- fi
-
- case $ac_option in
- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
- *) ac_optarg=yes ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case $ac_dashdash$ac_option in
- --)
- ac_dashdash=yes ;;
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir=$ac_optarg ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$ac_optarg ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file=$ac_optarg ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=*)
- datadir=$ac_optarg ;;
-
- -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
- | --dataroo | --dataro | --datar)
- ac_prev=datarootdir ;;
- -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
- | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
- datarootdir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- eval enable_$ac_feature=no ;;
-
- -docdir | --docdir | --docdi | --doc | --do)
- ac_prev=docdir ;;
- -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
- docdir=$ac_optarg ;;
-
- -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
- ac_prev=dvidir ;;
- -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
- dvidir=$ac_optarg ;;
-
- -enable-* | --enable-*)
- ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- eval enable_$ac_feature=\$ac_optarg ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix=$ac_optarg ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$ac_optarg ;;
-
- -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
- ac_prev=htmldir ;;
- -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
- | --ht=*)
- htmldir=$ac_optarg ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir=$ac_optarg ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir=$ac_optarg ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir=$ac_optarg ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir=$ac_optarg ;;
-
- -localedir | --localedir | --localedi | --localed | --locale)
- ac_prev=localedir ;;
- -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
- localedir=$ac_optarg ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst | --locals)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
- localstatedir=$ac_optarg ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir=$ac_optarg ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c | -n)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir=$ac_optarg ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix=$ac_optarg ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix=$ac_optarg ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix=$ac_optarg ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name=$ac_optarg ;;
-
- -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
- ac_prev=pdfdir ;;
- -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
- pdfdir=$ac_optarg ;;
-
- -psdir | --psdir | --psdi | --psd | --ps)
- ac_prev=psdir ;;
- -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
- psdir=$ac_optarg ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir=$ac_optarg ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir=$ac_optarg ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site=$ac_optarg ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir=$ac_optarg ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir=$ac_optarg ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval with_$ac_package=\$ac_optarg ;;
-
- -without-* | --without-*)
- ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package | sed 's/-/_/g'`
- eval with_$ac_package=no ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes=$ac_optarg ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries=$ac_optarg ;;
-
- -*) { echo "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; }
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
- { (exit 1); exit 1; }; }
- eval $ac_envvar=\$ac_optarg
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- { echo "$as_me: error: missing argument to $ac_option" >&2
- { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute directory names.
-for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
- datadir sysconfdir sharedstatedir localstatedir includedir \
- oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
-do
- eval ac_val=\$$ac_var
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) continue;;
- NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
- esac
- { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; }
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used." >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-ac_pwd=`pwd` && test -n "$ac_pwd" &&
-ac_ls_di=`ls -di .` &&
-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
- { echo "$as_me: error: Working directory cannot be determined" >&2
- { (exit 1); exit 1; }; }
-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
- { echo "$as_me: error: pwd does not report name of working directory" >&2
- { (exit 1); exit 1; }; }
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then the parent directory.
- ac_confdir=`$as_dirname -- "$0" ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$0" : 'X\(//\)[^/]' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-echo X"$0" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- srcdir=$ac_confdir
- if test ! -r "$srcdir/$ac_unique_file"; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r "$srcdir/$ac_unique_file"; then
- test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
- { (exit 1); exit 1; }; }
-fi
-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-ac_abs_confdir=`(
- cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
- { (exit 1); exit 1; }; }
- pwd)`
-# When building in place, set srcdir=.
-if test "$ac_abs_confdir" = "$ac_pwd"; then
- srcdir=.
-fi
-# Remove unnecessary trailing slashes from srcdir.
-# Double slashes in file names in object file debugging info
-# mess up M-x gdb in Emacs.
-case $srcdir in
-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
-esac
-for ac_var in $ac_precious_vars; do
- eval ac_env_${ac_var}_set=\${${ac_var}+set}
- eval ac_env_${ac_var}_value=\$${ac_var}
- eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
- eval ac_cv_env_${ac_var}_value=\$${ac_var}
-done
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat <<_ACEOF
-\`configure' configures sndlib 20 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
- --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
- --infodir=DIR info documentation [DATAROOTDIR/info]
- --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
- --mandir=DIR man documentation [DATAROOTDIR/man]
- --docdir=DIR documentation root [DATAROOTDIR/doc/sndlib]
- --htmldir=DIR html documentation [DOCDIR]
- --dvidir=DIR dvi documentation [DOCDIR]
- --pdfdir=DIR pdf documentation [DOCDIR]
- --psdir=DIR ps documentation [DOCDIR]
-_ACEOF
-
- cat <<\_ACEOF
-
-System types:
- --build=BUILD configure for building on BUILD [guessed]
- --host=HOST cross-compile to build programs to run on HOST [BUILD]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
- case $ac_init_help in
- short | recursive ) echo "Configuration of sndlib 20:";;
- esac
- cat <<\_ACEOF
-
-Optional Features:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --disable-largefile omit support for large files
-
-Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-esd use ESD
- --with-alsa use ALSA
- --with-jack use JACK
- --with-static-alsa use ALSA statically loaded
- --with-doubles use doubles throughout
- --with-guile use Guile
- --with-modules use if sndlib uses modules
- --with-hobbit include hobbit-style function arity checking
- --with-gauche use Gauche
- --with-float-samples use floats as the internal sample respresentation
- --with-sample-width=N use N bits of samples
- --with-ruby-prefix=PFX where Ruby is installed
- --with-ruby try to use Ruby as the extension language
- --with-forth try to use Forth as the extension language
-
-Some influential environment variables:
- CC C compiler command
- CFLAGS C compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
- you have headers in a nonstandard directory <include dir>
- CPP C preprocessor
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to <bil@ccrma.stanford.edu>.
-_ACEOF
-ac_status=$?
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d "$ac_dir" || continue
- ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A ".." for each directory in $ac_dir_suffix.
- ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
- case $ac_top_builddir_sub in
- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
- esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
- .) # We are building in place.
- ac_srcdir=.
- ac_top_srcdir=$ac_top_builddir_sub
- ac_abs_top_srcdir=$ac_pwd ;;
- [\\/]* | ?:[\\/]* ) # Absolute name.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir
- ac_abs_top_srcdir=$srcdir ;;
- *) # Relative name.
- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_build_prefix$srcdir
- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
- cd "$ac_dir" || { ac_status=$?; continue; }
- # Check for guested configure.
- if test -f "$ac_srcdir/configure.gnu"; then
- echo &&
- $SHELL "$ac_srcdir/configure.gnu" --help=recursive
- elif test -f "$ac_srcdir/configure"; then
- echo &&
- $SHELL "$ac_srcdir/configure" --help=recursive
- else
- echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi || ac_status=$?
- cd "$ac_pwd" || { ac_status=$?; break; }
- done
-fi
-
-test -n "$ac_init_help" && exit $ac_status
-if $ac_init_version; then
- cat <<\_ACEOF
-sndlib configure 20
-generated by GNU Autoconf 2.60
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit
-fi
-cat >config.log <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by sndlib $as_me 20, which was
-generated by GNU Autoconf 2.60. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-exec 5>>config.log
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- echo "PATH: $as_dir"
-done
-IFS=$as_save_IFS
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *\'*)
- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
- 2)
- ac_configure_args1="$ac_configure_args1 '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- ac_configure_args="$ac_configure_args '$ac_arg'"
- ;;
- esac
- done
-done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Use '\'' to represent an apostrophe within the trap.
-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
- {
- echo
-
- cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
- echo
- # The following way of writing the cache mishandles newlines in values,
-(
- for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
- eval ac_val=\$$ac_var
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
- *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- *) $as_unset $ac_var ;;
- esac ;;
- esac
- done
- (set) 2>&1 |
- case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
- *${as_nl}ac_space=\ *)
- sed -n \
- "s/'\''/'\''\\\\'\'''\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
- ;; #(
- *)
- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
- ;;
- esac |
- sort
-)
- echo
-
- cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=\$$ac_var
- case $ac_val in
- *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
- esac
- echo "$ac_var='\''$ac_val'\''"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- cat <<\_ASBOX
-## ------------------- ##
-## File substitutions. ##
-## ------------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=\$$ac_var
- case $ac_val in
- *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
- esac
- echo "$ac_var='\''$ac_val'\''"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
- echo
- cat confdefs.h
- echo
- fi
- test "$ac_signal" != 0 &&
- echo "$as_me: caught signal $ac_signal"
- echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core core.conftest.* &&
- rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
-' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -f -r conftest* confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
-if test -n "$CONFIG_SITE"; then
- set x "$CONFIG_SITE"
-elif test "x$prefix" != xNONE; then
- set x "$prefix/share/config.site" "$prefix/etc/config.site"
-else
- set x "$ac_default_prefix/share/config.site" \
- "$ac_default_prefix/etc/config.site"
-fi
-shift
-for ac_site_file
-do
- if test -r "$ac_site_file"; then
- { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special
- # files actually), so we avoid doing that.
- if test -f "$cache_file"; then
- { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . "$cache_file";;
- *) . "./$cache_file";;
- esac
- fi
-else
- { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $ac_precious_vars; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val=\$ac_cv_env_${ac_var}_value
- eval ac_new_val=\$ac_env_${ac_var}_value
- case $ac_old_set,$ac_new_set in
- set,)
- { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
-echo "$as_me: former value: $ac_old_val" >&2;}
- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
-echo "$as_me: current value: $ac_new_val" >&2;}
- ac_cache_corrupted=:
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-SNDLIB_VERSION=20
-
-ac_config_files="$ac_config_files makefile"
-
-ac_config_files="$ac_config_files sndlib-config"
-
-ac_config_files="$ac_config_files sndins/Makefile"
-
-ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
- if test -f "$ac_dir/install-sh"; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f "$ac_dir/install.sh"; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- elif test -f "$ac_dir/shtool"; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/shtool install -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
-echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
-
-
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
- { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
-echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
- { (exit 1); exit 1; }; }
-
-{ echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
-if test "${ac_cv_build+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
- ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
- { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
- { (exit 1); exit 1; }; }
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
- { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
-echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
-echo "$as_me: error: invalid value of canonical build" >&2;}
- { (exit 1); exit 1; }; };;
-esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
-if test "${ac_cv_host+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "x$host_alias" = x; then
- ac_cv_host=$ac_cv_build
-else
- ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
- { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
-echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
-echo "$as_me: error: invalid value of canonical host" >&2;}
- { (exit 1); exit 1; }; };;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
-
-ac_config_headers="$ac_config_headers mus-config.h sndlib.h"
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
- if test "x$ac_ct_CC" = x; then
- CC=""
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet. If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&5
-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet. If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&2;}
-ac_tool_warned=yes ;;
-esac
- CC=$ac_ct_CC
- fi
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
- fi
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl.exe
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl.exe
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
- test -n "$ac_ct_CC" && break
-done
-
- if test "x$ac_ct_CC" = x; then
- CC=""
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet. If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&5
-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet. If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&2;}
-ac_tool_warned=yes ;;
-esac
- CC=$ac_ct_CC
- fi
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO: checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (ac_try="$ac_compiler --version >&5"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compiler --version >&5") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (ac_try="$ac_compiler -v >&5"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compiler -v >&5") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (ac_try="$ac_compiler -V >&5"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compiler -V >&5") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-#
-# List of possible output files, starting from the most likely.
-# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
-# only as a last resort. b.out is created by i960 compilers.
-ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
-#
-# The IRIX 6 linker writes into existing files which may not be
-# executable, retaining their permissions. Remove them first so a
-# subsequent execution test works.
-ac_rmfiles=
-for ac_file in $ac_files
-do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
- * ) ac_rmfiles="$ac_rmfiles $ac_file";;
- esac
-done
-rm -f $ac_rmfiles
-
-if { (ac_try="$ac_link_default"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link_default") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile. We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
- then :; else
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- fi
- # We set ac_cv_exeext here because the later test for it is not
- # safe: cross compilers may not add the suffix if given an `-o'
- # argument, so we may need to know it at that point already.
- # Even if this section looks crufty: it has the advantage of
- # actually working.
- break;;
- * )
- break;;
- esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; }
-fi
-
-ac_exeext=$ac_cv_exeext
-{ echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6; }
-
-# Check that the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
- if { ac_try='./$ac_file'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
- fi
- fi
-fi
-{ echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-# Check that the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }
-{ echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6; }
-
-{ echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- break;;
- * ) break;;
- esac
-done
-else
- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-{ echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }
-if test "${ac_cv_objext+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- for ac_file in conftest.o conftest.obj conftest.*; do
- test -f "$ac_file" || continue;
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_compiler_gnu=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_save_c_werror_flag=$ac_c_werror_flag
- ac_c_werror_flag=yes
- ac_cv_prog_cc_g=no
- CFLAGS="-g"
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- CFLAGS=""
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_c_werror_flag=$ac_save_c_werror_flag
- CFLAGS="-g"
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_c_werror_flag=$ac_save_c_werror_flag
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
-echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
- inside strings and character constants. */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
- -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_c89=$ac_arg
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext
- test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
- x)
- { echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6; } ;;
- xno)
- { echo "$as_me:$LINENO: result: unsupported" >&5
-echo "${ECHO_T}unsupported" >&6; } ;;
- *)
- CC="$CC $ac_cv_prog_cc_c89"
- { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-{ echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
-echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Extract the first word of "grep ggrep" to use in msg output
-if test -z "$GREP"; then
-set dummy grep ggrep; ac_prog_name=$2
-if test "${ac_cv_path_GREP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_path_GREP_found=false
-# Loop through the user's path and test for each of PROGNAME-LIST
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in grep ggrep; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_GREP" && $as_executable_p "$ac_path_GREP"; } || continue
- # Check for GNU ac_path_GREP and select it if it is found.
- # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
- ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
- ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- echo 'GREP' >> "conftest.nl"
- "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- ac_count=`expr $ac_count + 1`
- if test $ac_count -gt ${ac_path_GREP_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_GREP="$ac_path_GREP"
- ac_path_GREP_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-
- $ac_path_GREP_found && break 3
- done
-done
-
-done
-IFS=$as_save_IFS
-
-
-fi
-
-GREP="$ac_cv_path_GREP"
-if test -z "$GREP"; then
- { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-else
- ac_cv_path_GREP=$GREP
-fi
-
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
-echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
- then ac_cv_path_EGREP="$GREP -E"
- else
- # Extract the first word of "egrep" to use in msg output
-if test -z "$EGREP"; then
-set dummy egrep; ac_prog_name=$2
-if test "${ac_cv_path_EGREP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_path_EGREP_found=false
-# Loop through the user's path and test for each of PROGNAME-LIST
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in egrep; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_EGREP" && $as_executable_p "$ac_path_EGREP"; } || continue
- # Check for GNU ac_path_EGREP and select it if it is found.
- # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
- ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
- ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- echo 'EGREP' >> "conftest.nl"
- "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- ac_count=`expr $ac_count + 1`
- if test $ac_count -gt ${ac_path_EGREP_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_EGREP="$ac_path_EGREP"
- ac_path_EGREP_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-
- $ac_path_EGREP_found && break 3
- done
-done
-
-done
-IFS=$as_save_IFS
-
-
-fi
-
-EGREP="$ac_cv_path_EGREP"
-if test -z "$EGREP"; then
- { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-else
- ac_cv_path_EGREP=$EGREP
-fi
-
-
- fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
-echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_header_stdc=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then
- :
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- return 2;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-
-audio_system="unknown"
-
-#--------------------------------------------------------------------------------
-# configuration options
-# --with-alsa use ALSA if possible
-# --with-jack use Jack
-# --with-static-alsa use ALSA statically loaded (for RPM generation)
-# --with-doubles use doubles throughout (default is floats)
-# --with-float-samples represent samples internally as floats
-# --with-sample-width=N use N bits of samples (default = 24)
-# --with-esd use Enlightened Sound Daemon
-# --with-guile build with Guile (default)
-# --with-ruby try to use Ruby as the extension language
-# --with-ruby-prefix set prefix for ruby.h
-# --with-forth use Forth as extension language
-# --with-gauche use Gauche as extension language
-# --with-static-gsl try to statically load GSL
-# --with-modules put sndlib names into modules
-# --with-hobbit include hobbit-style function arity checking
-#--------------------------------------------------------------------------------
-
-
-# Check whether --with-esd was given.
-if test "${with_esd+set}" = set; then
- withval=$with_esd;
-fi
-
-
-# Check whether --with-alsa was given.
-if test "${with_alsa+set}" = set; then
- withval=$with_alsa;
-fi
-
-
-# Check whether --with-jack was given.
-if test "${with_jack+set}" = set; then
- withval=$with_jack;
-fi
-
-
-# Check whether --with-static-alsa was given.
-if test "${with_static_alsa+set}" = set; then
- withval=$with_static_alsa;
-fi
-
-
-# Check whether --with-doubles was given.
-if test "${with_doubles+set}" = set; then
- withval=$with_doubles;
-fi
-
-
-# Check whether --with-guile was given.
-if test "${with_guile+set}" = set; then
- withval=$with_guile;
-fi
-
-
-# Check whether --with-modules was given.
-if test "${with_modules+set}" = set; then
- withval=$with_modules;
-fi
-
-
-# Check whether --with-hobbit was given.
-if test "${with_hobbit+set}" = set; then
- withval=$with_hobbit;
-fi
-
-
-# Check whether --with-gauche was given.
-if test "${with_gauche+set}" = set; then
- withval=$with_gauche;
-fi
-
-
-if test "$with_doubles" = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define Float double
-_ACEOF
-
-else
- cat >>confdefs.h <<\_ACEOF
-#define Float float
-_ACEOF
-
-fi
-
-if test "$with_hobbit" = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define WITH_HOBBIT 1
-_ACEOF
-
-fi
-
-SNDLIB_BITS="24"
-
-# Check whether --with-float-samples was given.
-if test "${with_float_samples+set}" = set; then
- withval=$with_float_samples; if test "$with_float_samples" = yes ; then
- cat >>confdefs.h <<\_ACEOF
-#define SNDLIB_USE_FLOATS 1
-_ACEOF
-
- if test "$with_doubles" = yes ; then
- SNDLIB_BITS="8"
- else
- SNDLIB_BITS="4"
- fi
- else
- cat >>confdefs.h <<\_ACEOF
-#define SNDLIB_USE_FLOATS 0
-_ACEOF
-
- fi
-else
- cat >>confdefs.h <<\_ACEOF
-#define SNDLIB_USE_FLOATS 0
-_ACEOF
-
-fi
-
-
-
-# Check whether --with-sample-width was given.
-if test "${with_sample_width+set}" = set; then
- withval=$with_sample_width; { echo "$as_me:$LINENO: result: Using $with_sample_width bit samples" >&5
-echo "${ECHO_T}Using $with_sample_width bit samples" >&6; }
- cat >>confdefs.h <<_ACEOF
-#define MUS_SAMPLE_BITS $with_sample_width
-_ACEOF
-
- SNDLIB_BITS=$with_sample_width
-
-else
- cat >>confdefs.h <<\_ACEOF
-#define MUS_SAMPLE_BITS 24
-_ACEOF
-
-
-fi
-
-
-
-
-
-#--------------------------------------------------------------------------------
-# standard libraries, header files, functions, OSS special cases
-#--------------------------------------------------------------------------------
-
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in
- ./ | .// | /cC/* | \
- /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
- ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
- /usr/ucb/* ) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; }; then
- if test $ac_prog = install &&
- grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- elif test $ac_prog = install &&
- grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # program-specific install script used by HP pwplus--don't use.
- :
- else
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
- fi
- done
- done
- ;;
-esac
-done
-IFS=$as_save_IFS
-
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL=$ac_cv_path_install
- else
- # As a last resort, use the slow shell script. Don't cache a
- # value for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
- INSTALL=$ac_install_sh
- fi
-fi
-{ echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6; }
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-
-{ echo "$as_me:$LINENO: checking for main in -lm" >&5
-echo $ECHO_N "checking for main in -lm... $ECHO_C" >&6; }
-if test "${ac_cv_lib_m_main+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_m_main=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_m_main=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_main" >&5
-echo "${ECHO_T}$ac_cv_lib_m_main" >&6; }
-if test $ac_cv_lib_m_main = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
- LIBS="-lm $LIBS"
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for main in -lc" >&5
-echo $ECHO_N "checking for main in -lc... $ECHO_C" >&6; }
-if test "${ac_cv_lib_c_main+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lc $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_c_main=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_c_main=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_c_main" >&5
-echo "${ECHO_T}$ac_cv_lib_c_main" >&6; }
-if test $ac_cv_lib_c_main = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBC 1
-_ACEOF
-
- LIBS="-lc $LIBS"
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for main in -ldl" >&5
-echo $ECHO_N "checking for main in -ldl... $ECHO_C" >&6; }
-if test "${ac_cv_lib_dl_main+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_main=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_dl_main=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_main" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_main" >&6; }
-if test $ac_cv_lib_dl_main = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBDL 1
-_ACEOF
-
- LIBS="-ldl $LIBS"
-
-fi
-
-LIBS=""
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Header=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-
-
-
-
-
-for ac_header in fcntl.h limits.h unistd.h string.h sys/soundcard.h machine/soundcard.h sys/mixer.h byteswap.h stdbool.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
- { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-for ac_header in libc.h stdint.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
- { echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-if test "${ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for /usr/local/lib/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /usr/local/lib/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking /usr/local/lib/oss/include/sys/soundcard.h usability" >&5
-echo $ECHO_N "checking /usr/local/lib/oss/include/sys/soundcard.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include </usr/local/lib/oss/include/sys/soundcard.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking /usr/local/lib/oss/include/sys/soundcard.h presence" >&5
-echo $ECHO_N "checking /usr/local/lib/oss/include/sys/soundcard.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include </usr/local/lib/oss/include/sys/soundcard.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: /usr/local/lib/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for /usr/local/lib/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /usr/local/lib/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h" >&6; }
-
-fi
-if test $ac_cv_header__usr_local_lib_oss_include_sys_soundcard_h = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define MUS_HAVE_USR_LOCAL_LIB_OSS 1
-_ACEOF
-
-fi
-
-
-if test "${ac_cv_header__usr_lib_oss_include_sys_soundcard_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for /usr/lib/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /usr/lib/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__usr_lib_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__usr_lib_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__usr_lib_oss_include_sys_soundcard_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking /usr/lib/oss/include/sys/soundcard.h usability" >&5
-echo $ECHO_N "checking /usr/lib/oss/include/sys/soundcard.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include </usr/lib/oss/include/sys/soundcard.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking /usr/lib/oss/include/sys/soundcard.h presence" >&5
-echo $ECHO_N "checking /usr/lib/oss/include/sys/soundcard.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include </usr/lib/oss/include/sys/soundcard.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: /usr/lib/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: /usr/lib/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for /usr/lib/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /usr/lib/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__usr_lib_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header__usr_lib_oss_include_sys_soundcard_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__usr_lib_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__usr_lib_oss_include_sys_soundcard_h" >&6; }
-
-fi
-if test $ac_cv_header__usr_lib_oss_include_sys_soundcard_h = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define MUS_HAVE_USR_LIB_OSS 1
-_ACEOF
-
-fi
-
-
-if test "${ac_cv_header__opt_oss_include_sys_soundcard_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for /opt/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /opt/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__opt_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__opt_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__opt_oss_include_sys_soundcard_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking /opt/oss/include/sys/soundcard.h usability" >&5
-echo $ECHO_N "checking /opt/oss/include/sys/soundcard.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include </opt/oss/include/sys/soundcard.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking /opt/oss/include/sys/soundcard.h presence" >&5
-echo $ECHO_N "checking /opt/oss/include/sys/soundcard.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include </opt/oss/include/sys/soundcard.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: /opt/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: /opt/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for /opt/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /opt/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__opt_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header__opt_oss_include_sys_soundcard_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__opt_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__opt_oss_include_sys_soundcard_h" >&6; }
-
-fi
-if test $ac_cv_header__opt_oss_include_sys_soundcard_h = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define MUS_HAVE_OPT_OSS 1
-_ACEOF
-
-fi
-
-
-if test "${ac_cv_header__var_lib_oss_include_sys_soundcard_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for /var/lib/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /var/lib/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__var_lib_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__var_lib_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__var_lib_oss_include_sys_soundcard_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking /var/lib/oss/include/sys/soundcard.h usability" >&5
-echo $ECHO_N "checking /var/lib/oss/include/sys/soundcard.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include </var/lib/oss/include/sys/soundcard.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking /var/lib/oss/include/sys/soundcard.h presence" >&5
-echo $ECHO_N "checking /var/lib/oss/include/sys/soundcard.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include </var/lib/oss/include/sys/soundcard.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: /var/lib/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: /var/lib/oss/include/sys/soundcard.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for /var/lib/oss/include/sys/soundcard.h" >&5
-echo $ECHO_N "checking for /var/lib/oss/include/sys/soundcard.h... $ECHO_C" >&6; }
-if test "${ac_cv_header__var_lib_oss_include_sys_soundcard_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header__var_lib_oss_include_sys_soundcard_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header__var_lib_oss_include_sys_soundcard_h" >&5
-echo "${ECHO_T}$ac_cv_header__var_lib_oss_include_sys_soundcard_h" >&6; }
-
-fi
-if test $ac_cv_header__var_lib_oss_include_sys_soundcard_h = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define MUS_HAVE_VAR_LIB_OSS 1
-_ACEOF
-
-fi
-
-
-if test "${ac_cv_header_sys_sam9407_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for sys/sam9407.h" >&5
-echo $ECHO_N "checking for sys/sam9407.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_sys_sam9407_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_sam9407_h" >&5
-echo "${ECHO_T}$ac_cv_header_sys_sam9407_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking sys/sam9407.h usability" >&5
-echo $ECHO_N "checking sys/sam9407.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <sys/sam9407.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking sys/sam9407.h presence" >&5
-echo $ECHO_N "checking sys/sam9407.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/sam9407.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: sys/sam9407.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: sys/sam9407.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: sys/sam9407.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: sys/sam9407.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: sys/sam9407.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: sys/sam9407.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: sys/sam9407.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/sam9407.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: sys/sam9407.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for sys/sam9407.h" >&5
-echo $ECHO_N "checking for sys/sam9407.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_sys_sam9407_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_sys_sam9407_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_sam9407_h" >&5
-echo "${ECHO_T}$ac_cv_header_sys_sam9407_h" >&6; }
-
-fi
-if test $ac_cv_header_sys_sam9407_h = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SAM_9407 1
-_ACEOF
-
-fi
-
-
-if test "${ac_cv_header_gnu_libc_version_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for gnu/libc-version.h" >&5
-echo $ECHO_N "checking for gnu/libc-version.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_gnu_libc_version_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_gnu_libc_version_h" >&5
-echo "${ECHO_T}$ac_cv_header_gnu_libc_version_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking gnu/libc-version.h usability" >&5
-echo $ECHO_N "checking gnu/libc-version.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <gnu/libc-version.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking gnu/libc-version.h presence" >&5
-echo $ECHO_N "checking gnu/libc-version.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <gnu/libc-version.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: gnu/libc-version.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: gnu/libc-version.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for gnu/libc-version.h" >&5
-echo $ECHO_N "checking for gnu/libc-version.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_gnu_libc_version_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_gnu_libc_version_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_gnu_libc_version_h" >&5
-echo "${ECHO_T}$ac_cv_header_gnu_libc_version_h" >&6; }
-
-fi
-if test $ac_cv_header_gnu_libc_version_h = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_GNU_LIBC_VERSION_H 1
-_ACEOF
-
-fi
-
-
-if test "${ac_cv_header_alsa_asoundlib_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for alsa/asoundlib.h" >&5
-echo $ECHO_N "checking for alsa/asoundlib.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_alsa_asoundlib_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_alsa_asoundlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_alsa_asoundlib_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking alsa/asoundlib.h usability" >&5
-echo $ECHO_N "checking alsa/asoundlib.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <alsa/asoundlib.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking alsa/asoundlib.h presence" >&5
-echo $ECHO_N "checking alsa/asoundlib.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <alsa/asoundlib.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for alsa/asoundlib.h" >&5
-echo $ECHO_N "checking for alsa/asoundlib.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_alsa_asoundlib_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_alsa_asoundlib_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_alsa_asoundlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_alsa_asoundlib_h" >&6; }
-
-fi
-if test $ac_cv_header_alsa_asoundlib_h = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_ALSA_ASOUNDLIB_H 1
-_ACEOF
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
-echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; }
-if test "${ac_cv_header_time+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-
-int
-main ()
-{
-if ((struct tm *) 0)
-return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_time=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_header_time=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
-echo "${ECHO_T}$ac_cv_header_time" >&6; }
-if test $ac_cv_header_time = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define TIME_WITH_SYS_TIME 1
-_ACEOF
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for mode_t" >&5
-echo $ECHO_N "checking for mode_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_mode_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-typedef mode_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
- return 0;
-if (sizeof (ac__type_new_))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_mode_t=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_mode_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
-echo "${ECHO_T}$ac_cv_type_mode_t" >&6; }
-if test $ac_cv_type_mode_t = yes; then
- :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define mode_t int
-_ACEOF
-
-fi
-
-{ echo "$as_me:$LINENO: checking for size_t" >&5
-echo $ECHO_N "checking for size_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_size_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-typedef size_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
- return 0;
-if (sizeof (ac__type_new_))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_size_t=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_size_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
-echo "${ECHO_T}$ac_cv_type_size_t" >&6; }
-if test $ac_cv_type_size_t = yes; then
- :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define size_t unsigned int
-_ACEOF
-
-fi
-
-{ echo "$as_me:$LINENO: checking for pid_t" >&5
-echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_pid_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-typedef pid_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
- return 0;
-if (sizeof (ac__type_new_))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_pid_t=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_pid_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
-echo "${ECHO_T}$ac_cv_type_pid_t" >&6; }
-if test $ac_cv_type_pid_t = yes; then
- :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define pid_t int
-_ACEOF
-
-fi
-
-{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
-echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; }
-if test "${ac_cv_c_bigendian+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # See if sys/param.h defines the BYTE_ORDER macro.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/param.h>
-
-int
-main ()
-{
-#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
- bogus endian macros
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- # It does; now see whether it defined to BIG_ENDIAN or not.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/param.h>
-
-int
-main ()
-{
-#if BYTE_ORDER != BIG_ENDIAN
- not big endian
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_c_bigendian=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_c_bigendian=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # It does not; compile a test program.
-if test "$cross_compiling" = yes; then
- # try to guess the endianness by grepping values into an object file
- ac_cv_c_bigendian=unknown
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
-short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
-void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
-short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
-short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
-void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
-int
-main ()
-{
- _ascii (); _ebcdic ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
- ac_cv_c_bigendian=yes
-fi
-if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
- if test "$ac_cv_c_bigendian" = unknown; then
- ac_cv_c_bigendian=no
- else
- # finding both strings is unlikely to happen, but who knows?
- ac_cv_c_bigendian=unknown
- fi
-fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-
- /* Are we little or big endian? From Harbison&Steele. */
- union
- {
- long int l;
- char c[sizeof (long int)];
- } u;
- u.l = 1;
- return u.c[sizeof (long int) - 1] == 1;
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_c_bigendian=no
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_c_bigendian=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
-echo "${ECHO_T}$ac_cv_c_bigendian" >&6; }
-case $ac_cv_c_bigendian in
- yes)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_LITTLE_ENDIAN 0
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define WORDS_BIGENDIAN 1
-_ACEOF
-
- case "$host" in
- *-apple-*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_AUDIO_COMPATIBLE_FORMAT MUS_BFLOAT
-_ACEOF
-
- ;;
- *)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_AUDIO_COMPATIBLE_FORMAT MUS_BSHORT
-_ACEOF
-
- ;;
- esac
- if test "$with_float_samples" != no ; then
- if test "$with_doubles" = yes ; then
- cat >>confdefs.h <<\_ACEOF
-#define MUS_OUT_FORMAT MUS_BDOUBLE
-_ACEOF
-
- else
- cat >>confdefs.h <<\_ACEOF
-#define MUS_OUT_FORMAT MUS_BFLOAT
-_ACEOF
-
- fi
- else
- cat >>confdefs.h <<\_ACEOF
-#define MUS_OUT_FORMAT MUS_BINT
-_ACEOF
-
- fi
- ;;
- no)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_LITTLE_ENDIAN 1
-_ACEOF
-
- case "$host" in
- *-apple-*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_AUDIO_COMPATIBLE_FORMAT MUS_LFLOAT
-_ACEOF
-
- ;;
- *)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_AUDIO_COMPATIBLE_FORMAT MUS_LSHORT
-_ACEOF
-
- ;;
- esac
- if test "$with_float_samples" != no ; then
- if test "$with_doubles" = yes ; then
- cat >>confdefs.h <<\_ACEOF
-#define MUS_OUT_FORMAT MUS_LDOUBLE
-_ACEOF
-
- else
- cat >>confdefs.h <<\_ACEOF
-#define MUS_OUT_FORMAT MUS_LFLOAT
-_ACEOF
-
- fi
- else
- cat >>confdefs.h <<\_ACEOF
-#define MUS_OUT_FORMAT MUS_LINT
-_ACEOF
-
- fi
- ;;
- *)
- { { echo "$as_me:$LINENO: error: unknown endianness
-presetting ac_cv_c_bigendian=no (or yes) will help" >&5
-echo "$as_me: error: unknown endianness
-presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
- { (exit 1); exit 1; }; } ;;
-esac
-
-
-# Check whether --enable-largefile was given.
-if test "${enable_largefile+set}" = set; then
- enableval=$enable_largefile;
-fi
-
-if test "$enable_largefile" != no; then
-
- { echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
-echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6; }
-if test "${ac_cv_sys_largefile_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_sys_largefile_CC=no
- if test "$GCC" != yes; then
- ac_save_CC=$CC
- while :; do
- # IRIX 6.2 and later do not support large files by default,
- # so use the C compiler's -n32 option if that helps.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
- rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext
- CC="$CC -n32"
- rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sys_largefile_CC=' -n32'; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext
- break
- done
- CC=$ac_save_CC
- rm -f conftest.$ac_ext
- fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
-echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6; }
- if test "$ac_cv_sys_largefile_CC" != no; then
- CC=$CC$ac_cv_sys_largefile_CC
- fi
-
- { echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
-echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6; }
-if test "${ac_cv_sys_file_offset_bits+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- while :; do
- ac_cv_sys_file_offset_bits=no
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#define _FILE_OFFSET_BITS 64
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sys_file_offset_bits=64; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- break
-done
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
-echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6; }
-if test "$ac_cv_sys_file_offset_bits" != no; then
-
-cat >>confdefs.h <<_ACEOF
-#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
-_ACEOF
-
-fi
-rm -f conftest*
- { echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
-echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6; }
-if test "${ac_cv_sys_large_files+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- while :; do
- ac_cv_sys_large_files=no
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#define _LARGE_FILES 1
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply define LARGE_OFF_T to be 9223372036854775807,
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sys_large_files=1; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- break
-done
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
-echo "${ECHO_T}$ac_cv_sys_large_files" >&6; }
-if test "$ac_cv_sys_large_files" != no; then
-
-cat >>confdefs.h <<_ACEOF
-#define _LARGE_FILES $ac_cv_sys_large_files
-_ACEOF
-
-fi
-rm -f conftest*
-fi
-
-{ echo "$as_me:$LINENO: checking for off_t" >&5
-echo $ECHO_N "checking for off_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_off_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-typedef off_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
- return 0;
-if (sizeof (ac__type_new_))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_off_t=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_off_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
-echo "${ECHO_T}$ac_cv_type_off_t" >&6; }
-if test $ac_cv_type_off_t = yes; then
- :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define off_t long int
-_ACEOF
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking for off_t" >&5
-echo $ECHO_N "checking for off_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_off_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-typedef off_t ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
- return 0;
-if (sizeof (ac__type_new_))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_off_t=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_off_t=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
-echo "${ECHO_T}$ac_cv_type_off_t" >&6; }
-
-{ echo "$as_me:$LINENO: checking size of off_t" >&5
-echo $ECHO_N "checking size of off_t... $ECHO_C" >&6; }
-if test "${ac_cv_sizeof_off_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$ac_cv_type_off_t" = yes; then
- # The cast to long int works around a bug in the HP C Compiler
- # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
- # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
- # This bug is HP SR number 8606223364.
- if test "$cross_compiling" = yes; then
- # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
- typedef off_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_lo=0 ac_mid=0
- while :; do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
- typedef off_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=$ac_mid; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_lo=`expr $ac_mid + 1`
- if test $ac_lo -le $ac_mid; then
- ac_lo= ac_hi=
- break
- fi
- ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
- typedef off_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=-1 ac_mid=-1
- while :; do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
- typedef off_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_lo=$ac_mid; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_hi=`expr '(' $ac_mid ')' - 1`
- if test $ac_mid -le $ac_hi; then
- ac_lo= ac_hi=
- break
- fi
- ac_mid=`expr 2 '*' $ac_mid`
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_lo= ac_hi=
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
- ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
- typedef off_t ac__type_sizeof_;
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=$ac_mid
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_off_t=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t)
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (off_t)
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; } ;;
-esac
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
- typedef off_t ac__type_sizeof_;
-static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
-static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
- FILE *f = fopen ("conftest.val", "w");
- if (! f)
- return 1;
- if (((long int) (sizeof (ac__type_sizeof_))) < 0)
- {
- long int i = longval ();
- if (i != ((long int) (sizeof (ac__type_sizeof_))))
- return 1;
- fprintf (f, "%ld\n", i);
- }
- else
- {
- unsigned long int i = ulongval ();
- if (i != ((long int) (sizeof (ac__type_sizeof_))))
- return 1;
- fprintf (f, "%lu\n", i);
- }
- return ferror (f) || fclose (f) != 0;
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sizeof_off_t=`cat conftest.val`
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t)
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (off_t)
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; }
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.val
-else
- ac_cv_sizeof_off_t=0
-fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5
-echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6; }
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_OFF_T $ac_cv_sizeof_off_t
-_ACEOF
-
-
-
-if test "$SIZEOF_INT" = "0" ; then
- { { echo "$as_me:$LINENO: error: big trouble: configure thinks ints have 0 bytes" >&5
-echo "$as_me: error: big trouble: configure thinks ints have 0 bytes" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-{ echo "$as_me:$LINENO: checking whether isnan is declared" >&5
-echo $ECHO_N "checking whether isnan is declared... $ECHO_C" >&6; }
-if test "${ac_cv_have_decl_isnan+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <math.h>
-
-int
-main ()
-{
-#ifndef isnan
- char *p = (char *) isnan;
- return !p;
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_have_decl_isnan=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_have_decl_isnan=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isnan" >&5
-echo "${ECHO_T}$ac_cv_have_decl_isnan" >&6; }
-if test $ac_cv_have_decl_isnan = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ISNAN 1
-_ACEOF
-
-
-else
- cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ISNAN 0
-_ACEOF
-
-
-fi
-
-
-{ echo "$as_me:$LINENO: checking whether isinf is declared" >&5
-echo $ECHO_N "checking whether isinf is declared... $ECHO_C" >&6; }
-if test "${ac_cv_have_decl_isinf+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <math.h>
-
-int
-main ()
-{
-#ifndef isinf
- char *p = (char *) isinf;
- return !p;
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_have_decl_isinf=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_have_decl_isinf=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isinf" >&5
-echo "${ECHO_T}$ac_cv_have_decl_isinf" >&6; }
-if test $ac_cv_have_decl_isinf = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ISINF 1
-_ACEOF
-
-
-else
- cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ISINF 0
-_ACEOF
-
-
-fi
-
-
-
-{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5
-echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; }
-if test "${ac_cv_type_signal+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <signal.h>
-
-int
-main ()
-{
-return *(signal (0, 0)) (0) == 1;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_signal=int
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_signal=void
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5
-echo "${ECHO_T}$ac_cv_type_signal" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define RETSIGTYPE $ac_cv_type_signal
-_ACEOF
-
-
-
-
-
-
-
-
-
-
-
-for ac_func in getcwd strerror access vsnprintf snprintf memmove strdup fileno strftime
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined __stub_$ac_func || defined __stub___$ac_func
-choke me
-#endif
-
-int
-main ()
-{
-return $ac_func ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_var=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_var=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-ac_res=`eval echo '${'$as_ac_var'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_var'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-# having <complex.h> + a cacos declaration is not enough: C++ dies with a complaint about a "deprecated header"
-if test "$with_gsl" != yes; then
- LIBS="$LIBS -lm"
- { echo "$as_me:$LINENO: checking for complex trig" >&5
-echo $ECHO_N "checking for complex trig... $ECHO_C" >&6; }
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <complex.h>
-int
-main ()
-{
- _Complex double val;
- double rl, im;
- val = 1.0 + 0.5 * _Complex_I;
- rl = creal(val);
- im = cimag(val);
- val = ccosh(cacosh(1.5) / 100.0)
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_COMPLEX_TRIG 1
-_ACEOF
-
- { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
- with_gsl=no
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-
-
-# -------- GSL --------
-GSL_LIBS=""
-GSL_CFLAGS=""
-if test "$with_gsl" != no; then
-# Extract the first word of "gsl-config", so it can be a program name with args.
-set dummy gsl-config; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_path_GSL_CONFIG+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $GSL_CONFIG in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_GSL_CONFIG="$GSL_CONFIG" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_path_GSL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_path_GSL_CONFIG" && ac_cv_path_GSL_CONFIG="no"
- ;;
-esac
-fi
-GSL_CONFIG=$ac_cv_path_GSL_CONFIG
-if test -n "$GSL_CONFIG"; then
- { echo "$as_me:$LINENO: result: $GSL_CONFIG" >&5
-echo "${ECHO_T}$GSL_CONFIG" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
-{ echo "$as_me:$LINENO: checking for GSL" >&5
-echo $ECHO_N "checking for GSL... $ECHO_C" >&6; }
-if test "$GSL_CONFIG" = "no" ; then
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-else
- GSL_CFLAGS=`$GSL_CONFIG --cflags`
- GSL_PREFIX=`$GSL_CONFIG --prefix`
- if test "$with_static_gsl" = yes ; then
- as_ac_File=`echo "ac_cv_file_$GSL_PREFIX/lib/libgsl.a" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $GSL_PREFIX/lib/libgsl.a" >&5
-echo $ECHO_N "checking for $GSL_PREFIX/lib/libgsl.a... $ECHO_C" >&6; }
-if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- test "$cross_compiling" = yes &&
- { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
-echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
- { (exit 1); exit 1; }; }
-if test -r "$GSL_PREFIX/lib/libgsl.a"; then
- eval "$as_ac_File=yes"
-else
- eval "$as_ac_File=no"
-fi
-fi
-ac_res=`eval echo '${'$as_ac_File'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_File'}'` = yes; then
- GSL_LIBS="$GSL_PREFIX/lib/libgsl.a"
-else
- GSL_LIBS=`$GSL_CONFIG --libs`
- with_static_gsl=no
- { echo "$as_me:$LINENO: WARNING: can't find libgsl.a" >&5
-echo "$as_me: WARNING: can't find libgsl.a" >&2;}
-fi
-
- else
- GSL_LIBS=`$GSL_CONFIG --libs`
- fi
- gsl_version="`$GSL_CONFIG --version`"
- { echo "$as_me:$LINENO: result: $gsl_version" >&5
-echo "${ECHO_T}$gsl_version" >&6; }
- cat >>confdefs.h <<_ACEOF
-#define MUS_GSL_VERSION "${gsl_version}"
-_ACEOF
-
- if test "`$GSL_CONFIG --version`" = "0.6" || test "`$GSL_CONFIG --version`" = "0.7"; then
- { echo "$as_me:$LINENO: WARNING: sndlib needs GSL 0.8 or later" >&5
-echo "$as_me: WARNING: sndlib needs GSL 0.8 or later" >&2;}
- else
- if test "`$GSL_CONFIG --version`" = "0.8" && test "$with_static_gsl" = yes ; then
- GSL_LIBS="$GSL_LIBS $GSL_PREFIX/lib/libgslcblas.a"
- fi
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_GSL 1
-_ACEOF
-
- fi
-fi
-fi
-
-
-
-
-SNDLIB_LANGUAGE="None"
-RUBY="ruby"
-
-# Check whether --with-ruby-prefix was given.
-if test "${with_ruby_prefix+set}" = set; then
- withval=$with_ruby_prefix; ruby_prefix="$withval"
- RUBY="$ruby_prefix/bin/ruby"
-else
- ruby_prefix=""
-fi
-
-
-
-# Check whether --with-ruby was given.
-if test "${with_ruby+set}" = set; then
- withval=$with_ruby; if test "$with_ruby" = yes ; then
- { echo "$as_me:$LINENO: checking for Ruby" >&5
-echo $ECHO_N "checking for Ruby... $ECHO_C" >&6; }
- RUBY_VERSION=`$RUBY -e 'puts RUBY_VERSION'`
- RUBY_RELEASE_DATE=`$RUBY -e 'puts RUBY_RELEASE_DATE'`
- if test "$RUBY_VERSION" > "0" ; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_RUBY 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 1
-_ACEOF
-
- { echo "$as_me:$LINENO: result: $RUBY_VERSION" >&5
-echo "${ECHO_T}$RUBY_VERSION" >&6; }
- cat >>confdefs.h <<_ACEOF
-#define MUS_RUBY_VERSION "${RUBY_VERSION}"
-_ACEOF
-
- cat >>confdefs.h <<_ACEOF
-#define RUBY_RELEASE_DATE "${RUBY_RELEASE_DATE}"
-_ACEOF
-
-
- GUILE_CFLAGS=`$RUBY -e '\$:.each {|path| print "-I", path, " "}'`
- GUILE_LIBS=`$RUBY -e '\$:.each {|path| print "-L", path, " "}'`
-# RUBY_SEARCH_PATH=`$RUBY -e [['\$:.each {|path| print path, ":"}']]`
- RUBY_LIBS=`$RUBY -e 'require "rbconfig"; include Config; print CONFIG["LIBS"]'`
-
- GUILE_LIBS="$GUILE_LIBS -lruby $RUBY_LIBS"
- { echo "$as_me:$LINENO: checking for readline in -lreadline" >&5
-echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6; }
-if test "${ac_cv_lib_readline_readline+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lreadline "-lncurses" $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char readline ();
-int
-main ()
-{
-return readline ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_readline_readline=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_readline_readline=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5
-echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6; }
-if test $ac_cv_lib_readline_readline = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_READLINE 1
-_ACEOF
-
- GUILE_LIBS="$GUILE_LIBS -lreadline -lncurses"
-fi
-
-
-
- SNDLIB_LANGUAGE="Ruby"
-
- OLD_LIBS="$LIBS"
- LIBS="$GUILE_LIBS"
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$GUILE_CFLAGS -lm"
- { echo "$as_me:$LINENO: checking for rb_gc_disable in -lruby" >&5
-echo $ECHO_N "checking for rb_gc_disable in -lruby... $ECHO_C" >&6; }
-if test "${ac_cv_lib_ruby_rb_gc_disable+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lruby $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char rb_gc_disable ();
-int
-main ()
-{
-return rb_gc_disable ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_ruby_rb_gc_disable=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_ruby_rb_gc_disable=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_ruby_rb_gc_disable" >&5
-echo "${ECHO_T}$ac_cv_lib_ruby_rb_gc_disable" >&6; }
-if test $ac_cv_lib_ruby_rb_gc_disable = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_RB_GC_DISABLE 1
-_ACEOF
-
-fi
-
- { echo "$as_me:$LINENO: checking for rb_ary_dup in -lruby" >&5
-echo $ECHO_N "checking for rb_ary_dup in -lruby... $ECHO_C" >&6; }
-if test "${ac_cv_lib_ruby_rb_ary_dup+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lruby $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char rb_ary_dup ();
-int
-main ()
-{
-return rb_ary_dup ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_ruby_rb_ary_dup=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_ruby_rb_ary_dup=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_ruby_rb_ary_dup" >&5
-echo "${ECHO_T}$ac_cv_lib_ruby_rb_ary_dup" >&6; }
-if test $ac_cv_lib_ruby_rb_ary_dup = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_RB_ARY_DUP 1
-_ACEOF
-
-fi
-
- LIBS="$OLD_LIBS"
- CFLAGS="$OLD_CFLAGS"
-
- else
- { echo "$as_me:$LINENO: WARNING: can't find Ruby!" >&5
-echo "$as_me: WARNING: can't find Ruby!" >&2;}
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_RUBY 0
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 0
-_ACEOF
-
- fi
- fi
-fi
-
-
-#--------------------------------------------------------------------------------
-# Gauche
-#--------------------------------------------------------------------------------
-
-if test "$with_gauche" = yes ; then
- # Extract the first word of "gauche-config", so it can be a program name with args.
-set dummy gauche-config; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_path_GAUCHE_CONFIG+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $GAUCHE_CONFIG in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_GAUCHE_CONFIG="$GAUCHE_CONFIG" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_path_GAUCHE_CONFIG="$as_dir/$ac_word$ac_exec_ext"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_path_GAUCHE_CONFIG" && ac_cv_path_GAUCHE_CONFIG="no"
- ;;
-esac
-fi
-GAUCHE_CONFIG=$ac_cv_path_GAUCHE_CONFIG
-if test -n "$GAUCHE_CONFIG"; then
- { echo "$as_me:$LINENO: result: $GAUCHE_CONFIG" >&5
-echo "${ECHO_T}$GAUCHE_CONFIG" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
- { echo "$as_me:$LINENO: checking for Gauche" >&5
-echo $ECHO_N "checking for Gauche... $ECHO_C" >&6; }
- if test "$GAUCHE_CONFIG" = "no" ; then
- { echo "$as_me:$LINENO: WARNING: can't find Gauche!" >&5
-echo "$as_me: WARNING: can't find Gauche!" >&2;}
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 0
-_ACEOF
-
- else
- # check for version >= 0.8.7
- gauche_version="`$GAUCHE_CONFIG -V`"
- { echo "$as_me:$LINENO: result: $gauche_version" >&5
-echo "${ECHO_T}$gauche_version" >&6; }
-
- OLD_CFLAGS="CFLAGS"
- # gauche-config inserts idiotic single-quotes in the -I and -L results thereby rendering them useless,
- # so the following sed command tries to remove them. You apparently can't quote a single-quote
- # in this context, so I use \x27 = ASCII for single quote.
-# GUILE_CFLAGS=`$GAUCHE_CONFIG -I | sed 's/\x27//g'`
- GUILE_CFLAGS=`$GAUCHE_CONFIG -I | tr -d "'"`
- CFLAGS="$CFLAGS $GUILE_CFLAGS"
-
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <gauche.h>
-int
-main ()
-{
-#if (GAUCHE_MAJOR_VERSION == 0)
- #if (GAUCHE_MINOR_VERSION < 8)
- #error too old
- #else
- #if (GAUCHE_MINOR_VERSION == 8) && (GAUCHE_MICRO_VERSION < 7)
- #error too old
- #endif
- #endif
- #endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_GAUCHE 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCHEME 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 1
-_ACEOF
-
- GUILE_LIBS=`$GAUCHE_CONFIG -L | sed 's/\x27//g'`
- GUILE_LIBS="$GUILE_LIBS -lgauche"
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
- { echo "$as_me:$LINENO: WARNING: We need Gauche 0.8.7 or later" >&5
-echo "$as_me: WARNING: We need Gauche 0.8.7 or later" >&2;}
- with_gauche=no
- CFLAGS="$OLD_CFLAGS"
- GUILE_CFLAGS=""
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
-fi
-
-#--------------------------------------------------------------------------------
-# Forth
-#--------------------------------------------------------------------------------
-
-## fth.m4 -- Autoconf macros for configuring FTH -*- Autoconf -*-
-
-## Copyright (C) 2006 Michael Scholz
-
-## Author: Michael Scholz <scholz-micha@gmx.de>
-## Created: Mon Mar 13 17:14:46 CET 2006
-## Changed: Thu Mar 23 13:46:43 CET 2006
-## Ident: $Id: fth.m4,v 1.1.1.1 2006/03/25 21:29:50 mi-scholz Exp $
-
-## This file is part of FTH.
-
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-## Commentary:
-
-# FTH_CHECK_LIB(action-if-found, [action-if-not-found])
-#
-# Usage: FTH_CHECK_LIB([AC_DEFINE([HAVE_FORTH])])
-#
-# Don't quote this macro: [FTH_CHECK_LIB(...)] isn't correct.
-# Instead call it FTH_CHECK_LIB(...).
-#
-# Six variables will be substituted:
-#
-# FTH fth program path or no
-# FTH_VERSION version string or ""
-# FTH_CFLAGS -I${prefix}/include/fth or ""
-# FTH_LIBS -L${prefix}/lib -lfth or ""
-# FTH_HAVE_COMPLEX yes or no
-# FTH_HAVE_RATIO yes or no
-
-## Code:
-
-# AC_CHECK_LIB was written by David MacKenzie.
-# This version is slightly changed to fit to FTH_CHECK_LIB.
-
-# fth_AC_CHECK_LIB
-
-# FTH_CHECK_LIB
-
-## fth.m4 ends here
-
-
-# Check whether --with-forth was given.
-if test "${with_forth+set}" = set; then
- withval=$with_forth; if test "$with_forth" = yes ; then
-
- # Extract the first word of "fth", so it can be a program name with args.
-set dummy fth; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_path_FTH+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $FTH in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_FTH="$FTH" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_path_FTH="$as_dir/$ac_word$ac_exec_ext"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_path_FTH" && ac_cv_path_FTH="no"
- ;;
-esac
-fi
-FTH=$ac_cv_path_FTH
-if test -n "$FTH"; then
- { echo "$as_me:$LINENO: result: $FTH" >&5
-echo "${ECHO_T}$FTH" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
- FTH_VERSION=""
- FTH_CFLAGS=""
- FTH_LIBS=""
- FTH_HAVE_COMPLEX=no
- FTH_HAVE_RATIO=no
- { echo "$as_me:$LINENO: checking for Forth" >&5
-echo $ECHO_N "checking for Forth... $ECHO_C" >&6; }
- if test "${FTH}" != no ; then
- FTH_VERSION=`${FTH} --no-init-file --eval .version`
- FTH_CFLAGS=`${FTH} --no-init-file --eval .cflags`
- FTH_LIBS=`${FTH} --no-init-file --eval .libs`
- { echo "$as_me:$LINENO: result: FTH version ${FTH_VERSION}" >&5
-echo "${ECHO_T}FTH version ${FTH_VERSION}" >&6; }
-
- { echo "$as_me:$LINENO: checking whether FTH supports complex numbers" >&5
-echo $ECHO_N "checking whether FTH supports complex numbers... $ECHO_C" >&6; }
-if test "${ac_cv_lib_fth_fth_make_complex+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- fth_check_lib_save_LIBS=$LIBS
- LIBS="-lfth ${FTH_LIBS} $LIBS"
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char fth_make_complex ();
-int
-main ()
-{
-return fth_make_complex ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_fth_fth_make_complex=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_fth_fth_make_complex=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$fth_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_fth_fth_make_complex" >&5
-echo "${ECHO_T}$ac_cv_lib_fth_fth_make_complex" >&6; }
- if test $ac_cv_lib_fth_fth_make_complex = yes; then
- FTH_HAVE_COMPLEX=yes
-fi
-
-
- { echo "$as_me:$LINENO: checking whether FTH supports rational numbers" >&5
-echo $ECHO_N "checking whether FTH supports rational numbers... $ECHO_C" >&6; }
-if test "${ac_cv_lib_fth_fth_ratio_floor+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- fth_check_lib_save_LIBS=$LIBS
- LIBS="-lfth ${FTH_LIBS} $LIBS"
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char fth_ratio_floor ();
-int
-main ()
-{
-return fth_ratio_floor ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_fth_fth_ratio_floor=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_fth_fth_ratio_floor=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- LIBS=$fth_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_fth_fth_ratio_floor" >&5
-echo "${ECHO_T}$ac_cv_lib_fth_fth_ratio_floor" >&6; }
- if test $ac_cv_lib_fth_fth_ratio_floor = yes; then
- FTH_HAVE_RATIO=yes
-fi
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_FORTH 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 1
-_ACEOF
-
- if test "$FTH_HAVE_COMPLEX" = yes ; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_COMPLEX_TRIG 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_MAKE_COMPLEX 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_C_MAKE_RECTANGULAR 1
-_ACEOF
-
- fi
- if test "$FTH_HAVE_RATIO" = yes ; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_MAKE_RATIO 1
-_ACEOF
-
- fi
- GUILE_CFLAGS=$FTH_CFLAGS
-
- GUILE_LIBS=$FTH_LIBS
-
- SNDLIB_LANGUAGE="Forth"
- else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-
- fi
-
-
-
-
-
-
- fi
-fi
-
-
-
-#--------------------------------------------------------------------------------
-# Guile
-#--------------------------------------------------------------------------------
-
-if test "$with_guile" != no && test "$with_gauche" != yes && test "$with_ruby" != yes && test "$with_forth" != yes ; then
-
-GUILE_LIBS=""
-GUILE_CFLAGS=""
-# GUILE_CONFIG_path=""
-# allow user to specify this in invocation line
-GUILE_LIB_path=""
-XM_LIBS=""
-SNDLIB_MODULES="no"
-
-if test "$with_guile" = no ; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_GUILE 0
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 0
-_ACEOF
-
-else
-
- { echo "$as_me:$LINENO: checking for /usr/lib/snd/bin/guile-config" >&5
-echo $ECHO_N "checking for /usr/lib/snd/bin/guile-config... $ECHO_C" >&6; }
-if test "${ac_cv_file__usr_lib_snd_bin_guile_config+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- test "$cross_compiling" = yes &&
- { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
-echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
- { (exit 1); exit 1; }; }
-if test -r "/usr/lib/snd/bin/guile-config"; then
- ac_cv_file__usr_lib_snd_bin_guile_config=yes
-else
- ac_cv_file__usr_lib_snd_bin_guile_config=no
-fi
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_file__usr_lib_snd_bin_guile_config" >&5
-echo "${ECHO_T}$ac_cv_file__usr_lib_snd_bin_guile_config" >&6; }
-if test $ac_cv_file__usr_lib_snd_bin_guile_config = yes; then
-
- GUILE_CONFIG_path=/usr/lib/snd/bin/
- GUILE_LIB_path=/usr/lib/snd/lib
-
-fi
-
-
- { echo "$as_me:$LINENO: checking for Guile" >&5
-echo $ECHO_N "checking for Guile... $ECHO_C" >&6; }
- if test "$GUILE_CONFIG_path" != "" ; then
- if ! test -x "${GUILE_CONFIG_path}guile-config" ; then
- # try adding the "/" to the path
- GUILE_CONFIG_path="${GUILE_CONFIG_path}/"
- fi
- fi
- if (${GUILE_CONFIG_path}guile-config link > /dev/null) 2>&1; then
- GUILE_CONFIG_works=yes
- else
- GUILE_CONFIG_works=no
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
- fi
-
-if test $GUILE_CONFIG_works = yes; then
- GUILE_CFLAGS="`${GUILE_CONFIG_path}guile-config compile`"
- if test "$GUILE_LIB_path" != "" ; then
- # MacOSX linker doesn't know the -rpath stuff, but user may have placed Guile in /usr/lib/snd/bin
- case "$host" in
- *-apple-*)
- GUILE_LIBS="`${GUILE_CONFIG_path}guile-config link`"
- ;;
- *)
- GUILE_LIBS="-Xlinker -rpath -Xlinker $GUILE_LIB_path `${GUILE_CONFIG_path}guile-config link`"
- XM_LIBS="`${GUILE_CONFIG_path}guile-config link`"
- ;;
- esac
- else
- GUILE_LIBS="`${GUILE_CONFIG_path}guile-config link`"
- fi
-
- guile_version="`${GUILE_CONFIG_path}guile -c '(display (version))'`"
- { echo "$as_me:$LINENO: result: $guile_version" >&5
-echo "${ECHO_T}$guile_version" >&6; }
-
- if test "`${GUILE_CONFIG_path}guile -c '(display (string>=? (version) "1.3.4"))'`" != "#t"; then
- { echo "$as_me:$LINENO: WARNING: sndlib needs Guile 1.3.4 or later" >&5
-echo "$as_me: WARNING: sndlib needs Guile 1.3.4 or later" >&2;}
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_GUILE 0
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 0
-_ACEOF
-
- else
-
- if test "$XM_LIBS" = ""; then
- XM_LIBS="$GUILE_LIBS"
- fi
-
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_GUILE 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCHEME 1
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 1
-_ACEOF
-
- SNDLIB_LANGUAGE="Guile"
-
- OLD_LIBS="$LIBS"
- LIBS="$GUILE_LIBS"
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$GUILE_CFLAGS"
- GNAME="guile"
-
-# special Mac OSX stuff -- need to protect against multiple -lguile's, add -all_load, and add -lguile-ltdl
- case "$host" in
- *-apple-*)
- CFLAGS="$CFLAGS -all_load"
- GNAME="m"
- esac
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_set_smob_apply" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_set_smob_apply in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_set_smob_apply in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_set_smob_apply ();
-int
-main ()
-{
-return scm_set_smob_apply ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_APPLICABLE_SMOB 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_remember_upto_here" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_remember_upto_here in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_remember_upto_here in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_remember_upto_here ();
-int
-main ()
-{
-return scm_remember_upto_here ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_REMEMBER_UPTO_HERE 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_make_real" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_make_real in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_make_real in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_make_real ();
-int
-main ()
-{
-return scm_make_real ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_MAKE_REAL 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_object_to_string" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_object_to_string in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_object_to_string in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_object_to_string ();
-int
-main ()
-{
-return scm_object_to_string ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_OBJECT_TO_STRING 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_num2long_long" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_num2long_long in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_num2long_long in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_num2long_long ();
-int
-main ()
-{
-return scm_num2long_long ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_NUM2LONG_LONG 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_num2int" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_num2int in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_num2int in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_num2int ();
-int
-main ()
-{
-return scm_num2int ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_NUM2INT 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_c_make_vector" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_c_make_vector in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_c_make_vector in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_c_make_vector ();
-int
-main ()
-{
-return scm_c_make_vector ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_C_MAKE_VECTOR 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_c_define" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_c_define in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_c_define in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_c_define ();
-int
-main ()
-{
-return scm_c_define ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_C_DEFINE 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_c_define_gsubr" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_c_define_gsubr in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_c_define_gsubr in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_c_define_gsubr ();
-int
-main ()
-{
-return scm_c_define_gsubr ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_C_DEFINE_GSUBR 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_c_eval_string" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_c_eval_string in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_c_eval_string in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_c_eval_string ();
-int
-main ()
-{
-return scm_c_eval_string ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_C_EVAL_STRING 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_list_n" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_list_n in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_list_n in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_list_n ();
-int
-main ()
-{
-return scm_list_n ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_LIST_N 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_str2symbol" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_str2symbol in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_str2symbol in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_str2symbol ();
-int
-main ()
-{
-return scm_str2symbol ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_STR2SYMBOL 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_to_signed_integer" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_to_signed_integer in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_to_signed_integer in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_to_signed_integer ();
-int
-main ()
-{
-return scm_to_signed_integer ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_TO_SIGNED_INTEGER 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_c_make_rectangular" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_c_make_rectangular in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_c_make_rectangular in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_c_make_rectangular ();
-int
-main ()
-{
-return scm_c_make_rectangular ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_C_MAKE_RECTANGULAR 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_car" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_car in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_car in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_car ();
-int
-main ()
-{
-return scm_car ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_CAR 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_from_locale_keyword" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_from_locale_keyword in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_from_locale_keyword in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_from_locale_keyword ();
-int
-main ()
-{
-return scm_from_locale_keyword ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_FROM_LOCALE_KEYWORD 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_is_vector" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_is_vector in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_is_vector in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_is_vector ();
-int
-main ()
-{
-return scm_is_vector ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_IS_VECTOR 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_is_simple_vector" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_is_simple_vector in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_is_simple_vector in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_is_simple_vector ();
-int
-main ()
-{
-return scm_is_simple_vector ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_IS_SIMPLE_VECTOR 1
-_ACEOF
-
-fi
-
- as_ac_Lib=`echo "ac_cv_lib_$GNAME''_scm_c_define_module" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for scm_c_define_module in -l$GNAME" >&5
-echo $ECHO_N "checking for scm_c_define_module in -l$GNAME... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$GNAME $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char scm_c_define_module ();
-int
-main ()
-{
-return scm_c_define_module ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Lib=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_Lib=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- if test "$with_modules" = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define WITH_MODULES 1
-_ACEOF
-
- SNDLIB_MODULES="yes"
- fi
-fi
-
- { echo "$as_me:$LINENO: checking for scm_t_catch_body" >&5
-echo $ECHO_N "checking for scm_t_catch_body... $ECHO_C" >&6; }
-if test "${ac_cv_type_scm_t_catch_body+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <guile/gh.h>
-
-typedef scm_t_catch_body ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
- return 0;
-if (sizeof (ac__type_new_))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_scm_t_catch_body=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_scm_t_catch_body=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_scm_t_catch_body" >&5
-echo "${ECHO_T}$ac_cv_type_scm_t_catch_body" >&6; }
-if test $ac_cv_type_scm_t_catch_body = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_SCM_T_CATCH_BODY 1
-_ACEOF
-
-fi
-
- { echo "$as_me:$LINENO: checking for scm_t_guard" >&5
-echo $ECHO_N "checking for scm_t_guard... $ECHO_C" >&6; }
-if test "${ac_cv_type_scm_t_guard+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <guile/gh.h>
-
-typedef scm_t_guard ac__type_new_;
-int
-main ()
-{
-if ((ac__type_new_ *) 0)
- return 0;
-if (sizeof (ac__type_new_))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_scm_t_guard=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_type_scm_t_guard=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_type_scm_t_guard" >&5
-echo "${ECHO_T}$ac_cv_type_scm_t_guard" >&6; }
-if test $ac_cv_type_scm_t_guard = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_DYNAMIC_WIND 1
-_ACEOF
-
-fi
-
- LIBS="$OLD_LIBS"
- CFLAGS="$OLD_CFLAGS"
-
- if test "`${GUILE_CONFIG_path}guile -c '(display (string<=? (version) "1.3.4"))'`" = "#t"; then
- echo found old out-of-date Guile library
- fi
- fi
-else
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_GUILE 0
-_ACEOF
-
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_EXTENSION_LANGUAGE 0
-_ACEOF
-
-fi
-fi
-fi
-
-
-#--------------------------------------------------------------------------------
-# Audio library
-#--------------------------------------------------------------------------------
-
-AUDIO_LIB=""
-LDSO_FLAGS=""
-SO_FLAGS=""
-SO_LD="ld"
-SO_INSTALL="install"
-A_INSTALL="install"
-# A_LD="ld"
-# A_LD_FLAGS=""
-A_LD="ar"
-A_LD_FLAGS="-rc"
-
-LD_FLAGS="-r"
-
-# we need the sndlib.h equivalents to try to find the native sound support (see config.guess)
-# this only matters for those cases where we've implemented the audio code in audio.c
-# test for ALSA courtesy of Paul Barton-Davis
-# test for ESD courtesy of Nick Bailey
-# test for BSD courtesy of Steven Schultz
-# test for Jack courtesy of Kjetil S. Matheussen
-
-if test "$with_esd" = yes ; then
- { echo "$as_me:$LINENO: checking for main in -lesd" >&5
-echo $ECHO_N "checking for main in -lesd... $ECHO_C" >&6; }
-if test "${ac_cv_lib_esd_main+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lesd $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_esd_main=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_esd_main=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_esd_main" >&5
-echo "${ECHO_T}$ac_cv_lib_esd_main" >&6; }
-if test $ac_cv_lib_esd_main = yes; then
-
- if test "${ac_cv_header_esd_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for esd.h" >&5
-echo $ECHO_N "checking for esd.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_esd_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_esd_h" >&5
-echo "${ECHO_T}$ac_cv_header_esd_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking esd.h usability" >&5
-echo $ECHO_N "checking esd.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <esd.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking esd.h presence" >&5
-echo $ECHO_N "checking esd.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <esd.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: esd.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: esd.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: esd.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: esd.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: esd.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: esd.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: esd.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: esd.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: esd.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: esd.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: esd.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: esd.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: esd.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: esd.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: esd.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: esd.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for esd.h" >&5
-echo $ECHO_N "checking for esd.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_esd_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_esd_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_esd_h" >&5
-echo "${ECHO_T}$ac_cv_header_esd_h" >&6; }
-
-fi
-if test $ac_cv_header_esd_h = yes; then
-
- cat >>confdefs.h <<\_ACEOF
-#define MUS_ESD 1
-_ACEOF
-
- esd_version="`esd-config --version`"
- cat >>confdefs.h <<_ACEOF
-#define MUS_ESD_VERSION "${esd_version}"
-_ACEOF
-
- audiofile_version="`audiofile-config --version`"
- cat >>confdefs.h <<_ACEOF
-#define MUS_AUDIOFILE_VERSION "${audiofile_version}"
-_ACEOF
-
- AUDIO_LIB="`esd-config --libs`"
-# ESD_CFLAGS="`esd-config --cflags`"
-
- audio_system=ESD
-
-else
- { echo "$as_me:$LINENO: WARNING: can't find the ESD header files" >&5
-echo "$as_me: WARNING: can't find the ESD header files" >&2;}
-fi
-
-
-else
- { echo "$as_me:$LINENO: WARNING: can't find the ESD library" >&5
-echo "$as_me: WARNING: can't find the ESD library" >&2;}
-fi
-
-fi
-
-if test "$audio_system" != unknown ; then
- { echo "$as_me:$LINENO: result: Using the $audio_system audio system" >&5
-echo "${ECHO_T}Using the $audio_system audio system" >&6; }
-else
-
-case "$host" in
- *-*-linux*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_LINUX 1
-_ACEOF
-
- LDSO_FLAGS="-shared"
- if test "$GCC" = yes ; then
- SO_FLAGS="-fPIC $SO_FLAGS"
- fi
- SO_LD="gcc"
-# A_LD="ld"
-# This ^ used to be gcc, but that no longer seems to work
- LIBS="-L/usr/lib -lm"
-# This ^ used to be "" but in redhat 7 the -lm needs to be explicit for make sndsine etc
-# it was "" to cancel -lXpm without the needed -L<dir> for the same case
- audio_system=OSS
-
- if test "$with_alsa" = yes || test "$with_static_alsa" = yes ; then
- { echo "$as_me:$LINENO: checking for main in -lasound" >&5
-echo $ECHO_N "checking for main in -lasound... $ECHO_C" >&6; }
-if test "${ac_cv_lib_asound_main+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lasound $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_asound_main=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_asound_main=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_asound_main" >&5
-echo "${ECHO_T}$ac_cv_lib_asound_main" >&6; }
-if test $ac_cv_lib_asound_main = yes; then
-
- if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for sys/asoundlib.h" >&5
-echo $ECHO_N "checking for sys/asoundlib.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_asoundlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_sys_asoundlib_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking sys/asoundlib.h usability" >&5
-echo $ECHO_N "checking sys/asoundlib.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <sys/asoundlib.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking sys/asoundlib.h presence" >&5
-echo $ECHO_N "checking sys/asoundlib.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/asoundlib.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: sys/asoundlib.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for sys/asoundlib.h" >&5
-echo $ECHO_N "checking for sys/asoundlib.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_sys_asoundlib_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_asoundlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_sys_asoundlib_h" >&6; }
-
-fi
-if test $ac_cv_header_sys_asoundlib_h = yes; then
- audio_system=ALSA
-else
- if test "${ac_cv_header_alsa_asoundlib_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for alsa/asoundlib.h" >&5
-echo $ECHO_N "checking for alsa/asoundlib.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_alsa_asoundlib_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_alsa_asoundlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_alsa_asoundlib_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking alsa/asoundlib.h usability" >&5
-echo $ECHO_N "checking alsa/asoundlib.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <alsa/asoundlib.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking alsa/asoundlib.h presence" >&5
-echo $ECHO_N "checking alsa/asoundlib.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <alsa/asoundlib.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: alsa/asoundlib.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: alsa/asoundlib.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for alsa/asoundlib.h" >&5
-echo $ECHO_N "checking for alsa/asoundlib.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_alsa_asoundlib_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_alsa_asoundlib_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_alsa_asoundlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_alsa_asoundlib_h" >&6; }
-
-fi
-if test $ac_cv_header_alsa_asoundlib_h = yes; then
- audio_system=ALSA
-else
- { echo "$as_me:$LINENO: WARNING: can't find the ALSA header files" >&5
-echo "$as_me: WARNING: can't find the ALSA header files" >&2;}
-fi
-
-
-fi
-
-
-else
- { echo "$as_me:$LINENO: WARNING: can't find the ALSA library" >&5
-echo "$as_me: WARNING: can't find the ALSA library" >&2;}
-fi
-
- else
- if test "$with_jack" = yes ; then
- { echo "$as_me:$LINENO: checking for main in -ljack" >&5
-echo $ECHO_N "checking for main in -ljack... $ECHO_C" >&6; }
-if test "${ac_cv_lib_jack_main+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ljack $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
-int
-main ()
-{
-return main ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_jack_main=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_jack_main=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_jack_main" >&5
-echo "${ECHO_T}$ac_cv_lib_jack_main" >&6; }
-if test $ac_cv_lib_jack_main = yes; then
-
- if test "${ac_cv_header_jack_jack_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for jack/jack.h" >&5
-echo $ECHO_N "checking for jack/jack.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_jack_jack_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_jack_jack_h" >&5
-echo "${ECHO_T}$ac_cv_header_jack_jack_h" >&6; }
-else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking jack/jack.h usability" >&5
-echo $ECHO_N "checking jack/jack.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <jack/jack.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking jack/jack.h presence" >&5
-echo $ECHO_N "checking jack/jack.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <jack/jack.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: jack/jack.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: jack/jack.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: jack/jack.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: jack/jack.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: jack/jack.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: jack/jack.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: jack/jack.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: jack/jack.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: jack/jack.h: in the future, the compiler will take precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------------- ##
-## Report this to bil@ccrma.stanford.edu ##
-## ------------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for jack/jack.h" >&5
-echo $ECHO_N "checking for jack/jack.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_jack_jack_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_jack_jack_h=$ac_header_preproc
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_jack_jack_h" >&5
-echo "${ECHO_T}$ac_cv_header_jack_jack_h" >&6; }
-
-fi
-if test $ac_cv_header_jack_jack_h = yes; then
- audio_system=JACK
-else
- with_jack=no
- { echo "$as_me:$LINENO: WARNING: can't find the JACK header files" >&5
-echo "$as_me: WARNING: can't find the JACK header files" >&2;}
-fi
-
-
-else
- with_jack=no
- { echo "$as_me:$LINENO: WARNING: can't find the JACK library" >&5
-echo "$as_me: WARNING: can't find the JACK library" >&2;}
-fi
-
- fi
- fi
-
- case $audio_system in
- ALSA)
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_ALSA 1
-_ACEOF
-
- if test "$with_static_alsa" = yes ; then
- AUDIO_LIB="/usr/lib/libasound.a"
- else
- AUDIO_LIB="-lasound"
- fi
-
-# snd_config_get_id argnum changed in Nov-01
- snd_config_get_id_args=1
- { echo "$as_me:$LINENO: checking snd_config_get_id args" >&5
-echo $ECHO_N "checking snd_config_get_id args... $ECHO_C" >&6; }
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <alsa/asoundlib.h>
-int
-main ()
-{
-snd_config_t *c;
- const char *id;
- snd_config_get_id(c, &id)
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- snd_config_get_id_args=2
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- { echo "$as_me:$LINENO: result: $snd_config_get_id_args" >&5
-echo "${ECHO_T}$snd_config_get_id_args" >&6; }
- cat >>confdefs.h <<_ACEOF
-#define SND_CONFIG_GET_ID_ARGS $snd_config_get_id_args
-_ACEOF
-
- if test "$with_jack" = yes ; then
- if test "$with_static_alsa" = yes ; then
- AUDIO_LIB="/usr/lib/libasound.a -ljack -l samplerate"
- else
- AUDIO_LIB="-lasound -ljack -lsamplerate"
- fi
- A_INSTALL=":"
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_JACK 1
-_ACEOF
-
- fi
- ;;
- JACK)
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_JACK 1
-_ACEOF
-
- AUDIO_LIB="-ljack -lsamplerate"
- A_LD=":"
- A_INSTALL=":"
- # no libjack.a so give up on sndlib.a
- ;;
- OSS)
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_OSS 1
-_ACEOF
-
- ;;
- esac
- ;;
- *-*-sunos4*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_SUN 1
-_ACEOF
-
- LIBS="-lm"
- audio_system=Sun
- ;;
- *-*-solaris*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_SUN 1
-_ACEOF
-
-# LIBS="-lm -ldl"
- LIBS="-lm"
- audio_system=Sun
- LDSO_FLAGS="-G"
- ;;
- *-*-hpux*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_HPUX 1
-_ACEOF
-
- audio_system=Hpux
- if test "$GCC" = yes ; then
- SO_FLAGS="-fPIC $SO_FLAGS"
- fi
- LDSO_FLAGS="+z -Ae +DA1.1"
- ;;
- *-sgi*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_SGI 1
-_ACEOF
-
- audio_system=SGI
- AUDIO_LIB="-laudio -lmd"
-
- if test $GUILE_CONFIG_works = no; then
- LIBS="-lm -lc"
- else
- LIBS="$LIBS -lm -lc"
- fi
- LDSO_FLAGS=""
- SO_INSTALL=":"
- SO_LD=":"
- LD_FLAGS=""
- if test $GCC = yes; then
- LD_FLAGS=""
- fi
- ;;
- alpha*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_ALPHA 1
-_ACEOF
-
- ;;
- *-*-bsdi*)
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_OSS 1
-_ACEOF
-
- LIBS="-lm"
- if test "$GCC" = yes ; then
- SO_FLAGS="-fPIC $SO_FLAGS"
- fi
- audio_system=OSS
- ;;
- *-*-freebsd*)
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_OSS 1
-_ACEOF
-
- LIBS="-lm"
- audio_system=OSS
- if test "$GCC" = yes ; then
- SO_FLAGS="-fPIC $SO_FLAGS"
- LDSO_FLAGS="-shared"
- SO_LD="gcc"
- fi
- ;;
- *-*-openbsd*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_OPENBSD 1
-_ACEOF
-
- audio_system=Sun
- if test "$GCC" = yes ; then
- SO_FLAGS="-fPIC $SO_FLAGS"
- fi
- ;;
- *-*-netbsd*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_NETBSD 1
-_ACEOF
-
- audio_system=NetBSD
- if test "$GCC" = yes ; then
- SO_FLAGS="-fPIC $SO_FLAGS"
- LDSO_FLAGS="-shared"
- SO_LD="gcc"
- fi
- ;;
- *-*-cygwin*)
- cat >>confdefs.h <<\_ACEOF
-#define MUS_WINDOZE 1
-_ACEOF
-
- audio_system=Windoze
- ;;
- *-apple-*)
- LDSO_FLAGS=""
- SO_INSTALL=":"
- SO_LD=":"
- cat >>confdefs.h <<\_ACEOF
-#define MUS_MAC_OSX 1
-_ACEOF
-
- audio_system=MacOSX
- AUDIO_LIB="-framework CoreAudio -framework CoreFoundation -framework CoreMIDI"
-
- { echo "$as_me:$LINENO: checking for kAudioDevicePropertyDeviceManufacturer" >&5
-echo $ECHO_N "checking for kAudioDevicePropertyDeviceManufacturer... $ECHO_C" >&6; }
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <CoreServices/CoreServices.h>
- #include <CoreAudio/CoreAudio.h>
-int
-main ()
-{
-AudioDeviceID deviceID;
- UInt32 trans_size = 0, trans;
- trans_size = sizeof(UInt32);
- AudioDeviceGetProperty(deviceID, 0, true, kAudioDevicePropertyTransportType, &trans_size, &trans)
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_KAUDIODEVICEPROPERTYTRANSPORTTYPE 1
-_ACEOF
-
- { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- { echo "$as_me:$LINENO: checking for kLinearPCMFormatFlagIsNonInterleaved" >&5
-echo $ECHO_N "checking for kLinearPCMFormatFlagIsNonInterleaved... $ECHO_C" >&6; }
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <CoreServices/CoreServices.h>
- #include <CoreAudio/CoreAudio.h>
-int
-main ()
-{
-int i; i = kLinearPCMFormatFlagIsNonInterleaved
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_KLINEARPCMFORMATFLAGISNONINTERLEAVED 1
-_ACEOF
-
- { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for audio system" >&5
-echo $ECHO_N "checking for audio system... $ECHO_C" >&6; }
-{ echo "$as_me:$LINENO: result: $audio_system" >&5
-echo "${ECHO_T}$audio_system" >&6; }
-fi
-
-AUDIO_CHOICE="$audio_system"
-
-CFLAGS="-I. $CFLAGS"
-# needed since we're looking for <mus-config.h>, I think
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(
- for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
- eval ac_val=\$$ac_var
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
- *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- *) $as_unset $ac_var ;;
- esac ;;
- esac
- done
-
- (set) 2>&1 |
- case $as_nl`(ac_space=' '; set) 2>&1` in #(
- *${as_nl}ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;; #(
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
- ;;
- esac |
- sort
-) |
- sed '
- /^ac_cv_env_/b end
- t clear
- :clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
- if test -w "$cache_file"; then
- test "x$cache_file" != "x/dev/null" &&
- { echo "$as_me:$LINENO: updating cache $cache_file" >&5
-echo "$as_me: updating cache $cache_file" >&6;}
- cat confcache >$cache_file
- else
- { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
-echo "$as_me: not updating unwritable cache $cache_file" >&6;}
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
- ac_i=`echo "$ac_i" | sed "$ac_script"`
- # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
- # will be set to the directory where LIBOBJS objects are built.
- ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
- ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-
-# PATH needs CR
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order. Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-as_nl='
-'
-IFS=" "" $as_nl"
-
-# Find who we are. Look in the path if we contain no directory separator.
-case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-IFS=$as_save_IFS
-
- ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
- as_myself=$0
-fi
-if test ! -f "$as_myself"; then
- echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
- { (exit 1); exit 1; }
-fi
-
-# Work around bugs in pre-3.0 UWIN ksh.
-for as_var in ENV MAIL MAILPATH
-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{
- s//\1/
- q
- }
- /^X\/\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\/\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
-
-# CDPATH.
-$as_unset CDPATH
-
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line after each line using $LINENO; the second 'sed'
- # does the real work. The second script uses 'N' to pair each
- # line-number line with the line containing $LINENO, and appends
- # trailing '-' during substitution so that $LINENO is not a special
- # case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # scripts with optimization help from Paolo Bonzini. Blame Lee
- # E. McMahon (1931-1989) for sed's syntax. :-)
- sed -n '
- p
- /[$]LINENO/=
- ' <$as_myself |
- sed '
- s/[$]LINENO.*/&-/
- t lineno
- b
- :lineno
- N
- :loop
- s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
- t loop
- s/-\n.*//
- ' >$as_me.lineno &&
- chmod +x "$as_me.lineno" ||
- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensitive to this).
- . "./$as_me.lineno"
- # Exit status is that of the last command.
- exit
-}
-
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
- as_dirname=dirname
-else
- as_dirname=false
-fi
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in
--n*)
- case `echo 'x\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
- *) ECHO_C='\c';;
- esac;;
-*)
- ECHO_N='-n';;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
- rm -f conf$$.dir/conf$$.file
-else
- rm -f conf$$.dir
- mkdir conf$$.dir
-fi
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- as_ln_s='ln -s'
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-# Find out whether ``test -x'' works. Don't use a zero-byte file, as
-# systems may use methods other than mode bits to determine executability.
-cat >conf$$.file <<_ASEOF
-#! /bin/sh
-exit 0
-_ASEOF
-chmod +x conf$$.file
-if test -x conf$$.file >/dev/null 2>&1; then
- as_executable_p="test -x"
-else
- as_executable_p=:
-fi
-rm -f conf$$.file
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-
-# Save the log message, to keep $[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by sndlib $as_me 20, which was
-generated by GNU Autoconf 2.60. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -q, --quiet do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to <bug-autoconf@gnu.org>."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-sndlib config.status 20
-configured by $0, generated by GNU Autoconf 2.60,
- with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2006 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-INSTALL='$INSTALL'
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value. By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=*)
- ac_option=`expr "X$1" : 'X\([^=]*\)='`
- ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- *)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- esac
-
- case $ac_option in
- # Handling of the options.
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
- echo "$ac_cs_version"; exit ;;
- --debug | --debu | --deb | --de | --d | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- CONFIG_FILES="$CONFIG_FILES $ac_optarg"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
- ac_need_defaults=false;;
- --he | --h)
- # Conflict between --help and --header
- { echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
- echo "$ac_cs_usage"; exit ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) { echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; } ;;
-
- *) ac_config_targets="$ac_config_targets $1"
- ac_need_defaults=false ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
- CONFIG_SHELL=$SHELL
- export CONFIG_SHELL
- exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
- echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
- case $ac_config_target in
- "makefile") CONFIG_FILES="$CONFIG_FILES makefile" ;;
- "sndlib-config") CONFIG_FILES="$CONFIG_FILES sndlib-config" ;;
- "sndins/Makefile") CONFIG_FILES="$CONFIG_FILES sndins/Makefile" ;;
- "mus-config.h") CONFIG_HEADERS="$CONFIG_HEADERS mus-config.h" ;;
- "sndlib.h") CONFIG_HEADERS="$CONFIG_HEADERS sndlib.h" ;;
-
- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
- { (exit 1); exit 1; }; };;
- esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
- tmp=
- trap 'exit_status=$?
- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
-' 0
- trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=./conf$$-$RANDOM
- (umask 077 && mkdir "$tmp")
-} ||
-{
- echo "$me: cannot create a temporary directory in ." >&2
- { (exit 1); exit 1; }
-}
-
-#
-# Set up the sed scripts for CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "$CONFIG_FILES"; then
-
-_ACEOF
-
-
-
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
- cat >conf$$subs.sed <<_ACEOF
-SHELL!$SHELL$ac_delim
-PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
-PACKAGE_NAME!$PACKAGE_NAME$ac_delim
-PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
-PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
-PACKAGE_STRING!$PACKAGE_STRING$ac_delim
-PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
-exec_prefix!$exec_prefix$ac_delim
-prefix!$prefix$ac_delim
-program_transform_name!$program_transform_name$ac_delim
-bindir!$bindir$ac_delim
-sbindir!$sbindir$ac_delim
-libexecdir!$libexecdir$ac_delim
-datarootdir!$datarootdir$ac_delim
-datadir!$datadir$ac_delim
-sysconfdir!$sysconfdir$ac_delim
-sharedstatedir!$sharedstatedir$ac_delim
-localstatedir!$localstatedir$ac_delim
-includedir!$includedir$ac_delim
-oldincludedir!$oldincludedir$ac_delim
-docdir!$docdir$ac_delim
-infodir!$infodir$ac_delim
-htmldir!$htmldir$ac_delim
-dvidir!$dvidir$ac_delim
-pdfdir!$pdfdir$ac_delim
-psdir!$psdir$ac_delim
-libdir!$libdir$ac_delim
-localedir!$localedir$ac_delim
-mandir!$mandir$ac_delim
-DEFS!$DEFS$ac_delim
-ECHO_C!$ECHO_C$ac_delim
-ECHO_N!$ECHO_N$ac_delim
-ECHO_T!$ECHO_T$ac_delim
-LIBS!$LIBS$ac_delim
-build_alias!$build_alias$ac_delim
-host_alias!$host_alias$ac_delim
-target_alias!$target_alias$ac_delim
-build!$build$ac_delim
-build_cpu!$build_cpu$ac_delim
-build_vendor!$build_vendor$ac_delim
-build_os!$build_os$ac_delim
-host!$host$ac_delim
-host_cpu!$host_cpu$ac_delim
-host_vendor!$host_vendor$ac_delim
-host_os!$host_os$ac_delim
-CC!$CC$ac_delim
-CFLAGS!$CFLAGS$ac_delim
-LDFLAGS!$LDFLAGS$ac_delim
-CPPFLAGS!$CPPFLAGS$ac_delim
-ac_ct_CC!$ac_ct_CC$ac_delim
-EXEEXT!$EXEEXT$ac_delim
-OBJEXT!$OBJEXT$ac_delim
-CPP!$CPP$ac_delim
-GREP!$GREP$ac_delim
-EGREP!$EGREP$ac_delim
-SNDLIB_BITS!$SNDLIB_BITS$ac_delim
-INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
-INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
-INSTALL_DATA!$INSTALL_DATA$ac_delim
-GSL_CONFIG!$GSL_CONFIG$ac_delim
-GSL_LIBS!$GSL_LIBS$ac_delim
-GSL_CFLAGS!$GSL_CFLAGS$ac_delim
-GUILE_LIBS!$GUILE_LIBS$ac_delim
-GUILE_CFLAGS!$GUILE_CFLAGS$ac_delim
-GAUCHE_CONFIG!$GAUCHE_CONFIG$ac_delim
-FTH_VERSION!$FTH_VERSION$ac_delim
-FTH_CFLAGS!$FTH_CFLAGS$ac_delim
-FTH_LIBS!$FTH_LIBS$ac_delim
-FTH_HAVE_COMPLEX!$FTH_HAVE_COMPLEX$ac_delim
-FTH_HAVE_RATIO!$FTH_HAVE_RATIO$ac_delim
-FTH!$FTH$ac_delim
-XM_LIBS!$XM_LIBS$ac_delim
-AUDIO_LIB!$AUDIO_LIB$ac_delim
-LDSO_FLAGS!$LDSO_FLAGS$ac_delim
-SO_FLAGS!$SO_FLAGS$ac_delim
-SO_INSTALL!$SO_INSTALL$ac_delim
-A_INSTALL!$A_INSTALL$ac_delim
-SO_LD!$SO_LD$ac_delim
-A_LD!$A_LD$ac_delim
-A_LD_FLAGS!$A_LD_FLAGS$ac_delim
-LD_FLAGS!$LD_FLAGS$ac_delim
-SNDLIB_VERSION!$SNDLIB_VERSION$ac_delim
-SNDLIB_LANGUAGE!$SNDLIB_LANGUAGE$ac_delim
-SNDLIB_MODULES!$SNDLIB_MODULES$ac_delim
-AUDIO_CHOICE!$AUDIO_CHOICE$ac_delim
-LIBOBJS!$LIBOBJS$ac_delim
-LTLIBOBJS!$LTLIBOBJS$ac_delim
-_ACEOF
-
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 87; then
- break
- elif $ac_last_try; then
- { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
-echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
- { (exit 1); exit 1; }; }
- else
- ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
- fi
-done
-
-ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
-if test -n "$ac_eof"; then
- ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
- ac_eof=`expr $ac_eof + 1`
-fi
-
-cat >>$CONFIG_STATUS <<_ACEOF
-cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
-_ACEOF
-sed '
-s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
-s/^/s,@/; s/!/@,|#_!!_#|/
-:n
-t n
-s/'"$ac_delim"'$/,g/; t
-s/$/\\/; p
-N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
-' >>$CONFIG_STATUS <conf$$subs.sed
-rm -f conf$$subs.sed
-cat >>$CONFIG_STATUS <<_ACEOF
-:end
-s/|#_!!_#|//g
-CEOF$ac_eof
-_ACEOF
-
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/
-s/:*\${srcdir}:*/:/
-s/:*@srcdir@:*/:/
-s/^\([^=]*=[ ]*\):*/\1/
-s/:*$//
-s/^[^=]*=[ ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-fi # test -n "$CONFIG_FILES"
-
-
-for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS
-do
- case $ac_tag in
- :[FHLC]) ac_mode=$ac_tag; continue;;
- esac
- case $ac_mode$ac_tag in
- :[FHL]*:*);;
- :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
-echo "$as_me: error: Invalid tag $ac_tag." >&2;}
- { (exit 1); exit 1; }; };;
- :[FH]-) ac_tag=-:-;;
- :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
- esac
- ac_save_IFS=$IFS
- IFS=:
- set x $ac_tag
- IFS=$ac_save_IFS
- shift
- ac_file=$1
- shift
-
- case $ac_mode in
- :L) ac_source=$1;;
- :[FH])
- ac_file_inputs=
- for ac_f
- do
- case $ac_f in
- -) ac_f="$tmp/stdin";;
- *) # Look for the file first in the build tree, then in the source tree
- # (if the path is not absolute). The absolute path cannot be DOS-style,
- # because $ac_f cannot contain `:'.
- test -f "$ac_f" ||
- case $ac_f in
- [\\/$]*) false;;
- *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
- esac ||
- { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
-echo "$as_me: error: cannot find input file: $ac_f" >&2;}
- { (exit 1); exit 1; }; };;
- esac
- ac_file_inputs="$ac_file_inputs $ac_f"
- done
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- configure_input="Generated from "`IFS=:
- echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
- if test x"$ac_file" != x-; then
- configure_input="$ac_file. $configure_input"
- { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
- fi
-
- case $ac_tag in
- *:-:* | *:-) cat >"$tmp/stdin";;
- esac
- ;;
- esac
-
- ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- { as_dir="$ac_dir"
- case $as_dir in #(
- -*) as_dir=./$as_dir;;
- esac
- test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
- as_dirs=
- while :; do
- case $as_dir in #(
- *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
- *) as_qdir=$as_dir;;
- esac
- as_dirs="'$as_qdir' $as_dirs"
- as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- test -d "$as_dir" && break
- done
- test -z "$as_dirs" || eval "mkdir $as_dirs"
- } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
-echo "$as_me: error: cannot create directory $as_dir" >&2;}
- { (exit 1); exit 1; }; }; }
- ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A ".." for each directory in $ac_dir_suffix.
- ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
- case $ac_top_builddir_sub in
- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
- esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
- .) # We are building in place.
- ac_srcdir=.
- ac_top_srcdir=$ac_top_builddir_sub
- ac_abs_top_srcdir=$ac_pwd ;;
- [\\/]* | ?:[\\/]* ) # Absolute name.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir
- ac_abs_top_srcdir=$srcdir ;;
- *) # Relative name.
- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_build_prefix$srcdir
- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
- case $ac_mode in
- :F)
- #
- # CONFIG_FILE
- #
-
- case $INSTALL in
- [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
- *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
- esac
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-
-case `sed -n '/datarootdir/ {
- p
- q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p
-' $ac_file_inputs` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
- { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
- ac_datarootdir_hack='
- s&@datadir@&$datadir&g
- s&@docdir@&$docdir&g
- s&@infodir@&$infodir&g
- s&@localedir@&$localedir&g
- s&@mandir@&$mandir&g
- s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF
- sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s&@configure_input@&$configure_input&;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-s&@INSTALL@&$ac_INSTALL&;t t
-$ac_datarootdir_hack
-" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
- { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined." >&5
-echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined." >&2;}
-
- rm -f "$tmp/stdin"
- case $ac_file in
- -) cat "$tmp/out"; rm -f "$tmp/out";;
- *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
- esac
- ;;
- :H)
- #
- # CONFIG_HEADER
- #
-_ACEOF
-
-# Transform confdefs.h into a sed script `conftest.defines', that
-# substitutes the proper values into config.h.in to produce config.h.
-rm -f conftest.defines conftest.tail
-# First, append a space to every undef/define line, to ease matching.
-echo 's/$/ /' >conftest.defines
-# Then, protect against being on the right side of a sed subst, or in
-# an unquoted here document, in config.status. If some macros were
-# called several times there might be several #defines for the same
-# symbol, which is useless. But do not sort them, since the last
-# AC_DEFINE must be honored.
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
-# NAME is the cpp macro being defined, VALUE is the value it is being given.
-# PARAMS is the parameter list in the macro definition--in most cases, it's
-# just an empty string.
-ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*'
-ac_dB='\\)[ (].*,\\1define\\2'
-ac_dC=' '
-ac_dD=' ,'
-
-uniq confdefs.h |
- sed -n '
- t rset
- :rset
- s/^[ ]*#[ ]*define[ ][ ]*//
- t ok
- d
- :ok
- s/[\\&,]/\\&/g
- s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
- s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
- ' >>conftest.defines
-
-# Remove the space that was appended to ease matching.
-# Then replace #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-# (The regexp can be short, since the line contains either #define or #undef.)
-echo 's/ $//
-s,^[ #]*u.*,/* & */,' >>conftest.defines
-
-# Break up conftest.defines:
-ac_max_sed_lines=50
-
-# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1"
-# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2"
-# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1"
-# et cetera.
-ac_in='$ac_file_inputs'
-ac_out='"$tmp/out1"'
-ac_nxt='"$tmp/out2"'
-
-while :
-do
- # Write a here document:
- cat >>$CONFIG_STATUS <<_ACEOF
- # First, check the format of the line:
- cat >"\$tmp/defines.sed" <<\\CEOF
-/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def
-/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def
-b
-:def
-_ACEOF
- sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
- echo 'CEOF
- sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
- ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
- sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
- grep . conftest.tail >/dev/null || break
- rm -f conftest.defines
- mv conftest.tail conftest.defines
-done
-rm -f conftest.defines conftest.tail
-
-echo "ac_result=$ac_in" >>$CONFIG_STATUS
-cat >>$CONFIG_STATUS <<\_ACEOF
- if test x"$ac_file" != x-; then
- echo "/* $configure_input */" >"$tmp/config.h"
- cat "$ac_result" >>"$tmp/config.h"
- if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
- else
- rm -f $ac_file
- mv "$tmp/config.h" $ac_file
- fi
- else
- echo "/* $configure_input */"
- cat "$ac_result"
- fi
- rm -f "$tmp/out12"
- ;;
-
-
- esac
-
-
- case $ac_file$ac_mode in
- "sndlib-config":F) chmod +x sndlib-config ;;
-
- esac
-done # for ac_tag
-
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || { (exit 1); exit 1; }
-fi
-
-
diff --git a/third_party/resample/sndlib-20/headers.c b/third_party/resample/sndlib-20/headers.c
deleted file mode 100644
index 676066a4..00000000
--- a/third_party/resample/sndlib-20/headers.c
+++ /dev/null
@@ -1,5797 +0,0 @@
-/* readers/writers for various sound file headers
- *
- * --------------------------------
- * int mus_header_read (const char *name)
- * int mus_header_write (const char *name, int type, int in_srate, int in_chans, off_t loc, off_t size_in_samples, int format, const char *comment, int len)
- * int mus_header_initialize (void)
- *
- * Once mus_header_read has been called, the data in it can be accessed through:
- *
- * off_t mus_header_samples (void) samples
- * off_t mus_header_data_location (void) location of data (bytes)
- * int mus_header_chans (void) channels
- * int mus_header_srate (void) srate
- * int mus_header_type (void) header type (i.e. aiff, wave, etc) (see sndlib.h)
- * int mus_header_format (void) data format (see sndlib.h)
- * off_t mus_header_comment_start (void) comment start location (if any) (bytes)
- * off_t mus_header_comment_end (void) comment end location
- * off_t mus_header_aux_comment_start (int n) if multiple comments, nth start location
- * off_t mus_header_aux_comment_end (int n) if multiple comments, nth end location
- * int mus_header_type_specifier (void) original (header-specific) type ID
- * int mus_header_bits_per_sample (void) sample width in bits
- * off_t mus_header_true_length (void) true (lseek) file length
- * int mus_bytes_per_sample (int format) sample width in bytes
- * bool mus_header_writable(int type, int format) can we write this header
- * --------------------------------
- *
- * "Linear" below means 2's complement integer.
- *
- * Currently supported read/write (in standard data formats):
- * NeXT/Sun/DEC/AFsp
- * AIFF/AIFC
- * RIFF (microsoft wave)
- * IRCAM (old style)
- * NIST-sphere
- * no header
- *
- * Currently supported read-only (in selected data formats):
- * 8SVX (IFF), EBICSF, INRS, ESPS, SPPACK, ADC (OGI), AVR, VOC, CSL, snack "SMP", PVF,
- * Sound Tools, Turtle Beach SMP, SoundFont 2.0, Sound Designer I, PSION alaw, MAUD,
- * Gravis Ultrasound, Comdisco SPW, Goldwave sample, OMF, NVF,
- * Sonic Foundry, SBStudio II, Delusion digital, Digiplayer ST3, Farandole Composer WaveSample,
- * Ultratracker WaveSample, Sample Dump exchange, Yamaha SY85 and SY99 (buggy), Yamaha TX16W,
- * Covox v8, AVI, Kurzweil 2000, Paris Ensoniq, Impulse tracker, Korg, Akai type 4, Maui,
- *
- * for a few of these I'm still trying to get documentation -- best sources of info
- * are ftp.cwi.nl:pub/audio (info files), the AFsp sources, and the SOX sources.
- * sox and gsm are at ftp.cwi.nl, AFsp is from kabal@Polaris.EE.McGill.CA (Peter Kabal) as
- * ftp.TSP.EE.McGill.CA:/pub/AFsp/AFsp-V3R2.tar.Z. The Sound Designer formats are described
- * in the "Developer Documentation" from Digidesign. Other useful sources can be found at
- * ftp.x.org:/contrib/audio/nas, svr-ftp.eng.cam.ac.uk:/comp.speech/tools, and
- * at http://www.wotsit.org. I put many of my test cases in
- * ccrma-ftp.stanford.edu:/pub/Lisp/sf.tar.gz. The RIFF format is described in the
- * Microsoft Multimedia Programmer's Reference Manual at ftp.microsoft.com:/SoftLib/MSLFILES/MDRK.EXE.
- * AVI format is described in http://www.rahul.net/jfm/avi.html.
- *
- * For a lot of info and examples see http://www.TSP.ECE.McGill.CA/MMSP/Documents/AudioFormats/index.html
- *
- * The main problem with compressed sound files is that you can't do reliable
- * random access to the data, can't easily read backwards, and most of the compression
- * schemes are proprietary (and appalling), but to translate Mus10/Sam, HCOM, IEEE text,
- * MIDI sample dumps, various adpcm cases, NIST shortpack files, and AVI see snd-trans.c
- * in the sound editor (snd-8.tar.gz).
- *
- * If anyone has information on any other header or data formats, I would be most interested in it,
- * but only if it can be included in this file.
- *
- * ivc format appears to have 16 bytes of header (-1 5 0 0 0 0 -> mulaw) followed by mulaw or alaw data
- */
-
-#include <mus-config.h>
-
-#if USE_SND
- #include "snd.h"
-#else
- #if HAVE_RUBY && (!CLM)
- #include "xen.h"
- #endif
-#endif
-
-#include <math.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#if HAVE_STRING_H
- #include <string.h>
-#endif
-#if (defined(HAVE_LIBC_H) && (!defined(HAVE_UNISTD_H)))
- #include <libc.h>
-#else
- #if (!(defined(_MSC_VER)))
- #include <unistd.h>
- #endif
-#endif
-
-#include "_sndlib.h"
-#include "sndlib-strings.h"
-
-static bool hdrbuf_is_inited = false;
-
-#define HDRBUFSIZ 256
-static unsigned char *hdrbuf;
-#define INITIAL_READ_SIZE 32
-
-/* AIFF files can have any number of ANNO chunks, so we'll grab at least 4 of them */
-#define AUX_COMMENTS 4
-static off_t *aux_comment_start = NULL, *aux_comment_end = NULL;
-
-#define LOOPS 2
-static int *loop_modes = NULL, *loop_starts = NULL, *loop_ends = NULL;
-static int markers = 0;
-static int *marker_ids = NULL, *marker_positions = NULL;
-
-/* for CLM */
-void mus_reset_headers_c(void)
-{
- hdrbuf_is_inited = false;
- markers = 0;
-}
-
-int mus_header_initialize(void)
-{
- if (!hdrbuf_is_inited)
- {
- hdrbuf_is_inited = true;
- hdrbuf = (unsigned char *)CALLOC(HDRBUFSIZ, sizeof(unsigned char));
- aux_comment_start = (off_t *)CALLOC(AUX_COMMENTS, sizeof(off_t));
- aux_comment_end = (off_t *)CALLOC(AUX_COMMENTS, sizeof(off_t));
- loop_modes = (int *)CALLOC(LOOPS, sizeof(int));
- loop_starts = (int *)CALLOC(LOOPS, sizeof(int));
- loop_ends = (int *)CALLOC(LOOPS, sizeof(int));
- if ((hdrbuf == NULL) || (aux_comment_start == NULL) || (aux_comment_end == NULL) ||
- (loop_modes == NULL) || (loop_starts == NULL) || (loop_ends == NULL))
- return(mus_error(MUS_MEMORY_ALLOCATION_FAILED, "mus_header_initialize: buffer allocation failed"));
- }
- return(MUS_NO_ERROR);
-}
-
-
-static const unsigned char I_DSND[4] = {'.','s','n','d'}; /* NeXT/Sun/Dec/SGI/AFsp first word */
-static const unsigned char I_FORM[4] = {'F','O','R','M'}; /* AIFF first word */
-static const unsigned char I_AIFF[4] = {'A','I','F','F'}; /* AIFF second word */
-static const unsigned char I_AIFC[4] = {'A','I','F','C'}; /* ditto but might be compressed data */
-static const unsigned char I_COMM[4] = {'C','O','M','M'};
-static const unsigned char I_COMT[4] = {'C','O','M','T'};
-static const unsigned char I_INFO[4] = {'I','N','F','O'};
-static const unsigned char I_INST[4] = {'I','N','S','T'};
-static const unsigned char I_inst[4] = {'i','n','s','t'}; /* RIFF wants lower case, just to be different */
-static const unsigned char I_MARK[4] = {'M','A','R','K'};
-static const unsigned char I_SSND[4] = {'S','S','N','D'};
-static const unsigned char I_FVER[4] = {'F','V','E','R'};
-static const unsigned char I_NONE[4] = {'N','O','N','E'};
-static const unsigned char I_ULAW[4] = {'U','L','A','W'}; /* AIFC compression types that we can handle */
-static const unsigned char I_ulaw[4] = {'u','l','a','w'}; /* or maybe it's lowercase (Apple) ... */
-static const unsigned char I_ima4[4] = {'i','m','a','4'}; /* AIFC IMA adpcm apparently */
-static const unsigned char I_raw_[4] = {'r','a','w',' '}; /* AIFC offset binary OS 8.5 (others are 'MAC3' 'MAC6' 'cdx4' 'cdx2' 'str4') */
-static const unsigned char I_sowt[4] = {'s','o','w','t'}; /* AIFC 16-bit little endian -- used by Mac when extracting CD tracks */
-static const unsigned char I_in32[4] = {'i','n','3','2'}; /* AIFC */
-static const unsigned char I_in24[4] = {'i','n','2','4'}; /* AIFC */
-static const unsigned char I_ni23[4] = {'n','i','2','3'}; /* AIFC */
-static const unsigned char I_fl32[4] = {'f','l','3','2'}; /* AIFC 32-bit float */
-static const unsigned char I_FL32[4] = {'F','L','3','2'}; /* AIFC 32-bit float (apparently used by CSound and SoundHack) */
-static const unsigned char I_fl64[4] = {'f','l','6','4'}; /* AIFC 64-bit float */
-static const unsigned char I_twos[4] = {'t','w','o','s'}; /* AIFC big endian? */
-static const unsigned char I_ALAW[4] = {'A','L','A','W'};
-static const unsigned char I_alaw[4] = {'a','l','a','w'}; /* apple */
-static const unsigned char I_APPL[4] = {'A','P','P','L'};
-static const unsigned char I_MUS_[4] = {'C','L','M',' '}; /* I hereby claim this AIFF chunk name */
-static const unsigned char I_RIFF[4] = {'R','I','F','F'}; /* RIFF first word */
-static const unsigned char I_RIFX[4] = {'R','I','F','X'}; /* RIFX first word (big-endian RIFF file) */
-static const unsigned char I_WAVE[4] = {'W','A','V','E'};
-static const unsigned char I_fmt_[4] = {'f','m','t',' '};
-static const unsigned char I_data[4] = {'d','a','t','a'};
-static const unsigned char I_fact[4] = {'f','a','c','t'}; /* used by compressed RIFF files */
-static const unsigned char I_clm_[4] = {'c','l','m',' '};
-static const unsigned char I_NIST[4] = {'N','I','S','T'}; /* first word of NIST SPHERE files */
-static const unsigned char I_8SVX[4] = {'8','S','V','X'}; /* AIFF other choice */
-static const unsigned char I_16SV[4] = {'1','6','S','V'}; /* hmmm... 16-bit 8svx? */
-static const unsigned char I_VOC0[4] = {'C','r','e','a'}; /* Actual text is "Creative Voice File" */
-static const unsigned char I_VOC1[4] = {'t','i','v','e'};
-static const unsigned char I_SOUN[4] = {'S','O','U','N'}; /* Sound Tools first word="SOUND" -- not unique as SMP files start with "SOUND SAMPLE" */
-static const unsigned char I_D_SA[4] = {'D',' ','S','A'};
-static const unsigned char I_MPLE[4] = {'M','P','L','E'};
-static const unsigned char I_BODY[4] = {'B','O','D','Y'}; /* next 4 for 8svx chunk names */
-static const unsigned char I_VHDR[4] = {'V','H','D','R'};
-static const unsigned char I_CHAN[4] = {'C','H','A','N'};
-static const unsigned char I_ANNO[4] = {'A','N','N','O'};
-static const unsigned char I_NAME[4] = {'N','A','M','E'};
-static const unsigned char I_AVR_[4] = {'2','B','I','T'}; /* first word of AVR files */
-static const unsigned char I_HCOM[4] = {'H','C','O','M'};
-static const unsigned char I_FSSD[4] = {'F','S','S','D'};
-static const unsigned char I_SPIB[4] = {'%','/','/','\n'}; /* first word of IEEE spib text sound files */
-static const unsigned char I_S___[4] = {'%','-','-','-'}; /* first word of other IEEE spib text sound files */
-static const unsigned char I_ALaw[4] = {'A','L','a','w'}; /* first word of PSION alaw files */
-static const unsigned char I_Soun[4] = {'S','o','u','n'}; /* second */
-static const unsigned char I_MAUD[4] = {'M','A','U','D'}; /* MAUD specialization of AIFF */
-static const unsigned char I_MHDR[4] = {'M','H','D','R'};
-static const unsigned char I_MDAT[4] = {'M','D','A','T'};
-static const unsigned char I_mdat[4] = {'m','d','a','t'}; /* quicktime */
-static const unsigned char I_MThd[4] = {'M','T','h','d'}; /* sigh -- the M word */
-static const unsigned char I_DECN[4] = {'.','s','d','\0'}; /* first word of DEC files (?) */
-static const unsigned char I_sfbk[4] = {'s','f','b','k'}; /* SoundFont 2.0 */
-static const unsigned char I_sdta[4] = {'s','d','t','a'};
-static const unsigned char I_shdr[4] = {'s','h','d','r'};
-static const unsigned char I_pdta[4] = {'p','d','t','a'};
-static const unsigned char I_LIST[4] = {'L','I','S','T'};
-static const unsigned char I_GF1P[4] = {'G','F','1','P'}; /* first word of Gravis Ultrsound patch files */
-static const unsigned char I_ATCH[4] = {'A','T','C','H'}; /* second word */
-static const unsigned char I_DSIG[4] = {'$','S','I','G'}; /* first word of Comdisco SPW file */
-static const unsigned char I_NAL_[4] = {'N','A','L','_'}; /* second word */
-static const unsigned char I_GOLD[4] = {'G','O','L','D'}; /* first word Goldwave(?) sample file */
-static const unsigned char I__WAV[4] = {' ','S','A','M'}; /* second word */
-static const unsigned char I_SRFS[4] = {'S','R','F','S'}; /* first word Sonic Resource Foundry file(?) */
-static const unsigned char I_Diam[4] = {'D','i','a','m'}; /* first word DiamondWare file */
-static const unsigned char I_ondW[4] = {'o','n','d','W'}; /* second word */
-static const unsigned char I_CSRE[4] = {'C','S','R','E'}; /* adf first word -- second starts with "40" */
-static const unsigned char I_SND_[4] = {'S','N','D',' '}; /* SBStudio II */
-static const unsigned char I_SNIN[4] = {'S','N','I','N'};
-static const unsigned char I_SNNA[4] = {'S','N','N','A'};
-static const unsigned char I_SNDT[4] = {'S','N','D','T'};
-static const unsigned char I_DDSF[4] = {'D','D','S','F'}; /* Delusion Digital Sound File */
-static const unsigned char I_FSMt[4] = {'F','S','M',(unsigned char)'\376'}; /* Farandole Composer WaveSample */
-static const unsigned char I_SDXc[4] = {'S','D','X',':'}; /* Sample dump exchange format */
-static const unsigned char I_UWFD[4] = {'U','W','F','D'}; /* Ultratracker Wavesample */
-static const unsigned char I_LM89[4] = {'L','M','8','9'}; /* Yamaha TX-16 */
-static const unsigned char I_SY80[4] = {'S','Y','8','0'}; /* Yamaha SY-99 */
-static const unsigned char I_SY85[4] = {'S','Y','8','5'}; /* Yamaha SY-85 */
-static const unsigned char I_SCRS[4] = {'S','C','R','S'}; /* Digiplayer ST3 */
-static const unsigned char I_covox[4] = {(unsigned char)'\377','\125',(unsigned char)'\377',(unsigned char)'\252'};
-/* static const unsigned char I_DSPL[4] = {'D','S','P','L'}; */ /* Digitracker SPL (now obsolete) */
-static const unsigned char I_AVI_[4] = {'A','V','I',' '}; /* RIFF AVI */
-static const unsigned char I_strf[4] = {'s','t','r','f'};
-static const unsigned char I_movi[4] = {'m','o','v','i'};
-static const unsigned char I_PRAM[4] = {'P','R','A','M'}; /* Kurzweil 2000 */
-static const unsigned char I_ones[4] = {(unsigned char)'\377',(unsigned char)'\377',(unsigned char)'\377',(unsigned char)'\377'};
-static const unsigned char I_zeros[4] = {'\0','\0','\0','\0'};
-static const unsigned char I_asf0[4] = {(unsigned char)'\321','\051',(unsigned char)'\342',(unsigned char)'\326'};
-static const unsigned char I_asf1[4] = {(unsigned char)'\332','\065',(unsigned char)'\321','\021'};
-static const unsigned char I_asf2[4] = {(unsigned char)'\220','\064','\000',(unsigned char)'\240'};
-static const unsigned char I_asf3[4] = {(unsigned char)'\311','\003','\111',(unsigned char)'\276'};
-static const unsigned char I__PAF[4] = {' ','p','a','f'}; /* Paris Ensoniq */
-static const unsigned char I_FAP_[4] = {'f','a','p',' '}; /* Paris Ensoniq */
-static const unsigned char I_DS16[4] = {'D','S','1','6'}; /* CSL */
-static const unsigned char I_HEDR[4] = {'H','E','D','R'};
-static const unsigned char I_HDR8[4] = {'H','D','R','8'};
-static const unsigned char I_SDA_[4] = {'S','D','A','_'};
-static const unsigned char I_SDAB[4] = {'S','D','A','B'};
-static const unsigned char I_SD_B[4] = {'S','D','_','B'};
-static const unsigned char I_NOTE[4] = {'N','O','T','E'};
-static const unsigned char I_file[4] = {'f','i','l','e'}; /* snack "SMP" */
-static const unsigned char I__sam[4] = {'=','s','a','m'};
-static const unsigned char I_SU7M[4] = {'S','U','7','M'};
-static const unsigned char I_SU7R[4] = {'S','U','7','R'};
-static const unsigned char I_PVF1[4] = {'P','V','F','1'}; /* portable voice format (mgetty) */
-static const unsigned char I_PVF2[4] = {'P','V','F','2'};
-static const unsigned char I_AUTH[4] = {'A','U','T','H'};
-static const unsigned char I_riff[4] = {'r','i','f','f'}; /* SoundForge */
-static const unsigned char I_TWIN[4] = {'T','W','I','N'}; /* TwinVQ */
-static const unsigned char I_IMPS[4] = {'I','M','P','S'}; /* Impulse Tracker */
-static const unsigned char I_SMP1[4] = {'S','M','P','1'}; /* Korg */
-static const unsigned char I_Maui[4] = {'M','a','u','i'}; /* Turtle Beach */
-static const unsigned char I_SDIF[4] = {'S','D','I','F'}; /* IRCAM sdif */
-static const unsigned char I_NVF_[4] = {'N','V','F',' '}; /* Nomad II Creative NVF */
-static const unsigned char I_VFMT[4] = {'V','F','M','T'}; /* Nomad II Creative NVF */
-static const unsigned char I_OggS[4] = {'O','g','g','S'}; /* Ogg-related files, apparently -- ogg123 has "vorbis" instead of "Speex" */
-static const unsigned char I_fLaC[4] = {'f','L','a','C'}; /* FLAC */
-static const unsigned char I_ajkg[4] = {'a','j','k','g'}; /* shorten */
-static const unsigned char I_TTA1[4] = {'T','T','A','1'}; /* ttaenc */
-static const unsigned char I_wvpk[4] = {'w','v','p','k'}; /* wavpack */
-
-#define I_IRCAM_VAX 0x0001a364
-#define I_IRCAM_SUN 0x0002a364
-#define I_IRCAM_MIPS 0x0003a364
-#define I_IRCAM_NEXT 0x0004a364
-
-#define NINRS 7
-static const unsigned int I_INRS[NINRS] = {0xcb460020, 0xd0465555, 0xfa460000, 0x1c470040, 0x3b470080, 0x7a470000, 0x9c470040};
-
-static off_t data_location = 0;
-static int srate = 0, chans = 0, header_type = MUS_UNSUPPORTED, data_format = MUS_UNKNOWN, original_data_format = 0;
-static int type_specifier = 0, bits_per_sample = 0, block_align = 0, fact_samples = 0;
-static off_t comment_start = 0, comment_end = 0;
-static off_t true_file_length = 0, data_size = 0;
-static int base_detune = 0, base_note = 0;
-static bool little_endian = false;
-
-off_t mus_header_samples(void) {return(data_size);}
-off_t mus_header_data_location(void) {return(data_location);}
-int mus_header_chans(void) {return(chans);}
-int mus_header_srate(void) {return(srate);}
-int mus_header_type(void) {return(header_type);}
-int mus_header_format(void) {return(data_format);}
-off_t mus_header_comment_start(void) {return(comment_start);}
-off_t mus_header_comment_end(void) {return(comment_end);}
-off_t mus_header_aux_comment_start(int n) {if (aux_comment_start) return(aux_comment_start[n]); else return(-1);}
-off_t mus_header_aux_comment_end(int n) {if (aux_comment_end) return(aux_comment_end[n]); else return(-1);}
-int mus_header_type_specifier(void) {return(type_specifier);}
-int mus_header_bits_per_sample(void) {return(bits_per_sample);}
-int mus_header_fact_samples(void) {return(fact_samples);}
-int mus_header_block_align(void) {return(block_align);}
-off_t mus_header_true_length(void) {return(true_file_length);}
-int mus_header_original_format(void) {return(original_data_format);}
-int mus_header_loop_mode(int which) {if (loop_modes) return(loop_modes[which]); else return(-1);}
-int mus_header_loop_start(int which) {if (loop_starts) return(loop_starts[which]); else return(-1);}
-int mus_header_loop_end(int which) {if (loop_ends) return(loop_ends[which]); else return(-1);}
-int mus_header_mark_position(int id) {int i; for (i = 0; i < markers; i++) {if (marker_ids[i] == id) return(marker_positions[i]);} return(-1);}
-int mus_header_base_detune(void) {return(base_detune);}
-int mus_header_base_note(void) {return(base_note);}
-
-int mus_bytes_per_sample(int format)
-{
- switch (format)
- {
- case MUS_BYTE: return(1); break;
- case MUS_BSHORT: return(2); break;
- case MUS_UBYTE: return(1); break;
- case MUS_MULAW: return(1); break;
- case MUS_ALAW: return(1); break;
- case MUS_BINT: return(4); break;
- case MUS_BFLOAT: return(4); break;
- case MUS_BFLOAT_UNSCALED: return(4); break;
- case MUS_B24INT: return(3); break;
- case MUS_BDOUBLE: return(8); break;
- case MUS_BDOUBLE_UNSCALED: return(8); break;
- case MUS_LSHORT: return(2); break;
- case MUS_LINT: return(4); break;
- case MUS_LFLOAT: return(4); break;
- case MUS_LDOUBLE: return(8); break;
- case MUS_LFLOAT_UNSCALED: return(4); break;
- case MUS_LDOUBLE_UNSCALED: return(8); break;
- case MUS_L24INT: return(3); break;
- case MUS_UBSHORT: return(2); break;
- case MUS_ULSHORT: return(2); break;
- case MUS_BINTN: return(4); break;
- case MUS_LINTN: return(4); break;
- default: return(1); break; /* we divide by this number, so 0 is not safe */
- }
-}
-
-off_t mus_samples_to_bytes (int format, off_t size) {return(size * (mus_bytes_per_sample(format)));}
-off_t mus_bytes_to_samples (int format, off_t size) {return((off_t)(size / (mus_bytes_per_sample(format))));}
-
-
-static bool equal_big_or_little_endian(const unsigned char *n1, const unsigned int n2)
-{
- return((mus_char_to_ubint(n1) == n2) || (mus_char_to_ulint(n1) == n2));
-}
-
-static short big_or_little_endian_short(const unsigned char *n, bool little)
-{
- if (little) return(mus_char_to_lshort(n));
- return(mus_char_to_bshort(n));
-}
-
-static int big_or_little_endian_int(const unsigned char *n, bool little)
-{
- if (little) return(mus_char_to_lint(n));
- return(mus_char_to_bint(n));
-}
-
-static unsigned int big_or_little_endian_uint(const unsigned char *n, bool little)
-{
- if (little) return(mus_char_to_ulint(n));
- return(mus_char_to_ubint(n));
-}
-
-static float big_or_little_endian_float(const unsigned char *n, bool little)
-{
- if (little) return(mus_char_to_lfloat(n));
- return(mus_char_to_bfloat(n));
-}
-
-static bool match_four_chars(const unsigned char *head, const unsigned char *match)
-{
- return((head[0] == match[0]) &&
- (head[1] == match[1]) &&
- (head[2] == match[2]) &&
- (head[3] == match[3]));
-}
-
-static void write_four_chars(unsigned char *head, const unsigned char *match)
-{
- head[0] = match[0];
- head[1] = match[1];
- head[2] = match[2];
- head[3] = match[3];
-}
-
-const char *mus_header_type_name(int type)
-{
- switch (type)
- {
- case MUS_NEXT: return("Sun/Next"); break;
- case MUS_AIFC: return("AIFC"); break;
- case MUS_RIFF: return("RIFF"); break;
- case MUS_BICSF: return("BICSF"); break;
- case MUS_NIST: return("NIST"); break;
- case MUS_INRS: return("INRS"); break;
- case MUS_ESPS: return("ESPS"); break;
- case MUS_SVX: return("SVX8"); break;
- case MUS_VOC: return("VOC"); break;
- case MUS_SNDT: return("SNDT"); break;
- case MUS_RAW: return("raw (no header)"); break;
- case MUS_SMP: return("SMP"); break;
- case MUS_AVR: return("AVR"); break;
- case MUS_IRCAM: return("IRCAM"); break;
- case MUS_SD1: return("Sound Designer 1"); break;
- case MUS_SPPACK: return("SPPACK"); break;
- case MUS_MUS10: return("Mus10"); break;
- case MUS_HCOM: return("HCOM"); break;
- case MUS_PSION: return("PSION"); break;
- case MUS_MAUD: return("MAUD"); break;
- case MUS_IEEE: return("IEEE text"); break;
- case MUS_MATLAB: return("Matlab"); break;
- case MUS_ADC: return("ADC/OGI"); break;
- case MUS_MIDI: return("MIDI"); break;
- case MUS_SOUNDFONT: return("SoundFont"); break;
- case MUS_GRAVIS: return("Gravis Ultrasound patch"); break;
- case MUS_COMDISCO: return("Comdisco SPW signal"); break;
- case MUS_GOLDWAVE: return("Goldwave sample"); break;
- case MUS_SRFS: return("SRFS"); break;
- case MUS_MIDI_SAMPLE_DUMP: return("MIDI sample dump"); break;
- case MUS_DIAMONDWARE: return("DiamondWare"); break;
- case MUS_ADF: return("CSRE adf"); break;
- case MUS_SBSTUDIOII: return("SBStudioII"); break;
- case MUS_DELUSION: return("Delusion"); break;
- case MUS_FARANDOLE: return("Farandole"); break;
- case MUS_SAMPLE_DUMP: return("Sample dump"); break;
- case MUS_ULTRATRACKER: return("Ultratracker"); break;
- case MUS_YAMAHA_TX16W: return("TX-16W"); break;
- case MUS_YAMAHA_SY85: return("Sy-85"); break;
- case MUS_YAMAHA_SY99: return("Sy-99"); break;
- case MUS_KURZWEIL_2000: return("Kurzweil 2000"); break;
- case MUS_KORG: return("Korg"); break;
- case MUS_MAUI: return("Turtle Beach"); break;
- case MUS_IMPULSETRACKER: return("Impulse Tracker"); break;
- case MUS_AKAI4: return("AKAI 4"); break;
- case MUS_DIGIPLAYER: return("Digiplayer ST3"); break;
- case MUS_COVOX: return("Covox V8"); break;
- case MUS_AVI: return("AVI"); break;
- case MUS_OMF: return("OMF"); break;
- case MUS_QUICKTIME: return("Quicktime"); break;
- case MUS_ASF: return("asf"); break;
- case MUS_AIFF: return("AIFF"); break;
- case MUS_PAF: return("Ensoniq Paris"); break;
- case MUS_CSL: return("CSL"); break;
- case MUS_FILE_SAMP: return("snack SMP"); break;
- case MUS_PVF: return("Portable Voice Format"); break;
- case MUS_SOUNDFORGE: return("SoundForge"); break;
- case MUS_TWINVQ: return("TwinVQ"); break;
- case MUS_SDIF: return("IRCAM sdif"); break;
- case MUS_NVF: return("Creative NVF"); break;
- case MUS_OGG: return("Ogg Vorbis"); break;
- case MUS_FLAC: return("Flac"); break;
- case MUS_SPEEX: return("Speex"); break;
- case MUS_MPEG: return("mpeg"); break;
- case MUS_SHORTEN: return("shorten"); break;
- case MUS_TTA: return("tta"); break;
- case MUS_WAVPACK: return("wavpack"); break;
- default: return("unsupported"); break;
- }
-}
-
-const char *mus_data_format_name(int format)
-{
- switch (format)
- {
- case MUS_BSHORT: return("big endian short (16 bits)"); break;
- case MUS_MULAW: return("mulaw (8 bits)"); break;
- case MUS_BYTE: return("signed byte (8 bits)"); break;
- case MUS_BFLOAT: return("big endian float (32 bits)"); break;
- case MUS_BFLOAT_UNSCALED: return("big endian float (32 bits, unscaled)"); break;
- case MUS_BINT: return("big endian int (32 bits)"); break;
- case MUS_ALAW: return("alaw (8 bits)"); break;
- case MUS_UBYTE: return("unsigned byte (8 bits)"); break;
- case MUS_B24INT: return("big endian int (24 bits)"); break;
- case MUS_BDOUBLE: return("big endian double (64 bits)"); break;
- case MUS_BDOUBLE_UNSCALED: return("big endian double (64 bits, unscaled)"); break;
- case MUS_LSHORT: return("little endian short (16 bits)"); break;
- case MUS_LINT: return("little endian int (32 bits)"); break;
- case MUS_LFLOAT: return("little endian float (32 bits)"); break;
- case MUS_LDOUBLE: return("little endian double (64 bits)"); break;
- case MUS_LFLOAT_UNSCALED: return("little endian float (32 bits, unscaled)"); break;
- case MUS_LDOUBLE_UNSCALED: return("little endian double (64 bits, unscaled)"); break;
- case MUS_UBSHORT: return("unsigned big endian short (16 bits)"); break;
- case MUS_ULSHORT: return("unsigned little endian short (16 bits)"); break;
- case MUS_L24INT: return("little endian int (24 bits)"); break;
- case MUS_BINTN: return("normalized big endian int (32 bits)"); break;
- case MUS_LINTN: return("normalized little endian int (32 bits)"); break;
- default: return("unknown"); break;
- }
-}
-
-const char *mus_data_format_short_name(int format)
-{
- switch (format)
- {
- case MUS_BSHORT: return("short int"); break;
- case MUS_MULAW: return("mulaw"); break;
- case MUS_BYTE: return("signed byte"); break;
- case MUS_BFLOAT: return("float"); break;
- case MUS_BFLOAT_UNSCALED: return("float unscaled)"); break;
- case MUS_BINT: return("int"); break;
- case MUS_ALAW: return("alaw"); break;
- case MUS_UBYTE: return("unsigned byte"); break;
- case MUS_B24INT: return("24-bit int"); break;
- case MUS_BDOUBLE: return("double"); break;
- case MUS_BDOUBLE_UNSCALED: return("double unscaled"); break;
- case MUS_LSHORT: return("short int"); break;
- case MUS_LINT: return("int"); break;
- case MUS_LFLOAT: return("float"); break;
- case MUS_LDOUBLE: return("double"); break;
- case MUS_LFLOAT_UNSCALED: return("float unscaled"); break;
- case MUS_LDOUBLE_UNSCALED: return("double unscaled"); break;
- case MUS_UBSHORT: return("unsigned short"); break;
- case MUS_ULSHORT: return("unsigned short"); break;
- case MUS_L24INT: return("24-bit int"); break;
- case MUS_BINTN: return("normalized int"); break;
- case MUS_LINTN: return("normalized int"); break;
- default: return("unknown"); break;
- }
-}
-
-#if HAVE_RUBY
- #define TO_LANG(Str) strdup(xen_scheme_constant_to_ruby(Str))
-#else
- #define TO_LANG(Str) Str
-#endif
-
-char *mus_header_type_to_string(int type)
-{
- switch (type)
- {
- case MUS_NEXT: return(TO_LANG(S_mus_next));
- case MUS_AIFF: return(TO_LANG(S_mus_aiff));
- case MUS_AIFC: return(TO_LANG(S_mus_aifc));
- case MUS_RIFF: return(TO_LANG(S_mus_riff));
- case MUS_NIST: return(TO_LANG(S_mus_nist));
- case MUS_IRCAM: return(TO_LANG(S_mus_ircam));
- case MUS_RAW: return(TO_LANG(S_mus_raw));
- case MUS_BICSF: return(TO_LANG(S_mus_bicsf));
- case MUS_VOC: return(TO_LANG(S_mus_voc));
- case MUS_SVX: return(TO_LANG(S_mus_svx));
- case MUS_SOUNDFONT: return(TO_LANG(S_mus_soundfont));
- }
- return(NULL);
-}
-
-char *mus_data_format_to_string(int format)
-{
- switch (format)
- {
- case MUS_BSHORT: return(TO_LANG(S_mus_bshort));
- case MUS_LSHORT: return(TO_LANG(S_mus_lshort));
- case MUS_MULAW: return(TO_LANG(S_mus_mulaw));
- case MUS_ALAW: return(TO_LANG(S_mus_alaw));
- case MUS_BYTE: return(TO_LANG(S_mus_byte));
- case MUS_UBYTE: return(TO_LANG(S_mus_ubyte));
- case MUS_BFLOAT: return(TO_LANG(S_mus_bfloat));
- case MUS_LFLOAT: return(TO_LANG(S_mus_lfloat));
- case MUS_BINT: return(TO_LANG(S_mus_bint));
- case MUS_LINT: return(TO_LANG(S_mus_lint));
- case MUS_BINTN: return(TO_LANG(S_mus_bintn));
- case MUS_LINTN: return(TO_LANG(S_mus_lintn));
- case MUS_B24INT: return(TO_LANG(S_mus_b24int));
- case MUS_L24INT: return(TO_LANG(S_mus_l24int));
- case MUS_BDOUBLE: return(TO_LANG(S_mus_bdouble));
- case MUS_LDOUBLE: return(TO_LANG(S_mus_ldouble));
- case MUS_UBSHORT: return(TO_LANG(S_mus_ubshort));
- case MUS_ULSHORT: return(TO_LANG(S_mus_ulshort));
- case MUS_BDOUBLE_UNSCALED: return(TO_LANG(S_mus_bdouble_unscaled));
- case MUS_LDOUBLE_UNSCALED: return(TO_LANG(S_mus_ldouble_unscaled));
- case MUS_BFLOAT_UNSCALED: return(TO_LANG(S_mus_bfloat_unscaled));
- case MUS_LFLOAT_UNSCALED: return(TO_LANG(S_mus_lfloat_unscaled));
- }
- return(NULL);
-}
-
-static const char *any_data_format_name(int sndlib_format)
-{
- if (MUS_DATA_FORMAT_OK(sndlib_format))
- return(mus_data_format_name(sndlib_format));
- else return(mus_header_original_format_name(mus_header_original_format(),
- mus_header_type()));
-}
-
-#define SEEK_FILE_LENGTH(File) lseek(File, 0L, SEEK_END)
-static int read_bicsf_header(const char *filename, int chan);
-
-
-/* ------------------------------------ NeXT (or Sun) --------------------------------
- *
- * 0: ".snd"
- * 4: data_location (bytes) (not necessarily word aligned on Sun)
- * 8: data_size (bytes) -- sometimes incorrect ("advisory")
- * 12: data format indicator -- see below
- * 16: srate (int)
- * 20: chans
- * 24: comment start
- *
- * in an AFsp file, the first 4 bytes of the comment are "AFsp",
- * for bicsf, the integer at 28 is 107364 or 107415
- *
- * on NeXTStep, always big-endian. ".snd"==0x2e736e64 on big-endian machines.
- *
- * formats are:
- * 0 unspecified, 1 mulaw_8, 2 linear_8, 3 linear_16, 4 linear_24, 5 linear_32, 6 float,
- * 7 double, 8 indirect, 9 nested, 10 dsp_core, 11 dsp_data_8, 12 dsp_data_16, 13 dsp_data_24,
- * 14 dsp_data_32, 16 display, 17 mulaw_squelch, 18 emphasized, 19 compressed, 20 compressed_emphasized
- * 21 dsp_commands, 22 dsp_commands_samples, 23 adpcm_g721, 24 adpcm_g722, 25 adpcm_g723,
- * 26 adpcm_g723_5, 27 alaw_8, 28 aes, 29 delat_mulaw_8
- * internal Snd(lib)-only formats:
- * 30: mus_lint, 31: mus_lfloat,
- * 32: mus_bintn, 33: mus_lintn,
- * 34: mus_ldouble and others... (added by me for Snd internal use)
- */
-
-/* according to the file /usr/share/magic, the DECN versions were little endian */
-
-static int read_next_header(const char *filename, int chan)
-{
- int maybe_bicsf, err = MUS_NO_ERROR, i;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf);
- data_location = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- if (data_location < 24) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data location: " OFF_TD "?", filename, data_location));
- data_size = mus_char_to_bint((unsigned char *)(hdrbuf + 8));
- /* can be bogus -- fixup if possible */
- true_file_length = SEEK_FILE_LENGTH(chan);
- if ((data_size <= 24) || (data_size > true_file_length))
- data_size = (true_file_length - data_location);
- else
- {
- if (true_file_length > (off_t)(1 << 31))
- data_size = true_file_length - data_location; /* assume size field overflowed 32 bits */
- }
- original_data_format = mus_char_to_bint((unsigned char *)(hdrbuf + 12));
- switch (original_data_format)
- {
- case 1: data_format = MUS_MULAW; break;
- case 2: data_format = MUS_BYTE; break; /* some sound files assume MUS_UBYTE here! (NAS from 1994 X11R6 contrib) */
- case 3: data_format = MUS_BSHORT; break;
- case 4: data_format = MUS_B24INT; break;
- case 5: data_format = MUS_BINT; break;
- case 6: data_format = MUS_BFLOAT; break;
- case 7: data_format = MUS_BDOUBLE; break;
- case 18: data_format = MUS_BSHORT; break; /* "emphasized": Xavier Serra's de-emphasis filter: y(n) = x(n) + .9 y(n-1) */
- case 27: data_format = MUS_ALAW; break;
- case 30: data_format = MUS_LINT; break; /* from here on, for Snd's internal benefit -- these are probably not used elsewhere */
- case 31: data_format = MUS_LFLOAT; break;
- case 32: data_format = MUS_BINTN; break;
- case 33: data_format = MUS_LINTN; break;
- case 34: data_format = MUS_LDOUBLE; break;
- case 35: data_format = MUS_ULSHORT; break;
- case 36: data_format = MUS_UBSHORT; break;
- case 37: data_format = MUS_LFLOAT_UNSCALED; break;
- case 38: data_format = MUS_BFLOAT_UNSCALED; break;
- case 39: data_format = MUS_LDOUBLE_UNSCALED; break;
- case 40: data_format = MUS_BDOUBLE_UNSCALED; break;
- case 41: data_format = MUS_LSHORT; break;
- case 42: data_format = MUS_L24INT; break;
- case 43: data_format = MUS_UBYTE; break;
- default: data_format = MUS_UNKNOWN; break;
- }
- srate = mus_char_to_bint((unsigned char *)(hdrbuf + 16));
- chans = mus_char_to_bint((unsigned char *)(hdrbuf + 20));
- comment_start = 0;
- comment_end = 0;
- for (i = 24; i < data_location - 1; i++)
- if (hdrbuf[i] == '\0')
- break;
- else
- {
- if (hdrbuf[i] != ' ')
- {
- comment_start = i;
- comment_end = data_location - 1;
- break;
- }
- }
- if (comment_end < comment_start) comment_end = comment_start;
- maybe_bicsf = mus_char_to_bint((unsigned char *)(hdrbuf + 28));
- if (maybe_bicsf == 107364) err = read_bicsf_header(filename, chan);
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(err);
-}
-
-static int sndlib_format_to_next(int format)
-{
- switch (format)
- {
- case MUS_MULAW: return(1); break;
- case MUS_BYTE: return(2); break;
- case MUS_BSHORT: return(3); break;
- case MUS_B24INT: return(4); break;
- case MUS_BINT: return(5); break;
- case MUS_BFLOAT: return(6); break;
- case MUS_BDOUBLE: return(7); break;
- case MUS_ALAW: return(27); break;
- case MUS_LINT: return(30); break; /* see above */
- case MUS_LFLOAT: return(31); break;
- case MUS_BINTN: return(32); break;
- case MUS_LINTN: return(33); break;
- case MUS_LDOUBLE: return(34); break;
- case MUS_ULSHORT: return(35); break;
- case MUS_UBSHORT: return(36); break;
- case MUS_LFLOAT_UNSCALED: return(37); break;
- case MUS_BFLOAT_UNSCALED: return(38); break;
- case MUS_LDOUBLE_UNSCALED: return(39); break;
- case MUS_BDOUBLE_UNSCALED: return(40); break;
- case MUS_LSHORT: return(41); break;
- case MUS_L24INT: return(42); break;
- case MUS_UBYTE: return(43); break;
- default:
- return(mus_error(MUS_UNSUPPORTED_DATA_FORMAT, "Next header: can't write data format: %d (%s)",
- format,
- any_data_format_name(format)));
- break;
- }
-}
-
-#if MUS_DEBUGGING
- #define CHK_WRITE(Fd, Buf, Len) \
- do { size_t bytes = 0; \
- if (((Len) > 0) && ((bytes = write(Fd, Buf, Len)) == 0)) \
- fprintf(stderr, "%s[%d]: header write error (wrote: %d != requested: %d)", c__FUNCTION__, __LINE__, (int)bytes, (int)(Len)); \
- } while (0)
- #define CHK_READ(Fd, Buf, Len) \
- do { size_t bytes = 0; \
- if (((Len) > 0) && ((bytes = read(Fd, Buf, (Len))) == 0)) \
- fprintf(stderr, "%s[%d]: header read error (read %d != requested %d)", c__FUNCTION__, __LINE__, (int)bytes, (int)(Len)); \
- } while (0)
-#else
- #define CHK_WRITE(Fd, Buf, Len) do {if (((Len) > 0) && (write(Fd, Buf, Len) == 0)) fprintf(stderr, "header write error");} while (0)
- #define CHK_READ(Fd, Buf, Len) do {if (((Len) > 0) && (read(Fd, Buf, Len) == 0)) fprintf(stderr, "header read error");} while (0)
-#endif
-
-static void write_next_comment(int fd, const char *comment, int len, int loc)
-{
- if (len > 0)
- CHK_WRITE(fd, (unsigned char *)comment, len);
- len = loc - (len + 24);
- if (len > 0)
- {
- unsigned char *combuf;
- combuf = (unsigned char *)CALLOC(len, sizeof(char));
- CHK_WRITE(fd, combuf, len);
- FREE(combuf);
- }
-}
-
-int mus_header_write_next_header(int chan, int wsrate, int wchans, int loc, int siz, int format, const char *comment, int len)
-{
- int i, j;
- write_four_chars((unsigned char *)hdrbuf, I_DSND); /* ".snd" */
- i = len / 4;
- j = 24 + (4 * (i + 1));
- if (loc < j) loc = j;
- mus_bint_to_char((unsigned char *)(hdrbuf + 4), loc);
- mus_bint_to_char((unsigned char *)(hdrbuf + 8), siz);
- mus_bint_to_char((unsigned char *)(hdrbuf + 12), sndlib_format_to_next(format));
- mus_bint_to_char((unsigned char *)(hdrbuf + 16), wsrate);
- mus_bint_to_char((unsigned char *)(hdrbuf + 20), wchans);
- CHK_WRITE(chan, hdrbuf, 24);
- write_next_comment(chan, comment, len, loc);
- data_location = loc;
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ AIFF ------------------------------------
- *
- * 0: "FORM"
- * 4: size (bytes)
- * 8: "AIFF" or "AIFC" -- the latter includes compressed formats (list extended for 8.5 Sound.h)
- *
- * Thereafter the file is organized into "chunks", each chunk being
- * a 4-byte identifer followed by an int (4-bytes) giving the chunk size
- * not including the 8-byte header. AIFF data is signed. If the chunk
- * size is odd, an extra (unaccounted-for) null byte is added at the end.
- *
- * The chunks we want are "COMM", "SSND", and "APPL".
- *
- * COMM: 0: chans
- * 2: frames
- * 6: bits per sample
- * 8: srate as 80-bit IEEE float
- * then if AIFC (not AIFF), 4 bytes giving compression id ("NONE"=not compressed)
- * followed by Pascal string giving long name of compression type
- *
- * SSND: 0: data location (offset within SSND chunk)
- *
- * Other chunks include: ANNO: a comment, INST: loop control, MARK: marker, MIDI: midi,
- * COMT: comment (max 65536 chars), NAME: sound name, AUTH: author's name
- * (c), AESD: recording data, APPL: application specific stuff
- * "MARK" size short-#marks {marks} -- latter are short-ID long-position pstring-name.
- * "INST" size chars[baseNote detune lowNote highNote lowVelocity HighVelocity] short-gain loops[sustain release]
- * loop: short-playMode marker-begin marker-end (signed?) shorts)
- * playMode: 0 no loop, 1 forward loop, 2 forward/backward loop
- * chars are MIDI data (detune is in cents)
- * "MIDI" size MIDI-data...
- * "AESD" size AES Channel Status Data (24 bytes as specified by AES)
- * see "AES: Guidelines for the use of the AES3 interface"
- * byte 0: bit 0: 0 = consumer, 1 = pro
- * bit 1: 0 = audio, 1 = non-audio
- * bits 2:4: emphasis: 0:none, 4:none, 6:CD, 7:CCITT J17
- * bits 6:7: srate: 00 = 48KHz, 01 = 48, 10 = 44.1, 11 = 32
- * byte 1: bits 0:3: chans: 2:mono, else stereo
- * byte 2 for word size stuff (always ends up 16-bit): bits 3-5 = sample length where 4 = 16-bit
- * byte 3: multi-channels modes, 4: AES sync ref, 5:unused, 6-9:ASCII source ID, 10-13:ASCII destination ID
- * byte 14-17:local sample addr, 18-21:time of day addr, then CRC checks
- * "APPL" size signature data
- * "COMT" size short-#comments {comments} -- the latter are long-time marker short-text-length char-text
- * time is in seconds since 1-Jan-1904
- * "NAME"/"AUTH"/"(c) "/"ANNO" size char-name
- * "FVER" size(4) AIFC-format-version -- currently always 0xA2805140
- * "SAXL" -- a desperate kludge to get around Apple's own compression schemes!
- *
- * always big-endian
- * There was also (briefly) an AIFS file, now deprecated.
- */
-
-/* ieee-80 conversions -- design by committee! */
-/* this code taken from CSound sources -- apparently originally written by Malcolm Slaney at Apple */
-
-#define ULPOW2TO31 ((unsigned int)0x80000000)
-#define DPOW2TO31 ((double)2147483648.0) /* 2^31 */
-
-static double myUlongToDouble(unsigned int ul)
-{
- double val;
- if(ul & ULPOW2TO31) val = DPOW2TO31 + (ul & (~ULPOW2TO31));
- else val = ul;
- return val;
-}
-
-static unsigned int myDoubleToUlong(double val)
-{
- unsigned int ul;
- if(val < DPOW2TO31) ul = (unsigned int)val;
- else ul = ULPOW2TO31 | (unsigned int)(val-DPOW2TO31);
- return ul;
-}
-
-static double ieee_80_to_double(unsigned char *p)
-{
- unsigned char sign;
- short lexp = 0;
- unsigned int mant1 = 0;
- unsigned int mant0 = 0;
- lexp = *p++; lexp <<= 8; lexp |= *p++; sign = (lexp & 0x8000) ? 1 : 0; lexp &= 0x7FFF;
- mant1 = *p++; mant1 <<= 8; mant1 |= *p++; mant1 <<= 8; mant1 |= *p++; mant1 <<= 8; mant1 |= *p++;
- mant0 = *p++; mant0 <<= 8; mant0 |= *p++; mant0 <<= 8; mant0 |= *p++; mant0 <<= 8; mant0 |= *p++;
- if(mant1 == 0 && mant0 == 0 && lexp == 0 && sign == 0)
- return 0.0;
- else
- {
- double val;
- val = myUlongToDouble(mant0) * pow(2.0, -63.0);
- val += myUlongToDouble(mant1) * pow(2.0, -31.0);
- val *= pow(2.0, ((double) lexp) - 16383.0);
- return sign ? -val : val;
- }
-}
-
-static void double_to_ieee_80(double val, unsigned char *p)
-{
- short lexp = 0;
- unsigned char sign = 0;
- unsigned int mant1 = 0;
- unsigned int mant0 = 0;
- if(val < 0.0) { sign = 1; val = -val; }
- if(val != 0.0) /* val identically zero -> all elements zero */
- {
- lexp = (short)(log(val) / log(2.0) + 16383.0);
- val *= pow(2.0, 31.0 + 16383.0 - (double)lexp);
- mant1 = myDoubleToUlong(val);
- val -= myUlongToDouble(mant1);
- val *= pow(2.0, 32.0);
- mant0 = myDoubleToUlong(val);
- }
- *p++ = ((sign << 7) | (lexp >> 8)); *p++ = 0xFF & lexp;
- *p++ = 0xFF & (mant1 >> 24); *p++ = 0xFF & (mant1 >> 16); *p++ = 0xFF & (mant1 >> 8); *p++ = 0xFF & (mant1);
- *p++ = 0xFF & (mant0 >> 24); *p++ = 0xFF & (mant0 >> 16); *p++ = 0xFF & (mant0 >> 8); *p++ = 0xFF & (mant0);
-}
-
-
-static off_t update_form_size, update_frames_location, update_ssnd_location;
-
-static int seek_and_read(int chan, unsigned char *buf, off_t offset, int nbytes)
-{
- if (offset < 0) return(-1);
- lseek(chan, offset, SEEK_SET);
- return(read(chan, buf, nbytes));
-}
-
-static int read_aiff_marker(int m, unsigned char *buf)
-{
- int psize;
- marker_ids[m] = mus_char_to_bshort((unsigned char *)buf);
- marker_positions[m] = mus_char_to_bint((unsigned char *)(buf + 2));
- psize = (int)buf[6] + 1;
- if (psize & 1) psize++;
- return(psize+6);
-}
-
-static int read_aiff_header(const char *filename, int chan, int overall_offset)
-{
- /* we know we have checked for FORM xxxx AIFF|AIFC when we arrive here */
- /* as far as I can tell, the COMM block has the header data we seek, and the SSND block has the sound data */
- int chunksize, chunkloc, i, j, ssnd_bytes = 0;
- bool happy, got_comm = false;
- off_t offset;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)(hdrbuf + 8 + overall_offset));
- update_ssnd_location = 0;
- chunkloc = 12 + overall_offset;
- offset = 0;
- for (i = 0; i < AUX_COMMENTS; i++) aux_comment_start[i] = 0;
- data_format = MUS_BSHORT;
- srate = 0;
- chans = 0;
- happy = true;
- true_file_length = SEEK_FILE_LENGTH(chan);
- update_form_size = mus_char_to_bint((unsigned char *)(hdrbuf + 4 + overall_offset)); /* should be file-size-8 unless there are multiple forms */
- while (happy)
- {
- offset += chunkloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 32) <= 0)
- {
- if ((got_comm) && (data_location > 0))
- {
- mus_print("%s, aiff header: chunks confused at " OFF_TD "; will try to continue", filename, offset);
- break;
- }
- return(mus_error(MUS_HEADER_READ_FAILED, "%s, aiff header: chunks confused at " OFF_TD , filename, offset));
- }
- chunksize = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- if ((chunksize == 0) && /* can be empty data chunk */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- /* fprintf(stderr,"chunk: %c%c%c%c for %d\n", hdrbuf[0], hdrbuf[1], hdrbuf[2], hdrbuf[3], chunksize); */
- if (match_four_chars((unsigned char *)hdrbuf, I_COMM))
- {
- int frames;
- got_comm = true;
- chans = mus_char_to_bshort((unsigned char *)(hdrbuf + 8));
- frames = mus_char_to_ubint((unsigned char *)(hdrbuf + 10)); /* was bint 27-Jul-01 */
- update_frames_location = 10 + offset;
- original_data_format = mus_char_to_bshort((unsigned char *)(hdrbuf + 14));
- if ((original_data_format % 8) != 0)
- {
- /* weird sizes are legal --
- * these samples are left-justified (and zero padded on the right), so
- * we can handle any bit size by rounding up to the nearest byte.
- */
- original_data_format = 8 * (1 + (original_data_format >> 3));
- }
- if (original_data_format == 8) data_format = MUS_BYTE;
- else if (original_data_format == 16) data_format = MUS_BSHORT;
- else if (original_data_format == 24) data_format = MUS_B24INT;
- else if (original_data_format == 32) data_format = MUS_BINT;
- else if (original_data_format == 64) data_format = MUS_BDOUBLE;
- else return(mus_error(MUS_HEADER_READ_FAILED, "%s: bits per sample: %d?", filename, mus_char_to_bshort((unsigned char *)(hdrbuf + 14))));
- srate = (int)ieee_80_to_double((unsigned char *)(hdrbuf + 16));
- /* if AIFC, compression type over-rides (possibly bogus) original_data_format */
- if (type_specifier == mus_char_to_uninterpreted_int((unsigned const char *)I_AIFC))
- {
- /* some aifc files assume the compression field is a new and very weird chunk!! -- surely a bug? */
- /* AIFF spec says COMM size is always 18, but this is amended in the newer AIFC spec */
- if (chunksize == 18) chunksize += (5 + ((int)hdrbuf[30])); /* 5 = chunk header length in this case */
- if ((!(match_four_chars((unsigned char *)(hdrbuf + 26), I_NONE))) &&
- (!(match_four_chars((unsigned char *)(hdrbuf + 26), I_twos))))
- {
- original_data_format = mus_char_to_uninterpreted_int((unsigned char *)(hdrbuf + 26));
- if ((match_four_chars((unsigned char *)(hdrbuf + 26), I_ALAW)) ||
- (match_four_chars((unsigned char *)(hdrbuf + 26), I_alaw)))
- data_format = MUS_ALAW;
- else
- {
- if ((match_four_chars((unsigned char *)(hdrbuf + 26), I_ULAW)) ||
- (match_four_chars((unsigned char *)(hdrbuf + 26), I_ulaw)))
- data_format = MUS_MULAW;
- else
- {
- if ((match_four_chars((unsigned char *)(hdrbuf + 26), I_sowt)) ||
- (match_four_chars((unsigned char *)(hdrbuf + 26), I_ni23)))
- {
- /* Sound.h sez sowt is just 16-bit format */
- if (data_format == MUS_BSHORT) data_format = MUS_LSHORT;
- else if (data_format == MUS_B24INT) data_format = MUS_L24INT;
- else if (data_format == MUS_BINT) data_format = MUS_LINT;
- }
- else
- {
- if (match_four_chars((unsigned char *)(hdrbuf + 26), I_raw_))
- {
- if (data_format == MUS_BYTE) data_format = MUS_UBYTE;
- else if (data_format == MUS_BSHORT) data_format = MUS_UBSHORT;
- }
- else
- {
- if ((match_four_chars((unsigned char *)(hdrbuf + 26), I_fl32)) ||
- (match_four_chars((unsigned char *)(hdrbuf + 26), I_FL32)))
- data_format = MUS_BFLOAT;
- else
- {
- if (match_four_chars((unsigned char *)(hdrbuf + 26), I_fl64))
- data_format = MUS_BDOUBLE;
- else
- {
- if (match_four_chars((unsigned char *)(hdrbuf + 26), I_ima4))
- {
- block_align = 34;
- original_data_format = MUS_AIFF_IMA_ADPCM;
- }
- else
- {
- if (match_four_chars((unsigned char *)(hdrbuf + 26), I_in32))
- data_format = MUS_BINT;
- else
- {
- if (match_four_chars((unsigned char *)(hdrbuf + 26), I_in24))
- data_format = MUS_B24INT;
- else
- {
- /* others from Sound.h:
- 0x6D730002, -- Microsoft ADPCM - ACM code 2
- 0x6D730011, -- DVI/Intel IMA ADPCM - ACM code 17
- 'MAC3' -- MACE 3:1
- 'MAC6' -- MACE 6:1
- 'cdx4' -- CD/XA 4:1
- 'cdx2' -- CD/XA 2:1
- 'dvca' -- DV Audio
- 'QDMC' -- QDesign music
- 'QDM2' -- QDesign2 music
- 'Qclp' -- QUALCOMM PureVoice
- 0x6D730055 -- MPEG Layer 3, CBR only (pre QT4.1)
- '.mp3' -- MPEG Layer 3, CBR & VBR (QT4.1 and later)
- */
- data_format = MUS_UNKNOWN;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- data_size = (frames * mus_bytes_per_sample(data_format) * chans);
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_SSND))
- {
- if (data_location != 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: two SSND chunks found", filename));
- update_ssnd_location = offset + 4;
- data_location = mus_char_to_bint((unsigned char *)(hdrbuf + 8)) + offset + 16; /* Baroque! */
- /* offset is where the hdrbuf is positioned in the file, the sound data offset itself is at loc+8 and the */
- /* 0-based location of the sound data is at the end of the chunk = 16 (8 = header+4 = offset+4 = blocksize) */
- /* the next int can be the block size if the data is block-aligned */
- /* only one SSND per AIFF is allowed */
- if (chunksize == 0) break; /* this may happen while pre-reading an in-progress output file for updating */
- ssnd_bytes = offset + chunksize - data_location + 8;
- }
- else
- {
- if ((match_four_chars((unsigned char *)hdrbuf, I_ANNO)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_COMT)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_NAME)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_AUTH)))
- {
- j = 0;
- for (i = 0; i < AUX_COMMENTS; i++)
- if (aux_comment_start[i] == 0)
- {
- j = i;
- break;
- }
- if (j >= AUX_COMMENTS)
- {
- mus_print("read_aiff_header: ran out of auxiliary comment space");
- j = 0;
- }
- aux_comment_start[j] = offset + 8;
- if (match_four_chars((unsigned char *)hdrbuf, I_COMT))
- aux_comment_start[j] += 8; /* skip time stamp and markerId (not ID, I assume!) */
- aux_comment_end[j] = offset + 7 + chunksize;
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_APPL))
- {
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_MUS_))
- {
- /* my own chunk has the arbitrary length comment I use (actually the ASCII */
- /* representation of a lisp program evaluated in the CLM package) to handle mix et al. */
- /* It is nothing more than the actual string -- remember to pad to even length here. */
- comment_start = offset + 12;
- comment_end = comment_start + chunksize - 5;
- }
- else
- {
- if ((match_four_chars((unsigned char *)(hdrbuf + 8), I_SU7M)) ||
- (match_four_chars((unsigned char *)(hdrbuf + 8), I_SU7R)))
- {
- mus_print("this is an SU700 ssp file?");
- data_location = 512;
- chans = 1;
- /* actually SU7M and SU7R point to 2 chan data as separate chunks */
- }
- }
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_INST))
- {
- base_note = hdrbuf[8];
- base_detune = hdrbuf[9];
- loop_modes[0] = mus_char_to_bshort((unsigned char *)(hdrbuf + 16));
- loop_starts[0] = mus_char_to_bshort((unsigned char *)(hdrbuf + 18));
- loop_ends[0] = mus_char_to_bshort((unsigned char *)(hdrbuf + 20));
- loop_modes[1] = mus_char_to_bshort((unsigned char *)(hdrbuf + 22));
- loop_starts[1] = mus_char_to_bshort((unsigned char *)(hdrbuf + 24));
- loop_ends[1] = mus_char_to_bshort((unsigned char *)(hdrbuf + 26));
- /* these are mark numbers */
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_MARK))
- {
- int num_marks, m, moff, msize;
- /* unsigned short #marks, each mark: id pos name (pstring damn it) */
- num_marks = mus_char_to_ubshort((unsigned char *)(hdrbuf + 8));
- if (num_marks > markers)
- {
- if (markers > 0)
- {
- if (marker_ids) FREE(marker_ids);
- if (marker_positions) FREE(marker_positions);
- }
- markers = num_marks;
- marker_ids = (int *)CALLOC(markers, sizeof(int));
- marker_positions = (int *)CALLOC(markers, sizeof(int));
- }
- moff = 10;
- for (m = 0; m < num_marks; m++)
- {
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset + moff, 8) > 0)
- {
- msize = read_aiff_marker(m, (unsigned char *)hdrbuf);
- moff += msize;
- }
- }
- }
- }
- }
- }
- }
- }
- chunkloc = (8 + chunksize);
- if (chunksize & 1) chunkloc++; /* extra null appended to odd-length chunks */
- if ((offset + chunkloc) >= update_form_size) happy = false;
- }
- if (!got_comm)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no COMM chunk", filename));
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no SSND (data) chunk", filename));
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- if ((data_size > ssnd_bytes) && (data_format != MUS_UNKNOWN))
- data_size = ssnd_bytes;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-static int sndlib_format_to_aiff_bits(int format)
-{
- switch (format)
- {
- case MUS_BSHORT: case MUS_LSHORT: case MUS_UBSHORT: case MUS_ULSHORT: return(16); break;
- case MUS_B24INT: case MUS_L24INT: return(24); break;
- case MUS_BINT: case MUS_LINT: case MUS_BFLOAT: case MUS_LFLOAT: return(32); break;
- case MUS_BDOUBLE: case MUS_LDOUBLE: return(64); break;
- case MUS_BYTE: case MUS_UBYTE: case MUS_MULAW: case MUS_ALAW: return(8); break;
- default:
- return(mus_error(MUS_UNSUPPORTED_DATA_FORMAT, "aiff header: can't write data format: %d (%s)",
- format,
- any_data_format_name(format)));
- break;
- }
-}
-
-static const char *sndlib_format_to_aifc_name(int format)
-{
- switch (format)
- {
- case MUS_BSHORT: case MUS_B24INT: case MUS_BINT: case MUS_BYTE: return((const char *)I_NONE); break; /* use in24 and in32? */
- case MUS_LSHORT: case MUS_L24INT: case MUS_LINT: return((const char *)I_sowt); break; /* should this use ni23? */
- case MUS_BFLOAT: return((const char *)I_fl32); break;
- case MUS_BDOUBLE: return((const char *)I_fl64); break;
- case MUS_UBYTE: case MUS_UBSHORT: return((const char *)I_raw_); break;
- case MUS_MULAW: return((const char *)I_ulaw); break;
- case MUS_ALAW: return((const char *)I_alaw); break;
- default: return((const char *)I_NONE); break;
- }
-}
-
-static int write_aif_header(int chan, int wsrate, int wchans, int siz, int format, const char *comment, int len, bool aifc_header)
-{
- /* we write the simplest possible AIFC header: AIFC | COMM | APPL-MUS_ if needed | SSND eof. */
- /* the assumption being that we're going to be appending sound data once the header is out */
- /* INST and MARK chunks added Jul-95 for various programs that expect them (MixView). */
- int i, j, lenhdr, lenloop, curend, extra; /* set aifc to 0 to get old-style AIFF header */
- char *str;
- lenhdr = 0;
- extra = 0;
- curend = 0;
- lenloop = 38;
- if ((loop_modes[0] != 0) || (loop_modes[1] != 0)) lenloop = 42 + 28;
- if (len != 0)
- {
- lenhdr = 12;
- if ((len % 4) != 0)
- extra = (4 - (len % 4));
- }
- write_four_chars((unsigned char *)hdrbuf, I_FORM);
- if (aifc_header)
- mus_bint_to_char((unsigned char *)(hdrbuf + 4), len + 30 + 16 + lenloop + siz + lenhdr + extra + 12 + 10);
- else mus_bint_to_char((unsigned char *)(hdrbuf + 4), len + 30 + 16 + lenloop + siz + lenhdr + extra);
- /*
- * comment length + 4 for AIFF 18+8 for I_COMM info + 16 for I_SSND info + 38 for INST and MARK +
- * siz for data + 12 for comment header if any + padding == total size - 8 (i.e. FORM header).
- * INST+MARK (38) added 3-Jul-95 for Notam software compatibility
- */
- if (aifc_header)
- {
- write_four_chars((unsigned char *)(hdrbuf + 8), I_AIFC);
- CHK_WRITE(chan, hdrbuf, 12);
- curend = 12;
- write_four_chars((unsigned char *)hdrbuf, I_FVER);
- mus_bint_to_char((unsigned char *)(hdrbuf + 4), 4);
- mus_bint_to_char((unsigned char *)(hdrbuf + 8), 0xA2805140);
- }
- else write_four_chars((unsigned char *)(hdrbuf + 8), I_AIFF);
- write_four_chars((unsigned char *)(hdrbuf + 12), I_COMM);
- if (aifc_header)
- mus_bint_to_char((unsigned char *)(hdrbuf + 16), 18 + 10);
- else mus_bint_to_char((unsigned char *)(hdrbuf + 16), 18);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 20), (short)wchans);
- if (wchans > 0)
- mus_bint_to_char((unsigned char *)(hdrbuf + 22), siz / (wchans * mus_bytes_per_sample(format)));
- mus_bshort_to_char((unsigned char *)(hdrbuf + 26), sndlib_format_to_aiff_bits(format));
- double_to_ieee_80((double)wsrate, (unsigned char *)(hdrbuf + 28));
- if (aifc_header)
- {
- str = (char *)sndlib_format_to_aifc_name(format);
- write_four_chars((unsigned char *)(hdrbuf + 38), (const unsigned char *)str);
- (*(unsigned char *)(hdrbuf + 42)) = 4; /* final pad null not accounted-for */
- write_four_chars((unsigned char *)(hdrbuf + 43), (const unsigned char *)str);
- (*(unsigned char *)(hdrbuf + 47)) = 0;
- i = 48;
- }
- else i = 38;
- if (len != 0)
- {
- if (aifc_header)
- {
- write_four_chars((unsigned char *)(hdrbuf + 48), I_APPL);
- mus_bint_to_char((unsigned char *)(hdrbuf + 52), len + 4 + extra);
- write_four_chars((unsigned char *)(hdrbuf + 56), I_MUS_);
- i = 60;
- }
- else
- {
- write_four_chars((unsigned char *)(hdrbuf + 38), I_APPL);
- mus_bint_to_char((unsigned char *)(hdrbuf + 42), len + 4 + extra);
- write_four_chars((unsigned char *)(hdrbuf + 46), I_MUS_);
- i = 50;
- }
- for (j = 0; j < len; j++)
- {
- if (i == HDRBUFSIZ)
- {
- curend += HDRBUFSIZ;
- CHK_WRITE(chan, hdrbuf, HDRBUFSIZ);
- i = 0;
- }
- hdrbuf[i] = comment[j];
- i++;
- }
- if (extra != 0)
- {
- if ((i + extra) > HDRBUFSIZ)
- {
- curend += i;
- CHK_WRITE(chan, hdrbuf, i);
- i = 0;
- }
- for (j = 0; j < extra; j++)
- {
- hdrbuf[i] = 0;
- i++;
- }
- }
- }
- curend += i;
- CHK_WRITE(chan, hdrbuf, i);
- if ((loop_modes[0] == 0) && (loop_modes[1] == 0))
- {
- write_four_chars((unsigned char *)hdrbuf, I_MARK); /* SoundHack includes a blank MARK chunk for some reason */
- mus_bint_to_char((unsigned char *)(hdrbuf + 4), 2);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 8), 0);
- write_four_chars((unsigned char *)(hdrbuf + 10), I_INST);
- mus_bint_to_char((unsigned char *)(hdrbuf + 14), 20);
- mus_bint_to_char((unsigned char *)(hdrbuf + 18), 0x3c00007f); /* base-note = middle C, detune = 0, lownote = 0, highnote = 0x7f */
- mus_bint_to_char((unsigned char *)(hdrbuf + 22), 0x017f0000); /* lowvelocity = 1, highvelocity = 0x7f, gain = 0 */
- mus_bint_to_char((unsigned char *)(hdrbuf + 26), 0); /* no loops */
- mus_bint_to_char((unsigned char *)(hdrbuf + 30), 0);
- mus_bint_to_char((unsigned char *)(hdrbuf + 34), 0);
- CHK_WRITE(chan, hdrbuf, 38);
- curend += 38;
- }
- else
- {
- write_four_chars((unsigned char *)hdrbuf, I_MARK);
- mus_bint_to_char((unsigned char *)(hdrbuf + 4), 8 * 4 + 2); /* 2 for mark#, then 2:id + 4:pos + 2:pstr */
- /* loop_info: 0..3 are markers positions (ids 1..4) */
- mus_bshort_to_char((unsigned char *)(hdrbuf + 8), 4);
- for (j = 0; j < 4; j++)
- {
- mus_bshort_to_char((unsigned char *)(hdrbuf + 10 + 8 * j), j + 1);
- switch (j)
- {
- case 0: mus_bint_to_char((unsigned char *)(hdrbuf + 10 + 8 * j + 2), loop_starts[0]); break;
- case 1: mus_bint_to_char((unsigned char *)(hdrbuf + 10 + 8 * j + 2), loop_ends[0]); break;
- case 2: mus_bint_to_char((unsigned char *)(hdrbuf + 10 + 8 * j + 2), loop_starts[1]); break;
- case 3: mus_bint_to_char((unsigned char *)(hdrbuf + 10 + 8 * j + 2), loop_ends[1]); break;
- }
- mus_bshort_to_char((unsigned char *)(hdrbuf + 10 + 8 * j + 6), 0);
- }
- CHK_WRITE(chan, hdrbuf, 42);
- curend += 42;
- write_four_chars((unsigned char *)hdrbuf, I_INST);
- mus_bint_to_char((unsigned char *)(hdrbuf + 4), 20);
- mus_bint_to_char((unsigned char *)(hdrbuf + 8), 0x3c00007f);
- mus_bint_to_char((unsigned char *)(hdrbuf + 12), 0x017f0000);
- hdrbuf[8] = (unsigned char)(base_note);
- hdrbuf[9] = (unsigned char)(base_detune);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 16), loop_modes[0]);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 18), 1);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 20), 2);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 22), loop_modes[1]);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 24), 3);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 26), 4);
- CHK_WRITE(chan, hdrbuf, 28);
- curend += 28;
- }
- write_four_chars((unsigned char *)(hdrbuf), I_SSND);
- mus_bint_to_char((unsigned char *)(hdrbuf + 4), siz + 8);
- mus_bint_to_char((unsigned char *)(hdrbuf + 8), 0); /* "offset" */
- mus_bint_to_char((unsigned char *)(hdrbuf + 12), 0); /* "blocksize " */
- CHK_WRITE(chan, hdrbuf, 16);
- data_location = 16 + curend;
- return(MUS_NO_ERROR);
-}
-
-char *mus_header_aiff_aux_comment(const char *name, off_t *starts, off_t *ends)
-{
- /* AIFC: look for aux comments (ANNO chunks) */
- char *sc = NULL;
- if ((starts) && (starts[0] != 0))
- {
- off_t full_len;
- int fd, i;
- fd = mus_file_open_read(name);
- if (fd == -1) return(NULL);
- full_len = 0;
- for (i = 0; i < AUX_COMMENTS; i++)
- if ((starts[i] > 0) &&
- (starts[i] < ends[i]))
- full_len += (ends[i] - starts[i] + 3);
- if (full_len > 0)
- {
- off_t sc_len;
- sc = (char *)CALLOC(full_len, sizeof(char));
- sc_len = 0;
- for (i = 0; i < AUX_COMMENTS; i++)
- {
- off_t start, end, len;
- start = starts[i];
- end = ends[i];
- if ((start > 0) && (start < end))
- {
- int j;
- len = end - start + 1;
- lseek(fd, start, SEEK_SET);
- CHK_READ(fd, (char *)(sc + sc_len), len);
- for (j = 0; j < len; j++)
- if (sc[j + sc_len] == 0)
- sc[j + sc_len] = ' ';
- sc_len += len;
- sc[sc_len++] = '\n';
- }
- }
- }
- CLOSE(fd, name);
- }
- return(sc);
-}
-
-/* ------------------------------------ RIFF (wave) ------------------------------------
- *
- * see ftp.microsoft.com:/SoftLib/MSLFILES/MDRK.EXE (also MMSYSTEM.H and MMREG.H)
- * ftp://ftp.isi.edu/in-notes/rfc2361.txt
- *
- * 0: "RIFF" (little-endian) or "RIFX" (big-endian)
- * 4: size
- * 8: "WAVE" ("RMID" = midi data, others are AVI, CPPO, ACON, DLS? etc)
- * AVI chunk can include audio data
- *
- * rest very similar to AIFF (odd-sized chunks are padded)
- *
- * fmt 0: format code (see below)
- * 2: chans
- * 4: srate (long)
- * 8: average rate "for buffer estimation"
- * 12: alignment "block size"
- * 14: data size (bits per sample) (PCM only)
- * 16: count (bytes) of extra info in the header (i.e. trailing info added to this basic header)
- * 20: samples per block (short) in dvi_adpcm
- *
- * formats are: 0: unknown, 1: PCM, 2: ADPCM, 3: IEEE float, 4: VSELP, 5: IBM_CVSD, 6: alaw, 7: mulaw
- * 0x10: OKI_ADPCM, 0x11: DVI_ADPCM, 0x12: MediaSpace_ADPCM,
- * 0x13: Sierra_ADPCM, 0x14: G723_ADPCM, 0x15: DIGISTD, 0x16: DIGIFIX, 0x17: Dialogic ADPCM,
- * 0x18: Mediavision ADPCM, 0x19: HP cu codec,
- * 0x20: Yamaha_ADPCM, 0x21: SONARC, 0x22: DSPGroup_TrueSpeech
- * 0x23: EchoSC1, 0x24: AudioFile_AF36, 0x25: APTX, 0x26: AudioFile_AF10
- * 0x27: prosody 1612, 0x28: lrc,
- * 0x30: Dolby_Ac2, 0x31: GSM610, 0x32: MSN audio codec, 0x33: Antext_ADPCM, 0x34: Control_res_vqlpc,
- * 0x35: DIGIREAL, 0x36: DIGIADPCM, 0x37: Control_res_cr10, 0x38: NMS_VBXADPCM, 0x39:Roland rdac,
- * 0x3a: echo sc3, 0x3b: Rockwell adpcm, 0x3c: Rockwell digitalk codec, 0x3d: Xebec,
- * 0x40: G721_ADPCM, 0x41: G728 CELP, 0x42: MS G723, 0x50: MPEG,
- * 0x52: RT24, 0x53: PAC, 0x55: Mpeg layer 3, 0x59: Lucent G723, 0x60: Cirrus,
- * 0x61: ESS Tech pcm, 0x62: voxware (obsolete), 0x63: canopus atrac,
- * 0x64: G726, 0x65: G722, 0x66: DSAT, 0x67: DSAT display,
- * 0x69: voxware (obsolete), 0x70: voxware ac8 (obsolete), 0x71: voxware ac10 (obsolete),
- * 0x72: voxware ac16 (obsolete), 0x73: voxware ac20 (obsolete), 0x74: voxware rt24,
- * 0x75: voxware rt29, 0x76: voxware rt29hw (obsolete), 0x77: voxware vr12 (obsolete),
- * 0x78: voxware vr18 (obsolete), 0x79: voxware tq40 (obsolete),
- * 0x80: softsound, 0x81: voxware tq60 (obsolete), 0x82: MS RT24, 0x83: G729A,
- * 0x84: MVI_MVI2, 0x85: DF G726, 0x86: DF GSM610, 0x88: isaudio, 0x89: onlive,
- * 0x91: sbc24, 0x92: dolby ac3 spdif, 0x97: zyxel adpcm, 0x98: philips lpcbb,
- * 0x99: packed, 0x100: rhetorex adpcm,
- * 0x101: Irat, 0x102: IBM_alaw?, 0x103: IBM_ADPCM?,
- * 0x111: vivo G723, 0x112: vivo siren, 0x123: digital g273
- * 0x200: Creative_ADPCM, 0x202: Creative fastspeech 8, 0x203: Creative fastspeech 10,
- * 0x220: quarterdeck, 0x300: FM_TOWNS_SND, 0x400: BTV digital, 0x680: VME vmpcm,
- * 0x1000: OLIGSM, 0x1001: OLIADPCM, 0x1002: OLICELP, 0x1003: OLISBC, 0x1004: OLIOPR
- * 0x1100: LH codec, 0x1400: Norris, 0x1401: isaudio, 0x1500: Soundspace musicompression, 0x2000: DVM
- * (see http://www.microsoft.com/asf/resources/draft-ietf-fleischman-codec-subtree-00.txt)
- * and new: 0xFFFE: wave_format_extensible: bits/sample, mapping, 16 byte guid, 1st 2 bytes are code as above
- *
- * RIFF and LIST chunks have nested chunks. Registered chunk names include:
- * LIST with subchunks, one of which can be:
- * INFO itself containing:
- * IARL: archival location, IART: artist, ICMS: commissioned, ICMT: comment, ICOP: copyright, ICRD: creation date,
- * ICRP: uh...cropped, IDIM: dimensions, IDPI: dpi, IENG: engineer, IGNR: genre, IKEY: keywords, ILGT: lightness,
- * IMED: medium, INAM: name, IPLT: palette, IPRD: product, ISBJ: subject, ISFT: software, ISHP: sharpness,
- * ISRC: source, ISRF: source form, ITCH: technician, ISMP: SMPTE time code, IDIT: digitization time
- *
- * data chunk has the samples
- * other (currently ignored) chunks are wavl = waveform data, fact, cues of some sort, slnt = silence,
- * plst = playlist, adtl = associated data list, labl = cue label, note = cue comments,
- * ltxt = text associated with data segment (cue), file, DISP = displayable object,
- * JUNK = outdated info, PAD = padding, etc
- * fact chunk generally has number of samples (used in compressed files)
- */
-
-static int wave_to_sndlib_format(int osf, int bps, bool little)
-{
- switch (osf)
- {
- case 1:
- switch (bps)
- {
- case 8: return(MUS_UBYTE); break;
- case 16: if (little) return(MUS_LSHORT); else return(MUS_BSHORT); break;
- case 32: if (little) return(MUS_LINT); else return(MUS_BINT); break;
- case 24: if (little) return(MUS_L24INT); else return(MUS_B24INT); break;
- default: return(MUS_UBYTE); break;
- }
- break;
- case 3:
- if (little)
- {
- if (bps == 64)
- return(MUS_LDOUBLE);
- else return(MUS_LFLOAT);
- }
- else
- {
- if (bps == 64)
- return(MUS_BDOUBLE);
- else return(MUS_BFLOAT);
- }
- break;
- case 6: if (bps == 8) return(MUS_ALAW); break;
- case 7: if (bps == 8) return(MUS_MULAW); break;
- /* IBM mulaw follows G711 specs like other versions (this info direct from IBM) */
- case 0x101: return(MUS_MULAW); break;
- case 0x102: return(MUS_ALAW); break;
- }
- return(MUS_UNKNOWN);
-}
-
-static int read_riff_header(const char *filename, int chan)
-{
- /* we know we have checked for RIFF xxxx WAVE when we arrive here */
- int chunksize, chunkloc, i;
- bool little, got_fmt = false;
- off_t offset;
- little = true;
- if (match_four_chars((unsigned char *)hdrbuf, I_RIFX)) little = false; /* big-endian data in this case, but I've never seen one */
- little_endian = little;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)(hdrbuf + 8));
- chunkloc = 12;
- offset = 0;
- data_format = MUS_UNKNOWN;
- srate = 0;
- chans = 0;
- fact_samples = 0;
- bits_per_sample = 0;
- for (i = 0; i < AUX_COMMENTS; i++) aux_comment_start[i] = 0;
- true_file_length = SEEK_FILE_LENGTH(chan);
- update_form_size = big_or_little_endian_int((unsigned char *)(hdrbuf + 4), little);
- while (true)
- {
- offset += chunkloc;
- if (offset >= true_file_length) break;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 64) <= 0) break;
- chunksize = big_or_little_endian_int((unsigned char *)(hdrbuf + 4), little);
- if ((chunksize == 0) && /* can be empty data chunk */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- if (match_four_chars((unsigned char *)hdrbuf, I_fmt_))
- {
- /*
- * 8: short format code --1 = PCM for example
- * 10: short chans --1
- * 12: long rate --48000 (0xbb80)
- * 16: long ave rate --65655 (0x10077)
- * 20: short align --2
- * 22: short data size (bits) --16
- * 24: bytes of extra
- * ... some extra data dependent on format
- *
- * R I F F # # # # W A V E f m t sp
- * 5249 4646 f851 0500 5741 5645 666d 7420
- * e40f 0000 0100 0100 80bb 0000 0077 0100
- * 0200 1000 0000 0000 0000 0000 0000 0000
- *
- * #x000551f8 = 348664 = size in bytes - 8
- * #x00000fe4 = 4068 [fmt_ chunk size?]
- */
- got_fmt = true;
- original_data_format = big_or_little_endian_short((unsigned char *)(hdrbuf + 8), little);
- chans = big_or_little_endian_short((unsigned char *)(hdrbuf + 10), little);
- srate = big_or_little_endian_int((unsigned char *)(hdrbuf + 12), little);
- update_frames_location = 12 + offset;
- block_align = big_or_little_endian_short((unsigned char *)(hdrbuf + 20), little);
- bits_per_sample = big_or_little_endian_short((unsigned char *)(hdrbuf + 22), little);
- if (original_data_format == -2) /* 0xFFFE = "extensible" : short size=22, short bits, long chanmap, short format */
- original_data_format = big_or_little_endian_short((unsigned char *)(hdrbuf + 24 + 8), little);
- data_format = wave_to_sndlib_format(original_data_format, bits_per_sample, little);
- }
- else
- {
- if ((match_four_chars((unsigned char *)hdrbuf, I_data)) && (data_location == 0))
- {
- update_ssnd_location = offset + 4;
- data_location = offset + 8;
- data_size = big_or_little_endian_uint((unsigned char *)(hdrbuf + 4), little); /* was int 27-Jul-01 */
- if (chunksize == 0) break; /* see aiff comment */
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_fact))
- {
- fact_samples = big_or_little_endian_int((unsigned char *)(hdrbuf + 8), little);
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_inst))
- {
- base_note = hdrbuf[8];
- base_detune = hdrbuf[9];
- /* rest is gain low-note high-note low-velocity high-velocity */
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_clm_))
- {
- comment_start = offset + 8;
- comment_end = comment_start + chunksize - 1; /* end of comment not start of next chunk */
- }
- else
- {
- if ((match_four_chars((unsigned char *)hdrbuf, I_LIST)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 8), I_INFO)))
- {
- aux_comment_start[0] = offset + 8;
- aux_comment_end[0] = offset + 8 + chunksize - 1;
- }
- }
- }
- }
- }
- }
- chunkloc = (8 + chunksize);
- if (chunksize & 1) chunkloc++; /* extra null appended to odd-length chunks */
- }
- if (!got_fmt)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no fmt chunk?", filename));
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no data chunk?", filename));
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-static int write_riff_header(int chan, int wsrate, int wchans, int siz, int format, const char *comment, int len)
-{
- int i, j, lenhdr, extra;
- off_t offset, curend;
- lenhdr = 0;
- extra = 0;
- if (len != 0)
- {
- lenhdr = 12;
- if ((len % 4) != 0)
- extra = (4 - (len % 4));
- }
- write_four_chars((unsigned char *)hdrbuf, I_RIFF);
- mus_lint_to_char((unsigned char *)(hdrbuf + 4), len + 36 + siz + lenhdr + extra);
- write_four_chars((unsigned char *)(hdrbuf + 8), I_WAVE);
- write_four_chars((unsigned char *)(hdrbuf + 12), I_fmt_);
- mus_lint_to_char((unsigned char *)(hdrbuf + 16), 24 - 8);
- switch (format)
- {
- case MUS_MULAW:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 7);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 8);
- break;
- case MUS_ALAW:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 6);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 8);
- break;
- case MUS_UBYTE:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 1);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 8);
- break;
- case MUS_LSHORT:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 1);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 16);
- break;
- case MUS_L24INT:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 1);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 24);
- break;
- case MUS_LINT:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 1);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 32);
- break;
- case MUS_LFLOAT:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 3);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 32);
- break;
- case MUS_LDOUBLE:
- mus_lshort_to_char((unsigned char *)(hdrbuf + 20), 3);
- mus_lshort_to_char((unsigned char *)(hdrbuf + 34), 64);
- break;
- default:
- return(mus_error(MUS_UNSUPPORTED_DATA_FORMAT, "riff header: can't write data format: %d (%s)",
- format,
- any_data_format_name(format)));
- break;
- }
- mus_lshort_to_char((unsigned char *)(hdrbuf + 22), (short)wchans);
- mus_lint_to_char((unsigned char *)(hdrbuf + 24), wsrate);
- mus_lint_to_char((unsigned char *)(hdrbuf + 28), wsrate * wchans * mus_bytes_per_sample(format)); /* added chans 10-Mar-99 */
- mus_lshort_to_char((unsigned char *)(hdrbuf + 32), (short)(wchans * mus_bytes_per_sample(format)));
-
- offset = 36;
- i = 36;
- curend = 0;
- if (len != 0)
- {
- offset += len + 12;
- write_four_chars((unsigned char *)(hdrbuf + 36), I_clm_);
- mus_lint_to_char((unsigned char *)(hdrbuf + 40), len + extra);
- i = 44;
- for (j = 0; j < len; j++)
- {
- if (i == HDRBUFSIZ)
- {
- curend += HDRBUFSIZ;
- CHK_WRITE(chan, hdrbuf, HDRBUFSIZ);
- i = 0;
- }
- hdrbuf[i] = comment[j];
- i++;
- }
- if (extra != 0)
- {
- if ((i + extra) > HDRBUFSIZ)
- {
- curend += i;
- CHK_WRITE(chan, hdrbuf, i);
- i = 0;
- }
- for (j = 0; j < extra; j++)
- {
- hdrbuf[i] = 0;
- i++;
- }
- }
- }
- curend += i;
- CHK_WRITE(chan, hdrbuf, i);
- write_four_chars((unsigned char *)hdrbuf, I_data);
- mus_lint_to_char((unsigned char *)(hdrbuf + 4), siz);
- data_location = 8 + curend;
- CHK_WRITE(chan, hdrbuf, 8);
- return(MUS_NO_ERROR);
-}
-
-char *mus_header_riff_aux_comment(const char *name, off_t *starts, off_t *ends)
-{
- char *sc = NULL, *auxcom;
- if ((starts) && (starts[0] != 0))
- {
- int len, j, fd, k, m;
- off_t i, end;
- /* found a LIST+INFO chunk (and no other comment) */
- fd = mus_file_open_read(name);
- if (fd == -1) return(NULL);
- i = starts[0];
- end = ends[0];
- sc = (char *)CALLOC(end - i + 2, sizeof(char));
- j = 0;
- k = 4;
- lseek(fd, i, SEEK_SET);
- auxcom = (char *)CALLOC(end - i + 2, sizeof(char));
- CHK_READ(fd, auxcom, end - i + 1);
- CLOSE(fd, name);
- i += 4;
- while (i < end)
- {
- for (m = 0; m < 4; m++) sc[j++] = auxcom[k++];
- len = mus_char_to_lint((unsigned char *)(auxcom + k));
- if ((len <= 0) || (len > end)) break;
- sc[j++] = ':';
- sc[j++] = ' ';
- k += 4;
- for (m = 0; m < len; m++)
- if (auxcom[k] != 0)
- sc[j++] = auxcom[k++];
- else k++;
- sc[j++] ='\n';
- if (len & 1)
- {
- len++;
- k++;
- }
- i += (len + 8);
- }
- FREE(auxcom);
- }
- return(sc);
-}
-
-
-/* soundforge -- just a quick hack until I get better documentation */
-static long little_long_long(unsigned char *buf)
-{
- return(mus_char_to_lint((unsigned char *)(buf)));
-}
-
-static int read_soundforge_header(const char *filename, int chan)
-{
- /* like RIFF but lowercase and 64-bit vals */
- int chunksize, chunkloc, i, off;
- off_t offset;
- chunkloc = 12 * 2 + 16;
- offset = 0;
- data_format = MUS_UNKNOWN;
- srate = 0;
- chans = 0;
- fact_samples = 0;
- bits_per_sample = 0;
- for (i = 0; i < AUX_COMMENTS; i++) aux_comment_start[i] = 0;
- true_file_length = SEEK_FILE_LENGTH(chan);
- update_form_size = little_long_long((unsigned char *)(hdrbuf + 4 * 2));
- while (true)
- {
- offset += chunkloc;
- if (offset >= true_file_length) break;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 64) <= 0) break;
- chunksize = little_long_long((unsigned char *)(hdrbuf + 16));
- if ((chunksize == 0) && /* can be empty data chunk? */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- if (match_four_chars((unsigned char *)hdrbuf, I_fmt_))
- {
- off = 16;
- original_data_format = mus_char_to_lshort((unsigned char *)(hdrbuf + 8 + off));
- chans = mus_char_to_lshort((unsigned char *)(hdrbuf + 10 + off));
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 12 + off));
- block_align = mus_char_to_lshort((unsigned char *)(hdrbuf + 20 + off));
- bits_per_sample = mus_char_to_lshort((unsigned char *)(hdrbuf + 22 + off));
- data_format = wave_to_sndlib_format(original_data_format, bits_per_sample, true);
- }
- else
- {
- if ((match_four_chars((unsigned char *)hdrbuf, I_data)) && (data_location == 0))
- {
- data_location = offset + 16 + 8;
- data_size = mus_char_to_ulint((unsigned char *)(hdrbuf + 16));
- if (chunksize == 0) break; /* see aiff comment */
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_fact))
- {
- fact_samples = mus_char_to_lint((unsigned char *)(hdrbuf + 8));
- }
- }
- }
- chunkloc = (8 + chunksize);
- chunkloc -= 8;
- if (chunksize & 1) chunkloc++; /* extra null appended to odd-length chunks */
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no data chunk?", filename));
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ AVI ------------------------------------
- * actually a video format, but it sometimes contains embedded 'wave' data
- *
- * RIFF xxx AVI
- * <various LISTs>
- * LIST xxxx hdr1 LIST strl(?) strh | strf | strn etc
- * strf is the WAVE header starting with the sound format
- * LIST xxxx movi ##db|##wb -- wb subblocks have the audio data (these need to be collected as a single stream)
- * there are many complications that we make no effort to handle here
- *
- * described in http://www.rahul.net/jfm/avi.html
- */
-
-static int read_avi_header(const char *filename, int chan)
-{
- /* we know we have checked for RIFF xxxx AVI when we arrive here */
- int chunksize, chunkloc, cksize, bits;
- bool happy;
- off_t ckoff, cktotal, offset;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)(hdrbuf + 8));
- chunkloc = 12;
- offset = 0;
- data_format = MUS_UNKNOWN;
- srate = 0;
- chans = 1;
- happy = true;
- true_file_length = SEEK_FILE_LENGTH(chan);
- while (happy)
- {
- offset += chunkloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 32) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s avi header: chunks confused at " OFF_TD, filename, offset));
- chunksize = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- if ((chunksize == 0) && /* can be empty data chunk? */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- if (match_four_chars((unsigned char *)hdrbuf, I_LIST))
- {
- ckoff = offset + 12;
- cktotal = 12;
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_movi))
- {
- while (cktotal < chunksize)
- {
- lseek(chan, ckoff, SEEK_SET);
- CHK_READ(chan, hdrbuf, 8);
- cksize = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- if ((hdrbuf[2] == 'w') && (hdrbuf[3] == 'b'))
- {
- data_location = ckoff;
- if (srate != 0) happy = false;
- break;
- }
- ckoff += (8 + cksize);
- cktotal += (8 + cksize);
- }
- }
- else
- {
- while (cktotal < chunksize)
- {
- lseek(chan, ckoff, SEEK_SET);
- CHK_READ(chan, hdrbuf, 8);
- cksize = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- ckoff += (8 + cksize);
- cktotal += (8 + cksize);
- if (match_four_chars((unsigned char *)hdrbuf, I_LIST))
- {
- off_t cksizer, ckoffr, cktotalr, rdsize;
- ckoffr = ckoff + 12;
- cktotalr = 12;
- while (cktotalr < cksize)
- {
- lseek(chan, ckoffr, SEEK_SET);
- CHK_READ(chan, hdrbuf, 8);
- cksizer = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- ckoffr += (8 + cksizer);
- cktotalr += (8 + cksizer);
- if (match_four_chars((unsigned char *)hdrbuf, I_strf))
- {
- if (cksizer < HDRBUFSIZ)
- rdsize = cksizer;
- else rdsize = HDRBUFSIZ;
- CHK_READ(chan, hdrbuf, rdsize);
- original_data_format = mus_char_to_lshort((unsigned char *)hdrbuf);
- chans = mus_char_to_lshort((unsigned char *)(hdrbuf + 2));
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- /* block_align = mus_char_to_lshort((unsigned char *)(hdrbuf + 12)); */
- bits = mus_char_to_lshort((unsigned char *)(hdrbuf + 14));
- /* only 16 bit linear little endian for now */
- if ((bits == 16) && (original_data_format == 1))
- data_format = MUS_LSHORT;
- if (data_location != 0) happy = false;
- break;
- }
- }
- }
- }
- }
- }
- chunkloc = (8 + chunksize);
- if (chunksize & 1) chunkloc++; /* extra null appended to odd-length chunks */
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no movi chunk?", filename));
- if (data_location > true_file_length)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ SoundFont 2.0 ------------------------------------
- *
- * Emu's SoundFont(tm) format uses RIFF -- at ftp.creaf.com:/pub/emu/sf2_00a.ps)
- *
- * RIFF xxxx sfbk followed by
- * LIST xxxx INFO chunk (nothing of interest -- icmt subchunk might have comments)
- * LIST xxxx sdta chunk = data
- * smpl chunk (16 bit linear little-endian)
- * LIST xxxx pdta list chunk
- * shdr subchunk has srate at 40 (int), samples at 28
- *
- * http://smurf.sourceforge.net/sfont_intro.php
- * http://www.hammersound.net/
- */
-
-static int soundfont_entries = 0;
-static int *soundfont_starts = NULL, *soundfont_ends = NULL, *soundfont_loop_starts = NULL, *soundfont_loop_ends = NULL;
-static int soundfont_size = 0;
-static char **soundfont_names = NULL;
-
-static void soundfont_entry(const char *name, int start, int end, int loop_start, int loop_end)
-{
- if (soundfont_entries == soundfont_size)
- {
- int i;
- if (soundfont_size == 0)
- {
- soundfont_size = 8;
- soundfont_starts = (int *)CALLOC(soundfont_size, sizeof(int));
- soundfont_ends = (int *)CALLOC(soundfont_size, sizeof(int));
- soundfont_loop_starts = (int *)CALLOC(soundfont_size, sizeof(int));
- soundfont_loop_ends = (int *)CALLOC(soundfont_size, sizeof(int));
- soundfont_names = (char **)CALLOC(soundfont_size, sizeof(char *));
- }
- else
- {
- soundfont_size += 8;
- soundfont_starts = (int *)REALLOC(soundfont_starts, soundfont_size * sizeof(int));
- soundfont_ends = (int *)REALLOC(soundfont_ends, soundfont_size * sizeof(int));
- soundfont_loop_starts = (int *)REALLOC(soundfont_loop_starts, soundfont_size * sizeof(int));
- soundfont_loop_ends = (int *)REALLOC(soundfont_loop_ends, soundfont_size * sizeof(int));
- soundfont_names = (char **)REALLOC(soundfont_names, soundfont_size * sizeof(char *));
- }
- for (i = soundfont_entries; i < soundfont_size; i++) soundfont_names[i] = NULL;
- }
- if (soundfont_names[soundfont_entries] == NULL) soundfont_names[soundfont_entries] = (char *)CALLOC(20, sizeof(char));
- strcpy(soundfont_names[soundfont_entries], name);
- soundfont_starts[soundfont_entries] = start;
- soundfont_ends[soundfont_entries] = end;
- soundfont_loop_starts[soundfont_entries] = loop_start;
- soundfont_loop_ends[soundfont_entries] = loop_end;
- soundfont_entries++;
-}
-
-int mus_header_sf2_entries(void) {return(soundfont_entries);}
-char *mus_header_sf2_name(int n) {return(soundfont_names[n]);}
-int mus_header_sf2_start(int n) {return(soundfont_starts[n]);}
-int mus_header_sf2_end(int n) {return(soundfont_ends[n]);}
-int mus_header_sf2_loop_start(int n) {return(soundfont_loop_starts[n]);}
-int mus_header_sf2_loop_end(int n) {return(soundfont_loop_ends[n]);}
-
-static int read_soundfont_header(const char *filename, int chan)
-{
- /* we know we have checked for RIFF xxxx sfbk when we arrive here */
- int chunksize, chunkloc, type, cksize, i, this_end, last_end;
- off_t ckoff, offset;
- bool happy;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)(hdrbuf + 8));
- chunkloc = 12;
- offset = 0;
- soundfont_entries = 0;
- data_format = MUS_LSHORT;
- srate = 0;
- chans = 1;
- happy = true;
- last_end = 0;
- true_file_length = SEEK_FILE_LENGTH(chan);
- while (happy)
- {
- offset += chunkloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 32) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s soundfont header: chunks confused at " OFF_TD, filename, offset));
- chunksize = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- if ((chunksize == 0) && /* can be empty data chunk? */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- if (match_four_chars((unsigned char *)hdrbuf, I_LIST))
- {
- /* everything is squirreled away in LIST chunks in this format */
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_pdta))
- {
- /* go searching for I_shdr -- headers this complicated should be illegal. */
- ckoff = offset + 12;
- lseek(chan, ckoff, SEEK_SET);
- while (srate == 0)
- {
- size_t bytes;
- bytes = read(chan, hdrbuf, 8);
- if (bytes == 0)
- {
- happy = false;
- break;
- }
- i = 0;
- cksize = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- ckoff += (8 + cksize);
- /* here we need to jump over subchunks! -- 4-Aug-97 */
- if (match_four_chars((unsigned char *)hdrbuf, I_shdr))
- {
- /* each sound:
- * 0: name
- * 20: start (in samples from start of bank)
- * 24: end
- * 28: loop start (also relative to start of bank)
- * 32: loop end
- * 36: sample rate
- * 40: pitch (60 = middle C)
- * 41: detune (cents)
- * 42: link (to other channel if any?)
- * 44: type (1 = mono, 2 = mono right, 4 = mono left, others (0x8000) apparently for ROM presets?)
- */
- while (i < cksize)
- {
- CHK_READ(chan, hdrbuf, 46);
- i += 46;
- type = mus_char_to_lshort((unsigned char *)(hdrbuf + 44));
- if ((type == 1) &&
- (mus_char_to_lint((unsigned char *)(hdrbuf + 24)) > 0))
- {
- if (srate == 0)
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 36));
- soundfont_entry((char *)(hdrbuf),
- mus_char_to_lint((unsigned char *)(hdrbuf + 20)),
- this_end = mus_char_to_lint((unsigned char *)(hdrbuf + 24)),
- mus_char_to_lint((unsigned char *)(hdrbuf + 28)),
- mus_char_to_lint((unsigned char *)(hdrbuf + 32)));
- if (this_end > last_end) last_end = this_end;
- }
- }
- happy = (data_location == 0);
- }
- else
- {
- if (ckoff >= offset + 8 + chunksize)
- break;
- lseek(chan, ckoff, SEEK_SET);
- }
- }
- }
- else
- {
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_sdta))
- {
- /* assume smpl follows + subchunk size */
- /* Convert 1.4 appears to create a separate smpl chunk */
- data_location = offset + 20; /* LIST xxxx sdta smpl xxxx ... */
- happy = (srate == 0);
- }
- }
- }
- chunkloc = (8 + chunksize);
- if (chunksize & 1) chunkloc++; /* extra null appended to odd-length chunks */
- }
- if (srate == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: srate == 0", filename));
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no sdta chunk?", filename));
- if (last_end > 0)
- data_size = last_end; /* samples already */
- else data_size = (true_file_length - data_location) / 2;
- return(MUS_NO_ERROR);
-}
-
-
-
-
-/* ------------------------------------ NIST ------------------------------------
- *
- * code available in ogitools-v1.0.tar.gz at svr-ftp.eng.cam.ac.uk:comp.speech/sources
- *
- * 0: "NIST_1A"
- * 8: data_location as ASCII representation of integer (apparently always " 1024")
- * 16: start of complicated header -- see below for details
- *
- * The most recent version of the SPHERE package is available
- * via anonymous ftp from jaguar.ncsl.nist.gov [129.6.48.157] in the pub directory
- * in compressed tar form as "sphere-v.tar.Z" (where "v" is the version
- * code 2.6a last I looked). shortpack is also at this site.
- *
- * here's an example:
- *
- * NIST_1A
- * 1024
- * database_id -s5 TIMIT
- * database_version -s3 1.0
- * utterance_id -s8 aks0_sa1
- * channel_count -i 1
- * sample_count -i 63488
- * sample_rate -i 16000
- * sample_min -i -6967
- * sample_max -i 7710
- * sample_n_bytes -i 2
- * sample_byte_format -s2 01
- * sample_sig_bits -i 16
- * end_head
- *
- * the sample_byte_format can be "10"=big-endian or "01"=little-endian, or "shortpack-v0"=compressed via shortpack
- * other formats are wavpack and shorten.
- *
- * another field is 'sample_coding' which can be pcm (i.e. linear), 'pcm, embedded-shorten-v1.09', mu-law, alaw, ulaw, pculaw etc --
- * so unpredictable as to be totally useless. This means we sometimes try to decode shorten-encoded files because
- * we ignore this field. And worse, there's a 'channels_interleaved' field that (apparently) can be false. Tough.
- */
-
-#define MAX_FIELD_LENGTH 80
-
-static int decode_nist_value(char *str, int base, int end)
-{
- /* can be -i -r or -snnn where nnn = ascii rep of integer = len of string (!) */
- /* we'll deal only with integer fields (and well-behaved string fields) */
- int i, j;
- char value[MAX_FIELD_LENGTH];
- memset((void *)value, 0, MAX_FIELD_LENGTH);
- i = base;
- while ((i < end) && (i < MAX_FIELD_LENGTH) && (str[i] != '-')) i++; /* look for -i or whatever */
- while ((i < end) && (i < MAX_FIELD_LENGTH) && (str[i] != ' ')) i++; /* look for space after it */
- i++;
- if (i >= MAX_FIELD_LENGTH) return(0);
- for (j = 0; i < end; j++, i++)
- value[j] = str[i];
- value[j] = 0;
- if (value[0] =='s') return(MUS_NIST_SHORTPACK);
- sscanf(value, "%d", &i);
- return(i);
-}
-
-static int read_nist_header(const char *filename, int chan)
-{
- char str[MAX_FIELD_LENGTH], name[MAX_FIELD_LENGTH];
- bool happy = true;
- off_t curbase;
- int k, hend, j, n, nm, samples, bytes, byte_format, idata_location = 0;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf); /* the actual id is "NIST_1A" */
- memset((void *)str, 0, MAX_FIELD_LENGTH);
- memset((void *)name, 0, MAX_FIELD_LENGTH);
- for (k = 8; k < 16; k++)
- str[k - 8] = hdrbuf[k];
- sscanf(str, "%d", &idata_location); /* always "1024" */
- if (idata_location != 1024)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s NIST data location: %d?", filename, idata_location));
- data_location = 1024;
- n = 16;
- hend = INITIAL_READ_SIZE;
- k = 0;
- curbase = 0;
- samples = 0;
- bytes = 0;
- srate = 0;
- chans = 0;
- comment_start = 16;
- comment_end = 16;
- byte_format = 10;
- for (j = 0; j < MAX_FIELD_LENGTH; j++)
- str[j] =' ';
- while (happy)
- {
- /* much as in xIFF files, march through the file looking for the data we're after */
- /* in this case we munch a character at a time... */
- str[k] = hdrbuf[n];
- if ((((str[k] == '\0') || (str[k] == '\n')) || ((curbase + n + 1) >= data_location)) || (k == 79))
- {
- /* got a complete record (assuming no embedded newlines, of course) */
- /* now look for a record we care about and decode it */
- nm = 0;
- while ((nm < MAX_FIELD_LENGTH) && (str[nm] != ' ') && (str[nm] != '\0') && (str[nm] != '\n'))
- {
- name[nm] = str[nm];
- nm++;
- }
- if (nm >= MAX_FIELD_LENGTH)
- {
- header_type = MUS_RAW;
- data_format = MUS_UNKNOWN;
- return(mus_error(MUS_UNSUPPORTED_HEADER_TYPE, "%s nist header: unreadable field (length = %d)?", filename, nm));
- }
- name[nm] = 0;
- if (strcmp(name, "sample_rate") == 0) srate = decode_nist_value(str, nm, k); else
- if (strcmp(name, "channel_count") == 0) chans = decode_nist_value(str, nm, k); else
- if (strcmp(name, "end_head") == 0) {happy = false; comment_end = curbase + n - 9;} else
- if (strcmp(name, "sample_count") == 0) samples = decode_nist_value(str, nm, k); else
- if ((bytes == 0) && (strcmp(name, "sample_n_bytes") == 0)) bytes = decode_nist_value(str, nm, k); else
- if ((bytes == 0) && (strcmp(name, "sample_sig_bits") == 0)) {bytes = decode_nist_value(str, nm, k); bytes = (bytes >> 3);} else
- if (strcmp(name, "sample_byte_format") == 0) byte_format = decode_nist_value(str, nm, k);
- for (j = 0; j <= k; j++) str[j] =' ';
- k = 0;
- if ((curbase + n + 1) > 1024) happy = false;
- }
- else
- k++;
- n++;
- if (n >= hend)
- {
- int read_bytes;
- curbase += hend;
- n = 0;
- read_bytes = read(chan, hdrbuf, HDRBUFSIZ);
- if (read_bytes < HDRBUFSIZ)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s NIST header truncated?", filename));
- hend = HDRBUFSIZ;
- }
- }
- data_size = samples * bytes;
- if (byte_format == MUS_NIST_SHORTPACK)
- {
- data_format = MUS_UNKNOWN;
- original_data_format = MUS_NIST_SHORTPACK;
- }
- else
- {
- switch (bytes)
- {
- case 1: data_format = MUS_MULAW; break;
- case 2:
- if (byte_format == 10)
- data_format = MUS_BSHORT;
- else data_format = MUS_LSHORT;
- break;
- case 3:
- if (byte_format == 10)
- data_format = MUS_B24INT;
- else data_format = MUS_L24INT;
- break;
- case 4:
- if (byte_format == 10)
- data_format = MUS_BINT;
- else data_format = MUS_LINT;
- break;
- default: data_format = MUS_BYTE; break;
- }
- }
- true_file_length = SEEK_FILE_LENGTH(chan);
- if ((data_size > true_file_length) && (original_data_format != MUS_NIST_SHORTPACK))
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-static int write_nist_header(int chan, int wsrate, int wchans, int siz, int format)
-{
- char *header;
- int datum;
- datum = mus_bytes_per_sample(format);
- header = (char *)CALLOC(1024, sizeof(char));
- sprintf(header, "NIST_1A\n 1024\nchannel_count -i %d\nsample_rate -i %d\nsample_n_bytes -i %d\nsample_byte_format -s2 %s\nsample_sig_bits -i %d\nsample_count -i %d\nend_head\n",
- wchans, wsrate, datum,
- ((format == MUS_BSHORT) || (format == MUS_B24INT) || (format == MUS_BINT)) ? "10" : "01",
- datum * 8, siz / datum);
- CHK_WRITE(chan, (unsigned char *)header, 1024);
- data_location = 1024;
- FREE(header);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ BICSF ------------------------------------
- * (actually, this is EBICSF and the old BICSF is called IRCAM below)
- *
- * 0-28: NeXT-compatible header, read by read_next_header above.
- * 28: bicsf magic number (107364 or trouble)
- * 32: srate as a 32-bit float
- * 36: chans
- * 40: data format indicator (2 = 16-bit linear, 4 = 32-bit float)
- * 44: begin chunks, if any
- *
- * followed by AIFF-style chunked header info with chunks like:
- *
- * COMM size comment
- * MAXA size {max amps (up to 4)} (frame offsets) time-tag unix msec counter
- * CUE, PRNT, ENV etc
- *
- * except in Paul Lansky's "hybrid" headers, according to MixViews.
- */
-
-static int read_bicsf_header(const char *filename, int chan)
-{
- int chunksize, chunkname, offset, chunkloc;
- bool happy;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)(hdrbuf + 28));
- header_type = MUS_BICSF;
- data_location = 1024;
- if (data_size == 0) data_size = (true_file_length - data_location);
- lseek(chan, 40, SEEK_SET);
- CHK_READ(chan, hdrbuf, HDRBUFSIZ);
- original_data_format = mus_char_to_bint((unsigned char *)hdrbuf);
- switch (original_data_format)
- {
- case 2: data_format = MUS_BSHORT; break;
- case 4: data_format = MUS_BFLOAT; break;
- case 8: data_format = MUS_BDOUBLE; break;
- default: break;
- }
-
- /* now check for a COMM chunk, setting the comment pointers */
- chunkloc = 4; /* next header + magic number, srate, chans, packing, then chunks, I think */
- offset = 40;
- happy = true;
- while (happy)
- {
- if (((offset + chunkloc) >= data_location) ||
- ((offset + chunkloc) < 40))
- happy = false;
- else
- {
- offset += chunkloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 32) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s bicsf header: chunks confused at %d", filename, offset));
- chunkname = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf);
- chunksize = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- if (match_four_chars((unsigned char *)hdrbuf, I_COMM))
- {
- comment_start = 8 + offset;
- comment_end = comment_start + chunksize -1;
- happy = false;
- }
- else
- {
- if ((chunkname == 0) || (chunksize <= 0))
- happy = false;
- }
- chunkloc = (8 + chunksize);
- }
- }
- return(MUS_NO_ERROR);
- /* from here we fall back into read_next_header */
-}
-
-
-
-/* ------------------------------------ IRCAM ------------------------------------
- * read/write CLM (old-style BICSF) -- added write option for Sun port 12-Dec-94
- *
- * 0: 0x1a364 or variations thereof -- byte order gives big/little_endian decision,
- * ^ digit gives machine info, according to AFsp sources -- see IRCAM ints above
- * 4: srate as a 32-bit float
- * 8: chans
- * 12: data format indicator (2 = 16-bit linear, 4 = 32-bit float)
- * according to new Sox (version 11), these packing modes are now bytes/sample in low short, code in high
- * so 1 = char, 0x10001 = alaw, 0x20001 = mulaw, 2 = short, 3 = 24bit?, 0x40004 = long, 4 = float (AFsp sez 4 can also be double)
- * 16: comment start -- how to tell if it's a real comment?
- * apparently these are separated as short code, short blocksize, then data
- * codes: 0 = end, 1 = maxamp, 2 = comment, 3 = pvdata, 4 = audioencode and codemax??
- * 1024: data start
- *
- * apparently the byte order depends on the machine.
- * and yet... convert 1.4 makes a .sf file with little endian header, the VAX id, and big endian data?
- * Csound also uses the VAX magic number with little-endian unscaled floats! Argh.
- * even worse, Paul Lansky plops some version of this at the end of a NeXT header! Complete chaos...
- */
-
-static int read_ircam_header(const char *filename, int chan)
-{
- short bcode, bloc, bsize;
- int offset;
- bool little, happy;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf);
- if ((mus_char_to_lint((unsigned char *)hdrbuf) == I_IRCAM_VAX) ||
- (mus_char_to_lint((unsigned char *)hdrbuf) == I_IRCAM_MIPS))
- little = true;
- else little = false;
- little_endian = little;
- data_location = 1024;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - 1024);
- original_data_format = big_or_little_endian_int((unsigned char *)(hdrbuf + 12), little);
- data_format = MUS_UNKNOWN;
- if (original_data_format == 2)
- {
- if (little)
- data_format = MUS_LSHORT;
- else data_format = MUS_BSHORT;
- }
- else if (original_data_format == 4)
- {
- if (little)
- {
- if (mus_char_to_lint((unsigned char *)hdrbuf) == I_IRCAM_VAX)
- data_format = MUS_LFLOAT_UNSCALED; /* Csound and MixViews */
- else data_format = MUS_LFLOAT;
- }
- else data_format = MUS_BFLOAT;
- }
- else if (original_data_format == 0x40004)
- {
- if (little) data_format = MUS_LINT;
- else data_format = MUS_BINT;
- }
- else if (original_data_format == 0x10001) data_format = MUS_ALAW;
- else if (original_data_format == 0x20001) data_format = MUS_MULAW;
- else if (original_data_format == 1) data_format = MUS_BYTE;
- else if (original_data_format == 3)
- {
- if (little) data_format = MUS_L24INT;
- else data_format = MUS_B24INT;
- }
- else if (original_data_format == 8)
- {
- if (little) data_format = MUS_LDOUBLE;
- else data_format = MUS_BDOUBLE;
- }
- srate = (int)big_or_little_endian_float((unsigned char *)(hdrbuf + 4), little);
- chans = big_or_little_endian_int((unsigned char *)(hdrbuf + 8), little);
- bloc = 16;
- happy = true;
- offset = 0;
- while (happy)
- {
- offset += bloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 32) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s ircam header: chunks confused at %d", filename, offset));
- bcode = big_or_little_endian_short((unsigned char *)hdrbuf, little);
- bsize = big_or_little_endian_short((unsigned char *)(hdrbuf + 2), little);
- if (bcode == 2)
- {
- happy = false;
- comment_start = 4 + offset;
- comment_end = comment_start + bsize - 1; /* was -5? */
- }
- bloc = bsize;
- if ((bsize <= 0) || (bcode <= 0) || ((offset + bloc) > 1023)) happy = false;
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-static int sndlib_format_to_ircam(int format)
-{
- switch (format)
- {
- case MUS_MULAW: return(0x20001); break;
- case MUS_ALAW: return(0x10001); break;
- case MUS_BSHORT: return(2); break;
- case MUS_BINT: return(0x40004); break;
- case MUS_BFLOAT: return(4); break;
- default:
- return(mus_error(MUS_UNSUPPORTED_DATA_FORMAT, "IRCAM header unsupported data format: %d (%s)", format, any_data_format_name(format)));
- break;
- }
-}
-
-static void write_ircam_comment(int fd, const char *comment, int len)
-{
- if (len > 0)
- {
- mus_bshort_to_char((unsigned char *)hdrbuf, 2);
- mus_bshort_to_char((unsigned char *)(hdrbuf + 2), (short)len);
- CHK_WRITE(fd, hdrbuf, 4);
- CHK_WRITE(fd, (unsigned char *)comment, len);
- }
- else
- {
- mus_bint_to_char((unsigned char *)hdrbuf, 0);
- CHK_WRITE(fd, hdrbuf, 4);
- }
- len = 1024 - (len + 20);
- if (len > 0)
- {
- unsigned char *combuf;
- combuf = (unsigned char *)CALLOC(len, sizeof(char));
- CHK_WRITE(fd, combuf, len);
- FREE(combuf);
- }
-}
-
-static int write_ircam_header(int chan, int wsrate, int wchans, int format, const char *comment, int len)
-{
- mus_bint_to_char((unsigned char *)hdrbuf, 0x2a364); /* SUN id */
- mus_bfloat_to_char((unsigned char *)(hdrbuf + 4), (float)wsrate);
- mus_bint_to_char((unsigned char *)(hdrbuf + 8), wchans);
- mus_bint_to_char((unsigned char *)(hdrbuf + 12), sndlib_format_to_ircam(format));
- CHK_WRITE(chan, hdrbuf, 16);
- data_location = 1024;
- write_ircam_comment(chan, comment, len);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ 8SVX -------------------------------------
- * (also known as IFF)
- *
- * very similar to AIFF:
- * "BODY" => [4] samples [n] data
- * "VHDR" => srate (short)
- * "CHAN" => chans
- * "ANNO" and "NAME"
- *
- * big_endian throughout
- */
-
-static int read_8svx_header(const char *filename, int chan, bool bytewise)
-{
- int chunksize, offset, chunkloc;
- bool happy;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf);
- chunkloc = 12;
- offset = 0;
- if (bytewise) data_format = MUS_BYTE; else data_format = MUS_BSHORT;
- srate = 0;
- chans = 1;
- happy = true;
- true_file_length = SEEK_FILE_LENGTH(chan);
- update_form_size = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- while (happy)
- {
- offset += chunkloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 32) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s 8svx header: chunks confused at %d", filename, offset));
- chunksize = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- if ((chunksize == 0) && /* can be empty data chunk? */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- if (match_four_chars((unsigned char *)hdrbuf, I_CHAN))
- {
- chans = mus_char_to_bint((unsigned char *)(hdrbuf + 8));
- chans = (chans & 0x01) +
- ((chans & 0x02) >> 1) +
- ((chans & 0x04) >> 2) +
- ((chans & 0x08) >> 3);
- /* what in heaven's name is this? Each bit corresponds to a channel? */
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_VHDR))
- {
- /* num_samples (int) at hdrbuf + 8 */
- srate = mus_char_to_ubshort((unsigned char *)(hdrbuf + 20));
- original_data_format = hdrbuf[23];
- if (original_data_format != 0)
- data_format = MUS_UNKNOWN;
- }
- else
- {
- if ((match_four_chars((unsigned char *)hdrbuf, I_ANNO)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_NAME)))
- {
- comment_start = offset + 8;
- comment_end = comment_start + chunksize - 1;
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_BODY))
- {
- data_size = chunksize;
- data_location = offset + 12;
- happy = false;
- }
- }
- }
- }
- chunkloc = (8 + chunksize);
- if (chunksize & 1) chunkloc++; /* extra null appended to odd-length chunks */
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no BODY chunk?", filename));
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ VOC --------------------------------------
- *
- * 0: "Creative Voice File" followed by a couple ctrl-Z ('32) (swapped data)
- * 20: header end (short) {8svx, 26 = data_offset, 0x10a = version, ((~version + 0x1234) & 0xffff) = 0x1129}
- * [20]: first block:
- * block code, 1 = data, 0 = end, 9 = data_16 (2 = continue, 3 = silence, 4 = marker, 5 = text, 6 = loop, 7 = loop-end, 8 = extended)
- * block len as 24 bit int(?)
- * if data, then rate code (byte), then data (assuming 8-bit unsigned, mono)
- * if data_16, long srate, byte: data size (8 or 16), byte chans
- * if text, ascii text (a comment)
- * if extended (8) precedes 1 (data): 8 4 then time constant (short), byte: packing code (0), byte chans (0 = mono)
- *
- * apparently always little_endian
- * updated extensively 29-Aug-95 from sox10 voc.c
- */
-
-static int read_voc_header(const char *filename, int chan)
-{
- off_t curbase;
- int type, len, voc_extended, bits, code;
- bool happy;
- data_format = MUS_UBYTE;
- chans = 1;
- happy = true;
- voc_extended = 0;
- true_file_length = SEEK_FILE_LENGTH(chan);
- curbase = mus_char_to_lshort((unsigned char *)(hdrbuf + 20));
- if (true_file_length < curbase)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: block location " OFF_TD " > file length: " OFF_TD, filename, curbase, true_file_length));
- lseek(chan, curbase, SEEK_SET);
- CHK_READ(chan, hdrbuf, HDRBUFSIZ);
- while (happy)
- {
- type = (int)(hdrbuf[0]);
- len = (((int)hdrbuf[3]) << 16) + (((int)hdrbuf[2]) << 8) + (((int)hdrbuf[1]));
- if (type == 1) /* voc_data */
- {
- data_size = len - 1; /* was -3 */
- data_location = curbase + 6;
- if (voc_extended == 0)
- {
- srate = (int)(1000000.0 / (256 - ((int)(hdrbuf[4] & 0xff))));
- original_data_format = hdrbuf[5];
- if (hdrbuf[5] == 0)
- data_format = MUS_UBYTE;
- else data_format = MUS_UNKNOWN;
- }
- happy = false;
- }
- else
- {
- if (type == 9) /* voc_data_16 */
- {
- data_size = len - 1; /* was -3 */
- data_location = curbase + 6;
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- bits = ((int)hdrbuf[8]);
- if (bits == 8)
- {
- code = mus_char_to_lshort((unsigned char *)(hdrbuf + 10));
- if (code == 6)
- data_format = MUS_ALAW;
- else
- if (code == 7)
- data_format = MUS_MULAW;
- else data_format = MUS_UBYTE;
- }
- else
- if (bits == 16)
- data_format = MUS_LSHORT;
- else data_format = MUS_UNKNOWN;
- chans = (int)hdrbuf[9];
- if (chans == 0) chans = 1;
- happy = false;
- }
- else
- {
- if (((len + curbase) < true_file_length) && (type != 0))
- {
- if (type == 5) /* voc_text */
- {
- comment_start = curbase + 4;
- comment_end = comment_start + len - 1;
- }
- else
- {
- if (type == 8) /* voc_extended */
- {
- srate = (256000000 / (65536 - mus_char_to_lshort((unsigned char *)(hdrbuf + 4))));
- if ((int)(hdrbuf[7]) == 0) chans = 1; else chans = 2;
- if ((int)(hdrbuf[6]) != 0) data_format = MUS_UNKNOWN;
- }
- /* I'd add loop support here if I had any example sound files to test with */
- }
- if (seek_and_read(chan, (unsigned char *)hdrbuf, curbase + len + 4, HDRBUFSIZ) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s voc header: ran off end of file", filename));
- curbase += len;
- }
- else happy = false;
- }
- }
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no data(type 1 or 9) chunk?", filename));
- if ((data_size > true_file_length) || (data_size < (off_t)(true_file_length / 10))) /* some VOC files seem to have completely bogus lengths */
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ TwinVQ ------------------------------------
- *
- * from Audio Tools Library (atl.zip) at http://jfaul.de/atl.
- * a chunked header for proprietary (and apparently obsolete?) compressed data
- *
- * 0: "TWIN"
- * 4: version id (string)
- * 12: header size ["cardinal" -> bint]
- * common chunk header (4 of ID, bint size)
- * 24: channels (bint: 0=mono 1=stereo)
- * bitrate (bint)
- * 32: srate (bint khz 11, 22, 44 else *1000)
- * security (bint 0)
- * filesize (bint bytes)
- * possible chunks: NAME COMT AUTH (c) FILE ALBM DATA
- */
-
-/* Monkey files start with "MAC ", but this is yet another compression-oriented format, I think (APE?) */
-
-static int read_twinvq_header(const char *filename, int chan)
-{
- data_format = MUS_UNKNOWN;
- data_location = mus_char_to_bint((unsigned char *)(hdrbuf + 12)) + 16 + 8;
- chans = 1 + mus_char_to_bint((unsigned char *)(hdrbuf + 24));
- srate = mus_char_to_bint((unsigned char *)(hdrbuf + 32));
- if (srate == 11) srate = 11025; else
- if (srate == 22) srate = 22050; else
- if (srate == 44) srate = 44100; else
- srate *= 1000;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- return(MUS_NO_ERROR);
-}
-
-
-static int read_sdif_header(const char *filename, int chan)
-{
- /* yeah, right! */
- return(MUS_UNSUPPORTED);
-}
-
-static int read_nvf_header(const char *filename, int chan)
-{
- /* info from nvftools by Tom Mander: */
- /*
- Numbers stored little-endian.
-
- bytes 0-3: "NVF " magic number
- bytes 4-7: 0x00000001 NVF version number?
- bytes 8-11: 0x00000020 size of rest of header
- bytes 12-15: "VFMT" VFMT chunk h
- bytes 16-19: 0x00000001 VFMT version number?
- bytes 20-23: 0x00000014 size of reset of VFMT header
- bytes 24-27: 0x00007D00 32000 bit/s bitrate
- bytes 28-29: 0x0001 channels
- bytes 30-31: 0x0000 unknown
- bytes 32-35: 0x00001F40 8000kHz sample rate
- bytes 36-39: 0x00003E80 16000
- bytes 40-41: 0x0002 width in bytes of uncompressed data?
- bytes 42-43: 0x0010 width in bits of compressed data?
-
- The rest of the data is G.721 data nibble packing big-endian, 4bits per
- sample (nibble) single channel at 32kbit. When the Nomad records an NVF
- file it does it in 92 sample (46 byte) frames or 0.0115sec.
- */
- if (mus_char_to_lint((unsigned char *)(hdrbuf + 4)) != 1) return(mus_error(MUS_HEADER_READ_FAILED, "%s: NVF[4] != 1", filename));
- if (!(match_four_chars((unsigned char *)(hdrbuf + 12), I_VFMT))) return(mus_error(MUS_HEADER_READ_FAILED, "%s: no VFMT chunk", filename));
- data_format = MUS_UNKNOWN; /* g721 --translate elsewhere */
- chans = 1;
- srate = 8000;
- data_location = 44;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location) * 2; /* 4 bit samps? */
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ ADC ------------------------------------
- * also known as OGI format
- * TIMIT format is identical except it omits the data format field (header size claims to be bytes)
- *
- * from ad.h and other files, ogitools-v1.0.tar.gz
- * we'll look for the big/little endian sequence (short) 8 1 1-or-2 given big/little decision
- *
- * 0: header size in shorts (8 = 16 bytes) (OGI says this is in bytes)
- * 2: version (1)
- * 4: chans
- * 6: rate (srate = 4000000/rate)
- * 8: samples (int) -- seems to be off by 2 -- are they counting ints here?
- * 12: data format (0 = big-endian)
- * 16: data start
-*/
-
-static int read_adc_header(const char *filename, int chan)
-{
- bool little;
- little = (mus_char_to_uninterpreted_int((unsigned char *)(hdrbuf + 12)) != 0); /* 0 = big endian */
- data_location = 16;
- if (little) data_format = MUS_LSHORT; else data_format = MUS_BSHORT;
- chans = big_or_little_endian_short((unsigned char *)(hdrbuf + 4), little);
- srate = 4000000 / big_or_little_endian_short((unsigned char *)(hdrbuf + 6), little);
- data_size = 2 * big_or_little_endian_int((unsigned char *)(hdrbuf + 8), little);
- comment_start = 0;
- comment_end = 0;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ AVR --------------------------------------
- *
- * 0: "2BIT"
- * 4: sample name (null padded ASCII)
- * 12: chans (short) (0 = mono, -1 = stereo)
- * 14: sample size (8 or 16 bit) (short) (value is 8, 12, or 16)
- * 16: sample format (signed or unsigned) (short) (0 = unsigned, -1 = signed)
- * 18: loop (on/off), 20: midi (-1 = no MIDI)
- * 22: srate
- * avr.txt has:
- * 22: Replay speed 0 = 5.485 Khz, 1 = 8.084 Khz, 2 = 10.971 Khz, 3 = 16.168 Khz, 4 = 21.942 Khz, 5 = 32.336 Khz, 6 = 43.885 Khz, 7 = 47.261 Khz
- * 23: sample rate in Hertz (as a 3 byte quantity??)
- * 26: length in samples
- * 30: loop beg, 34: loop end, 38: midi (keyboard split), 40: compression, 42: nada ("reserved"), 44: name
- * 64: comment (limited to 64 bytes)
- * 128: data start
- *
- * the Atari .avr files appear to be 8000 Hz, mono, 8-bit linear unsigned data with an unknown header of 128 words
- * apparently there was a change in format sometime in the 90's.
- *
- * The actual avr files I've found on the net are either garbled, or
- * something is wrong with this definition (taken from CMJ and www.wotsit.org's avr.txt).
- * SGI dmconvert assumes big-endian here -- this is an Atari format, so it's probably safe to assume big-endian.
- */
-
-static int read_avr_header(const char *filename, int chan)
-{
- int dsize, dsigned, i;
- chans = mus_char_to_bshort((unsigned char *)(hdrbuf + 12));
- if (chans == 0) chans = 1; else if (chans == -1) chans = 2; else return(mus_error(MUS_HEADER_READ_FAILED, "%s chans: %d", filename, chans));
- data_location = 128;
- data_size = mus_char_to_bint((unsigned char *)(hdrbuf + 26));
- srate = mus_char_to_ubshort((unsigned char *)(hdrbuf + 24));
- dsize = mus_char_to_bshort((unsigned char *)(hdrbuf + 14));
- dsigned = mus_char_to_bshort((unsigned char *)(hdrbuf + 16));
- if (dsize == 16)
- {
- if (dsigned == 0)
- data_format = MUS_UBSHORT;
- else data_format = MUS_BSHORT;
- }
- else
- {
- if (dsize == 8)
- {
- if (dsigned == 0)
- data_format = MUS_UBYTE;
- else data_format = MUS_BYTE;
- }
- else return(mus_error(MUS_HEADER_READ_FAILED, "%s: unknown data format", filename));
- }
- if (seek_and_read(chan, (unsigned char *)hdrbuf, 64, 64) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s avr header: ran off end of file", filename));
- comment_start = 64;
- i = 0;
- while ((i < 64) && (hdrbuf[i] != 0)) i++;
- comment_end = 64 + (i - 1);
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-
-/* ------------------------------------ SNDT -------------------------------------
- *
- * this taken from sndrtool.c (sox-10): (modified 6-Feb-98)
- * 0: "SOUND" (or off by two throughout if not "0x1a"?)
- * 5: 0x1a
- * 6-7: 0
- * 8-11: nsamps (at 12)
- * 12-15: 0
- * 16-19: nsamps
- * 20-21: srate (little endian short) (at 22)
- * 22-23: 0
- * 24-25: 10
- * 26-27: 4
- * 28-> : <filename> "- File created by Sound Exchange"
- * .->95: 0 ?
- */
-
-/* similar is Sounder format:
- * 0: 0
- * 2: short srate (little endian)
- * 4: 10
- * 6: 4
- * then data
- * but this format can't be distinguished from a raw sound file
- */
-
-static int read_sndt_header(const char *filename, int chan)
-{
- if (hdrbuf[4] != 'D') return(mus_error(MUS_HEADER_READ_FAILED, "%s: SNDT[4] != 'D'", filename));
- data_format = MUS_UBYTE;
- chans = 1;
- srate = mus_char_to_ulshort((unsigned char *)(hdrbuf + 20));
- data_location = 126;
- data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 8));
- if (data_size < 0) data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 10));
- if (srate <= 1) srate = mus_char_to_ulshort((unsigned char *)(hdrbuf + 22));
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Covox v8 -------------------------------------
- *
- * 0: 377 125 377 252 377 125 377 252 x x 0's to 16
- * then 8-bit unsigned data
- */
-
-static int read_covox_header(const char *filename, int chan)
-{
- data_format = MUS_UBYTE;
- chans = 1;
- data_location = 16;
- srate = 8000;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ SMP -------------------------------------
- *
- * 0: "SOUND SAMPLE DATA "
- * 18: "2.1 "
- * 22-81: comment
- * 82-111: sample name
- * header 112 bytes
- * long samples (bytes = samples*2)
- * then data start
- * data
- * always little endian
- */
-
-static int read_smp_header(const char *filename, int chan)
-{
- data_format = MUS_LSHORT;
- chans = 1;
- comment_start = 22;
- comment_end = 81;
- data_location = 116;
- lseek(chan, 112, SEEK_SET);
- if (read(chan, hdrbuf, 4) != 4) return(mus_error(MUS_HEADER_READ_FAILED, "%s: SMP header truncated?", filename));
- data_size = (mus_char_to_lint((unsigned char *)hdrbuf));
- data_format = MUS_LSHORT; /* just a guess */
- srate = 8000; /* docs mention an srate floating around at the end of the file, but I can't find it in any example */
- true_file_length = SEEK_FILE_LENGTH(chan);
- if ((data_size * 2) > true_file_length)
- {
- data_size = (true_file_length - data_location) / 2;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ SPPACK -------------------------------------
- *
- * from AF docs:
- * Bytes Type Contents
- * 0 160 char Text strings (2 * 80)
- * 160 80 char Command line
- * 240 2 int Domain (1-time, 2-freq, 3-qfreq)
- * 242 2 int Frame size
- * 244 4 float Sampling frequency
- * 252 2 int File identifier (i.e. #o100 #o303)
- * 254 2 int Data type (0xfc0e = sampled data file)
- * 256 2 int Resolution (in bits 8, 16)
- * 258 2 int Companding flag
- * 272 240 char Text strings (3 * 80)
- * 512 ... -- Audio data
- *
- * at least one program is writing these headers using little endian data...
- */
-
-static int read_sppack_header(const char *filename, int chan)
-{
- int typ, bits;
- data_location = 512;
- chans = 1;
- lseek(chan, 240, SEEK_SET);
- if (read(chan, hdrbuf, 22) != 22) return(mus_error(MUS_HEADER_READ_FAILED, "%s SPPACK header truncated?", filename));
- typ = mus_char_to_bshort((unsigned char *)hdrbuf);
- data_format = MUS_UNKNOWN;
- if (typ == 1)
- {
- if (((hdrbuf[254]) == 252) && ((hdrbuf[255]) == 14)) /* #xfc and #x0e */
- {
- float sr;
- typ = mus_char_to_bshort((unsigned char *)(hdrbuf + 18));
- bits = mus_char_to_bshort((unsigned char *)(hdrbuf + 16));
- sr = mus_char_to_bfloat((unsigned char *)(hdrbuf + 4));
- srate = (int)sr;
- switch (typ)
- {
- case 1: if (bits == 16) data_format = MUS_BSHORT; else data_format = MUS_BYTE; break;
- case 2: data_format = MUS_ALAW; break;
- case 3: data_format = MUS_MULAW; break;
- default: data_format = MUS_UNKNOWN; break;
- }
- data_size = SEEK_FILE_LENGTH(chan);
- data_size = mus_bytes_to_samples(data_format, data_size - 512);
- comment_start = 0;
- comment_end = 0;
- }
- }
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- if (data_size > mus_bytes_to_samples(data_format, true_file_length))
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ ESPS (Entropic Signal Processing System) -------------------------------------
- *
- * specs at ftp.entropic.com (also known as "SD" format)
- * from AFgetInfoES.c:
- *
- * Bytes Type Contents
- * 8 -> 11 -- Header size (bytes)
- * 12 -> 15 int Sampled data record size
- * 16 -> 19 int File identifier: 0x00006a1a or 0x1a6a0000
- * 40 -> 65 char File creation date
- * 124 -> 127 int Number of samples
- * 132 -> 135 int Number of doubles in a data record
- * 136 -> 139 int Number of floats in a data record
- * 140 -> 143 int Number of longs in a data record
- * 144 -> 147 int Number of shorts in a data record
- * 148 -> 151 int Number of chars in a data record
- * 160 -> 167 char User name
- * 333 -> H-1 -- "Generic" header items, including "record_freq" {followed by a "double8"=64-bit ?}
- * H -> ... -- Audio data
- */
-
-static int read_esps_header(const char *filename, int chan)
-{
- char str[80];
- bool happy = true;
- off_t curbase, hend;
- int k, j, n, chars, floats, shorts, doubles, bytes;
- bool little;
- little = (hdrbuf[18] == 0);
- if (little)
- data_location = mus_char_to_lint((unsigned char *)(hdrbuf + 8));
- else data_location = mus_char_to_bint((unsigned char *)(hdrbuf + 8));
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 8000;
- chans = 1;
- lseek(chan, 132, SEEK_SET);
- CHK_READ(chan, hdrbuf, HDRBUFSIZ);
- if (little)
- {
- doubles = mus_char_to_lint((unsigned char *)hdrbuf);
- floats = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- shorts = mus_char_to_lint((unsigned char *)(hdrbuf + 12));
- chars = mus_char_to_lint((unsigned char *)(hdrbuf + 16));
- }
- else
- {
- doubles = mus_char_to_bint((unsigned char *)hdrbuf);
- floats = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- shorts = mus_char_to_bint((unsigned char *)(hdrbuf + 12));
- chars = mus_char_to_bint((unsigned char *)(hdrbuf + 16));
- }
- if (shorts != 0)
- {
- data_format = ((little) ? MUS_LSHORT : MUS_BSHORT);
- chans = shorts;
- }
- else
- {
- if (doubles != 0)
- {
- data_format = ((little) ? MUS_LDOUBLE_UNSCALED : MUS_BDOUBLE_UNSCALED);
- chans = doubles;
- }
- else
- {
- if (floats != 0)
- {
- data_format = ((little) ? MUS_LFLOAT_UNSCALED : MUS_BFLOAT_UNSCALED);
- chans = floats;
- }
- else
- {
- if (chars != 0)
- {
- data_format = MUS_BYTE; /* ?? */
- chans = chars;
- }
- }
- }
- }
- /* search for "record_freq" to get srate */
- lseek(chan, 333, SEEK_SET);
- CHK_READ(chan, hdrbuf, HDRBUFSIZ);
- curbase = 333;
- hend = curbase + HDRBUFSIZ;
- k = 0;
- n = 0;
- for (j = 0; j < 80; j++) str[j] =' ';
- while (happy)
- {
- str[k] = hdrbuf[n];
- if ((str[k] == 'q') || (str[k] == 3) || ((curbase + n + 1) >= data_location) || (k == 78))
- { /* 3 = C-C marks end of record (?) */
- str[k + 1] = 0;
- if (strcmp(str, "record_freq") == 0)
- {
- if (seek_and_read(chan, (unsigned char *)hdrbuf, curbase + n, 32) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s esps header: ran off end of file", filename));
- n = 0;
- if (little)
- srate = (int)mus_char_to_ldouble((unsigned char *)(hdrbuf + 8));
- else srate = (int)mus_char_to_bdouble((unsigned char *)(hdrbuf + 8));
- happy = false;
- }
- if ((curbase + n + 1) >= data_location) happy = false;
- k = 0;
- }
- else
- k++;
- n++;
- if (n >= hend)
- {
- curbase += hend;
- n = 0;
- bytes = read(chan, hdrbuf, HDRBUFSIZ);
- if (bytes != HDRBUFSIZ) break;
- hend = HDRBUFSIZ;
- }
- }
- if (srate == 0) srate = 8000;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ INRS -------------------------------------
- *
- * from AFgetInfoIN.c:
- *
- * INRS-Telecommunications audio file:
- * Bytes Type Contents
- * 0 -> 3 float Sampling Frequency (VAX float format)
- * 6 -> 25 char Creation time (e.g. Jun 12 16:52:50 1990)
- * 26 -> 29 int Number of speech samples in the file (? -- old INRS files omit this)
- * The data in an INRS-Telecommunications audio file is in 16-bit integer (little-endian)
- * format. Header is always 512 bytes. Always mono.
- *
- */
-
-static int inrs_srates[NINRS] = {6500, 6667, 8000, 10000, 12000, 16000, 20000};
-
-static int read_inrs_header(const char *filename, int chan, int loc)
-{
- true_file_length = SEEK_FILE_LENGTH(chan);
- comment_start = 6;
- comment_end = 25;
- data_format = MUS_LSHORT;
- srate = loc;
- chans = 1;
- data_location = 512;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ MAUD -------------------------------------
- *
- * very similar to AIFF:
- * "MHDR" => 4: chunksize (32)
- * 8: samples
- * 12: bits
- * 14: ditto
- * 16: clock freq
- * 20: clock div (srate = freq/div)
- * 22: chan info (0 = mono, 1 = stereo)
- * 24: ditto(?!)
- * 26: format (0 = unsigned 8 or signed 16 (see bits), 2 = alaw, 3 = mulaw)
- * 28-40: unused
- * "MDAT" => data
- * "ANNO" => comment
- */
-
-static int read_maud_header(const char *filename, int chan)
-{
- int chunksize, offset, chunkloc;
- bool happy;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf);
- chunkloc = 12;
- offset = 0;
- data_format = MUS_BYTE;
- srate = 0;
- chans = 1;
- happy = true;
- update_form_size = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- while (happy)
- {
- offset += chunkloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 32) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s maud header: chunks confused at %d", filename, offset));
- chunksize = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- if ((chunksize == 0) && /* can be empty data chunk? */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- if (match_four_chars((unsigned char *)hdrbuf, I_MHDR))
- {
- int num, den;
- data_size = mus_char_to_bint((unsigned char *)(hdrbuf + 8));
- num = mus_char_to_bint((unsigned char *)(hdrbuf + 16));
- den = mus_char_to_bshort((unsigned char *)(hdrbuf + 20));
- if (den == 0) den = 1;
- srate = (int)(num / den);
- num = mus_char_to_bshort((unsigned char *)(hdrbuf + 12));
- den = mus_char_to_bshort((unsigned char *)(hdrbuf + 26));
- if (num == 8)
- {
- switch (den)
- {
- case 0: data_format = MUS_UBYTE; break;
- case 2: data_format = MUS_ALAW; break;
- case 3: data_format = MUS_MULAW; break;
- default: data_format = MUS_UNKNOWN; break;
- }
- }
- else data_format = MUS_BSHORT;
- num = mus_char_to_bshort((unsigned char *)(hdrbuf + 22));
- if (num == 0) chans = 1; else chans = 2;
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_ANNO))
- {
- comment_start = offset + 8;
- comment_end = comment_start + chunksize - 1;
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_MDAT))
- {
- data_location = offset + 12;
- happy = false;
- }
- }
- }
- chunkloc = (8 + chunksize);
- if (chunksize & 1) chunkloc++; /* extra null appended to odd-length chunks */
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no MDAT chunk?", filename));
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ CSL -------------------------------------
- *
- * "Computerized Speech Labs -- this info taken from wavesurfer/snack
- *
- * very similar to AIFF:
- * 0: FORM
- * 4: DS16 (kinda weird)
- * 8: size (int le)
- * 12: chunks
- * HEDR or HDR8
- * 4: size (int)
- * samp: short, chans: 1 at 36 if not (int) -1, chans: 2?
- * srate at 28 (le int?)
- * other chunks: SD_B, SDA_ SDAB with data bytes as data followed by data
- */
-
-static int read_csl_header(const char *filename, int chan)
-{
- int chunksize, offset, chunkloc;
- bool happy;
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf);
- chunkloc = 12;
- offset = 0;
- data_format = MUS_LSHORT;
- srate = 0;
- chans = 1;
- happy = true;
- update_form_size = mus_char_to_lint((unsigned char *)(hdrbuf + 8));
- while (happy)
- {
- offset += chunkloc;
- if (seek_and_read(chan, (unsigned char *)hdrbuf, offset, 64) <= 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s csl header: chunks confused at %d", filename, offset));
- chunksize = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- if ((chunksize == 0) && /* can be empty data chunk? */
- (hdrbuf[0] == 0) && (hdrbuf[1] == 0) && (hdrbuf[2] == 0) && (hdrbuf[3] == 0))
- break;
- if ((match_four_chars((unsigned char *)hdrbuf, I_HEDR)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_HDR8)))
- {
- /* 8..20: date as ascii */
- /* 32: data length (int) in bytes */
- if ((mus_char_to_lshort((unsigned char *)(hdrbuf + 36)) != -1) && /* these are maxamps, -1=none */
- (mus_char_to_lshort((unsigned char *)(hdrbuf + 38)) != -1))
- chans = 2;
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 28));
- }
- else
- {
- if (match_four_chars((unsigned char *)hdrbuf, I_NOTE))
- {
- comment_start = offset + 8;
- comment_end = comment_start + chunksize - 1;
- }
- else
- {
- if ((match_four_chars((unsigned char *)hdrbuf, I_SDA_)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SDAB)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SD_B)))
- {
- data_location = offset + 8;
- data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 4));
- happy = false;
- }
- }
- }
- chunkloc = (8 + chunksize);
- if (chunksize & 1) chunkloc++;
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no SDxx chunk?", filename));
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ snack SMP -------------------------------------
- *
- * there's apparently yet another "smp" format (from nist??)
- * file = samp
- * sftot = 22050
- * msb = last
- * nchans = 1
- * preemph = none
- * born = snack
- * msb = last here -> little endian?
- * data at 1024
- */
-
-static int read_file_samp_header(const char *filename, int chan)
-{
- int i = 0;
- char *locbuf;
- data_location = 1024;
- chans = 1;
- srate = 8000;
- data_format = MUS_LSHORT;
- lseek(chan, 10, SEEK_SET);
- locbuf = (char *)CALLOC(1024, sizeof(char));
- CHK_READ(chan, locbuf, 1024);
- while (i < 1024)
- {
- if (strncmp((char *)(locbuf + i), "sftot", 5) == 0)
- sscanf((const char *)(&locbuf[i + 6]), "%d", &srate);
- if (strncmp((char *)(locbuf + i), "nchans", 6) == 0)
- sscanf((const char *)(&locbuf[i + 7]), "%d", &chans);
- if (strncmp((char *)(locbuf + i), "msb", 3) == 0)
- if (strncmp((char *)(locbuf + i + 4), "first", 5) == 0)
- data_format = MUS_BSHORT;
- while ((i < 1024) && (locbuf[i] != 10) && (locbuf[i] != 0)) i++;
- i++;
- }
- FREE(locbuf);
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Sound Designer I -------------------------------------
- *
- * complicated and defined in terms of Pascal records, so the following is a stab in the dark:
- *
- * 0: 1336 (i.e. header size)
- * 764: comment (str255)
- * 1020: sample rate (long)
- * 1028: data size (short)
- * 1030: a code string describing the data type (i.e. "linear") (str32)
- * 1064: user comment (str255)
- *
- * file type: 'SFIL'
- *
- * always big_endian
- */
-
-static int read_sd1_header(const char *filename, int chan)
-{
- int n;
- chans = 1;
- data_location = 1336;
- lseek(chan, 1020, SEEK_SET);
- if (read(chan, hdrbuf, 64) != 64) return(mus_error(MUS_HEADER_READ_FAILED, "%s Sound Designer I header truncated?", filename));
- srate = mus_char_to_bint((unsigned char *)hdrbuf);
- n = mus_char_to_bshort((unsigned char *)(hdrbuf + 8));
- if (n == 16)
- data_format = MUS_BSHORT;
- else data_format = MUS_BYTE;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- n = ((unsigned char)hdrbuf[44]);
- if (n != 0)
- {
- comment_start = 1064;
- comment_end = comment_start + n - 1;
- }
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ PSION alaw -------------------------------------
- *
- * 0: "ALawSoundFile**"
- * 16: version
- * 18: length (bytes)
- * 22: padding
- * 24: repeats
- * 26-32: nada
- * 32: data
- *
- * always mono 8-bit alaw 8000 Hz. All the examples on the psion net site appear to be little endian.
- */
-
-static int read_psion_header(const char *filename, int chan)
-{
- if ((hdrbuf[13] != '*') || (hdrbuf[14] != '*')) return(mus_error(MUS_HEADER_READ_FAILED, "%s: PSION[13, 14] != '*'", filename));
- chans = 1;
- data_location = 32;
- srate = 8000;
- data_format = MUS_ALAW;
- data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 18)); /* always little-endian? */
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ Gravis Ultrasound Patch -------------------------------------
- *
- * http://www.gravis.com/Public/sdk/PATCHKIT.ZIP
- *
- * header [128], instruments [62], layers [49], waveheaders (nested)
- * always little endian, actual files don't match exactly with any documentation
- *
- * Header block:
- * 0: "GF1PATCH100" or "GF1PATCH110"
- * 12: "ID#000002"
- * 22: comment (copyright notice) (60 bytes ASCIZ)
- * 82: number of instruments
- * 83: number of voices
- * 84: wave channels
- * 85: number of waves
- * 87: vol
- * 89: size?
- * 93: reserved (36? bytes)
- *
- * Instrument block:
- * 0: id
- * 2: name (16 bytes)
- * 18: size
- * 22: number of layers
- * 23: reserved (40? bytes)
- *
- * Layer block:
- * 0: "previous"
- * 1: id
- * 2: size
- * 6: number of wave samples
- * 10: reserved (40? bytes)
- *
- * Wave block:
- * 0: name (7 bytes ASCIZ)
- * 7: "fractions"
- * 8: data size of wave sample
- * 12: loop start
- * 16: loop end
- * 20: sample rate
- * 22: low freq
- * 26: high freq
- * 30: root freq
- * 34: tune
- * 36: balance
- * 37: envelope data (6+6 bytes I think)
- * 49: tremolo and vibrato data (6 bytes)
- * 55: mode bit 0: 8/16, 1: signed/unsigned
- * 56: scale freq
- * 58: scale factor
- * 60: reserved (36 bytes)
- * followed by data presumably
- */
-
-static int read_gravis_header(const char *filename, int chan)
-{
- int mode;
- lseek(chan, 0, SEEK_SET);
- if (read(chan, hdrbuf, 128) != 128) return(mus_error(MUS_HEADER_READ_FAILED, "%s PAT header truncated?", filename));
- chans = hdrbuf[84];
- if (chans == 0) chans = 1;
- comment_start = 22;
- comment_end = 81;
- lseek(chan, 239, SEEK_SET); /* try to jump to wave sample block (128+62+49) */
- CHK_READ(chan, hdrbuf, 128);
- srate = mus_char_to_ulshort((unsigned char *)(hdrbuf + 20));
- data_size = mus_char_to_ulshort((unsigned char *)(hdrbuf + 8));
- mode = hdrbuf[55];
- if (mode & 1)
- {
- if (mode & 2)
- data_format = MUS_ULSHORT;
- else data_format = MUS_LSHORT;
- }
- else
- {
- if (mode & 2)
- data_format = MUS_UBYTE;
- else data_format = MUS_BYTE;
- }
- data_location = 337;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ Goldwave -------------------------------------
- *
- * http://web.cs.mun.ca/~chris3/goldwave/goldwave.html
- */
-
-static int read_goldwave_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = 28;
- data_format = MUS_LSHORT;
- data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 22));
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- if ((data_size <= 24) || (data_size > true_file_length))
- data_size = (true_file_length - data_location) / 2;
- else data_size /= 2;
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 18));
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Sonic Resource Foundry -------------------------------------
- *
- * more reverse engineering...
- * http://www.sfoundry.com/
- */
-
-static int read_srfs_header(const char *filename, int chan)
-{
- chans = 1; /* might be short at header[4] */
- data_location = 32;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = (true_file_length - data_location) / 2;
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 6));
- data_format = MUS_LSHORT;
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Quicktime -------------------------------------
- *
- * infinitely complicated -- see Quicktime File Format doc from Apple.
- * there's no relation between this document and actual files -- a bizarre joke?
- */
-
-static int read_qt_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = 12;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 11025; /* ?? */
- data_format = MUS_UBYTE;
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ SBStudioII -------------------------------------
- *
- * from a file created by Convert 1.4
- * 0: SND <space>
- * 8: file size - 8
- * SNNA SNIN SNDT blocks:
- *
- * built in blocks, other names are SNIN, SNDT
- * need to scan for SNDT, block length, data
- * SNNA len name
- * supposedly ends with END (but my examples don't)
- * SNIN:
- * num (2), reserved (2), tuning (1), vol (2), type (2) bit 0: 1 = PCM, bit 1: 1 = 16, 0 = 8 (then loop data)
- * info from Pac.txt (pac.zip) at http://www.wotsit.org/music.htm
- */
-
-static int read_sbstudio_header(const char *filename, int chan)
-{
- int i, tmp;
- bool happy;
- unsigned char *bp;
- lseek(chan, 0, SEEK_SET);
- CHK_READ(chan, hdrbuf, HDRBUFSIZ);
- chans = 1;
- srate = 8000; /* no sampling rate field in this header */
- data_format = MUS_UNKNOWN;
- true_file_length = SEEK_FILE_LENGTH(chan);
- happy = true;
- i = 8;
- bp = (unsigned char *)(hdrbuf + 8);
- while (happy)
- {
- if (match_four_chars(bp, I_SNDT))
- {
- data_size = mus_char_to_lint((unsigned char *)(bp + 4));
- data_location = i + 8;
- happy = false;
- }
- else
- {
- if (match_four_chars(bp, I_SNIN))
- {
- tmp = mus_char_to_lshort((unsigned char *)(bp + 15));
- if ((tmp & 1) == 0)
- data_format = MUS_UNKNOWN;
- else
- {
- if ((tmp & 2) == 0)
- data_format = MUS_BYTE;
- else data_format = MUS_LSHORT;
- }
- i += 26;
- bp += 26;
- }
- else
- {
- if (match_four_chars(bp, I_SNNA))
- {
- tmp = mus_char_to_lint((unsigned char *)(bp + 4));
- i += tmp;
- bp += tmp;
- }
- else
- {
- i++;
- bp++;
- }
- }
- }
- if (i >= HDRBUFSIZ)
- {
- data_format = MUS_UNKNOWN;
- happy = false;
- }
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no SNDT chunk?", filename));
- if ((data_size == 0) || (data_format == MUS_UNKNOWN))
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data size or format bogus", filename));
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Delusion Sound -------------------------------------
- *
- * more reverse engineering...
- * from a file created by Convert 1.4
- * 0: DDSF
- * 5: name (text)
- * 55: data
- * probaby similar to DMF format described in Dmf-form.txt but I don't see any other block names in the data
- */
-
-static int read_delusion_header(const char *filename, int chan)
-{
- if ((hdrbuf[4] != 1) || (hdrbuf[5] > 128) || (hdrbuf[6] > 128) || (hdrbuf[7] > 128))
- return(mus_error(MUS_HEADER_READ_FAILED, "%s DDSF name bogus", filename));
- chans = 1;
- data_location = 55;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 8000;
- data_format = MUS_LSHORT;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ Farandole Composer WaveSample -------------------------------------
- *
- * 0: FSM 254
- * libmodplug load_far.cpp uses: #define FARFILEMAGIC 0xFE524146 ("FAR="?)
- * 4: name (text) (32 bytes)
- * 36: 10, 13, 26 or something like that
- * 39: len?
- * 40: volume
- * 41: looping data
- * 49: type (0 = 8-bit, else 16)
- * 50: loop mode
- * 51: data
- * described in Fsm.txt and Far-form.txt http://www.wotsit.org/music.htm
- */
-
-static int read_farandole_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = 51;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 8000;
- if (hdrbuf[49] == 0)
- data_format = MUS_BYTE;
- else data_format = MUS_LSHORT;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ Yamaha TX-16W -------------------------------------
- *
- * ftp://ftp.t0.or.at/pub/sound/tx16w/samples.yamaha
- * ftp://ftp.t0.or.at/pub/sound/tx16w/faq/tx16w.tec
- * http://www.t0.or.at/~mpakesch/tx16w/
- *
- * from tx16w.c sox 12.15: (7-Oct-98) (Mark Lakata and Leigh Smith)
- * char filetype[6] "LM8953"
- * nulls[10],
- * dummy_aeg[6]
- * format 0x49 = looped, 0xC9 = non-looped
- * sample_rate 1 = 33 kHz, 2 = 50 kHz, 3 = 16 kHz
- * atc_length[3] if sample rate 0, [2]&0xfe = 6: 33kHz, 0x10:50, 0xf6: 16, depending on [5] but to heck with it
- * rpt_length[3] (these are for looped samples, attack and loop lengths)
- * unused[2]
- */
-
-static int read_tx16w_header(const char *filename, int chan)
-{
- if ((hdrbuf[4] != '5') || (hdrbuf[5] != '3')) return(mus_error(MUS_HEADER_READ_FAILED, "%s TX16 magic number bogus", filename));
- chans = 1;
- data_location = 32;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 16000;
- if (hdrbuf[23] == 1) srate = 33000;
- else if (hdrbuf[23] == 2) srate = 50000;
- else if (hdrbuf[23] == 3) srate = 16000;
- else if (hdrbuf[23] == 0)
- {
- if ((hdrbuf[26] & 0xFE) == 6) srate = 33000;
- else if ((hdrbuf[26] & 0xFE) == 0x10) srate = 50000;
- else if ((hdrbuf[26] & 0xFE) == 0xf6) srate = 16000;
- }
- original_data_format = MUS_UNKNOWN;
- data_format = MUS_UNKNOWN;
- data_size = (off_t)((double)data_size / 1.5);
- if (hdrbuf[22] == 0x49)
- {
- loop_modes[0] = 1;
- loop_starts[0] = ((hdrbuf[26] & 1) << 16) + (hdrbuf[25] << 8) + hdrbuf[24];
- loop_ends[0] = loop_starts[0] + ((hdrbuf[29] & 1) << 16) + (hdrbuf[28] << 8) + hdrbuf[27];
- }
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Yamaha SY-85 and SY-99 -------------------------------------
- *
- * more reverse engineering...
- * 0: SY85 (SY80 is SY-99) SY85ALL SY80 SYALL
- * 5: name ("WAVE1")
- * (26 int len)
- * (33: comment or prompt?)
- * data in 16-bit little endian (?)
- */
-
-static int read_sy85_header(const char *filename, int chan)
-{
- if ((hdrbuf[4] != ' ') && (hdrbuf[4] != 'A')) return(mus_error(MUS_HEADER_READ_FAILED, "%s: unknown magic number", filename));
- chans = 1;
- data_location = 1024;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 8000; /* unknown */
- data_format = MUS_BSHORT; /* not right */
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Kurzweil 2000 -------------------------------------
- *
- * "PRAM" then header len as big endian int??
- * from krz2tx.c (Mark Lakata)
- */
-static int read_kurzweil_2000_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = mus_char_to_bint((unsigned char *)(hdrbuf + 4));
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 44100; /* unknown */
- data_format = MUS_BSHORT;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Korg -------------------------------------
- *
- * "SMP1" -- guessing on the rest
- */
-static int read_korg_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = 70;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = mus_char_to_bint((unsigned char *)(hdrbuf + 48));
- data_format = MUS_BSHORT;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Maui -------------------------------------
- *
- * "Maui" -- guessing on the rest
- */
-static int read_maui_header(const char *filename, int chan)
-{
- lseek(chan, 420, SEEK_SET);
- if (read(chan, hdrbuf, 64) != 64) return(mus_error(MUS_HEADER_READ_FAILED, "%s truncated maui header?", filename));
- chans = 1;
- data_location = 776;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 8));
- if ((data_size * 2) > true_file_length)
- data_size = (true_file_length - data_location) / 2;
- srate = mus_char_to_lint((unsigned char *)(hdrbuf));
- data_format = MUS_LSHORT;
- return(MUS_NO_ERROR);
-}
-
-/* ------------------------------------ Impulse Tracker -------------------------------------
- *
- * data from its2raw.c by Ben Collver
- * 0: IMPS
- * 4: filename (12 bytes)
- * 17: global vol
- * 18: flags (1: 16-bit or 8(0), 2: stereo or mono(0)
- * 19: default vol
- * 20: sample name (26 bytes)
- * 46: convert
- * 47: default pan
- * 48: length (samps)
- * 52: loop start
- * 56: loop end
- * 60: srate
- * 64: sustain loop start
- * 68: sustain loop end
- * 72: data location
- * 76: vib speed
- * 77: vib depth
- * 78: vib wave
- * 79: vib rate
- */
-static int read_impulsetracker_header(const char *filename, int chan)
-{
- if (hdrbuf[18] & 4) chans = 2; else chans = 1;
- if (hdrbuf[18] & 2) data_format = MUS_LSHORT; else data_format = MUS_BYTE;
- data_location = mus_char_to_lint((unsigned char *)(hdrbuf + 72));
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = (true_file_length - data_location);
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 60));
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-#if 0
-/* ------------------------------------ AKAI 3? -------------------------------------
- */
-static int read_akai3_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = 192;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- if (hdrbuf[1] == 0) srate = 22050; else srate = 44100;
- data_format = MUS_LSHORT;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-#endif
-
-
-/* ------------------------------------ AKAI 4 -------------------------------------
- *
- * 1, 4, info from Paul Kellet -- lost the url ("MPC-2000")
- */
-static int read_akai4_header(const char *filename, int chan)
-{
- chans = hdrbuf[21] + 1;
- data_location = 42;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = mus_char_to_ulshort((unsigned char *)(hdrbuf + 40));
- data_format = MUS_LSHORT;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ PVF (portable voice format) -------------------------------------
- *
- * info from mgetty-voice-1.1.22/voice/libpvf/lib.c
- * this is a modem-related interchange format
- *
- * PVF1\n
- * 1 11025 32\n
- * then data
- * PVF1 = binary data, PVF2 = ascii
- * chans | srate | sample size
- */
-
-static int read_pvf_header(const char *filename, int chan)
-{
- char *buf;
- int bits, i;
- if (hdrbuf[4] != '\n') return(mus_error(MUS_HEADER_READ_FAILED, "PVF header messed up"));
- type_specifier = mus_char_to_uninterpreted_int((unsigned char *)hdrbuf);
- buf = (char *)(hdrbuf + 5);
- sscanf(buf, "%d %d %d", &chans, &srate, &bits);
- if (chans < 1) chans = 1;
- if (srate < 0) srate = 8000;
- if (bits < 8) bits = 8;
- for (i = 6; i < INITIAL_READ_SIZE; i++)
- if (hdrbuf[i] == '\n')
- {
- data_location = i + 1;
- break;
- }
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s PVF header bad data location", filename));
- if (match_four_chars((unsigned char *)hdrbuf, I_PVF2))
- {
- data_format = MUS_UNKNOWN; /* ascii text */
- return(mus_error(MUS_HEADER_READ_FAILED, "%s PVF header unknown data format", filename));
- }
- /* big endian data -- they're using htonl etc */
- if (bits == 8)
- data_format = MUS_BYTE;
- else
- if (bits == 16)
- data_format = MUS_BSHORT;
- else data_format = MUS_BINT;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Ultratracker WaveSample -------------------------------------
- *
- * 0..31: name (32 = ctrl-Z?)
- * 33: PMUWFD (but docs say this is "dos name" -- perhaps we can't recognize this header type reliably)
- * 44: 4 ints giving loop and size data
- * 60: vol
- * 61: "bidi" 0|8|24->8 bit else 16 -- but actual example has 0 with 16-bit
- * 62: finetune
- * 64: data (or 68?)
- * described in Ult-form.txt http://www.wotsit.org/music.htm
- */
-
-static int read_ultratracker_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = 64;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- data_size = (true_file_length - data_location);
- srate = 8000;
- data_format = MUS_LSHORT;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ Sample dump exchange -------------------------------------
- *
- * 0: SDX:
- * sdx2tx.c (Mark Lakata) reads from 4 for 26 (^z), then
- * version (1)
- * comment as pascal-style string (byte len, bytes chars)
- * then 23 bytes:
- * 0: packing (0 = pcm)
- * 1: midi channel
- * 2 + 256*[3]: sample number
- * 4: sample format (15: 16 bit unsigned(?), 8: 8bit unsigned(?)
- * 5: sample rate (big int?)
- * 9: sample length
- * 13: loop start
- * 17: loop end
- * 21: loop type
- * 22: reserved
- */
-
-static int read_sample_dump_header(const char *filename, int chan)
-{
- int i, len;
- for (i = 4; i < HDRBUFSIZ; i++) if (hdrbuf[i] == 26) break;
- len = hdrbuf[i + 2];
- if (len > 0)
- {
- comment_start = i + 3;
- comment_end = i + 3 + len;
- }
- seek_and_read(chan, (unsigned char *)hdrbuf, i + 3 + len, HDRBUFSIZ);
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + 5));
- loop_modes[0] = 0;
- if (hdrbuf[21] == 0)
- {
- loop_modes[0] = 1;
- loop_starts[0] = mus_char_to_lint((unsigned char *)(hdrbuf + 13));
- loop_ends[0] = mus_char_to_lint((unsigned char *)(hdrbuf + 17));
- }
- /* data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 9)); */
- if ((srate < 100) || (srate > 100000)) srate = 8000;
- chans = 1;
- data_location = i + 3 + len + 23;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- if (hdrbuf[0] == 0)
- data_format = MUS_ULSHORT;
- else data_format = MUS_UNKNOWN;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Digiplayer ST3 -------------------------------------
- *
- * 0: 1 (use 'SCRS' at 76)
- * 1: name
- * 13: nada
- * 14: "paragraph" offset of sample data
- * 16: length in bytes (looks like #samples in the actual files...)
- * 20: loop start
- * 24: loop end
- * 28: vol
- * 29: ?
- * 30: 0 = unpacked, 1 = DP30ADPCM
- * 31: bits: 0 = loop, 1 = stereo (chans not interleaved!), 2 = 16-bit samples (little endian)
- * 32: freq
- * 36: nada
- * 40: nada
- * 42: 512
- * 44: date?
- * 48: sample name (28 char ASCIZ)
- * 76: 'SCRS'
- * 80: data starts
- *
- * info from http://www.wotsit.org/ S3m-form.txt
- */
-
-static int read_digiplayer_header(const char *filename, int chan)
-{
- chans = 1;
- data_location = 80;
- true_file_length = SEEK_FILE_LENGTH(chan);
- data_size = (true_file_length - data_location);
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- srate = 8000;
- data_format = MUS_ULSHORT;
- if (hdrbuf[30] & 2) chans = 2;
- if (hdrbuf[30] & 1)
- data_format = MUS_UNKNOWN;
- else
- {
- if (hdrbuf[30] & 4) data_format = MUS_UBYTE; /* may be backwards -- using Convert 1.4 output here */
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ CSRE adf -------------------------------------
- *
- * Info from Stuart Rosen
- *
- * 0-7: CSRE40
- * 8: samples in file (long)
- * 12: center line(?) (long)
- * 16: start channel(?) (unsigned)
- * 18: bits -- 12 or 16 (unsigned) -- is 12 bit sample file packed?
- * 20: number system (0 = signed, 1 = unsigned)
- * 22: srate in kHz (float)
- * 26: peak sample in file (long) (can be 0)
- * 30-511: comment possibly
- *
- * probably always little-endian (S.R. reads each sample using sizeof(int) -> 16 bits I think)
- * if 12-bit unsigned we need to handle the offset somewhere
- */
-
-static int read_adf_header(const char *filename, int chan)
-{
- int bits, numsys;
- lseek(chan, 0, SEEK_SET);
- if ((hdrbuf[4] != '4') || (hdrbuf[5] != '0')) return(mus_error(MUS_HEADER_READ_FAILED, "%s csre header bad magic number", filename));
- if (read(chan, hdrbuf, 30) != 30) return(mus_error(MUS_HEADER_READ_FAILED, "%s csre header truncated?", filename));
- chans = 1;
- numsys = mus_char_to_ulshort((unsigned char *)(hdrbuf + 20));
- bits = mus_char_to_ulshort((unsigned char *)(hdrbuf + 18));
- if ((bits == 16) || (bits == 12))
- {
- if (numsys == 0)
- data_format = MUS_LSHORT;
- else data_format = MUS_ULSHORT;
- }
- else data_format = MUS_UNKNOWN;
- srate = (int)(1000 * mus_char_to_lfloat((unsigned char *)(hdrbuf + 22)));
- data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 8));
- data_location = 512;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- if (data_size > mus_bytes_to_samples(data_format, true_file_length - data_location))
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ Diamondware -------------------------------------
- *
- * info from Keith Weiner at DiamondWare (www.dw.com):
- *
- * 0-22: DWD Header Byte "DiamondWare Digitized\n\0"
- * 23: 1A (EOF to abort printing of file)
- * 24: Major version number
- * 25: Minor version number
- * 26-29: Unique sound ID (checksum XOR timestamp)
- * 30: Reserved
- * 31: Compression type (0 = none)
- * 32-33: Sampling rate (in Hz)
- * 34: Number of channels (1 = mono, 2 = stereo) (interleaved)
- * 35: Number of bits per sample (8, 16) (all data signed)
- * 36-37: Absolute value of largest sample in file
- * 38-41: length of data section (in bytes)
- * 42-45: # samples (16-bit stereo is 4 bytes/sample)
- * 46-49: Offset of data from start of file (in bytes)
- * 50-53: Reserved for future expansion (markers)
- * 54-55: Padding
- * 56:offset -- additional text: field = value
- * suggested fields: TITLE, ORGARTIST, GENRE, KEYWORDS, ORGMEDIUM, EDITOR, DIGITIZER, COMMENT, SUBJECT, COPYRIGHT, SOFTWARE, CREATEDATE
- *
- * since this is all Windows/DOS oriented, I'll assume little-endian byte order.
- */
-
-static int read_diamondware_header(const char *filename, int chan)
-{
- lseek(chan, 0, SEEK_SET);
- if (read(chan, hdrbuf, 64) != 64) return(mus_error(MUS_HEADER_READ_FAILED, "%s truncated diamondware header?", filename));
- chans = hdrbuf[34];
- if (hdrbuf[31] == 0)
- {
- if (hdrbuf[35] == 8) data_format = MUS_BYTE;
- else data_format = MUS_LSHORT;
- }
- else
- {
- data_format = MUS_UNKNOWN;
- return(mus_error(MUS_HEADER_READ_FAILED, "%s unknown data format", filename));
- }
- srate = mus_char_to_ulshort((unsigned char *)(hdrbuf + 32));
- data_size = mus_char_to_lint((unsigned char *)(hdrbuf + 38));
- data_location = mus_char_to_lint((unsigned char *)(hdrbuf + 46));
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- if (data_size > true_file_length - data_location)
- data_size = true_file_length - data_location;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-/* ------------------------------------ Ensoniq Paris -------------------------------------
- * _paf -> Ensoniq Paris? (this info from libaudiofile)
- * 0 paf (or fap)
- * 4 version (0)
- * 8 endianess (0 = big)
- * 12 rate (unsigned int)
- * 16 format (0: 16-bit linear, 24-bit linear)
- * 20 channels
- * 24 source (an encoded comment)
- * 2048 data (24 bit files are compressed)
- */
-
-static int read_paf_header(const char *filename, int chan)
-{
- int form;
- bool little = false;
- lseek(chan, 0, SEEK_SET);
- if (read(chan, hdrbuf, 32) != 32) return(mus_error(MUS_HEADER_READ_FAILED, "%s PAF header truncated?", filename));
- data_format = MUS_UNKNOWN;
- if (mus_char_to_bint((unsigned char *)(hdrbuf + 8))) little = true;
- if (little)
- {
- srate = mus_char_to_ulint((unsigned char *)(hdrbuf + 12));
- form = mus_char_to_ulint((unsigned char *)(hdrbuf + 16));
- if (form == 0) data_format = MUS_LSHORT;
- if (form == 2) data_format = MUS_BYTE;
- chans = mus_char_to_ulint((unsigned char *)(hdrbuf + 20));
- }
- else
- {
- srate = mus_char_to_ubint((unsigned char *)(hdrbuf + 12));
- form = mus_char_to_ubint((unsigned char *)(hdrbuf + 16));
- if (form == 0) data_format = MUS_BSHORT;
- if (form == 2) data_format = MUS_BYTE;
- chans = mus_char_to_ubint((unsigned char *)(hdrbuf + 20));
- }
- data_location = 2048;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (true_file_length < data_location)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_location " OFF_TD " > file length: " OFF_TD, filename, data_location, true_file_length));
- if (data_format != MUS_UNKNOWN)
- data_size = mus_bytes_to_samples(data_format, true_file_length - 2048);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ Comdisco SPW -------------------------------------
- * info from AFsp libtsp/AF/nucleus/AFgetSWpar.c
- *
- * header is text as in NIST:
- *
- * $SIGNAL_FILE 9\n (12 chars)
- * $USER_COMMENT
- * <comment line(s)>
- * $COMMON_INFO
- * SPW Version = 3.10
- * System Type = <machine> (e.g. "sun4", "hp700")
- * Sampling Frequency = <Sfreq> (e.g. "8000")
- * Starting Time = 0
- * $DATA_INFO
- * Number of points = <Nsamp> (e.g. "2000")
- * Signal Type = <type> ("Double", "Float", "Fixed-point", "Integer", "Logical")
- * Fixed Point Format = <16, 0, t> <16, 16, t> <8, 8, t> <8, 0, t> (optional)
- * Complex Format = Real_Imag (optional)
- * $DATA <data_type> ("ASCII", "BINARY")
- *
- * the fixed point <n, m, b> is decoded as n = number of bits total per sample, m = integer bits, b = t: signed, u: unsigned
- * if $DATA ASCII, data is ascii text as in IEEE text files.
- * There are other complications as well. We'll just hack up a stop-gap until someone complains.
- */
-
-static int read_comdisco_header(const char *filename, int chan)
-{
- /* need to grab a line at a time, call strcmp over and over. This is very tedious. */
- char *line = NULL;
- int i, j, k, m, n, curend, offset, len, type, d_size = 0;
- bool happy = true, little, commenting;
- k = 15;
- line = (char *)CALLOC(256, sizeof(char));
- little = false;
- offset = 0;
- type = 0;
- srate = 0;
- curend = INITIAL_READ_SIZE;
- commenting = false;
- while (happy)
- {
- for (i = 0; i < 256; i++)
- {
- if (k == curend)
- {
- offset += curend;
- if (read(chan, hdrbuf, HDRBUFSIZ) != HDRBUFSIZ)
- {
- FREE(line);
- return(mus_error(MUS_HEADER_READ_FAILED, "%s comdisco header truncated?", filename));
- }
- k = 0;
- curend = HDRBUFSIZ;
- }
- if (hdrbuf[k] == '\n')
- {
- k++;
- break;
- }
- line[i] = hdrbuf[k++];
- }
- line[i] = '\0';
- if ((strcmp(line, "$DATA BINARY") == 0) ||
- (strcmp(line, "$DATA ASCII") == 0))
- {
- happy = false;
- data_location = offset + k;
- }
- if (strcmp(line, "$USER_COMMENT") == 0)
- {
- comment_start = offset + k;
- commenting = true;
- }
- else
- {
- if (commenting)
- {
- if (line[0] == '$')
- {
- comment_end = offset + k - 2 - strlen(line);
- commenting = false;
- }
- }
- }
- if (line[0] != '$')
- {
- char portion[32];
- char value[32];
- len = strlen(line);
- for (j = 0; j < 8; j++)
- portion[j] = line[j];
- portion[8] ='\0';
- for (j = 8; j < len; j++)
- if (line[j] == '=')
- break;
- for (n = 0, m = j + 2; m < len; m++, n++)
- value[n] = line[m];
- value[n] ='\0';
- if (strcmp(portion, "Sampling") == 0) sscanf(value, "%d", &srate); else
- if (strcmp(portion, "Number o") == 0) sscanf(value, "%d", &d_size); else
- if (strcmp(portion, "Signal T") == 0) {if (value[1] == 'o') type = 2; else if (value[1] == 'l') type = 1;} else
- if (strcmp(portion, "Fixed Po") == 0) {if (value[1] == '8') type = 3;}
- }
- }
- /* now clean up this mess */
- if (data_location == 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: no $DATA BINARY field?", filename));
- if (srate == 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: srate == 0", filename));
- chans = 1;
- if (d_size != 0) data_size = (off_t)d_size;
- switch (type)
- {
- case 0: if (little) data_format = MUS_LSHORT; else data_format = MUS_BSHORT; break;
- case 1: if (little) data_format = MUS_LFLOAT; else data_format = MUS_BFLOAT; break;
- case 2: if (little) data_format = MUS_LDOUBLE; else data_format = MUS_BDOUBLE; break;
- case 3: data_format = MUS_BYTE; break;
- }
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > mus_bytes_to_samples(data_format, true_file_length - data_location))
- data_size = mus_bytes_to_samples(data_format, true_file_length - data_location);
- FREE(line);
- return(MUS_NO_ERROR);
-}
-
-
-/* ------------------------------------ MS ASF -------------------------------------
- *
- * asf format is described at http://www.microsoft.com/asf/specs.htm
- * http://www.microsoft.com/asf/spec3/ASF0198ps.exe
- *
- * this header is completely insane
- */
-
-static int read_asf_header(const char *filename, int chan)
-{
- /* a chunked data format, so not really acceptable here or elsewhere -- needs to be unchunked */
- int len, ilen = 0, i, j, bits = 0;
- bool asf_huge = false, present;
- /* apparently "huge" has some meaning in Windoze C */
- len = mus_char_to_lint((unsigned char *)(hdrbuf + 16)); /* actually 64 bits */
- i = (128+64) / 8;
- srate = 0;
- chans = 0;
- while (i < len)
- {
- seek_and_read(chan, (unsigned char *)hdrbuf, i, HDRBUFSIZ);
- if ((unsigned int)(hdrbuf[1]) == 0x29)
- switch (hdrbuf[0])
- {
- case 0xd0:
- asf_huge = (hdrbuf[((128+64+128+64+64+64+64+32)/8)] & 2);
- break;
- case 0xd4:
- present = ((hdrbuf[16+8+16+8+8+ 4+4+4+4+ 4+4] >> 3) & 0x3);
- if (present)
- j = 16+8+16+8+8+ 4+4+4+4+ 4+4+ 4+ (4+4+4) + 2;
- else j = 16+8+16+8+8+ 4+4+4+4+ 4+4+ 4+ 2;
- srate = mus_char_to_lint((unsigned char *)(hdrbuf + j+11+36));
- bits = mus_char_to_lint((unsigned char *)(hdrbuf + j+11+32));
- chans = mus_char_to_ulshort((unsigned char *)(hdrbuf + j+65));
- original_data_format = mus_char_to_lint((unsigned char *)(hdrbuf + j+11));
- break;
- default: break;
- }
- ilen = mus_char_to_lint((unsigned char *)(hdrbuf + 16));
- if (ilen <= 0) break;
- if ((chans > 0) && (srate > 0)) break;
- i += ilen;
- }
- i = len;
- seek_and_read(chan, (unsigned char *)hdrbuf, i, HDRBUFSIZ);
- data_format = MUS_UNKNOWN;
- if (((unsigned int)(hdrbuf[1]) == 0x29) && ((unsigned int)(hdrbuf[0]) == 0xd2))
- {
- int a_huge = 2;
- ilen = mus_char_to_lint((unsigned char *)(hdrbuf + 16));
- if (asf_huge) a_huge = 4;
- data_location = i + 20 + a_huge + 2+4+3+1;
- if (bits == 0) bits = 8;
- data_format = wave_to_sndlib_format(original_data_format, bits, true);
- }
- else return(mus_error(MUS_HEADER_READ_FAILED, "%s: unknown data format", filename));
- data_size = ilen - data_location;
- true_file_length = SEEK_FILE_LENGTH(chan);
- if (data_size > true_file_length)
- {
- data_size = true_file_length - data_location;
- if (data_size < 0) return(mus_error(MUS_HEADER_READ_FAILED, "%s: data_size = " OFF_TD "?", filename, data_size));
- }
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ------------------------------------ no header ------------------------------------- */
-
-static int header_raw_srate = 44100;
-static int header_raw_chans = 2;
-static int header_raw_format = MUS_BSHORT;
-
-static int read_no_header(const char *filename, int chan)
-{
- srate = header_raw_srate;
- chans = header_raw_chans;
- data_format = header_raw_format;
- data_location = 0;
- data_size = SEEK_FILE_LENGTH(chan);
- true_file_length = data_size;
- data_size = mus_bytes_to_samples(data_format, data_size);
- return(MUS_NO_ERROR);
-}
-
-void mus_header_set_raw_defaults(int sr, int chn, int frm)
-{
- if (sr > 0) header_raw_srate = sr;
- if (chn > 0) header_raw_chans = chn;
- if (MUS_DATA_FORMAT_OK(frm)) header_raw_format = frm;
-}
-
-void mus_header_raw_defaults(int *sr, int *chn, int *frm)
-{
- (*sr) = header_raw_srate;
- (*chn) = header_raw_chans;
- (*frm) = header_raw_format;
-}
-
-
-/* ------------------------------------ all together now ------------------------------------ */
-
-static int mus_header_read_1(const char *filename, int chan)
-{
- /* returns 0 on success (at least to the extent that we can report the header type), -1 for error */
- int i, loc = 0, bytes;
- bool happy;
- header_type = MUS_UNSUPPORTED;
- data_format = MUS_UNKNOWN;
- comment_start = 0;
- comment_end = 0;
- data_size = 0;
- data_location = 0;
- if (loop_modes)
- {
- loop_modes[0] = 0;
- loop_modes[1] = 0;
- }
- bytes = read(chan, hdrbuf, INITIAL_READ_SIZE);
- /* if it's a 0 length file we need to get out */
- if (bytes < 0)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: %s", filename, (errno) ? STRERROR(errno) : "bytes read < 0?"));
- if (bytes == 0)
- {
- header_type = MUS_RAW;
- srate = header_raw_srate;
- chans = header_raw_chans;
- data_format = header_raw_format;
- data_location = 0;
- true_file_length = 0;
- return(MUS_NO_ERROR);
- }
- if (bytes < 4)
- {
- header_type = MUS_RAW;
- return(read_no_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_DSND)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_DECN)))
- {
- if (bytes < 24)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s NeXT header truncated? found only %d bytes", filename, bytes));
- header_type = MUS_NEXT;
- return(read_next_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_FORM))
- {
- /* next 4 bytes are apparently the file size or something equally useless */
- if (bytes < 12)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s AIFF header truncated? found only %d bytes", filename, bytes));
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_AIFF))
- {
- header_type = MUS_AIFF;
- return(read_aiff_header(filename, chan, 0));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_AIFC))
- {
- header_type = MUS_AIFC;
- return(read_aiff_header(filename, chan, 0));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_8SVX))
- {
- header_type = MUS_SVX;
- return(read_8svx_header(filename, chan, true));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_16SV))
- {
- header_type = MUS_SVX;
- return(read_8svx_header(filename, chan, false));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_MAUD))
- {
- header_type = MUS_MAUD;
- return(read_maud_header(filename, chan));
- }
- /* apparently SAMP here -> sampled audio data (?) */
-
- if (match_four_chars((unsigned char *)(hdrbuf + 4), I_DS16))
- {
- header_type = MUS_CSL;
- return(read_csl_header(filename, chan));
- }
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: unrecognized \"FORM\" (i.e. AIFF) header", filename));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_RIFF)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_RIFX)))
- {
- if (bytes < 12)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s RIFF header truncated? found only %d bytes", filename, bytes));
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_WAVE))
- {
- header_type = MUS_RIFF;
- return(read_riff_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_sfbk))
- {
- header_type = MUS_SOUNDFONT;
- return(read_soundfont_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 8), I_AVI_))
- {
- header_type = MUS_AVI;
- return(read_avi_header(filename, chan));
- }
- return(mus_error(MUS_HEADER_READ_FAILED, "%s: unrecognized \"RIFF\" (i.e. 'wave') header", filename));
- }
- if ((equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_VAX)) ||
- (equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_SUN)) ||
- (equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_MIPS)) ||
- (equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_NEXT)))
- {
- if (bytes < 24)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s IRCAM header truncated? found only %d bytes", filename, bytes));
- header_type = MUS_IRCAM;
- return(read_ircam_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_NIST))
- {
- header_type = MUS_NIST;
- return(read_nist_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SOUN))
- {
- if ((match_four_chars((unsigned char *)(hdrbuf + 4), I_D_SA)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 8), I_MPLE)))
- {
- header_type = MUS_SMP;
- return(read_smp_header(filename, chan));
- }
- else
- {
- header_type = MUS_SNDT;
- return(read_sndt_header(filename, chan));
- }
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_VOC0)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I_VOC1)))
- {
- if (bytes < 24)
- return(mus_error(MUS_HEADER_READ_FAILED, "%s VOC header truncated? found only %d bytes", filename, bytes));
- header_type = MUS_VOC;
- return(read_voc_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_AVR_))
- {
- header_type = MUS_AVR;
- return(read_avr_header(filename, chan));
- }
- if (mus_char_to_bshort((unsigned char *)hdrbuf) == 1336)
- {
- header_type = MUS_SD1;
- return(read_sd1_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_ALaw)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I_Soun)))
- {
- header_type = MUS_PSION;
- return(read_psion_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_GF1P)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I_ATCH)))
- {
- header_type = MUS_GRAVIS;
- return(read_gravis_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_DSIG)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I_NAL_)))
- {
- header_type = MUS_COMDISCO;
- return(read_comdisco_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_GOLD)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I__WAV)))
- {
- header_type = MUS_GOLDWAVE;
- return(read_goldwave_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_Diam)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I_ondW)))
- {
- header_type = MUS_DIAMONDWARE;
- return(read_diamondware_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SRFS))
- {
- header_type = MUS_SRFS;
- return(read_srfs_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_CSRE))
- {
- header_type = MUS_ADF;
- return(read_adf_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_fLaC))
- {
- header_type = MUS_FLAC;
- return(MUS_NO_ERROR);
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_OggS))
- {
- if ((hdrbuf[29] == 'v') && (hdrbuf[30] == 'o') && (hdrbuf[31] == 'r'))
- header_type = MUS_OGG;
- else
- {
- if ((hdrbuf[28] == 'S') && (hdrbuf[29] == 'p') && (hdrbuf[30] == 'e'))
- header_type = MUS_SPEEX;
- }
- return(MUS_NO_ERROR);
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_file)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I__sam)))
- {
- header_type = MUS_FILE_SAMP;
- return(read_file_samp_header(filename, chan));
- }
- if ((hdrbuf[0] == 0xf0) && (hdrbuf[1] == 0x7e) && (hdrbuf[3] == 0x01))
- {
- header_type = MUS_MIDI_SAMPLE_DUMP;
- chans = 1;
- srate = (int)(1.0e9 / (float)((hdrbuf[7] + (hdrbuf[8] << 7) + (hdrbuf[9] << 14))));
- data_size = (hdrbuf[10] + (hdrbuf[11] << 7) + (hdrbuf[12] << 14));
- /* since this file type has embedded blocks, we have to translate it elsewhere */
- return(MUS_NO_ERROR);
- }
- /* no recognized magic number at start -- poke around in possible header for other types */
- /* ESPS is either 0x00006a1a or 0x1a6a0000 at byte 16 */
- if (equal_big_or_little_endian((unsigned char *)(hdrbuf + 16), 0x00006a1a))
- {
- header_type = MUS_ESPS;
- return(read_esps_header(filename, chan));
- }
- lseek(chan, 0, SEEK_SET);
- CHK_READ(chan, hdrbuf, 256);
- if ((hdrbuf[252] == 64) && (hdrbuf[253] == 195)) /* #o100 and #o303 */
- {
- header_type = MUS_SPPACK;
- return(read_sppack_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)(hdrbuf + 65), I_FSSD)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 128), I_HCOM)))
- {
- header_type = MUS_HCOM;
- return(MUS_NO_ERROR);
- }
- happy = false;
- for (i = 0; i < NINRS; i++)
- {
- if (equal_big_or_little_endian((unsigned char *)hdrbuf, I_INRS[i]))
- {
- happy = true;
- loc = inrs_srates[i];
- }
- }
- if (happy)
- {
- header_type = MUS_INRS;
- return(read_inrs_header(filename, chan, loc));
- }
- if (mus_char_to_ubint((unsigned char *)hdrbuf) == 0xAAAAAAAA)
- {
- header_type = MUS_MUS10;
- return(MUS_NO_ERROR);
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_SPIB)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_S___)))
- {
- header_type = MUS_IEEE;
- return(MUS_NO_ERROR);
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_riff))
- {
- header_type = MUS_SOUNDFORGE;
- return(read_soundforge_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I_PVF1)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_PVF2)))
- {
- header_type = MUS_PVF;
- return(read_pvf_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_MThd))
- {
- header_type = MUS_MIDI;
- return(MUS_ERROR);
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SND_))
- {
- header_type = MUS_SBSTUDIOII;
- return(read_sbstudio_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_FSMt))
- {
- header_type = MUS_FARANDOLE;
- return(read_farandole_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SDXc))
- {
- header_type = MUS_SAMPLE_DUMP;
- return(read_sample_dump_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_DDSF))
- {
- header_type = MUS_DELUSION;
- return(read_delusion_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_LM89))
- {
- header_type = MUS_YAMAHA_TX16W;
- return(read_tx16w_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SY85))
- {
- header_type = MUS_YAMAHA_SY85;
- return(read_sy85_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SY80))
- {
- header_type = MUS_YAMAHA_SY99;
- return(read_sy85_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_PRAM))
- {
- header_type = MUS_KURZWEIL_2000;
- return(read_kurzweil_2000_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SMP1))
- {
- header_type = MUS_KORG;
- return(read_korg_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_Maui))
- {
- header_type = MUS_MAUI;
- return(read_maui_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_IMPS))
- {
- header_type = MUS_IMPULSETRACKER;
- return(read_impulsetracker_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 35), I_UWFD))
- {
- header_type = MUS_ULTRATRACKER;
- return(read_ultratracker_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)(hdrbuf + 76), I_SCRS))
- {
- header_type = MUS_DIGIPLAYER;
- return(read_digiplayer_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_covox))
- {
- header_type = MUS_COVOX;
- return(read_covox_header(filename, chan));
- }
- if ((match_four_chars((unsigned char *)hdrbuf, I__PAF)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_FAP_)))
- {
- header_type = MUS_PAF;
- return(read_paf_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_TWIN))
- {
- header_type = MUS_TWINVQ;
- return(read_twinvq_header(filename, chan));
- }
-#if MUS_LITTLE_ENDIAN
- if (mus_char_to_uninterpreted_int((unsigned char *)hdrbuf) == 0x01000800)
-#else
- if (mus_char_to_uninterpreted_int((unsigned char *)hdrbuf) == 0x00080001)
-#endif
- {
- header_type = MUS_ADC;
- return(read_adc_header(filename, chan));
- }
-
- if ((match_four_chars((unsigned char *)hdrbuf, I_ones)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 12), I_FORM)))
- {
- /* possibly an OMF file with an embedded AIFF data file -- this is just a guess... */
- header_type = MUS_OMF;
- return(read_aiff_header(filename, chan, 12));
- /* another (apparently) along these lines is TOC */
- }
-
- if ((match_four_chars((unsigned char *)hdrbuf, I_zeros)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I_mdat)))
- {
- /* possibly quicktime?? */
- header_type = MUS_QUICKTIME;
- return(read_qt_header(filename, chan));
- }
- if ((hdrbuf[0] == 1) && (hdrbuf[1] == 4)) /* name follows --check? */
- {
- header_type = MUS_AKAI4;
- return(read_akai4_header(filename, chan));
- }
-#if 0
- if ((hdrbuf[0] == 3) && (hdrbuf[16] == 128))
- {
- header_type = MUS_AKAI4;
- return(read_akai3_header(filename, chan));
- }
-#endif
- if ((match_four_chars((unsigned char *)hdrbuf, I_asf0)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 4), I_asf1)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 8), I_asf2)) &&
- (match_four_chars((unsigned char *)(hdrbuf + 12), I_asf3)))
- {
- header_type = MUS_ASF;
- return(read_asf_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_SDIF))
- {
- header_type = MUS_SDIF;
- return(read_sdif_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_NVF_))
- {
- header_type = MUS_NVF;
- return(read_nvf_header(filename, chan));
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_ajkg))
- {
- header_type = MUS_SHORTEN;
- return(MUS_NO_ERROR);
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_TTA1))
- {
- header_type = MUS_TTA;
- return(MUS_NO_ERROR);
- }
- if (match_four_chars((unsigned char *)hdrbuf, I_wvpk))
- {
- header_type = MUS_WAVPACK;
- return(MUS_NO_ERROR);
- }
-
- header_type = MUS_RAW;
- return(read_no_header(filename, chan));
-}
-
-static int local_error_type = MUS_NO_ERROR;
-static char *local_error_msg = NULL;
-static mus_error_handler_t *old_error_handler;
-
-static void local_mus_error(int type, char *msg)
-{
- local_error_type = type;
- if (local_error_msg)
- free(local_error_msg);
- if (msg)
- local_error_msg = strdup(msg);
- else local_error_msg = NULL;
-}
-
-int mus_header_read(const char *name)
-{
- int chan, err = 0;
- chan = mus_file_open_read(name);
- if (chan == -1)
- return(mus_error(MUS_CANT_OPEN_FILE, "can't open %s: %s", name, STRERROR(errno)));
- old_error_handler = mus_error_set_handler(local_mus_error);
- err = mus_header_read_1(name, chan);
- mus_error_set_handler(old_error_handler);
- CLOSE(chan, name);
- if (err != MUS_NO_ERROR)
- return(mus_error(local_error_type, local_error_msg)); /* pass error info on up the chain now that we've cleaned up the open file descriptor */
- return(err);
-}
-
-static mus_header_write_hook_t *mus_header_write_hook = NULL;
-
-mus_header_write_hook_t *mus_header_write_set_hook(mus_header_write_hook_t *new_hook)
-{
- mus_header_write_hook_t *old_hook;
- old_hook = mus_header_write_hook;
- mus_header_write_hook = new_hook;
- return(old_hook);
-}
-
-int mus_header_write(const char *name, int type, int in_srate, int in_chans, off_t loc, off_t size_in_samples, int format, const char *comment, int len)
-{
- /* the "loc" arg is a mistake -- just always set it to 0 */
- int chan, err = MUS_NO_ERROR;
- off_t siz;
- chan = mus_file_create(name);
- if (chan == -1)
- return(mus_error(MUS_CANT_OPEN_FILE, "can't write %s: %s", name, STRERROR(errno)));
- if (mus_header_write_hook)
- (*mus_header_write_hook)(name);
- siz = mus_samples_to_bytes(format, size_in_samples);
- /* no mus_error calls within any of the write functions */
- switch (type)
- {
- case MUS_NEXT: err = mus_header_write_next_header(chan, in_srate, in_chans, loc, siz, format, comment, len); break;
- case MUS_AIFC: err = write_aif_header(chan, in_srate, in_chans, siz, format, comment, len, true); break;
- case MUS_AIFF: err = write_aif_header(chan, in_srate, in_chans, siz, format, comment, len, false); break;
- case MUS_RIFF: err = write_riff_header(chan, in_srate, in_chans, siz, format, comment, len); break;
- case MUS_IRCAM: err = write_ircam_header(chan, in_srate, in_chans, format, comment, len); break;
- case MUS_NIST: err = write_nist_header(chan, in_srate, in_chans, siz, format); break;
- case MUS_RAW:
- data_location = 0;
- data_size = mus_bytes_to_samples(format, siz);
- srate = in_srate;
- chans = in_chans;
- header_type = MUS_RAW;
- data_format = format;
- break;
- default:
- CLOSE(chan, name);
- return(mus_error(MUS_UNSUPPORTED_HEADER_TYPE, "can't write %s header for %s", mus_header_type_name(type), name));
- break;
- }
- CLOSE(chan, name);
- return(err);
-}
-
-int mus_header_change_data_size(const char *filename, int type, off_t size) /* in bytes */
-{
- /* the read header at sample update (sound-close) time could be avoided if the
- * ssnd_location (etc) were saved and passed in -- perhaps an added optimized
- * header change data size? Means saving the relevant data, and exporting it
- * from headers.c. Can we guarantee consistency here?
- */
- int chan, err = MUS_NO_ERROR;
- switch (type)
- {
- case MUS_AIFF:
- case MUS_AIFC:
- case MUS_NIST:
- case MUS_RIFF:
- err = mus_header_read(filename);
- break;
- default:
- break;
- }
- if (err == MUS_ERROR) return(err);
- chan = mus_file_reopen_write(filename);
- if (chan == -1) return(mus_error(MUS_HEADER_WRITE_FAILED, "%s: %s", filename, STRERROR(errno)));
- switch (type)
- {
- case MUS_NEXT:
- lseek(chan, 8L, SEEK_SET);
- mus_bint_to_char((unsigned char *)(hdrbuf + 0), (int)size);
- CHK_WRITE(chan, hdrbuf, 4);
- break;
- case MUS_AIFC:
- case MUS_AIFF:
- /* we apparently have to make sure the form size and the data size are correct
- * assumed here that we'll only be updating our own AIFF files
- * There are 3 such locations -- the 2nd word of the file which is the overall form size,
- * the frames variable in the COMM chunk, and the chunk-size variable in the SSND chunk
- * an unexpected hassle for CLM is that we can open/close the output file many times if running mix,
- * so we have to update the various size fields taking into account the old size
- */
-
- /* read sets current update_form_size, data_size, data_format, update_frames_location, update_ssnd_location */
-
- lseek(chan, 4L, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, (int)size + update_form_size - mus_samples_to_bytes(data_format, data_size));
- /* cancel old data_size from previous possible write */
- CHK_WRITE(chan, hdrbuf, 4);
- lseek(chan, update_frames_location, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, (int)size / (chans * mus_bytes_per_sample(data_format)));
- CHK_WRITE(chan, hdrbuf, 4);
- lseek(chan, update_ssnd_location, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, (int)size + 8);
- CHK_WRITE(chan, hdrbuf, 4);
- break;
- case MUS_RIFF:
-
- /* read sets current update_form_size, data_format, data_size, update_ssnd_location */
-
- lseek(chan, 4L, SEEK_SET);
- mus_lint_to_char((unsigned char *)hdrbuf, (int)size + update_form_size - mus_samples_to_bytes(data_format, data_size));
- CHK_WRITE(chan, hdrbuf, 4);
- lseek(chan, update_ssnd_location, SEEK_SET);
- mus_lint_to_char((unsigned char *)hdrbuf, (int)size);
- CHK_WRITE(chan, hdrbuf, 4);
- break;
- case MUS_IRCAM:
- case MUS_RAW:
- /* size is implicit in file size */
- break;
- case MUS_NIST:
-
- /* read sets current srate, chans, data_format */
-
- lseek(chan, 0L, SEEK_SET);
- write_nist_header(chan, mus_header_srate(), mus_header_chans(), size, mus_header_format());
- break;
- default:
- CLOSE(chan, filename);
- return(mus_error(MUS_UNSUPPORTED_HEADER_TYPE, "mus_header_change_data_size: can't update %s headers", mus_header_type_name(type)));
- break;
- }
- CLOSE(chan, filename);
- return(err);
-}
-
-int mus_header_change_chans(const char *filename, int type, int new_chans)
-{
- int err = MUS_NO_ERROR, fd;
- off_t new_frames;
- switch (type)
- {
- case MUS_AIFF:
- case MUS_AIFC:
- case MUS_NIST:
- case MUS_RIFF:
- err = mus_header_read(filename);
- break;
- default:
- break;
- }
- if (err == MUS_ERROR) return(err);
- fd = mus_file_reopen_write(filename);
- if (fd == -1)
- return(mus_error(MUS_CANT_OPEN_FILE, "mus_header_change_chans for %s failed: %s", filename, STRERROR(errno)));
- switch (type)
- {
- case MUS_NEXT:
- lseek(fd, 20L, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, new_chans);
- CHK_WRITE(fd, hdrbuf, 4);
- break;
- case MUS_IRCAM:
- lseek(fd, 8L, SEEK_SET);
- if (little_endian)
- mus_lint_to_char((unsigned char *)hdrbuf, new_chans);
- else mus_bint_to_char((unsigned char *)hdrbuf, new_chans);
- CHK_WRITE(fd, hdrbuf, 4);
- break;
- case MUS_NIST:
- lseek(fd, 0L, SEEK_SET);
- write_nist_header(fd, srate, new_chans, mus_bytes_per_sample(data_format) * data_size, data_format);
- /* header size is always 1024, so this is safe */
- break;
- case MUS_AIFF: case MUS_AIFC:
- lseek(fd, update_frames_location - 2, SEEK_SET);
- new_frames = data_size / new_chans;
- mus_bshort_to_char((unsigned char *)hdrbuf, new_chans);
- mus_bint_to_char((unsigned char *)(hdrbuf + 2), new_frames);
- CHK_WRITE(fd, hdrbuf, 6);
- break;
- case MUS_RIFF:
- lseek(fd, update_frames_location - 2, SEEK_SET);
- if (little_endian)
- mus_lshort_to_char((unsigned char *)hdrbuf, new_chans);
- else mus_bshort_to_char((unsigned char *)hdrbuf, new_chans);
- CHK_WRITE(fd, hdrbuf, 2);
- break;
- }
- CLOSE(fd, filename);
- return(err);
-}
-
-int mus_header_change_srate(const char *filename, int type, int new_srate)
-{
- int err = MUS_NO_ERROR, fd;
- switch (type)
- {
- case MUS_AIFF:
- case MUS_AIFC:
- case MUS_NIST:
- case MUS_RIFF:
- err = mus_header_read(filename);
- break;
- default:
- break;
- }
- if (err == MUS_ERROR) return(err);
- fd = mus_file_reopen_write(filename);
- if (fd == -1)
- return(mus_error(MUS_CANT_OPEN_FILE, "mus_header_change_srate for %s failed: %s", filename, STRERROR(errno)));
- switch (type)
- {
- case MUS_NEXT:
- lseek(fd, 16L, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, new_srate);
- CHK_WRITE(fd, hdrbuf, 4);
- break;
- case MUS_IRCAM:
- lseek(fd, 4L, SEEK_SET);
- if (little_endian)
- mus_lfloat_to_char((unsigned char *)hdrbuf, (float)new_srate);
- else mus_bfloat_to_char((unsigned char *)hdrbuf, (float)new_srate);
- CHK_WRITE(fd, hdrbuf, 4);
- break;
- case MUS_NIST:
- lseek(fd, 0L, SEEK_SET);
- write_nist_header(fd, new_srate, chans, mus_bytes_per_sample(data_format) * data_size, data_format);
- break;
- case MUS_AIFF:
- case MUS_AIFC:
- lseek(fd, update_frames_location + 6, SEEK_SET);
- double_to_ieee_80((double)new_srate, (unsigned char *)hdrbuf);
- CHK_WRITE(fd, hdrbuf, 10);
- break;
- case MUS_RIFF:
- lseek(fd, update_frames_location, SEEK_SET);
- if (little_endian)
- mus_lint_to_char((unsigned char *)hdrbuf, new_srate);
- else mus_bint_to_char((unsigned char *)hdrbuf, new_srate);
- CHK_WRITE(fd, hdrbuf, 4);
- break;
- }
- CLOSE(fd, filename);
- return(err);
-}
-
-int mus_header_change_type(const char *filename, int new_type, int new_format)
-{
- int err = MUS_NO_ERROR;
- /* open temp, write header, copy data, replace original with temp */
- err = mus_header_read(filename);
- if (err == MUS_NO_ERROR)
- {
- if (header_type != new_type)
- {
- int ofd, ifd, nbytes;
- off_t loc, len = 0;
- char *buf = NULL;
- char *new_file, *comment = NULL;
- new_file = (char *)CALLOC(strlen(filename) + 5, sizeof(char));
- sprintf(new_file, "%s.tmp", filename);
- loc = mus_header_data_location();
- if (new_type != MUS_RAW)
- {
- if (comment_end > comment_start)
- {
- len = comment_end - comment_start + 1;
- comment = (char *)CALLOC(len + 1, sizeof(char));
- ifd = mus_file_open_read(filename);
- lseek(ifd, comment_start, SEEK_SET);
- CHK_READ(ifd, (unsigned char *)comment, len);
- CLOSE(ifd, filename);
- }
- data_size = data_size * mus_bytes_per_sample(data_format) / mus_bytes_per_sample(new_format);
- mus_header_write(new_file, new_type, srate, chans, loc, data_size, new_format, comment, len);
- }
- else mus_file_create(new_file);
- ifd = mus_file_open_read(filename);
- lseek(ifd, loc, SEEK_SET);
- ofd = mus_file_reopen_write(new_file);
- lseek(ofd, 0L, SEEK_END);
- buf = (char *)CALLOC(8192, sizeof(char));
- while ((nbytes = read(ifd, buf, 8192))) CHK_WRITE(ofd, buf, nbytes);
- CLOSE(ifd, filename);
- CLOSE(ofd, new_file);
- FREE(buf);
- if (comment) FREE(comment);
- rename(new_file, filename);
- FREE(new_file);
- }
- }
- return(err);
-}
-
-int mus_header_change_format(const char *filename, int type, int new_format)
-{
- int err = MUS_NO_ERROR, fd;
- off_t old_bytes;
- switch (type)
- {
- case MUS_AIFF:
- case MUS_AIFC:
- case MUS_NIST:
- case MUS_RIFF:
- err = mus_header_read(filename);
- break;
- default:
- break;
- }
- if (err == MUS_ERROR) return(err);
- fd = mus_file_reopen_write(filename);
- if (fd == -1)
- return(mus_error(MUS_CANT_OPEN_FILE, "mus_header_change_format for %s failed: %s", filename, STRERROR(errno)));
- switch (type)
- {
- case MUS_NEXT:
- lseek(fd, 12L, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, sndlib_format_to_next(new_format));
- CHK_WRITE(fd, hdrbuf, 4);
- break;
- case MUS_IRCAM:
- lseek(fd, 12L, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, sndlib_format_to_ircam(new_format));
- CHK_WRITE(fd, hdrbuf, 4);
- break;
- case MUS_NIST:
- lseek(fd, 0L, SEEK_SET);
- write_nist_header(fd, srate, chans, mus_bytes_per_sample(data_format) * data_size, new_format);
- break;
- case MUS_AIFF:
- case MUS_AIFC:
- old_bytes = data_size * mus_bytes_per_sample(data_format);
- lseek(fd, update_frames_location, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, old_bytes / (chans * mus_bytes_per_sample(new_format)));
- mus_bshort_to_char((unsigned char *)(hdrbuf + 4), sndlib_format_to_aiff_bits(new_format));
- CHK_WRITE(fd, hdrbuf, 6);
- if (header_type == MUS_AIFC)
- {
- const char *str;
- str = sndlib_format_to_aifc_name(new_format);
- lseek(fd, update_frames_location + 16, SEEK_SET);
- write_four_chars((unsigned char *)(hdrbuf + 0), (const unsigned char *)str);
- (*(unsigned char *)(hdrbuf + 4)) = 4; /* final pad null not accounted-for */
- write_four_chars((unsigned char *)(hdrbuf + 5), (const unsigned char *)str);
- (*(unsigned char *)(hdrbuf + 9)) = 0;
- CHK_WRITE(fd, hdrbuf, 10);
- }
- break;
- case MUS_RIFF:
- lseek(fd, update_frames_location + 24, SEEK_SET);
- if (little_endian)
- mus_lshort_to_char((unsigned char *)hdrbuf, sndlib_format_to_aiff_bits(new_format));
- else mus_bshort_to_char((unsigned char *)hdrbuf, sndlib_format_to_aiff_bits(new_format));
- CHK_WRITE(fd, hdrbuf, 2);
- lseek(fd, update_frames_location + 10, SEEK_SET);
- switch (new_format)
- {
- case MUS_MULAW:
- new_format = 7;
- break;
- case MUS_ALAW:
- new_format = 6;
- break;
- case MUS_UBYTE:
- case MUS_LSHORT: case MUS_L24INT: case MUS_LINT:
- case MUS_BSHORT: case MUS_B24INT: case MUS_BINT:
- new_format = 1;
- break;
- case MUS_LFLOAT: case MUS_LDOUBLE:
- case MUS_BFLOAT: case MUS_BDOUBLE:
- new_format = 3;
- break;
- }
- if (little_endian)
- mus_lshort_to_char((unsigned char *)hdrbuf, new_format);
- else mus_bshort_to_char((unsigned char *)hdrbuf, new_format);
- CHK_WRITE(fd, hdrbuf, 2);
- break;
- }
- CLOSE(fd, filename);
- return(err);
-}
-
-int mus_header_change_location(const char *filename, int type, off_t new_location)
-{
- /* only Next/Sun changeable in this regard */
- int err = MUS_NO_ERROR, fd;
- fd = mus_file_reopen_write(filename);
- if (fd == -1)
- return(mus_error(MUS_CANT_OPEN_FILE, "mus_header_change_location for %s failed: %s", filename, STRERROR(errno)));
- if (type == MUS_NEXT)
- {
- lseek(fd, 4L, SEEK_SET);
- mus_bint_to_char((unsigned char *)hdrbuf, new_location);
- CHK_WRITE(fd, hdrbuf, 4);
- }
- CLOSE(fd, filename);
- return(err);
-}
-
-int mus_header_change_comment(const char *filename, int type, char *new_comment)
-{
- int err = MUS_NO_ERROR, fd, len = 0;
- bool need_ripple = false;
- err = mus_header_read(filename);
- if (err == MUS_NO_ERROR)
- {
- switch (type)
- {
- case MUS_IRCAM:
- fd = mus_file_reopen_write(filename);
- lseek(fd, 16L, SEEK_SET);
- if (new_comment) len = strlen(new_comment);
- write_ircam_comment(fd, new_comment, len);
- CLOSE(fd, filename);
- break;
- case MUS_NEXT:
- fd = mus_file_reopen_write(filename);
- lseek(fd, 24L, SEEK_SET);
- if (new_comment == NULL)
- write_next_comment(fd, new_comment, 0, data_location); /* erase old possibly */
- else
- {
- if ((comment_start != comment_end) &&
- ((int)(data_location - 24) >= (int)strlen(new_comment)))
- write_next_comment(fd, new_comment, strlen(new_comment), data_location); /* there's room to overwrite old comment */
- else need_ripple = true;
- }
- CLOSE(fd, filename);
- break;
- default:
- need_ripple = true;
- break;
- }
- if (need_ripple)
- {
- /* open temp, write header, copy data, replace original with temp */
- char *new_file;
- int ofd, ifd;
- off_t loc;
- int nbytes;
- char *buf = NULL;
- new_file = (char *)CALLOC(strlen(filename) + 5, sizeof(char));
- sprintf(new_file, "%s.tmp", filename);
- loc = mus_header_data_location();
- mus_header_write(new_file, header_type, srate, chans, loc, data_size, data_format, new_comment, (new_comment) ? strlen(new_comment) : 0);
- ifd = mus_file_open_read(filename);
- lseek(ifd, loc, SEEK_SET);
- ofd = mus_file_reopen_write(new_file);
- lseek(ofd, 0L, SEEK_END);
- buf = (char *)CALLOC(8192, sizeof(char));
- while ((nbytes = read(ifd, buf, 8192))) CHK_WRITE(ofd, buf, nbytes);
- CLOSE(ifd, filename);
- CLOSE(ofd, new_file);
- FREE(buf);
- rename(new_file, filename);
- FREE(new_file);
- }
- }
- return(err);
-}
-
-bool mus_header_writable(int type, int format) /* -2 to ignore format for this call */
-{
- switch (type)
- {
- case MUS_NEXT:
- if (format == MUS_UNKNOWN) return(false);
- return(true);
- break;
- case MUS_NIST:
- if (format == -2) return(true);
- switch (format)
- {
- case MUS_BYTE: case MUS_BSHORT: case MUS_B24INT: case MUS_BINT:
- case MUS_LSHORT: case MUS_L24INT: case MUS_LINT:
- return(true); break;
- default:
- return(false); break;
- }
- break;
- case MUS_AIFC:
- if (format == -2) return(true);
- switch (format)
- {
- case MUS_BSHORT: case MUS_B24INT: case MUS_BINT:
- case MUS_BYTE: case MUS_MULAW: case MUS_ALAW:
- case MUS_BFLOAT: case MUS_BDOUBLE: case MUS_UBYTE: case MUS_UBSHORT:
- case MUS_LSHORT: case MUS_L24INT: case MUS_LINT:
- return(true);
- break;
- default:
- return(false);
- break;
- }
- break;
- case MUS_AIFF:
- if (format == -2) return(true);
- switch (format)
- {
- case MUS_BSHORT: case MUS_B24INT: case MUS_BINT: case MUS_BYTE:
- return(true);
- break;
- default:
- return(false);
- break;
- }
- break;
- case MUS_RIFF:
- if (format == -2) return(true);
- switch (format)
- {
- case MUS_MULAW: case MUS_ALAW: case MUS_UBYTE: case MUS_LFLOAT:
- case MUS_LSHORT: case MUS_L24INT: case MUS_LINT: case MUS_LDOUBLE:
- return(true);
- break;
- default:
- return(false);
- break;
- }
- break;
- case MUS_IRCAM:
- if (format == -2) return(true);
- switch (format)
- {
- case MUS_MULAW: case MUS_ALAW: case MUS_BSHORT: case MUS_BINT: case MUS_BFLOAT:
- return(true);
- break;
- default:
- return(false);
- break;
- }
- break;
- case MUS_RAW:
- return(true);
- break;
- default: return(false); break;
- }
- return(false);
-}
-
-static char aifc_format[5];
-
-/* try to give some info on data formats that aren't supported by sndlib */
-const char *mus_header_original_format_name(int format, int type)
-{
- switch (type)
- {
- case MUS_NEXT:
- switch (format)
- {
- case 0: return("unspecified"); break; case 8: return("indirect"); break; case 9: return("nested"); break;
- case 10: return("dsp_core"); break; case 11: return("dsp_data_8"); break; case 12: return("dsp_data_16"); break;
- case 13: return("dsp_data_24"); break; case 14: return("dsp_data_32"); break; case 16: return("display"); break;
- case 17: return("mulaw_squelch"); break; case 18: return("emphasized"); break; case 19: return("compressed"); break;
- case 20: return("compressed_emphasized"); break; case 21: return("dsp_commands"); break; case 22: return("dsp_commands_samples"); break;
- case 23: return("adpcm_g721"); break; case 24: return("adpcm_g722"); break; case 25: return("adpcm_g723"); break;
- case 26: return("adpcm_g723_5"); break; case 28: return("aes"); break; case 29: return("delat_mulaw_8"); break;
- }
- break;
- case MUS_AIFC:
- aifc_format[4] = 0;
-#if MUS_LITTLE_ENDIAN
- sprintf(aifc_format, "%c%c%c%c", format & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff);
-#else
- sprintf(aifc_format, "%c%c%c%c", (format >> 24) & 0xff, (format >> 16) & 0xff, (format >> 8) & 0xff, format & 0xff);
-#endif
- return(aifc_format);
- break;
- case MUS_PVF:
- if (type_specifier == mus_char_to_uninterpreted_int((unsigned const char *)I_PVF2))
- return("ascii text");
- break;
- case MUS_RIFF:
- switch (format)
- {
- case 2: return("ADPCM"); break; case 4: return("VSELP"); break; case 5: return("IBM_CVSD"); break;
- case 0x10: return("OKI_ADPCM"); break; case 0x11: return("DVI_ADPCM"); break; case 0x12: return("MediaSpace_ADPCM"); break;
- case 0x13: return("Sierra_ADPCM"); break; case 0x14: return("G723_ADPCM"); break; case 0x15: return("DIGISTD"); break;
- case 0x16: return("DIGIFIX"); break; case 0x17: return("Dialogic ADPCM"); break; case 0x18: return("Mediavision ADPCM"); break;
- case 0x19: return("HP cu codec"); break; case 0x20: return("Yamaha_ADPCM"); break; case 0x21: return("SONARC"); break;
- case 0x22: return("DSPGroup_TrueSpeech"); break; case 0x23: return("EchoSC1"); break; case 0x24: return("AudioFile_AF36"); break;
- case 0x25: return("APTX"); break; case 0x26: return("AudioFile_AF10"); break; case 0x27: return("prosody 1612"); break;
- case 0x28: return("lrc"); break; case 0x30: return("Dolby_Ac2"); break; case 0x31: return("GSM610"); break;
- case 0x32: return("MSN audio codec"); break; case 0x33: return("Antext_ADPCM"); break; case 0x34: return("Control_res_vqlpc"); break;
- case 0x35: return("DIGIREAL"); break; case 0x36: return("DIGIADPCM"); break; case 0x37: return("Control_res_cr10"); break;
- case 0x38: return("NMS_VBXADPCM"); break; case 0x39: return("oland rdac"); break; case 0x3a: return("echo sc3"); break;
- case 0x3b: return("Rockwell adpcm"); break; case 0x3c: return("Rockwell digitalk codec"); break; case 0x3d: return("Xebec"); break;
- case 0x40: return("G721_ADPCM"); break; case 0x41: return("G728 CELP"); break; case 0x42: return("MS G723"); break;
- case 0x50: return("MPEG"); break; case 0x52: return("RT24"); break; case 0x53: return("PAC"); break;
- case 0x55: return("Mpeg layer 3"); break; case 0x59: return("Lucent G723"); break; case 0x60: return("Cirrus"); break;
- case 0x61: return("ESS Tech pcm"); break; case 0x62: return("voxware "); break; case 0x63: return("canopus atrac"); break;
- case 0x64: return("G726"); break; case 0x65: return("G722"); break; case 0x66: return("DSAT"); break;
- case 0x67: return("DSAT display"); break; case 0x69: return("voxware "); break; case 0x70: return("voxware ac8 "); break;
- case 0x71: return("voxware ac10 "); break; case 0x72: return("voxware ac16"); break; case 0x73: return("voxware ac20"); break;
- case 0x74: return("voxware rt24"); break; case 0x75: return("voxware rt29"); break; case 0x76: return("voxware rt29hw"); break;
- case 0x77: return("voxware vr12 "); break; case 0x78: return("voxware vr18"); break; case 0x79: return("voxware tq40"); break;
- case 0x80: return("softsound"); break; case 0x81: return("voxware tq60 "); break; case 0x82: return("MS RT24"); break;
- case 0x83: return("G729A"); break; case 0x84: return("MVI_MVI2"); break; case 0x85: return("DF G726"); break;
- case 0x86: return("DF GSM610"); break; case 0x88: return("isaudio"); break; case 0x89: return("onlive"); break;
- case 0x91: return("sbc24"); break; case 0x92: return("dolby ac3 spdif"); break; case 0x97: return("zyxel adpcm"); break;
- case 0x98: return("philips lpcbb"); break; case 0x99: return("packed"); break; case 0x100: return("rhetorex adpcm"); break;
- case 0x101: return("Irat"); break; case 0x102: return("IBM_alaw?"); break; case 0x103: return("IBM_ADPCM?"); break;
- case 0x111: return("vivo G723"); break; case 0x112: return("vivo siren"); break; case 0x123: return("digital g273"); break;
- case 0x200: return("Creative_ADPCM"); break; case 0x202: return("Creative fastspeech 8"); break;
- case 0x203: return("Creative fastspeech 10"); break;
- case 0x220: return("quarterdeck"); break; case 0x300: return("FM_TOWNS_SND"); break; case 0x400: return("BTV digital"); break;
- case 0x680: return("VME vmpcm"); break; case 0x1000: return("OLIGSM"); break; case 0x1001: return("OLIADPCM"); break;
- case 0x1002: return("OLICELP"); break; case 0x1003: return("OLISBC"); break; case 0x1004: return("OLIOPR"); break;
- case 0x1100: return("LH codec"); break; case 0x1400: return("Norris"); break; case 0x1401: return("isaudio"); break;
- case 0x1500: return("Soundspace musicompression"); break; case 0x2000: return("DVM"); break;
- }
- break;
- }
- return("unknown"); /* NULL here isn't safe -- Sun segfaults */
-}
-
-bool mus_header_no_header(const char *filename)
-{
- int chan, bytes;
- bool ok = false;
- chan = mus_file_open_read(filename);
- if (chan == -1)
- return(mus_error(MUS_CANT_OPEN_FILE, "mus_header: can't open %s: %s", filename, STRERROR(errno)));
- bytes = read(chan, hdrbuf, INITIAL_READ_SIZE);
- CLOSE(chan, filename);
- if (bytes > 4)
- ok = ((match_four_chars((unsigned char *)hdrbuf, I_DSND)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_DECN)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_FORM)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_RIFF)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_RIFX)) ||
- (equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_VAX)) ||
- (equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_SUN)) ||
- (equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_MIPS)) ||
- (equal_big_or_little_endian((unsigned char *)hdrbuf, I_IRCAM_NEXT)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_NIST)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SOUN)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_VOC0)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_AVR_)) ||
- (mus_char_to_bshort((unsigned char *)hdrbuf) == 1336) ||
- (match_four_chars((unsigned char *)hdrbuf, I_ALaw)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_GF1P)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_DSIG)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_GOLD)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_Diam)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SRFS)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_CSRE)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_file)) ||
- ((hdrbuf[0] == 0xf0) && (hdrbuf[1] == 0x7e) && (hdrbuf[3] == 0x01)) ||
- (equal_big_or_little_endian((unsigned char *)(hdrbuf + 16), 0x00006a1a)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SPIB)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_S___)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_riff)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_PVF1)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_PVF2)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_MThd)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SND_)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_FSMt)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_DDSF)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_LM89)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SY85)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SY80)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_PRAM)) ||
- (match_four_chars((unsigned char *)(hdrbuf + 35), I_UWFD)) ||
- (match_four_chars((unsigned char *)(hdrbuf + 76), I_SCRS)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_covox)) ||
- (match_four_chars((unsigned char *)hdrbuf, I__PAF)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_FAP_)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_TWIN)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_IMPS)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SMP1)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_Maui)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_SDIF)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_ajkg)) ||
- (match_four_chars((unsigned char *)hdrbuf, I_NVF_)));
- return(!ok);
-}
-
-void mus_header_set_aiff_loop_info(int *data)
-{
- /* include modes */
- if (data)
- {
- loop_starts[0] = data[0];
- loop_ends[0] = data[1];
- loop_starts[1] = data[2];
- loop_ends[1] = data[3];
- base_note = data[4];
- base_detune = data[5];
- loop_modes[0] = data[6];
- loop_modes[1] = data[7];
- }
- else
- {
- loop_modes[0] = 0;
- loop_modes[1] = 0;
- }
-}
diff --git a/third_party/resample/sndlib-20/io.c b/third_party/resample/sndlib-20/io.c
deleted file mode 100644
index 57376b7e..00000000
--- a/third_party/resample/sndlib-20/io.c
+++ /dev/null
@@ -1,1513 +0,0 @@
-/* IO handlers */
-/*
- * --------------------------------
- * int mus_file_read(int fd, int beg, int end, int chans, mus_sample_t **bufs)
- * int mus_file_write(int tfd, int beg, int end, int chans, mus_sample_t **bufs)
- * int mus_file_open_read(const char *arg)
- * int mus_file_open_write(const char *arg)
- * int mus_file_create(const char *arg)
- * int mus_file_reopen_write(const char *arg)
- * int mus_file_close(int fd)
- * bool mus_file_probe(const char *arg)
- * char *mus_format(const char *format, ...)
- * off_t mus_file_seek_frame(int tfd, off_t frame)
- * --------------------------------
- */
-
-#include <mus-config.h>
-
-#if USE_SND
- #include "snd.h"
-#endif
-
-#include <math.h>
-#include <stdio.h>
-#if HAVE_FCNTL_H
- #include <fcntl.h>
-#endif
-#if HAVE_LIMITS_H
- #include <limits.h>
-#endif
-#include <errno.h>
-#include <stdlib.h>
-
-#if (defined(HAVE_LIBC_H) && (!defined(HAVE_UNISTD_H)))
- #include <libc.h>
-#else
- #if (!(defined(_MSC_VER)))
- #include <unistd.h>
- #endif
-#endif
-#if HAVE_STRING_H
- #include <string.h>
-#endif
-#include <stdarg.h>
-
-#include "_sndlib.h"
-
-/* data translations for big/little endian machines
- * the m_* forms are macros where possible for speed (dating back to 1991 -- probably not needed)
- */
-
-void mus_bint_to_char(unsigned char *j, int x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if MUS_LITTLE_ENDIAN
- j[0] = ox[3]; j[1] = ox[2]; j[2] = ox[1]; j[3] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 4);
-#endif
-}
-
-int mus_char_to_bint(const unsigned char *inp)
-{
- int o;
- unsigned char *outp = (unsigned char *)&o;
-#if MUS_LITTLE_ENDIAN
- outp[0] = inp[3]; outp[1] = inp[2]; outp[2] = inp[1]; outp[3] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 4);
-#endif
- return(o);
-}
-
-void mus_lint_to_char(unsigned char *j, int x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if (!MUS_LITTLE_ENDIAN)
- j[0] = ox[3]; j[1] = ox[2]; j[2] = ox[1]; j[3] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 4);
-#endif
-}
-
-int mus_char_to_lint(const unsigned char *inp)
-{
- int o;
- unsigned char *outp = (unsigned char *)&o;
-#if (!MUS_LITTLE_ENDIAN)
- outp[0] = inp[3]; outp[1] = inp[2]; outp[2] = inp[1]; outp[3] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 4);
-#endif
- return(o);
-}
-
-int mus_char_to_uninterpreted_int(const unsigned char *inp)
-{
- int o;
- unsigned char *outp = (unsigned char *)&o;
- memcpy((void *)outp, (void *)inp, 4);
- return(o);
-}
-
-unsigned int mus_char_to_ubint(const unsigned char *inp)
-{
- unsigned int o;
- unsigned char *outp = (unsigned char *)&o;
-#if MUS_LITTLE_ENDIAN
- outp[0] = inp[3]; outp[1] = inp[2]; outp[2] = inp[1]; outp[3] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 4);
-#endif
- return(o);
-}
-
-unsigned int mus_char_to_ulint(const unsigned char *inp)
-{
- unsigned int o;
- unsigned char *outp = (unsigned char *)&o;
-#if (!MUS_LITTLE_ENDIAN)
- outp[0] = inp[3]; outp[1] = inp[2]; outp[2] = inp[1]; outp[3] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 4);
-#endif
- return(o);
-}
-
-
-void mus_bfloat_to_char(unsigned char *j, float x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if MUS_LITTLE_ENDIAN
- j[0] = ox[3]; j[1] = ox[2]; j[2] = ox[1]; j[3] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 4);
-#endif
-}
-
-float mus_char_to_bfloat(const unsigned char *inp)
-{
- float o;
- unsigned char *outp = (unsigned char *)&o;
-#if MUS_LITTLE_ENDIAN
- outp[0] = inp[3]; outp[1] = inp[2]; outp[2] = inp[1]; outp[3] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 4);
-#endif
- return(o);
-}
-
-void mus_lfloat_to_char(unsigned char *j, float x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if (!MUS_LITTLE_ENDIAN)
- j[0] = ox[3]; j[1] = ox[2]; j[2] = ox[1]; j[3] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 4);
-#endif
-}
-
-float mus_char_to_lfloat(const unsigned char *inp)
-{
- float o;
- unsigned char *outp = (unsigned char *)&o;
-#if (!MUS_LITTLE_ENDIAN)
- outp[0] = inp[3]; outp[1] = inp[2]; outp[2] = inp[1]; outp[3] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 4);
-#endif
- return(o);
-}
-
-void mus_bshort_to_char(unsigned char *j, short x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if MUS_LITTLE_ENDIAN
- j[0] = ox[1]; j[1] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 2); /* I wonder if this is faster */
-#endif
-}
-
-short mus_char_to_bshort(const unsigned char *inp)
-{
- short o;
- unsigned char *outp = (unsigned char *)&o;
-#if MUS_LITTLE_ENDIAN
- outp[0] = inp[1]; outp[1] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 2);
-#endif
- return(o);
-}
-
-void mus_lshort_to_char(unsigned char *j, short x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if (!MUS_LITTLE_ENDIAN)
- j[0] = ox[1]; j[1] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 2);
-#endif
-}
-
-short mus_char_to_lshort(const unsigned char *inp)
-{
- short o;
- unsigned char *outp = (unsigned char *)&o;
-#if (!MUS_LITTLE_ENDIAN)
- outp[0] = inp[1]; outp[1] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 2);
-#endif
- return(o);
-}
-
-void mus_ubshort_to_char(unsigned char *j, unsigned short x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if MUS_LITTLE_ENDIAN
- j[0] = ox[1]; j[1] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 2);
-#endif
-}
-
-unsigned short mus_char_to_ubshort(const unsigned char *inp)
-{
- unsigned short o;
- unsigned char *outp = (unsigned char *)&o;
-#if MUS_LITTLE_ENDIAN
- outp[0] = inp[1]; outp[1] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 2);
-#endif
- return(o);
-}
-
-void mus_ulshort_to_char(unsigned char *j, unsigned short x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if (!MUS_LITTLE_ENDIAN)
- j[0] = ox[1]; j[1] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 2);
-#endif
-}
-
-unsigned short mus_char_to_ulshort(const unsigned char *inp)
-{
- unsigned short o;
- unsigned char *outp = (unsigned char *)&o;
-#if (!MUS_LITTLE_ENDIAN)
- outp[0] = inp[1]; outp[1] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 2);
-#endif
- return(o);
-}
-
-double mus_char_to_ldouble(const unsigned char *inp)
-{
- double o;
- unsigned char *outp = (unsigned char *)&o;
-#if (MUS_LITTLE_ENDIAN)
- memcpy((void *)outp, (void *)inp, 8);
-#else
- outp[0] = inp[7]; outp[1] = inp[6]; outp[2] = inp[5]; outp[3] = inp[4]; outp[4] = inp[3]; outp[5] = inp[2]; outp[6] = inp[1]; outp[7] = inp[0];
-#endif
- return(o);
-}
-
-double mus_char_to_bdouble(const unsigned char *inp)
-{
- double o;
- unsigned char *outp = (unsigned char *)&o;
-#if (MUS_LITTLE_ENDIAN)
- outp[0] = inp[7]; outp[1] = inp[6]; outp[2] = inp[5]; outp[3] = inp[4]; outp[4] = inp[3]; outp[5] = inp[2]; outp[6] = inp[1]; outp[7] = inp[0];
-#else
- memcpy((void *)outp, (void *)inp, 8);
-#endif
- return(o);
-}
-
-void mus_bdouble_to_char(unsigned char *j, double x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if (MUS_LITTLE_ENDIAN)
- j[0] = ox[7]; j[1] = ox[6]; j[2] = ox[5]; j[3] = ox[4]; j[4] = ox[3]; j[5] = ox[2]; j[6] = ox[1]; j[7] = ox[0];
-#else
- memcpy((void *)j, (void *)ox, 8);
-#endif
-}
-
-void mus_ldouble_to_char(unsigned char *j, double x)
-{
- unsigned char *ox = (unsigned char *)&x;
-#if (MUS_LITTLE_ENDIAN)
- memcpy((void *)j, (void *)ox, 8);
-#else
- j[0] = ox[7]; j[1] = ox[6]; j[2] = ox[5]; j[3] = ox[4]; j[4] = ox[3]; j[5] = ox[2]; j[6] = ox[1]; j[7] = ox[0];
-#endif
-}
-
-#if HAVE_BYTESWAP_H
- #include <byteswap.h>
-#endif
-
-#if MUS_LITTLE_ENDIAN
-
- #if HAVE_BYTESWAP_H
- #define m_big_endian_short(n) ((short)(bswap_16((*((unsigned short *)n)))))
- #define m_big_endian_int(n) ((int)(bswap_32((*((unsigned int *)n)))))
- #define m_big_endian_unsigned_short(n) ((unsigned short)(bswap_16((*((unsigned short *)n)))))
- #else
- #define m_big_endian_short(n) (mus_char_to_bshort(n))
- #define m_big_endian_int(n) (mus_char_to_bint(n))
- #define m_big_endian_unsigned_short(n) (mus_char_to_ubshort(n))
- #endif
- #define m_big_endian_float(n) (mus_char_to_bfloat(n))
- #define m_big_endian_double(n) (mus_char_to_bdouble(n))
-
- #define m_little_endian_short(n) (*((short *)n))
- #define m_little_endian_int(n) (*((int *)n))
- #define m_little_endian_float(n) (*((float *)n))
- #define m_little_endian_double(n) (*((double *)n))
- #define m_little_endian_unsigned_short(n) (*((unsigned short *)n))
-
- #if HAVE_BYTESWAP_H
- #define m_set_big_endian_short(n, x) (*((short *)n)) = ((short)(bswap_16(x)))
- #define m_set_big_endian_int(n, x) (*((int *)n)) = ((int)(bswap_32(x)))
- #define m_set_big_endian_unsigned_short(n, x) (*((unsigned short *)n)) = ((unsigned short)(bswap_16(x)))
- #else
- #define m_set_big_endian_short(n, x) mus_bshort_to_char(n, x)
- #define m_set_big_endian_int(n, x) mus_bint_to_char(n, x)
- #define m_set_big_endian_unsigned_short(n, x) mus_ubshort_to_char(n, x)
- #endif
- #define m_set_big_endian_float(n, x) mus_bfloat_to_char(n, x)
- #define m_set_big_endian_double(n, x) mus_bdouble_to_char(n, x)
-
- #define m_set_little_endian_short(n, x) (*((short *)n)) = x
- #define m_set_little_endian_int(n, x) (*((int *)n)) = x
- #define m_set_little_endian_float(n, x) (*((float *)n)) = x
- #define m_set_little_endian_double(n, x) (*((double *)n)) = x
- #define m_set_little_endian_unsigned_short(n, x) (*((unsigned short *)n)) = x
-
-#else
-
- #ifndef MUS_SUN
- #define m_big_endian_short(n) (*((short *)n))
- #define m_big_endian_int(n) (*((int *)n))
- #define m_big_endian_float(n) (*((float *)n))
- #define m_big_endian_double(n) (*((double *)n))
- #define m_big_endian_unsigned_short(n) (*((unsigned short *)n))
-
- #define m_set_big_endian_short(n, x) (*((short *)n)) = x
- #define m_set_big_endian_int(n, x) (*((int *)n)) = x
- #define m_set_big_endian_float(n, x) (*((float *)n)) = x
- #define m_set_big_endian_double(n, x) (*((double *)n)) = x
- #define m_set_big_endian_unsigned_short(n, x) (*((unsigned short *)n)) = x
- #else
- #define m_big_endian_short(n) (mus_char_to_bshort(n))
- #define m_big_endian_int(n) (mus_char_to_bint(n))
- #define m_big_endian_float(n) (mus_char_to_bfloat(n))
- #define m_big_endian_double(n) (mus_char_to_bdouble(n))
- #define m_big_endian_unsigned_short(n) (mus_char_to_ubshort(n))
-
- #define m_set_big_endian_short(n, x) mus_bshort_to_char(n, x)
- #define m_set_big_endian_int(n, x) mus_bint_to_char(n, x)
- #define m_set_big_endian_float(n, x) mus_bfloat_to_char(n, x)
- #define m_set_big_endian_double(n, x) mus_bdouble_to_char(n, x)
- #define m_set_big_endian_unsigned_short(n, x) mus_ubshort_to_char(n, x)
- #endif
-
- #if HAVE_BYTESWAP_H
- #define m_little_endian_short(n) ((short)(bswap_16((*((unsigned short *)n)))))
- #define m_little_endian_int(n) ((int)(bswap_32((*((unsigned int *)n)))))
- #define m_little_endian_unsigned_short(n) ((unsigned short)(bswap_16((*((unsigned short *)n)))))
- #else
- #define m_little_endian_short(n) (mus_char_to_lshort(n))
- #define m_little_endian_int(n) (mus_char_to_lint(n))
- #define m_little_endian_unsigned_short(n) (mus_char_to_ulshort(n))
- #endif
- #define m_little_endian_float(n) (mus_char_to_lfloat(n))
- #define m_little_endian_double(n) (mus_char_to_ldouble(n))
-
- #if HAVE_BYTESWAP_H
- #define m_set_little_endian_short(n, x) (*((short *)n)) = ((short)(bswap_16(x)))
- #define m_set_little_endian_int(n, x) (*((int *)n)) = ((int)(bswap_32(x)))
- #define m_set_little_endian_unsigned_short(n, x) (*((unsigned short *)n)) = ((unsigned short)(bswap_16(x)))
- #else
- #define m_set_little_endian_short(n, x) mus_lshort_to_char(n, x)
- #define m_set_little_endian_int(n, x) mus_lint_to_char(n, x)
- #define m_set_little_endian_unsigned_short(n, x) mus_ulshort_to_char(n, x)
- #endif
- #define m_set_little_endian_float(n, x) mus_lfloat_to_char(n, x)
- #define m_set_little_endian_double(n, x) mus_ldouble_to_char(n, x)
-
-#endif
-
-
-/* ---------------- file descriptors ---------------- */
-
-typedef struct {
- char *name;
- int data_format, bytes_per_sample, chans, header_type;
- bool clipping;
- off_t data_location;
- Float prescaler;
-} io_fd;
-
-static int io_fd_size = 0;
-static io_fd **io_fds = NULL;
-#define IO_FD_ALLOC_SIZE 8
-static bool clipping_default = false;
-static Float prescaler_default = 1.0;
-
-bool mus_clipping(void) {return(clipping_default);}
-bool mus_set_clipping(bool new_value) {clipping_default = new_value; return(new_value);}
-Float mus_prescaler(void) {return(prescaler_default);}
-Float mus_set_prescaler(Float new_value) {prescaler_default = new_value; return(new_value);}
-
-int mus_file_open_descriptors(int tfd, const char *name, int format, int size /* datum size */, off_t location, int chans, int type)
-{
- io_fd *fd;
- int i, lim = -1;
- if (io_fd_size == 0)
- {
- io_fd_size = tfd + IO_FD_ALLOC_SIZE;
- io_fds = (io_fd **)CALLOC(io_fd_size, sizeof(io_fd *));
- if (!io_fds) return(MUS_MEMORY_ALLOCATION_FAILED);
- }
- if (io_fd_size <= tfd)
- {
- lim = io_fd_size;
- io_fd_size = tfd + IO_FD_ALLOC_SIZE;
- io_fds = (io_fd **)REALLOC(io_fds, io_fd_size * sizeof(io_fd *));
- for (i = lim; i < io_fd_size; i++) io_fds[i] = NULL;
- }
- if (io_fds[tfd] == NULL)
- {
- io_fds[tfd] = (io_fd *)CALLOC(1, sizeof(io_fd));
- if (!(io_fds[tfd])) return(MUS_MEMORY_ALLOCATION_FAILED);
- }
-
- fd = io_fds[tfd];
- fd->data_format = format;
- fd->bytes_per_sample = size;
-#if MUS_DEBUGGING
- if (size != mus_bytes_per_sample(format))
- fprintf(stderr, "format trouble in mus_file_open_descriptors: %d != %d\n", size, mus_bytes_per_sample(format));
-#endif
- fd->data_location = location;
- fd->clipping = clipping_default;
- fd->prescaler = prescaler_default;
- fd->header_type = type;
- fd->chans = chans;
- if (name)
- {
- fd->name = (char *)CALLOC(strlen(name) + 1, sizeof(char));
- strcpy(fd->name, name);
- }
- return(MUS_NO_ERROR);
-}
-
-bool mus_file_clipping(int tfd)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(false);
- fd = io_fds[tfd];
- return(fd->clipping);
-}
-
-int mus_file_set_clipping(int tfd, bool clipped)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED);
- fd = io_fds[tfd];
- fd->clipping = clipped;
- return(MUS_NO_ERROR);
-}
-
-int mus_file_set_header_type(int tfd, int type)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED);
- fd = io_fds[tfd];
- fd->header_type = type;
- return(MUS_NO_ERROR);
-}
-
-int mus_file_header_type(int tfd)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED);
- fd = io_fds[tfd];
- return(fd->header_type);
-}
-
-Float mus_file_prescaler(int tfd)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(0.0);
- fd = io_fds[tfd];
- return(fd->prescaler);
-}
-
-Float mus_file_set_prescaler(int tfd, Float val)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(0.0);
- fd = io_fds[tfd];
- fd->prescaler = val;
- return(val);
-}
-
-char *mus_file_fd_name(int tfd)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(NULL);
- fd = io_fds[tfd];
- return(fd->name);
-}
-
-int mus_file_set_chans(int tfd, int chans)
-{
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL)) return(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED);
- fd = io_fds[tfd];
- fd->chans = chans;
- return(MUS_NO_ERROR);
-}
-
-
-/* ---------------- open, creat, close ---------------- */
-
-int mus_file_open_read(const char *arg)
-{
- int fd;
-#ifdef MUS_WINDOZE
- fd = OPEN(arg, O_RDONLY | O_BINARY, 0);
-#else
- fd = OPEN(arg, O_RDONLY, 0);
-#endif
- return(fd);
-}
-
-bool mus_file_probe(const char *arg)
-{
-#if HAVE_ACCESS
- return(access(arg, F_OK) == 0);
-#else
- int fd;
-#ifdef O_NONBLOCK
- fd = OPEN(arg, O_RDONLY, O_NONBLOCK);
-#else
- fd = OPEN(arg, O_RDONLY, 0);
-#endif
- if (fd == -1) return(false);
- CLOSE(fd, arg);
- return(true);
-#endif
-}
-
-int mus_file_open_write(const char *arg)
-{
- int fd;
-#ifdef MUS_WINDOZE
- if ((fd = OPEN(arg, O_RDWR | O_BINARY, 0)) == -1)
-#else
- if ((fd = OPEN(arg, O_RDWR, 0)) == -1)
-#endif
- fd = CREAT(arg, 0666); /* equivalent to the new open(arg, O_RDWR | O_CREAT | O_TRUNC, 0666) */
- else lseek(fd, 0L, SEEK_END);
- return(fd);
-}
-
-int mus_file_create(const char *arg)
-{
- return(CREAT(arg, 0666));
-}
-
-int mus_file_reopen_write(const char *arg)
-{
- int fd;
-#ifdef MUS_WINDOZE
- fd = OPEN(arg, O_RDWR | O_BINARY, 0);
-#else
- fd = OPEN(arg, O_RDWR, 0);
-#endif
- return(fd);
-}
-
-int mus_file_close(int fd)
-{
- io_fd *fdp;
- int close_result = 0;
- if ((io_fds == NULL) || (fd >= io_fd_size) || (fd < 0) || (io_fds[fd] == NULL)) return(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED);
- fdp = io_fds[fd];
-#if USE_SND
- CLOSE(fd, fdp->name);
-#else
- close_result = close(fd);
-#endif
- if (fdp->name) {FREE(fdp->name); fdp->name = NULL;}
- FREE(fdp);
- io_fds[fd] = NULL;
- if (close_result < 0)
- return(MUS_CANT_CLOSE_FILE);
- return(MUS_NO_ERROR);
-}
-
-
-
-/* ---------------- seek ---------------- */
-
-off_t mus_file_seek_frame(int tfd, off_t frame)
-{
- io_fd *fd;
- if (io_fds == NULL)
- return(mus_error(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED, "mus_file_seek_frame: no file descriptors!"));
- if (tfd < 0)
- return(mus_error(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED, "mus_file_seek_frame: file descriptor = %d?", tfd));
- if ((tfd >= io_fd_size) ||
- (io_fds[tfd] == NULL))
- return(mus_error(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED,
- "mus_file_seek_frame: file descriptors not realloc'd? (tfd: %d, io_fd_size: %d)", tfd, io_fd_size));
- fd = io_fds[tfd];
- if (fd->data_format == MUS_UNKNOWN)
- return(mus_error(MUS_NOT_A_SOUND_FILE, "mus_file_seek_frame: invalid data format for %s", fd->name));
- return(lseek(tfd, fd->data_location + (fd->chans * frame * fd->bytes_per_sample), SEEK_SET));
-}
-
-
-
-/* ---------------- mulaw/alaw conversions ----------------
- *
- * x : input signal with max value 32767
- * mu : compression parameter (mu = 255 used for telephony)
- * y = (32767/log(1+mu))*log(1+mu*abs(x)/32767)*sign(x); -- this isn't right -- typo?
- */
-
-/* from sox g711.c */
-#define QUANT_MASK (0xf) /* Quantization field mask. */
-#define SEG_SHIFT (4) /* Left shift for segment number. */
-
-static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
-
-static int search(int val, short *table, int size)
-{
- int i;
- for (i = 0; i < size; i++) {if (val <= *table++) return (i);}
- return (size);
-}
-
-static unsigned char to_alaw(int pcm_val)
-{
- int mask, seg;
- if (pcm_val >= 0) mask = 0xD5; else {mask = 0x55; pcm_val = -pcm_val - 8;}
- seg = search(pcm_val, seg_end, 8);
- if (seg >= 8) return (0x7F ^ mask);
- else
- {
- unsigned char aval;
- aval = seg << SEG_SHIFT;
- if (seg < 2) aval |= (pcm_val >> 4) & QUANT_MASK; else aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
- return (aval ^ mask);
- }
-}
-
-static const int alaw[256] = {
- -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
- -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
- -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944, -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136,
- -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472, -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568,
- -344, -328, -376, -360, -280, -264, -312, -296, -472, -456, -504, -488, -408, -392, -440, -424,
- -88, -72, -120, -104, -24, -8, -56, -40, -216, -200, -248, -232, -152, -136, -184, -168,
- -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
- -688, -656, -752, -720, -560, -528, -624, -592, -944, -912, -1008, -976, -816, -784, -880, -848,
- 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
- 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
- 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
- 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
- 344, 328, 376, 360, 280, 264, 312, 296, 472, 456, 504, 488, 408, 392, 440, 424,
- 88, 72, 120, 104, 24, 8, 56, 40, 216, 200, 248, 232, 152, 136, 184, 168,
- 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
- 688, 656, 752, 720, 560, 528, 624, 592, 944, 912, 1008, 976, 816, 784, 880, 848
-};
-
-#define BIAS (0x84) /* Bias for linear code. */
-
-static unsigned char to_mulaw(int pcm_val)
-{
- int mask;
- int seg;
- if (pcm_val < 0) {pcm_val = BIAS - pcm_val; mask = 0x7F;} else {pcm_val += BIAS; mask = 0xFF;}
- seg = search(pcm_val, seg_end, 8);
- if (seg >= 8) return (0x7F ^ mask);
- else
- {
- unsigned char uval;
- uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF);
- return (uval ^ mask);
- }
-}
-
-/* generated by SNDiMulaw on a NeXT */
-static const int mulaw[256] = {
- -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, -23932, -22908, -21884, -20860,
- -19836, -18812, -17788, -16764, -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,
- -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, -7932, -7676, -7420, -7164, -6908,
- -6652, -6396, -6140, -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, -3900, -3772, -3644,
- -3516, -3388, -3260, -3132, -3004, -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, -1884,
- -1820, -1756, -1692, -1628, -1564, -1500, -1436, -1372, -1308, -1244, -1180, -1116, -1052, -988,
- -924, -876, -844, -812, -780, -748, -716, -684, -652, -620, -588, -556, -524, -492, -460, -428,
- -396, -372, -356, -340, -324, -308, -292, -276, -260, -244, -228, -212, -196, -180, -164, -148,
- -132, -120, -112, -104, -96, -88, -80, -72, -64, -56, -48, -40, -32, -24, -16, -8, 0, 32124, 31100,
- 30076, 29052, 28028, 27004, 25980, 24956, 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764,
- 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, 11900, 11388, 10876, 10364, 9852, 9340,
- 8828, 8316, 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, 5884, 5628, 5372, 5116, 4860, 4604,
- 4348, 4092, 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, 2876, 2748, 2620, 2492, 2364, 2236,
- 2108, 1980, 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, 1372, 1308, 1244, 1180, 1116, 1052,
- 988, 924, 876, 844, 812, 780, 748, 716, 684, 652, 620, 588, 556, 524, 492, 460, 428, 396, 372,
- 356, 340, 324, 308, 292, 276, 260, 244, 228, 212, 196, 180, 164, 148, 132, 120, 112, 104, 96,
- 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0};
-
-
-
-/* ---------------- read ---------------- */
-
-#define BUFLIM (64 * 1024)
-
-#if SNDLIB_USE_FLOATS
- #define MUS_SAMPLE_UNSCALED(n) ((n) / 32768.0)
-#else
- #define MUS_SAMPLE_UNSCALED(n) ((n) * (1 << (MUS_SAMPLE_BITS - 16)))
-#endif
-
-static int mus_read_any_1(int tfd, int beg, int chans, int nints, mus_sample_t **bufs, mus_sample_t **cm, char *inbuf)
-{
- int loclim;
- io_fd *fd;
- int bytes, j, lim, siz, total, leftover, total_read, k, loc, oldloc, siz_chans, buflim, format;
- unsigned char *jchar;
- char *charbuf = NULL;
- mus_sample_t *buffer;
- float prescaling;
- bool from_buffer = false;
- if (nints <= 0) return(0);
- if (inbuf) from_buffer = true;
- if (!from_buffer)
- {
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL))
- return(mus_error(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED, "mus_read: no file descriptors!"));
- fd = io_fds[tfd];
- if (fd->data_format == MUS_UNKNOWN)
- return(mus_error(MUS_FILE_CLOSED, "mus_read: invalid data format for %s", fd->name));
- format = fd->data_format;
- siz = fd->bytes_per_sample;
- if ((format == MUS_OUT_FORMAT) &&
- (chans == 1) &&
- (beg == 0)
-#if SNDLIB_USE_FLOATS
- && (fd->prescaler == 1.0)
-#endif
- )
- {
- bytes = nints * siz;
- total = read(tfd, (char *)(bufs[0]), bytes);
- if (total != bytes)
- {
- if (total <= 0)
- memset((void *)(bufs[0]), 0, bytes);
- else
- {
- int i, last;
- last = beg + nints;
- for (i = total / siz; i < last; i++)
- bufs[0][i] = MUS_SAMPLE_0;
- }
- }
- return(total / siz);
- }
-
- prescaling = (float)(fd->prescaler * MUS_FLOAT_TO_SAMPLE(1.0));
- /* not MUS_FLOAT_TO_SAMPLE(fd->prescaler) here because there's a possible cast to int which can overflow */
-
- charbuf = (char *)CALLOC(BUFLIM, sizeof(char));
- if (charbuf == NULL)
- return(mus_error(MUS_MEMORY_ALLOCATION_FAILED, "mus_read: IO buffer allocation failed"));
- }
- else
- {
- charbuf = inbuf;
- siz = mus_bytes_per_sample(tfd);
- prescaling = (float)(MUS_FLOAT_TO_SAMPLE(1.0));
- format = tfd;
- }
- siz_chans = siz * chans;
- leftover = (nints * siz_chans);
- k = (BUFLIM) % siz_chans;
- if (k != 0) /* for example, 3 channel output of 1-byte (mulaw) samples will need a mod 3 buffer */
- buflim = (BUFLIM) - k;
- else buflim = BUFLIM;
- total_read = 0;
- loc = beg;
- while (leftover > 0)
- {
- bytes = leftover;
- if (bytes > buflim)
- {
- leftover = (bytes - buflim);
- bytes = buflim;
- }
- else leftover = 0;
- if (!from_buffer)
- {
- total = read(tfd, charbuf, bytes);
- if (total <= 0)
- {
- /* zero out trailing section (some callers don't check the returned value) -- this added 9-May-99 */
-
- lim = beg + nints;
- if (loc < lim)
- for (k = 0; k < chans; k++)
- if ((cm == NULL) || (cm[k]))
- {
- if (loc == 0)
- memset((void *)(bufs[k]), 0, lim * sizeof(mus_sample_t));
- else
- for (j = loc; j < lim; j++)
- bufs[k][j] = MUS_SAMPLE_0;
- }
- FREE(charbuf);
- return(total_read);
- }
- lim = (int) (total / siz_chans); /* this divide must be exact (hence the buflim calc above) */
- }
- else
- {
- lim = nints; /* frames in this case */
- leftover = 0;
- }
- total_read += lim;
- oldloc = loc;
-
- for (k = 0; k < chans; k++)
- {
- if ((cm == NULL) || (cm[k]))
- {
- buffer = (mus_sample_t *)(bufs[k]);
- if (buffer)
- {
- loc = oldloc;
- loclim = loc + lim;
- jchar = (unsigned char *)charbuf;
- jchar += (k * siz);
- switch (format)
- {
- case MUS_BSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_SHORT_TO_SAMPLE(m_big_endian_short(jchar));
- break;
- case MUS_LSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_SHORT_TO_SAMPLE(m_little_endian_short(jchar));
- break;
- case MUS_BINT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_INT_TO_SAMPLE(m_big_endian_int(jchar));
- break;
- case MUS_LINT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_INT_TO_SAMPLE(m_little_endian_int(jchar));
- break;
- case MUS_BINTN:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_INT_TO_SAMPLE((m_big_endian_int(jchar) >> (32 - MUS_SAMPLE_BITS)));
- break;
- case MUS_LINTN:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_INT_TO_SAMPLE((m_little_endian_int(jchar) >> (32 - MUS_SAMPLE_BITS)));
- break;
- case MUS_MULAW:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_SHORT_TO_SAMPLE(mulaw[*jchar]);
- break;
- case MUS_ALAW:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_SHORT_TO_SAMPLE(alaw[*jchar]);
- break;
- case MUS_BYTE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_BYTE_TO_SAMPLE((signed char)(*jchar));
- break;
- case MUS_UBYTE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_BYTE_TO_SAMPLE((int)(*jchar) - 128);
- break;
- case MUS_BFLOAT:
- if (prescaling == 1.0)
- {
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (m_big_endian_float(jchar));
- }
- else
- {
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (prescaling * (m_big_endian_float(jchar)));
- }
- break;
- case MUS_BFLOAT_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (MUS_SAMPLE_UNSCALED(m_big_endian_float(jchar)));
- break;
- case MUS_BDOUBLE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (prescaling * (m_big_endian_double(jchar)));
- break;
- case MUS_BDOUBLE_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (MUS_SAMPLE_UNSCALED(m_big_endian_double(jchar)));
- break;
- case MUS_LFLOAT:
- if (prescaling == 1.0)
- {
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (m_little_endian_float(jchar));
- }
- else
- {
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (prescaling * (m_little_endian_float(jchar)));
- }
- break;
- case MUS_LFLOAT_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (MUS_SAMPLE_UNSCALED(m_little_endian_float(jchar)));
- break;
- case MUS_LDOUBLE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (prescaling * (m_little_endian_double(jchar)));
- break;
- case MUS_LDOUBLE_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = (mus_sample_t) (MUS_SAMPLE_UNSCALED(m_little_endian_double(jchar)));
- break;
- case MUS_UBSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_SHORT_TO_SAMPLE((int)(m_big_endian_unsigned_short(jchar)) - 32768);
- break;
- case MUS_ULSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_SHORT_TO_SAMPLE((int)(m_little_endian_unsigned_short(jchar)) - 32768);
- break;
- case MUS_B24INT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_INT24_TO_SAMPLE((int)(((jchar[0] << 24) +
- (jchar[1] << 16) +
- (jchar[2] << 8)) >> 8));
- break;
- case MUS_L24INT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- buffer[loc] = MUS_INT24_TO_SAMPLE((int)(((jchar[2] << 24) +
- (jchar[1] << 16) +
- (jchar[0] << 8)) >> 8));
- break;
- }
- }
- }
- }
- }
- if (!from_buffer) FREE(charbuf);
- return(total_read);
-}
-
-int mus_file_read_any(int tfd, int beg, int chans, int nints, mus_sample_t **bufs, mus_sample_t **cm)
-{
- return(mus_read_any_1(tfd, beg, chans, nints, bufs, cm, NULL));
-}
-
-int mus_file_read_file(int tfd, int beg, int chans, int nints, mus_sample_t **bufs)
-{
- return(mus_read_any_1(tfd, beg, chans, nints, bufs, NULL, NULL));
-}
-
-int mus_file_read_buffer(int charbuf_data_format, int beg, int chans, int nints, mus_sample_t **bufs, char *charbuf)
-{
- return(mus_read_any_1(charbuf_data_format, beg, chans, nints, bufs, NULL, charbuf));
-}
-
-int mus_file_read(int tfd, int beg, int end, int chans, mus_sample_t **bufs)
-{
- int num, rtn, i, k;
- num = (end - beg + 1);
- rtn = mus_read_any_1(tfd, beg, chans, num, bufs, NULL, NULL);
- if (rtn == MUS_ERROR) return(MUS_ERROR);
- if (rtn < num)
- /* this zeroing can be fooled if the file is chunked and has trailing, non-data chunks */
- for (k = 0; k < chans; k++)
- {
- mus_sample_t *buffer;
- buffer = bufs[k];
- i = rtn + beg;
- /* this happens routinely in mus_outa + initial write (reads ahead in effect) */
- memset((void *)(buffer + i), 0, (end - i + 1) * sizeof(mus_sample_t));
- }
- return(num);
-}
-
-int mus_file_read_chans(int tfd, int beg, int end, int chans, mus_sample_t **bufs, mus_sample_t **cm)
-{
- /* an optimization of mus_file_read -- just reads the desired channels */
- int num, rtn, i, k;
- num = (end - beg + 1);
- rtn = mus_read_any_1(tfd, beg, chans, num, bufs, cm, NULL);
- if (rtn == MUS_ERROR) return(MUS_ERROR);
- if (rtn < num)
- for (k = 0; k < chans; k++)
- if ((cm == NULL) || (cm[k]))
- {
- mus_sample_t *buffer;
- buffer = bufs[k];
- i = rtn + beg;
- memset((void *)(buffer + i), 0, (end - i + 1) * sizeof(mus_sample_t));
- }
- return(num);
-}
-
-
-/* ---------------- write ---------------- */
-
-static int checked_write(int tfd, char *buf, int chars)
-{
- int bytes;
- bytes = write(tfd, buf, chars);
- if (bytes != chars)
- {
- io_fd *fd;
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL))
- return(mus_error(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED, "mus_write: no file descriptors!"));
- fd = io_fds[tfd];
- if (fd->data_format == MUS_UNKNOWN)
- return(mus_error(MUS_FILE_CLOSED,
- "attempt to write closed file %s",
- fd->name));
- else
- return(mus_error(MUS_WRITE_ERROR,
- "mus_write: write error for %s%s%s: only %d of %d bytes written",
- fd->name, (errno) ? ": " : "", (errno) ? STRERROR(errno) : "",
- bytes, chars));
- }
- return(MUS_NO_ERROR);
-}
-
-static int mus_write_1(int tfd, int beg, int end, int chans, mus_sample_t **bufs, char *inbuf, bool clipped)
-{
- int loclim, c3;
- int err;
- io_fd *fd;
- int bytes, j, k, lim, siz, leftover, loc, bk, val, oldloc, buflim, siz_chans, cliploc, data_format;
- bool clipping = false;
- unsigned char *jchar;
- char *charbuf = NULL;
- bool to_buffer = false;
- mus_sample_t *buffer;
- if (chans <= 0) return(0);
- if (inbuf) to_buffer = true;
- if (!to_buffer)
- {
- if ((io_fds == NULL) || (tfd >= io_fd_size) || (tfd < 0) || (io_fds[tfd] == NULL))
- return(mus_error(MUS_FILE_DESCRIPTORS_NOT_INITIALIZED, "mus_write: no file descriptors!"));
- fd = io_fds[tfd];
- if (fd->data_format == MUS_UNKNOWN)
- return(mus_error(MUS_FILE_CLOSED, "mus_write: invalid data format for %s", fd->name));
-
- siz = fd->bytes_per_sample;
- data_format = fd->data_format;
- clipping = fd->clipping;
-
- if ((data_format == MUS_OUT_FORMAT) && (chans == 1) && (!clipping) && (beg == 0))
- {
- bytes = (end + 1) * siz;
- return(checked_write(tfd, (char *)(bufs[0]), bytes));
- }
- charbuf = (char *)CALLOC(BUFLIM, sizeof(char));
- if (charbuf == NULL)
- return(mus_error(MUS_MEMORY_ALLOCATION_FAILED, "mus_write: IO buffer allocation failed"));
- }
- else
- {
- charbuf = inbuf;
- siz = mus_bytes_per_sample(tfd);
- data_format = tfd; /* in this case, tfd is the data format (see mus_file_write_buffer below) -- this should be changed! */
- clipping = clipped;
- }
- lim = (end - beg + 1);
- siz_chans = siz * chans;
- leftover = lim * siz_chans;
- k = (BUFLIM) % siz_chans;
- if (k != 0)
- buflim = (BUFLIM) - k;
- else buflim = BUFLIM;
- loc = beg;
- while (leftover > 0)
- {
- bytes = leftover;
- if (bytes > buflim)
- {
- leftover = (bytes - buflim);
- bytes = buflim;
- }
- else leftover = 0;
- lim = (int)(bytes / siz_chans); /* see note above */
- oldloc = loc;
-
- for (k = 0; k < chans; k++)
- {
- if (bufs[k] == NULL) continue;
- loc = oldloc;
- buffer = (mus_sample_t *)(bufs[k]);
- if (clipping)
- {
- cliploc = oldloc;
- for (j = 0; j < lim; j++, cliploc++)
- if (buffer[cliploc] > MUS_SAMPLE_MAX)
- buffer[cliploc] = MUS_SAMPLE_MAX;
- else
- if (buffer[cliploc] < MUS_SAMPLE_MIN)
- buffer[cliploc] = MUS_SAMPLE_MIN;
- }
- loclim = loc + lim;
- jchar = (unsigned char *)charbuf; /* if to_buffer we should add the loop offset here, or never loop */
- jchar += (k * siz);
- switch (data_format)
- {
- case MUS_BSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_short(jchar, MUS_SAMPLE_TO_SHORT(buffer[loc]));
- break;
- case MUS_LSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_short(jchar, MUS_SAMPLE_TO_SHORT(buffer[loc]));
- break;
- case MUS_BINT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_int(jchar, MUS_SAMPLE_TO_INT(buffer[loc]));
- break;
- case MUS_LINT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_int(jchar, MUS_SAMPLE_TO_INT(buffer[loc]));
- break;
- case MUS_BINTN:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_int(jchar, MUS_SAMPLE_TO_INT(buffer[loc]) << (32 - MUS_SAMPLE_BITS));
- break;
- case MUS_LINTN:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_int(jchar, MUS_SAMPLE_TO_INT(buffer[loc]) << (32 - MUS_SAMPLE_BITS));
- break;
- case MUS_MULAW:
- for (; loc < loclim; loc++, jchar += siz_chans)
- (*jchar) = to_mulaw(MUS_SAMPLE_TO_SHORT(buffer[loc]));
- break;
- case MUS_ALAW:
- for (; loc < loclim; loc++, jchar += siz_chans)
- (*jchar) = to_alaw(MUS_SAMPLE_TO_SHORT(buffer[loc]));
- break;
- case MUS_BYTE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- (*((signed char *)jchar)) = MUS_SAMPLE_TO_BYTE(buffer[loc]);
- break;
- case MUS_UBYTE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- (*jchar) = MUS_SAMPLE_TO_BYTE(buffer[loc]) + 128;
- break;
- case MUS_BFLOAT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_float(jchar, MUS_SAMPLE_TO_FLOAT(buffer[loc]));
- break;
- case MUS_LFLOAT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_float(jchar, MUS_SAMPLE_TO_FLOAT(buffer[loc]));
- break;
- case MUS_BDOUBLE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_double(jchar, MUS_SAMPLE_TO_DOUBLE(buffer[loc]));
- break;
- case MUS_LDOUBLE:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_double(jchar, MUS_SAMPLE_TO_DOUBLE(buffer[loc]));
- break;
- case MUS_BFLOAT_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_float(jchar, 32768.0 * MUS_SAMPLE_TO_FLOAT(buffer[loc]));
- break;
- case MUS_LFLOAT_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_float(jchar, 32768.0 * MUS_SAMPLE_TO_FLOAT(buffer[loc]));
- break;
- case MUS_BDOUBLE_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_double(jchar, 32768.0 * MUS_SAMPLE_TO_DOUBLE(buffer[loc]));
- break;
- case MUS_LDOUBLE_UNSCALED:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_double(jchar, 32768.0 * MUS_SAMPLE_TO_DOUBLE(buffer[loc]));
- break;
- case MUS_UBSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_big_endian_unsigned_short(jchar, (unsigned short)(MUS_SAMPLE_TO_SHORT(buffer[loc]) + 32768));
- break;
- case MUS_ULSHORT:
- for (; loc < loclim; loc++, jchar += siz_chans)
- m_set_little_endian_unsigned_short(jchar, (unsigned short)(MUS_SAMPLE_TO_SHORT(buffer[loc]) + 32768));
- break;
- case MUS_B24INT:
- bk = (k * 3);
- c3 = chans * 3;
- for (; loc < loclim; loc++, bk += c3)
- {
- val = MUS_SAMPLE_TO_INT24(buffer[loc]);
- charbuf[bk] = (val >> 16);
- charbuf[bk + 1] = (val >> 8);
- charbuf[bk + 2] = (val & 0xFF);
- }
- break;
- case MUS_L24INT:
- bk = (k * 3);
- c3 = chans * 3;
- for (; loc < loclim; loc++, bk += c3)
- {
- val = MUS_SAMPLE_TO_INT24(buffer[loc]);
- charbuf[bk + 2] = (val >> 16);
- charbuf[bk + 1] = (val >> 8);
- charbuf[bk] = (val & 0xFF);
- }
- break;
- }
- }
- if (!to_buffer)
- {
- err = checked_write(tfd, charbuf, bytes);
- if (err == MUS_ERROR)
- {
- FREE(charbuf);
- return(MUS_ERROR);
- }
- }
- }
- if (!to_buffer) FREE(charbuf);
- return(MUS_NO_ERROR);
-}
-
-int mus_file_write(int tfd, int beg, int end, int chans, mus_sample_t **bufs)
-{
- return(mus_write_1(tfd, beg, end, chans, bufs, NULL, false));
-}
-
-int mus_file_write_file(int tfd, int beg, int end, int chans, mus_sample_t **bufs)
-{
- return(mus_write_1(tfd, beg, end, chans, bufs, NULL, false));
-}
-
-int mus_file_write_buffer(int charbuf_data_format, int beg, int end, int chans, mus_sample_t **bufs, char *charbuf, bool clipped)
-{
- return(mus_write_1(charbuf_data_format, beg, end, chans, bufs, charbuf, clipped));
-}
-
-
-/* for CLM */
-void mus_reset_io_c(void)
-{
- io_fd_size = 0;
- io_fds = NULL;
- clipping_default = false;
- prescaler_default = 1.0;
-}
-
-
-#if (!HAVE_STRDUP)
-/* this taken from libit-0.7 */
-char *strdup (const char *str)
-{
- char *newstr;
- newstr = (char *)malloc(strlen(str) + 1);
- if (newstr) strcpy(newstr, str);
- return(newstr);
-}
-#endif
-
-#if (!HAVE_FILENO)
-/* this is needed by XtAppAddInput */
-int fileno(FILE *fp)
-{
- if (fp == stdout)
- return(0);
- else
- {
- if (fp == stdin)
- return(1);
- }
- return(2);
-}
-#endif
-
-static int sndlib_strlen(const char *str)
-{
- /* strlen(NULL) -> seg fault! */
- if ((str) && (*str)) return(strlen(str));
- return(0);
-}
-
-char *mus_getcwd(void)
-{
- int i, path_max = 0;
- char *pwd = NULL, *res = NULL;
-#if HAVE_PATHCONF
- path_max = pathconf("/", _PC_PATH_MAX);
-#endif
- if (path_max < 1024)
- {
-#if defined(PATH_MAX)
- path_max = PATH_MAX;
-#endif
- if (path_max < 1024)
- path_max = 1024;
- }
-#if HAVE_GETCWD
- for (i = path_max;; i *= 2)
- {
- if (pwd) FREE(pwd);
- pwd = (char *)CALLOC(i, sizeof(char));
- res = getcwd(pwd, i);
- if (res) break; /* NULL is returned if failure, but what about success? should I check errno=ERANGE? */
- }
-#else
-#if HAVE_GETWD
- pwd = (char *)CALLOC(path_max, sizeof(char));
- getwd(pwd);
-#endif
-#endif
- return(pwd);
-}
-
-char *mus_expand_filename(const char *filename)
-{
- /* fill out under-specified library pathnames etc */
-#if defined(MUS_WINDOZE) && (!(defined(__CYGWIN__)))
- return(strdup(filename));
-#else
- char *file_name_buf = NULL;
- char *tok = NULL, *orig = NULL;
- int i, j = 0, len = 0;
- if ((filename) && (*filename))
- len = strlen(filename);
- else return(NULL);
- if (len == 0) return(NULL);
- orig = strdup(filename);
- tok = orig;
- /* get rid of "//" */
- for (i = 0; i < len - 1; i++)
- {
- if ((tok[i] == '/') &&
- (tok[i + 1] == '/'))
- j = i + 1;
- }
- if (j > 0)
- {
- for (i = 0; j < len; i++, j++)
- tok[i] = tok[j];
- tok[i] ='\0';
- }
- /* get rid of "~/" at start */
- if (tok[0] != '/')
- {
- char *home = NULL;
- if ((tok[0] == '~') && (home = getenv("HOME")))
- {
- file_name_buf = (char *)CALLOC(len + sndlib_strlen(home) + 8, sizeof(char));
- strcpy(file_name_buf, home);
- strcat(file_name_buf, ++tok);
- }
- else
- {
- char *pwd;
- pwd = mus_getcwd();
- file_name_buf = (char *)CALLOC(len + sndlib_strlen(pwd) + 8, sizeof(char));
- strcpy(file_name_buf, pwd);
- FREE(pwd);
- strcat(file_name_buf, "/");
- if (tok[0])
- strcat(file_name_buf, tok);
- }
- }
- else
- {
- file_name_buf = (char *)CALLOC(len + 8, sizeof(char));
- strcpy(file_name_buf, tok);
- }
- /* get rid of "/../" and "/./" also "/." at end */
- {
- int slash_at = -1;
- bool found_one = true;
- while (found_one)
- {
- found_one = false;
- len = strlen(file_name_buf);
- for (i = 0; i < len - 3; i++)
- if (file_name_buf[i] == '/')
- {
- if ((file_name_buf[i + 1] == '.') &&
- (file_name_buf[i + 2] == '.') &&
- (file_name_buf[i + 3] == '/'))
- {
- i += 4;
- for (j = slash_at + 1; i < len; i++, j++)
- file_name_buf[j] = file_name_buf[i];
- file_name_buf[j] = '\0';
- found_one = true;
- break;
- }
- else
- {
- if ((file_name_buf[i + 1] == '.') &&
- (file_name_buf[i + 2] == '/'))
- {
- for (j = i + 3, i = i + 1; j < len; i++, j++)
- file_name_buf[i] = file_name_buf[j];
- file_name_buf[i] = '\0';
- found_one = true;
- }
- else slash_at = i;
- }
- }
- }
- len = strlen(file_name_buf);
- if ((len > 1) &&
- (file_name_buf[len - 1] == '.') &&
- (file_name_buf[len - 2] == '/'))
- file_name_buf[len - 1] = '\0';
- }
- free(orig);
- return(file_name_buf);
-#endif
-}
-
-
-void mus_snprintf(char *buffer, int buffer_len, const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
-#if HAVE_VSNPRINTF
- vsnprintf(buffer, buffer_len, format, ap);
-#else
- vsprintf(buffer, format, ap);
-#endif
- va_end(ap);
-}
-
-#define MUS_FORMAT_STRING_MAX 1024
-
-char *mus_format(const char *format, ...)
-{
- /* caller should free result */
- char *buf = NULL, *rtn = NULL;
- va_list ap;
- buf = (char *)CALLOC(MUS_FORMAT_STRING_MAX, sizeof(char));
- va_start(ap, format);
-#if HAVE_VSNPRINTF
- vsnprintf(buf, MUS_FORMAT_STRING_MAX, format, ap);
-#else
- vsprintf(buf, format, ap);
-#endif
- va_end(ap);
-#if MUS_DEBUGGING
- rtn = copy_string(buf);
-#else
- rtn = strdup(buf);
-#endif
- FREE(buf);
- return(rtn);
-}
-
-Float mus_fclamp(Float lo, Float val, Float hi)
-{
- if (val > hi)
- return(hi);
- else
- if (val < lo)
- return(lo);
- else return(val);
-}
-
-int mus_iclamp(int lo, int val, int hi)
-{
- if (val > hi)
- return(hi);
- else
- if (val < lo)
- return(lo);
- else return(val);
-}
-
-off_t mus_oclamp(off_t lo, off_t val, off_t hi)
-{
- if (val > hi)
- return(hi);
- else
- if (val < lo)
- return(lo);
- else return(val);
-}
diff --git a/third_party/resample/sndlib-20/makefile.in b/third_party/resample/sndlib-20/makefile.in
deleted file mode 100644
index 72bf7c2d..00000000
--- a/third_party/resample/sndlib-20/makefile.in
+++ /dev/null
@@ -1,88 +0,0 @@
-SHELL = /bin/sh
-top_srcdir = .
-
-INSTALL = @INSTALL@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-datarootdir = @datarootdir@
-bindir = @bindir@
-srcdir = @srcdir@
-mandir = @mandir@
-libdir = @libdir@
-includedir = @includedir@
-VPATH = @srcdir@
-mkinstalldirs = $(SHELL) $(srcdir)/mkinstalldirs
-
-CC = @CC@
-DEFS = @DEFS@
-CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-
-GUILE_LIBS = @GUILE_LIBS@
-GUILE_CFLAGS = @GUILE_CFLAGS@
-AUDIO_LIB = @AUDIO_LIB@
-GSL_LIBS = @GSL_LIBS@
-GSL_FLAGS = @GSL_CFLAGS@
-
-LDSO_FLAGS = @LDSO_FLAGS@
-SO_FLAGS = @SO_FLAGS@
-SO_INSTALL = @SO_INSTALL@
-A_INSTALL = @A_INSTALL@
-SO_LD = @SO_LD@
-A_LD = @A_LD@
-A_LD_FLAGS = @A_LD_FLAGS@
-LD_FLAGS = @LD_FLAGS@
-
-.c.o:
- $(CC) -c $(DEFS) $(CFLAGS) $(SO_FLAGS) $(GUILE_CFLAGS) $<
-
-SNDLIB_HEADERS = sndlib.h sndlib-strings.h vct.h clm.h xen.h sndlib2xen.h clm2xen.h
-SNDLIB_O_FILES = headers.o audio.o io.o sound.o xen.o vct.o clm.o sndlib2xen.o clm2xen.o midi.o
-SNDLIB_SIMPLE_O_FILES = headers.o audio.o io.o sound.o
-
-
-sndlib: $(SNDLIB_HEADERS) $(SNDLIB_O_FILES)
- $(SO_LD) $(LDFLAGS) $(SNDLIB_O_FILES) -o sndlib.so $(LDSO_FLAGS) $(AUDIO_LIB) $(GSL_LIBS) $(GUILE_LIBS) $(LIBS)
-# $(A_LD) $(LD_FLAGS) $(LDFLAGS) $(SNDLIB_O_FILES) -o sndlib.a $(A_LD_FLAGS) $(AUDIO_LIB) $(GSL_LIBS) $(GUILE_LIBS) $(LIBS)
- $(A_LD) $(A_LD_FLAGS) sndlib.a $(SNDLIB_O_FILES)
-
-$(SNDLIB_O_FILES): $(SNDLIB_HEADERS)
-
-clean:
- rm -f $(SNDLIB_O_FILES)
-
-sndplay: $(SNDLIB_HEADERS) $(SNDLIB_O_FILES) sndplay.o
- $(CC) sndplay.c -o sndplay $(SNDLIB_SIMPLE_O_FILES) $(AUDIO_LIB) $(LIBS)
-
-sndrecord: $(SNDLIB_HEADERS) $(SNDLIB_O_FILES) sndrecord.o
- $(CC) sndrecord.c -o sndrecord $(SNDLIB_SIMPLE_O_FILES) $(AUDIO_LIB) $(LIBS)
-
-sndinfo: $(SNDLIB_HEADERS) $(SNDLIB_O_FILES) sndinfo.o
- $(CC) sndinfo.c -o sndinfo $(SNDLIB_SIMPLE_O_FILES) $(AUDIO_LIB) $(LIBS)
-
-audinfo: $(SNDLIB_HEADERS) $(SNDLIB_O_FILES) audinfo.o
- $(CC) audinfo.c -o audinfo $(SNDLIB_SIMPLE_O_FILES) $(AUDIO_LIB) $(LIBS)
-
-install: sndlib
- $(mkinstalldirs) $(bindir)
- $(mkinstalldirs) $(libdir)
- $(mkinstalldirs) $(includedir)
- $(SO_INSTALL) sndlib.so $(libdir)/libsndlib.so
- $(A_INSTALL) sndlib.a $(libdir)/libsndlib.a
- $(INSTALL) sndlib-config $(bindir)/sndlib-config
- $(INSTALL) sndlib.h $(includedir)/sndlib.h
-
-uninstall:
- rm -f $(libdir)/libsndlib.so
- rm -f $(libdir)/libsndlib.a
-
-Makefile: Makefile.in config.status
- ./config.status
-
-config.status: configure
- ./config.status --recheck
-
-configure: configure.in
- cd $(srcdir); autoconf
-
diff --git a/third_party/resample/sndlib-20/mus-config.h b/third_party/resample/sndlib-20/mus-config.h
deleted file mode 100644
index b32abfd6..00000000
--- a/third_party/resample/sndlib-20/mus-config.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* mus-config.h. Generated from mus-config.h.in by configure. */
-#ifndef SNDLIB_CONFIG_H_LOADED
-#define SNDLIB_CONFIG_H_LOADED
-
-/* Define to `int' or something if <sys/types.h> doesn't define. */
-/* #undef mode_t */
-/* #undef pid_t */
-/* #undef size_t */
-/* #undef off_t */
-
-#define HAVE_GETCWD 1
-#define HAVE_STRFTIME 1
-#define HAVE_STRERROR 1
-#define HAVE_ACCESS 1
-#define HAVE_VSNPRINTF 1
-#define HAVE_SNPRINTF 1
-#define HAVE_MEMMOVE 1
-#define HAVE_STRDUP 1
-#define HAVE_FILENO 1
-#define HAVE_COMPLEX_TRIG 1
-/* #undef WORDS_BIGENDIAN */
-
-#define HAVE_FCNTL_H 1
-#define HAVE_LIMITS_H 1
-#define HAVE_STRING_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_STDBOOL_H 1
-#define HAVE_SYS_SOUNDCARD_H 1
-/* #undef HAVE_MACHINE_SOUNDCARD_H */
-/* #undef HAVE_SYS_MIXER_H */
-/* #undef MUS_HAVE_USR_LIB_OSS */
-/* #undef MUS_HAVE_USR_LOCAL_LIB_OSS */
-/* #undef MUS_HAVE_OPT_OSS */
-/* #undef MUS_HAVE_VAR_LIB_OSS */
-/* #undef HAVE_LIBC_H */
-#define HAVE_ALSA_ASOUNDLIB_H 1
-#define HAVE_BYTESWAP_H 1
-#define HAVE_STDINT_H 1
-
-#define SIZEOF_OFF_T 8
-#define HAVE_DECL_ISNAN 1
-#define HAVE_DECL_ISINF 1
-
-#define MUS_LINUX 1
-/* #undef MUS_SGI */
-/* #undef MUS_ALPHA */
-/* #undef MUS_SUN */
-/* #undef MUS_OPENBSD */
-/* #undef MUS_NETBSD */
-/* #undef MUS_WINDOZE */
-#define HAVE_OSS 1
-/* #undef HAVE_ALSA */
-/* #undef HAVE_JACK */
-/* #undef HAVE_SAM_9407 */
-/* #undef MUS_MAC_OSX */
-/* #undef MUS_ESD */
-/* #undef MUS_HPUX */
-
-#define HAVE_GUILE 0
-/* #undef HAVE_SCHEME */
-/* #undef HAVE_RUBY */
-/* #undef HAVE_FORTH */
-/* #undef HAVE_GAUCHE */
-#define HAVE_EXTENSION_LANGUAGE 0
-/* #undef SND_CONFIG_GET_ID_ARGS */
-#define Float float
-#define _FILE_OFFSET_BITS 64
-/* #undef _LARGE_FILES */
-/* #undef HAVE_GSL */
-#define SNDLIB_USE_FLOATS 0
-#define MUS_SAMPLE_BITS 24
-/* #undef MUS_ESD_VERSION */
-/* #undef MUS_AUDIOFILE_VERSION */
-/* #undef HAVE_READLINE */
-/* #undef HAVE_APPLICABLE_SMOB */
-/* #undef HAVE_SCM_REMEMBER_UPTO_HERE */
-/* #undef HAVE_SCM_MAKE_REAL */
-/* #undef HAVE_SCM_OBJECT_TO_STRING */
-/* #undef HAVE_SCM_NUM2LONG_LONG */
-/* #undef HAVE_SCM_C_MAKE_VECTOR */
-/* #undef HAVE_SCM_C_DEFINE */
-/* #undef HAVE_SCM_C_DEFINE_GSUBR */
-/* #undef HAVE_SCM_C_EVAL_STRING */
-/* #undef HAVE_SCM_NUM2INT */
-/* #undef HAVE_SCM_LIST_N */
-/* #undef HAVE_SCM_STR2SYMBOL */
-/* #undef HAVE_SCM_T_CATCH_BODY */
-/* #undef HAVE_SCM_TO_SIGNED_INTEGER */
-/* #undef HAVE_SCM_C_MAKE_RECTANGULAR */
-/* #undef HAVE_SCM_CAR */
-/* #undef HAVE_SCM_FROM_LOCALE_KEYWORD */
-/* #undef HAVE_SCM_IS_VECTOR */
-/* #undef HAVE_SCM_IS_SIMPLE_VECTOR */
-/* #undef HAVE_RB_GC_DISABLE */
-/* #undef HAVE_RB_ARY_DUP */
-/* #undef WITH_MODULES */
-/* #undef HAVE_KAUDIODEVICEPROPERTYTRANSPORTTYPE */
-/* #undef HAVE_KLINEARPCMFORMATFLAGISNONINTERLEAVED */
-/* #undef WITH_HOBBIT */
-
-#define MUS_OUT_FORMAT MUS_LFLOAT
-#define USE_SND 0
-#endif
diff --git a/third_party/resample/sndlib-20/sndins/Makefile.in b/third_party/resample/sndlib-20/sndins/Makefile.in
deleted file mode 100644
index 1c2837c2..00000000
--- a/third_party/resample/sndlib-20/sndins/Makefile.in
+++ /dev/null
@@ -1,61 +0,0 @@
-# Makefile for libsndins.so
-
-prefix = @prefix@
-srcdir = @srcdir@
-libdir = $(prefix)/lib
-top_builddir = ..
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-includedir = @includedir@
-SHELL = @SHELL@
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-
-CC = @CC@
-DEFS = @DEFS@
-CFLAGS = @CFLAGS@ -fPIC
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-XEN_CFLAGS = @GUILE_CFLAGS@
-XEN_LIBS = @GUILE_LIBS@
-GSL_FLAGS = @GSL_CFLAGS@
-GSL_LIBS = @GSL_LIBS@
-
-INSTALL = @INSTALL@
-SO_INSTALL = @SO_INSTALL@
-SO_LD = @SO_LD@
-A_LD = ar
-A_LD_FLAGS = cr
-LD_FLAGS = @LD_FLAGS@
-LDSO_FLAGS = @LDSO_FLAGS@
-
-OBJS = sndins.o $(top_builddir)/sndlib.a
-SO_TARGET = libsndins.so
-A_TARGET = libsndins.a
-LIB_TARGET = sndins.so
-
-.c.o:
- $(CC) -c $(DEFS) $(CFLAGS) $(XEN_CFLAGS) $(GSL_FLAGS) -I$(top_builddir) -I$(top_srcdir) $<
-
-sndins: $(OBJS)
- $(SO_LD) $(LDSO_FLAGS) $(LDFLAGS) -o $(SO_TARGET) $(OBJS) $(XEN_LIBS) $(GSL_LIBS) $(LIBS)
- $(A_LD) $(A_LD_FLAGS) $(A_TARGET) $(OBJS)
- ranlib $(A_TARGET)
- cp $(SO_TARGET) $(LIB_TARGET)
-
-install: sndins
- $(mkinstalldirs) $(libdir)
- $(mkinstalldirs) $(includedir)
- $(INSTALL) $(A_TARGET) $(libdir)/$(A_TARGET)
- $(SO_INSTALL) $(SO_TARGET) $(libdir)/$(SO_TARGET)
-
-uninstall:
- rm -f $(libdir)/$(A_TARGET)
- rm -f $(libdir)/$(SO_TARGET)
-
-clean:
- rm -f *.so *.a *.o *.core core 0
-
-distclean: clean
- rm -f Makefile *~
-
-# Makefile ends here
diff --git a/third_party/resample/sndlib-20/sndlib-strings.h b/third_party/resample/sndlib-20/sndlib-strings.h
deleted file mode 100644
index ce35b49d..00000000
--- a/third_party/resample/sndlib-20/sndlib-strings.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#ifndef SNDLIB_STRINGS_H
-#define SNDLIB_STRINGS_H
-
-#define S_array_to_file "array->file"
-#define S_file_to_array "file->array"
-#define S_make_sound_data "make-sound-data"
-#define S_mus_aifc "mus-aifc"
-#define S_mus_aiff "mus-aiff"
-#define S_mus_alaw "mus-alaw"
-#define S_mus_alsa_buffer_size "mus-alsa-buffer-size"
-#define S_mus_alsa_buffers "mus-alsa-buffers"
-#define S_mus_alsa_capture_device "mus-alsa-capture-device"
-#define S_mus_alsa_device "mus-alsa-device"
-#define S_mus_alsa_playback_device "mus-alsa-playback-device"
-#define S_mus_alsa_squelch_warning "mus-alsa-squelch-warning"
-#define S_mus_audio_adat_in "mus-audio-adat-in"
-#define S_mus_audio_adat_out "mus-audio-adat-out"
-#define S_mus_audio_aes_in "mus-audio-aes-in"
-#define S_mus_audio_aes_out "mus-audio-aes-out"
-#define S_mus_audio_amp "mus-audio-amp"
-#define S_mus_audio_aux_input "mus-audio-aux-input"
-#define S_mus_audio_aux_output "mus-audio-aux-output"
-#define S_mus_audio_bass "mus-audio-bass"
-#define S_mus_audio_cd "mus-audio-cd"
-#define S_mus_audio_channel "mus-audio-channel"
-#define S_mus_audio_close "mus-audio-close"
-#define S_mus_audio_dac_filter "mus-audio-dac-filter"
-#define S_mus_audio_dac_out "mus-audio-dac-out"
-#define S_mus_audio_default "mus-audio-default"
-#define S_mus_audio_digital_in "mus-audio-digital-in"
-#define S_mus_audio_digital_out "mus-audio-digital-out"
-#define S_mus_audio_direction "mus-audio-direction"
-#define S_mus_audio_duplex_default "mus-audio-duplex-default"
-#define S_mus_audio_format "mus-audio-format"
-#define S_mus_audio_igain "mus-audio-igain"
-#define S_mus_audio_imix "mus-audio-imix"
-#define S_mus_audio_line "mus-audio-line"
-#define S_mus_audio_line1 "mus-audio-line1"
-#define S_mus_audio_line2 "mus-audio-line2"
-#define S_mus_audio_line3 "mus-audio-line3"
-#define S_mus_audio_line_in "mus-audio-line-in"
-#define S_mus_audio_line_out "mus-audio-line-out"
-#define S_mus_audio_microphone "mus-audio-microphone"
-#define S_mus_audio_mixer "mus-audio-mixer"
-#define S_mus_audio_mixer_read "mus-audio-mixer-read"
-#define S_mus_audio_mixer_write "mus-audio-mixer-write"
-#define S_mus_audio_ogain "mus-audio-ogain"
-#define S_mus_audio_open_input "mus-audio-open-input"
-#define S_mus_audio_open_output "mus-audio-open-output"
-#define S_mus_audio_pcm "mus-audio-pcm"
-#define S_mus_audio_pcm2 "mus-audio-pcm2"
-#define S_mus_audio_port "mus-audio-port"
-#define S_mus_audio_read "mus-audio-read"
-#define S_mus_audio_reclev "mus-audio-reclev"
-#define S_mus_audio_report "mus-audio-report"
-#define S_mus_audio_samples_per_channel "mus-audio-samples-per-channel"
-#define S_mus_audio_spdif_in "mus-audio-spdif-in"
-#define S_mus_audio_spdif_out "mus-audio-spdif-out"
-#define S_mus_audio_speakers "mus-audio-speakers"
-#define S_mus_audio_srate "mus-audio-srate"
-#define S_mus_audio_synth "mus-audio-synth"
-#define S_mus_audio_systems "mus-audio-systems"
-#define S_mus_audio_treble "mus-audio-treble"
-#define S_mus_audio_write "mus-audio-write"
-#define S_mus_b24int "mus-b24int"
-#define S_mus_bdouble "mus-bdouble"
-#define S_mus_bdouble_unscaled "mus-bdouble-unscaled"
-#define S_mus_bfloat "mus-bfloat"
-#define S_mus_bfloat_unscaled "mus-bfloat-unscaled"
-#define S_mus_bicsf "mus-bicsf"
-#define S_mus_bint "mus-bint"
-#define S_mus_bintn "mus-bintn"
-#define S_mus_bshort "mus-bshort"
-#define S_mus_byte "mus-byte"
-#define S_mus_bytes_per_sample "mus-bytes-per-sample"
-#define S_mus_clipping "mus-clipping"
-#define S_mus_data_format_name "mus-data-format-name"
-#define S_mus_data_format_to_string "mus-data-format->string"
-#define S_mus_error_type_to_string "mus-error-type->string"
-#define S_mus_expand_filename "mus-expand-filename"
-#define S_mus_file_clipping "mus-file-clipping"
-#define S_mus_file_prescaler "mus-file-prescaler"
-#define S_mus_header_raw_defaults "mus-header-raw-defaults"
-#define S_mus_header_type_name "mus-header-type-name"
-#define S_mus_header_type_to_string "mus-header-type->string"
-#define S_mus_ircam "mus-ircam"
-#define S_mus_l24int "mus-l24int"
-#define S_mus_ldouble "mus-ldouble"
-#define S_mus_ldouble_unscaled "mus-ldouble-unscaled"
-#define S_mus_lfloat "mus-lfloat"
-#define S_mus_lfloat_unscaled "mus-lfloat-unscaled"
-#define S_mus_lint "mus-lint"
-#define S_mus_lintn "mus-lintn"
-#define S_mus_lshort "mus-lshort"
-#define S_mus_mulaw "mus-mulaw"
-#define S_mus_netbsd_set_outputs "mus-netbsd-set-outputs"
-#define S_mus_next "mus-next"
-#define S_mus_nist "mus-nist"
-#define S_mus_oss_set_buffers "mus-oss-set-buffers"
-#define S_mus_out_format "mus-out-format"
-#define S_mus_prescaler "mus-prescaler"
-#define S_mus_raw "mus-raw"
-#define S_mus_riff "mus-riff"
-#define S_mus_sound_chans "mus-sound-chans"
-#define S_mus_sound_close_input "mus-sound-close-input"
-#define S_mus_sound_close_output "mus-sound-close-output"
-#define S_mus_sound_comment "mus-sound-comment"
-#define S_mus_sound_data_format "mus-sound-data-format"
-#define S_mus_sound_data_location "mus-sound-data-location"
-#define S_mus_sound_datum_size "mus-sound-datum-size"
-#define S_mus_sound_duration "mus-sound-duration"
-#define S_mus_sound_forget "mus-sound-forget"
-#define S_mus_sound_frames "mus-sound-frames"
-#define S_mus_sound_header_type "mus-sound-header-type"
-#define S_mus_sound_length "mus-sound-length"
-#define S_mus_sound_loop_info "mus-sound-loop-info"
-#define S_mus_sound_maxamp "mus-sound-maxamp"
-#define S_mus_sound_maxamp_exists "mus-sound-maxamp-exists?"
-#define S_mus_sound_open_input "mus-sound-open-input"
-#define S_mus_sound_open_output "mus-sound-open-output"
-#define S_mus_sound_prune "mus-sound-prune"
-#define S_mus_sound_read "mus-sound-read"
-#define S_mus_sound_reopen_output "mus-sound-reopen-output"
-#define S_mus_sound_report_cache "mus-sound-report-cache"
-#define S_mus_sound_samples "mus-sound-samples"
-#define S_mus_sound_seek_frame "mus-sound-seek-frame"
-#define S_mus_sound_srate "mus-sound-srate"
-#define S_mus_sound_type_specifier "mus-sound-type-specifier"
-#define S_mus_sound_write "mus-sound-write"
-#define S_mus_sound_write_date "mus-sound-write-date"
-#define S_mus_soundfont "mus-soundfont"
-#define S_mus_sun_set_outputs "mus-sun-set-outputs"
-#define S_mus_svx "mus-svx"
-#define S_mus_ubshort "mus-ubshort"
-#define S_mus_ubyte "mus-ubyte"
-#define S_mus_ulshort "mus-ulshort"
-#define S_mus_unknown "mus-unknown"
-#define S_mus_unsupported "mus-unsupported"
-#define S_mus_voc "mus-voc"
-#define S_new_sound_hook "new-sound-hook"
-#define S_sound_data_to_vct "sound-data->vct"
-#define S_sound_data_chans "sound-data-chans"
-#define S_sound_data_length "sound-data-length"
-#define S_sound_data_maxamp "sound-data-maxamp"
-#define S_sound_data_p "sound-data?"
-#define S_sound_data_ref "sound-data-ref"
-#define S_sound_data_setB "sound-data-set!"
-#define S_vct_to_sound_data "vct->sound-data"
-
-#endif
diff --git a/third_party/resample/sndlib-20/sndlib.h b/third_party/resample/sndlib-20/sndlib.h
deleted file mode 100644
index 61b749da..00000000
--- a/third_party/resample/sndlib-20/sndlib.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/* sndlib.h. Generated from sndlib.h.in by configure. */
-#ifndef SNDLIB_H
-#define SNDLIB_H
-
-#define SNDLIB_VERSION 20
-#define SNDLIB_REVISION 0
-#define SNDLIB_DATE "28-Mar-06"
-
-#include <stdio.h>
-
-/* these are picked up during configuration */
-
-#define MUS_LITTLE_ENDIAN 1
-#define SNDLIB_USE_FLOATS 0
-#define MUS_SAMPLE_BITS 24
-#define MUS_AUDIO_COMPATIBLE_FORMAT MUS_LSHORT
-#define MUS_OUT_FORMAT MUS_LFLOAT
-#define Float float
-
-#include <time.h>
-/* time_t used by mus_sound_write_date */
-#include <sys/types.h>
-/* off_t used everywhere -- should this be redefined to long if not defined in types.h? */
-
-/* not sure how to handle this one cleanly: */
-#ifndef __cplusplus
-#if HAVE_STDBOOL_H
- #include <stdbool.h>
-#else
-#ifndef true
- #define bool int
- #define true 1
- #define false 0
-#endif
-#endif
-#endif
-
-
-
-#if (!SNDLIB_USE_FLOATS)
- #define mus_sample_t int
- #ifndef MUS_SAMPLE_BITS
- #define MUS_SAMPLE_BITS 24
- #endif
- #define MUS_SAMPLE_0 0
- #define MUS_BYTE_TO_SAMPLE(n) ((mus_sample_t)((n) << (MUS_SAMPLE_BITS - 8)))
- #define MUS_SAMPLE_TO_BYTE(n) ((n) >> (MUS_SAMPLE_BITS - 8))
- #define MUS_SHORT_TO_SAMPLE(n) ((mus_sample_t)((n) << (MUS_SAMPLE_BITS - 16)))
- #define MUS_SAMPLE_TO_SHORT(n) ((short)((n) >> (MUS_SAMPLE_BITS - 16)))
- #if (MUS_SAMPLE_BITS < 24)
- #define MUS_INT24_TO_SAMPLE(n) ((mus_sample_t)((n) >> (24 - MUS_SAMPLE_BITS)))
- #define MUS_SAMPLE_TO_INT24(n) ((int)((n) << (24 - MUS_SAMPLE_BITS)))
- #else
- #define MUS_INT24_TO_SAMPLE(n) ((mus_sample_t)((n) << (MUS_SAMPLE_BITS - 24)))
- #define MUS_SAMPLE_TO_INT24(n) ((int)((n) >> (MUS_SAMPLE_BITS - 24)))
- #endif
- #define MUS_INT_TO_SAMPLE(n) ((mus_sample_t)(n))
- #define MUS_SAMPLE_TO_INT(n) ((int)(n))
- /* these are for direct read/write (no cross-image assumption is made about 32 bit int scaling) */
- #define MUS_FLOAT_TO_FIX ((MUS_SAMPLE_BITS < 32) ? (1 << (MUS_SAMPLE_BITS - 1)) : 0x7fffffff)
- #define MUS_FIX_TO_FLOAT (1.0 / (float)(MUS_FLOAT_TO_FIX))
- #define MUS_FLOAT_TO_SAMPLE(n) ((mus_sample_t)((n) * MUS_FLOAT_TO_FIX))
- #define MUS_SAMPLE_TO_FLOAT(n) ((float)((n) * MUS_FIX_TO_FLOAT))
- #define MUS_DOUBLE_TO_SAMPLE(n) ((mus_sample_t)((n) * MUS_FLOAT_TO_FIX))
- #define MUS_SAMPLE_TO_DOUBLE(n) ((double)((n) * MUS_FIX_TO_FLOAT))
- #define MUS_SAMPLE_MAX ((mus_sample_t)((MUS_SAMPLE_BITS < 32) ? (MUS_FLOAT_TO_FIX - 1) : 0x7fffffff))
- #define MUS_SAMPLE_MIN ((mus_sample_t)((MUS_SAMPLE_BITS < 32) ? (-(MUS_FLOAT_TO_FIX)) : -0x7fffffff))
- #define mus_sample_abs(Sample) abs(Sample)
-#else
- #define mus_sample_t Float
- #ifndef MUS_SAMPLE_BITS
- #define MUS_SAMPLE_BITS 24
- #endif
- #define MUS_SAMPLE_0 0.0
- #define MUS_BYTE_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << 7)))
- #define MUS_SHORT_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << 15)))
- #define MUS_INT_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << (MUS_SAMPLE_BITS - 1))))
- #define MUS_INT24_TO_SAMPLE(n) ((mus_sample_t)((Float)(n) / (Float)(1 << 23)))
- #define MUS_FLOAT_TO_FIX 1.0
- #define MUS_FIX_TO_FLOAT 1.0
- #define MUS_FLOAT_TO_SAMPLE(n) ((mus_sample_t)(n))
- #define MUS_DOUBLE_TO_SAMPLE(n) ((mus_sample_t)(n))
- #define MUS_SAMPLE_TO_FLOAT(n) ((Float)(n))
- #define MUS_SAMPLE_TO_DOUBLE(n) ((double)(n))
- #define MUS_SAMPLE_TO_INT(n) ((int)((n) * (1 << (MUS_SAMPLE_BITS - 1))))
- #define MUS_SAMPLE_TO_INT24(n) ((int)((n) * (1 << 23)))
- #define MUS_SAMPLE_TO_SHORT(n) ((short)((n) * (1 << 15)))
- #define MUS_SAMPLE_TO_BYTE(n) ((char)((n) * (1 << 7)))
- #define MUS_SAMPLE_MAX 0.99999
- #define MUS_SAMPLE_MIN (-1.0)
- #define mus_sample_abs(Sample) fabs(Sample)
-#endif
-
-enum {MUS_UNSUPPORTED, MUS_NEXT, MUS_AIFC, MUS_RIFF, MUS_BICSF, MUS_NIST, MUS_INRS, MUS_ESPS, MUS_SVX, MUS_VOC,
- MUS_SNDT, MUS_RAW, MUS_SMP, MUS_AVR, MUS_IRCAM, MUS_SD1, MUS_SPPACK, MUS_MUS10, MUS_HCOM, MUS_PSION, MUS_MAUD,
- MUS_IEEE, MUS_MATLAB, MUS_ADC, MUS_MIDI, MUS_SOUNDFONT, MUS_GRAVIS, MUS_COMDISCO, MUS_GOLDWAVE, MUS_SRFS,
- MUS_MIDI_SAMPLE_DUMP, MUS_DIAMONDWARE, MUS_ADF, MUS_SBSTUDIOII, MUS_DELUSION,
- MUS_FARANDOLE, MUS_SAMPLE_DUMP, MUS_ULTRATRACKER, MUS_YAMAHA_SY85, MUS_YAMAHA_TX16W, MUS_DIGIPLAYER,
- MUS_COVOX, MUS_AVI, MUS_OMF, MUS_QUICKTIME, MUS_ASF, MUS_YAMAHA_SY99, MUS_KURZWEIL_2000,
- MUS_AIFF, MUS_PAF, MUS_CSL, MUS_FILE_SAMP, MUS_PVF, MUS_SOUNDFORGE, MUS_TWINVQ, MUS_AKAI4,
- MUS_IMPULSETRACKER, MUS_KORG, MUS_NVF, MUS_MAUI, MUS_SDIF, MUS_OGG, MUS_FLAC, MUS_SPEEX, MUS_MPEG,
- MUS_SHORTEN, MUS_TTA, MUS_WAVPACK,
- MUS_NUM_HEADER_TYPES};
-
-#if defined(__GNUC__) && (!(defined(__cplusplus)))
- #define MUS_HEADER_TYPE_OK(n) ({ int _sndlib_h_0 = n; ((_sndlib_h_0 > MUS_UNSUPPORTED) && (_sndlib_h_0 <= MUS_MAUI)); })
-#else
- #define MUS_HEADER_TYPE_OK(n) (((n) > MUS_UNSUPPORTED) && ((n) <= MUS_MAUI))
-#endif
-
-enum {MUS_UNKNOWN, MUS_BSHORT, MUS_MULAW, MUS_BYTE, MUS_BFLOAT, MUS_BINT, MUS_ALAW, MUS_UBYTE, MUS_B24INT,
- MUS_BDOUBLE, MUS_LSHORT, MUS_LINT, MUS_LFLOAT, MUS_LDOUBLE, MUS_UBSHORT, MUS_ULSHORT, MUS_L24INT,
- MUS_BINTN, MUS_LINTN, MUS_BFLOAT_UNSCALED, MUS_LFLOAT_UNSCALED, MUS_BDOUBLE_UNSCALED, MUS_LDOUBLE_UNSCALED,
- MUS_NUM_DATA_FORMATS};
-
-/* MUS_LINTN and MUS_BINTN refer to 32 bit ints with 31 bits of "fraction" -- the data is "left justified" */
-/* "unscaled" means the float value is used directly (i.e. not as -1.0 to 1.0, but (probably) -32768.0 to 32768.0) */
-
-#if defined(__GNUC__) && (!(defined(__cplusplus)))
- #define MUS_DATA_FORMAT_OK(n) ({ int _sndlib_h_1 = n; ((_sndlib_h_1 > MUS_UNKNOWN) && (_sndlib_h_1 < MUS_NUM_DATA_FORMATS)); })
-#else
- #define MUS_DATA_FORMAT_OK(n) (((n) > MUS_UNKNOWN) && ((n) < MUS_NUM_DATA_FORMATS))
-#endif
-
-#define MUS_NIST_SHORTPACK 2
-#define MUS_AIFF_IMA_ADPCM 99
-
-#define MUS_AUDIO_PACK_SYSTEM(n) ((n) << 16)
-#define MUS_AUDIO_SYSTEM(n) (((n) >> 16) & 0xffff)
-#define MUS_AUDIO_DEVICE(n) ((n) & 0xffff)
-
-enum {MUS_AUDIO_DEFAULT, MUS_AUDIO_DUPLEX_DEFAULT, MUS_AUDIO_ADAT_IN, MUS_AUDIO_AES_IN, MUS_AUDIO_LINE_OUT,
- MUS_AUDIO_LINE_IN, MUS_AUDIO_MICROPHONE, MUS_AUDIO_SPEAKERS, MUS_AUDIO_DIGITAL_IN, MUS_AUDIO_DIGITAL_OUT,
- MUS_AUDIO_DAC_OUT, MUS_AUDIO_ADAT_OUT, MUS_AUDIO_AES_OUT, MUS_AUDIO_DAC_FILTER, MUS_AUDIO_MIXER,
- MUS_AUDIO_LINE1, MUS_AUDIO_LINE2, MUS_AUDIO_LINE3, MUS_AUDIO_AUX_INPUT, MUS_AUDIO_CD,
- MUS_AUDIO_AUX_OUTPUT, MUS_AUDIO_SPDIF_IN, MUS_AUDIO_SPDIF_OUT, MUS_AUDIO_AMP, MUS_AUDIO_SRATE,
- MUS_AUDIO_CHANNEL, MUS_AUDIO_FORMAT, MUS_AUDIO_IMIX, MUS_AUDIO_IGAIN, MUS_AUDIO_RECLEV,
- MUS_AUDIO_PCM, MUS_AUDIO_PCM2, MUS_AUDIO_OGAIN, MUS_AUDIO_LINE, MUS_AUDIO_SYNTH,
- MUS_AUDIO_BASS, MUS_AUDIO_TREBLE, MUS_AUDIO_PORT, MUS_AUDIO_SAMPLES_PER_CHANNEL,
- MUS_AUDIO_DIRECTION
-};
-/* Snd's recorder uses MUS_AUDIO_DIRECTION to find the size of this list */
-
-#if defined(__GNUC__) && (!(defined(__cplusplus)))
- #define MUS_AUDIO_DEVICE_OK(a) ({ int _sndlib_h_2 = a; ((_sndlib_h_2 >= MUS_AUDIO_DEFAULT) && (_sndlib_h_2 <= MUS_AUDIO_DIRECTION)); })
-#else
- #define MUS_AUDIO_DEVICE_OK(a) (((a) >= MUS_AUDIO_DEFAULT) && ((a) <= MUS_AUDIO_DIRECTION))
-#endif
-
-#define MUS_ERROR -1
-
-enum {MUS_NO_ERROR, MUS_NO_FREQUENCY, MUS_NO_PHASE, MUS_NO_GEN, MUS_NO_LENGTH,
- MUS_NO_FREE, MUS_NO_DESCRIBE, MUS_NO_DATA, MUS_NO_SCALER,
- MUS_MEMORY_ALLOCATION_FAILED, MUS_UNSTABLE_TWO_POLE_ERROR,
- MUS_CANT_OPEN_FILE, MUS_NO_SAMPLE_INPUT, MUS_NO_SAMPLE_OUTPUT,
- MUS_NO_SUCH_CHANNEL, MUS_NO_FILE_NAME_PROVIDED, MUS_NO_LOCATION, MUS_NO_CHANNEL,
- MUS_NO_SUCH_FFT_WINDOW, MUS_UNSUPPORTED_DATA_FORMAT, MUS_HEADER_READ_FAILED,
- MUS_UNSUPPORTED_HEADER_TYPE,
- MUS_FILE_DESCRIPTORS_NOT_INITIALIZED, MUS_NOT_A_SOUND_FILE, MUS_FILE_CLOSED, MUS_WRITE_ERROR,
- MUS_HEADER_WRITE_FAILED, MUS_CANT_OPEN_TEMP_FILE, MUS_INTERRUPTED, MUS_BAD_ENVELOPE,
-
- MUS_AUDIO_CHANNELS_NOT_AVAILABLE, MUS_AUDIO_SRATE_NOT_AVAILABLE, MUS_AUDIO_FORMAT_NOT_AVAILABLE,
- MUS_AUDIO_NO_INPUT_AVAILABLE, MUS_AUDIO_CONFIGURATION_NOT_AVAILABLE,
- MUS_AUDIO_NO_LINES_AVAILABLE, MUS_AUDIO_WRITE_ERROR, MUS_AUDIO_SIZE_NOT_AVAILABLE, MUS_AUDIO_DEVICE_NOT_AVAILABLE,
- MUS_AUDIO_CANT_CLOSE, MUS_AUDIO_CANT_OPEN, MUS_AUDIO_READ_ERROR, MUS_AUDIO_AMP_NOT_AVAILABLE,
- MUS_AUDIO_CANT_WRITE, MUS_AUDIO_CANT_READ, MUS_AUDIO_NO_READ_PERMISSION,
- MUS_CANT_CLOSE_FILE, MUS_ARG_OUT_OF_RANGE,
- MUS_MIDI_OPEN_ERROR, MUS_MIDI_READ_ERROR, MUS_MIDI_WRITE_ERROR, MUS_MIDI_CLOSE_ERROR, MUS_MIDI_INIT_ERROR, MUS_MIDI_MISC_ERROR,
-
- MUS_NO_CHANNELS, MUS_NO_HOP, MUS_NO_WIDTH, MUS_NO_FILE_NAME, MUS_NO_RAMP, MUS_NO_RUN,
- MUS_NO_INCREMENT, MUS_NO_OFFSET,
- MUS_NO_XCOEFF, MUS_NO_YCOEFF, MUS_NO_XCOEFFS, MUS_NO_YCOEFFS, MUS_NO_RESET,
- MUS_INITIAL_ERROR_TAG};
-
-/* keep this list in sync with mus_error_names in sound.c and snd-test.scm|rb */
-
-#define MUS_LOOP_INFO_SIZE 8
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* -------- sound.c -------- */
-
-#ifdef __GNUC__
- int mus_error(int error, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
- void mus_print(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
- char *mus_format(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
- void mus_snprintf(char *buffer, int buffer_len, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-#else
- int mus_error(int error, const char *format, ...);
- void mus_print(const char *format, ...);
- char *mus_format(const char *format, ...);
- void mus_snprintf(char *buffer, int buffer_len, const char *format, ...);
-#endif
-
-typedef void mus_error_handler_t(int type, char *msg);
-mus_error_handler_t *mus_error_set_handler (mus_error_handler_t *new_error_handler);
-int mus_make_error(char *error_name);
-const char *mus_error_type_to_string(int err);
-
-typedef void mus_print_handler_t(char *msg);
-mus_print_handler_t *mus_print_set_handler (mus_print_handler_t *new_print_handler);
-
-off_t mus_sound_samples(const char *arg);
-off_t mus_sound_frames(const char *arg);
-int mus_sound_datum_size(const char *arg);
-off_t mus_sound_data_location(const char *arg);
-int mus_sound_chans(const char *arg);
-int mus_sound_srate(const char *arg);
-int mus_sound_header_type(const char *arg);
-int mus_sound_data_format(const char *arg);
-int mus_sound_original_format(const char *arg);
-off_t mus_sound_comment_start(const char *arg);
-off_t mus_sound_comment_end(const char *arg);
-off_t mus_sound_length(const char *arg);
-int mus_sound_fact_samples(const char *arg);
-time_t mus_sound_write_date(const char *arg);
-int mus_sound_type_specifier(const char *arg);
-int mus_sound_block_align(const char *arg);
-int mus_sound_bits_per_sample(const char *arg);
-
-int mus_sound_set_chans(const char *arg, int val);
-int mus_sound_set_srate(const char *arg, int val);
-int mus_sound_set_header_type(const char *arg, int val);
-int mus_sound_set_data_format(const char *arg, int val);
-int mus_sound_set_data_location(const char *arg, off_t val);
-int mus_sound_set_samples(const char *arg, off_t val);
-
-const char *mus_header_type_name(int type);
-const char *mus_data_format_name(int format);
-char *mus_header_type_to_string(int type);
-char *mus_data_format_to_string(int format);
-const char *mus_data_format_short_name(int format);
-char *mus_sound_comment(const char *name);
-int mus_bytes_per_sample(int format);
-float mus_sound_duration(const char *arg);
-int mus_sound_initialize(void);
-int mus_sample_bits(void);
-int mus_sound_override_header(const char *arg, int srate, int chans, int format, int type, off_t location, off_t size);
-int mus_sound_forget(const char *name);
-int mus_sound_prune(void);
-void mus_sound_report_cache(FILE *fp);
-int *mus_sound_loop_info(const char *arg);
-void mus_sound_set_loop_info(const char *arg, int *loop);
-
-int mus_sound_open_input(const char *arg);
-int mus_sound_open_output(const char *arg, int srate, int chans, int data_format, int header_type, const char *comment);
-int mus_sound_reopen_output(const char *arg, int chans, int format, int type, off_t data_loc);
-int mus_sound_close_input(int fd);
-int mus_sound_close_output(int fd, off_t bytes_of_data);
-#define mus_sound_seek_frame(Ifd, Frm) mus_file_seek_frame(Ifd, Frm)
-#define mus_sound_read(Fd, Beg, End, Chans, Bufs) mus_file_read(Fd, Beg, End, Chans, Bufs)
-#define mus_sound_write(Fd, Beg, End, Chans, Bufs) mus_file_write(Fd, Beg, End, Chans, Bufs)
-
-off_t mus_sound_maxamps(const char *ifile, int chans, mus_sample_t *vals, off_t *times);
-int mus_sound_set_maxamps(const char *ifile, int chans, mus_sample_t *vals, off_t *times);
-bool mus_sound_maxamp_exists(const char *ifile);
-int mus_file_to_array(const char *filename, int chan, int start, int samples, mus_sample_t *array);
-int mus_array_to_file(const char *filename, mus_sample_t *ddata, int len, int srate, int channels);
-char *mus_array_to_file_with_error(const char *filename, mus_sample_t *ddata, int len, int srate, int channels);
-int mus_file_to_float_array(const char *filename, int chan, off_t start, int samples, Float *array);
-int mus_float_array_to_file(const char *filename, Float *ddata, int len, int srate, int channels);
-
-
-
-/* -------- audio.c -------- */
-
-void mus_audio_describe(void);
-char *mus_audio_report(void);
-int mus_audio_open_output(int dev, int srate, int chans, int format, int size);
-int mus_audio_open_input(int dev, int srate, int chans, int format, int size);
-int mus_audio_write(int line, char *buf, int bytes);
-int mus_audio_close(int line);
-int mus_audio_read(int line, char *buf, int bytes);
-
-int mus_audio_write_buffers(int line, int frames, int chans, mus_sample_t **bufs, int output_format, bool clipped);
-int mus_audio_read_buffers(int line, int frames, int chans, mus_sample_t **bufs, int input_format);
-
-int mus_audio_mixer_read(int dev, int field, int chan, float *val);
-int mus_audio_mixer_write(int dev, int field, int chan, float *val);
-int mus_audio_initialize(void);
-
-int mus_audio_reinitialize(void); /* 29-Aug-01 for CLM/Snd bugfix? */
-int mus_audio_systems(void);
-char *mus_audio_system_name(int sys);
-char *mus_audio_moniker(void);
-int mus_audio_api(void);
-int mus_audio_compatible_format(int dev);
-
-void mus_netbsd_set_outputs(int speakers, int headphones, int line_out);
-void mus_sun_set_outputs(int speakers, int headphones, int line_out);
-#define mus_audio_sun_outputs mus_sun_set_outputs
-
-void mus_oss_set_buffers(int num, int size);
-#define mus_audio_set_oss_buffers mus_oss_set_buffers
-
-char *mus_alsa_playback_device(void);
-char *mus_alsa_set_playback_device(const char *name);
-char *mus_alsa_capture_device(void);
-char *mus_alsa_set_capture_device(const char *name);
-char *mus_alsa_device(void);
-char *mus_alsa_set_device(const char *name);
-int mus_alsa_buffer_size(void);
-int mus_alsa_set_buffer_size(int size);
-int mus_alsa_buffers(void);
-int mus_alsa_set_buffers(int num);
-bool mus_alsa_squelch_warning(void);
-bool mus_alsa_set_squelch_warning(bool val);
-
-
-
-/* -------- io.c -------- */
-
-int mus_file_open_descriptors(int tfd, const char *arg, int df, int ds, off_t dl, int dc, int dt);
-int mus_file_open_read(const char *arg);
-bool mus_file_probe(const char *arg);
-int mus_file_open_write(const char *arg);
-int mus_file_create(const char *arg);
-int mus_file_reopen_write(const char *arg);
-int mus_file_close(int fd);
-off_t mus_file_seek_frame(int tfd, off_t frame);
-int mus_file_read(int fd, int beg, int end, int chans, mus_sample_t **bufs);
-int mus_file_read_chans(int fd, int beg, int end, int chans, mus_sample_t **bufs, mus_sample_t **cm);
-int mus_file_write(int tfd, int beg, int end, int chans, mus_sample_t **bufs);
-int mus_file_read_any(int tfd, int beg, int chans, int nints, mus_sample_t **bufs, mus_sample_t **cm);
-int mus_file_read_file(int tfd, int beg, int chans, int nints, mus_sample_t **bufs);
-int mus_file_read_buffer(int charbuf_data_format, int beg, int chans, int nints, mus_sample_t **bufs, char *charbuf);
-int mus_file_write_file(int tfd, int beg, int end, int chans, mus_sample_t **bufs);
-int mus_file_write_buffer(int charbuf_data_format, int beg, int end, int chans, mus_sample_t **bufs, char *charbuf, bool clipped);
-char *mus_expand_filename(const char *name);
-char *mus_getcwd(void);
-
-bool mus_clipping(void);
-bool mus_set_clipping(bool new_value);
-bool mus_file_clipping(int tfd);
-int mus_file_set_clipping(int tfd, bool clipped);
-
-int mus_file_set_header_type(int tfd, int type);
-int mus_file_header_type(int tfd);
-char *mus_file_fd_name(int tfd);
-int mus_file_set_chans(int tfd, int chans);
-
-Float mus_file_prescaler(int tfd);
-Float mus_file_set_prescaler(int tfd, Float val);
-Float mus_prescaler(void);
-Float mus_set_prescaler(Float new_value);
-
-void mus_bint_to_char(unsigned char *j, int x);
-int mus_char_to_bint(const unsigned char *inp);
-void mus_lint_to_char(unsigned char *j, int x);
-int mus_char_to_lint(const unsigned char *inp);
-int mus_char_to_uninterpreted_int(const unsigned char *inp);
-void mus_bfloat_to_char(unsigned char *j, float x);
-float mus_char_to_bfloat(const unsigned char *inp);
-void mus_lfloat_to_char(unsigned char *j, float x);
-float mus_char_to_lfloat(const unsigned char *inp);
-void mus_bshort_to_char(unsigned char *j, short x);
-short mus_char_to_bshort(const unsigned char *inp);
-void mus_lshort_to_char(unsigned char *j, short x);
-short mus_char_to_lshort(const unsigned char *inp);
-void mus_ubshort_to_char(unsigned char *j, unsigned short x);
-unsigned short mus_char_to_ubshort(const unsigned char *inp);
-void mus_ulshort_to_char(unsigned char *j, unsigned short x);
-unsigned short mus_char_to_ulshort(const unsigned char *inp);
-double mus_char_to_ldouble(const unsigned char *inp);
-double mus_char_to_bdouble(const unsigned char *inp);
-void mus_bdouble_to_char(unsigned char *j, double x);
-void mus_ldouble_to_char(unsigned char *j, double x);
-unsigned int mus_char_to_ubint(const unsigned char *inp);
-unsigned int mus_char_to_ulint(const unsigned char *inp);
-
-int mus_iclamp(int lo, int val, int hi);
-off_t mus_oclamp(off_t lo, off_t val, off_t hi);
-Float mus_fclamp(Float lo, Float val, Float hi);
-
-/* for CLM */
-/* these are needed to clear a saved lisp image to the just-initialized state */
-void mus_reset_io_c(void);
-void mus_reset_headers_c(void);
-void mus_reset_audio_c(void);
-
-
-
-/* -------- headers.c -------- */
-
-off_t mus_header_samples(void);
-off_t mus_header_data_location(void);
-int mus_header_chans(void);
-int mus_header_srate(void);
-int mus_header_type(void);
-int mus_header_format(void);
-off_t mus_header_comment_start(void);
-off_t mus_header_comment_end(void);
-int mus_header_type_specifier(void);
-int mus_header_bits_per_sample(void);
-int mus_header_fact_samples(void);
-int mus_header_block_align(void);
-int mus_header_loop_mode(int which);
-int mus_header_loop_start(int which);
-int mus_header_loop_end(int which);
-int mus_header_mark_position(int id);
-int mus_header_base_note(void);
-int mus_header_base_detune(void);
-void mus_header_set_raw_defaults(int sr, int chn, int frm);
-void mus_header_raw_defaults(int *sr, int *chn, int *frm);
-off_t mus_header_true_length(void);
-int mus_header_original_format(void);
-off_t mus_samples_to_bytes(int format, off_t size);
-off_t mus_bytes_to_samples(int format, off_t size);
-int mus_header_write_next_header(int chan, int srate, int chans, int loc, int siz, int format, const char *comment, int len);
-int mus_header_read(const char *name);
-int mus_header_write(const char *name, int type, int srate, int chans, off_t loc, off_t size_in_samples, int format, const char *comment, int len);
-off_t mus_header_aux_comment_start(int n);
-off_t mus_header_aux_comment_end(int n);
-int mus_header_initialize(void);
-bool mus_header_writable(int type, int format);
-void mus_header_set_aiff_loop_info(int *data);
-int mus_header_sf2_entries(void);
-char *mus_header_sf2_name(int n);
-int mus_header_sf2_start(int n);
-int mus_header_sf2_end(int n);
-int mus_header_sf2_loop_start(int n);
-int mus_header_sf2_loop_end(int n);
-const char *mus_header_original_format_name(int format, int type);
-bool mus_header_no_header(const char *name);
-
-char *mus_header_riff_aux_comment(const char *name, off_t *starts, off_t *ends);
-char *mus_header_aiff_aux_comment(const char *name, off_t *starts, off_t *ends);
-
-int mus_header_change_chans(const char *filename, int type, int new_chans);
-int mus_header_change_srate(const char *filename, int type, int new_srate);
-int mus_header_change_type(const char *filename, int new_type, int new_format);
-int mus_header_change_format(const char *filename, int type, int new_format);
-int mus_header_change_location(const char *filename, int type, off_t new_location);
-int mus_header_change_comment(const char *filename, int type, char *new_comment);
-int mus_header_change_data_size(const char *filename, int type, off_t bytes);
-
-typedef void mus_header_write_hook_t(const char *filename);
-mus_header_write_hook_t *mus_header_write_set_hook(mus_header_write_hook_t *new_hook);
-
-
-/* -------- midi.c -------- */
-int mus_midi_open_read(const char *name);
-int mus_midi_open_write(const char *name);
-int mus_midi_close(int line);
-int mus_midi_read(int line, unsigned char *buffer, int bytes);
-int mus_midi_write(int line, unsigned char *buffer, int bytes);
-char *mus_midi_device_name(int sysdev);
-char *mus_midi_describe(void);
-void mus_midi_init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/third_party/resample/sndlib-20/sound.c b/third_party/resample/sndlib-20/sound.c
deleted file mode 100644
index 8443dcaa..00000000
--- a/third_party/resample/sndlib-20/sound.c
+++ /dev/null
@@ -1,1072 +0,0 @@
-/* sound.c */
-
-#include <mus-config.h>
-
-#if USE_SND
- #include "snd.h"
-#endif
-
-#include <math.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <stdarg.h>
-
-#if (defined(HAVE_LIBC_H) && (!defined(HAVE_UNISTD_H)))
- #include <libc.h>
-#else
- #if (!(defined(_MSC_VER)))
- #include <unistd.h>
- #endif
- #if HAVE_STRING_H
- #include <string.h>
- #endif
-#endif
-
-#include "_sndlib.h"
-#include "sndlib-strings.h"
-
-static mus_error_handler_t *mus_error_handler = NULL;
-
-mus_error_handler_t *mus_error_set_handler(mus_error_handler_t *new_error_handler)
-{
- mus_error_handler_t *old_handler;
- old_handler = mus_error_handler;
- mus_error_handler = new_error_handler;
- return(old_handler);
-}
-
-#define MUS_ERROR_BUFFER_SIZE 1024
-static char *mus_error_buffer = NULL;
-
-int mus_error(int error, const char *format, ...)
-{
- va_list ap;
- if (format == NULL) return(MUS_ERROR); /* else bus error in Mac OSX */
- if (mus_error_buffer == NULL)
- mus_error_buffer = (char *)CALLOC(MUS_ERROR_BUFFER_SIZE, sizeof(char));
- va_start(ap, format);
-#if HAVE_VSNPRINTF
- vsnprintf(mus_error_buffer, MUS_ERROR_BUFFER_SIZE, format, ap);
-#else
- vsprintf(mus_error_buffer, format, ap);
-#endif
- va_end(ap);
- if (mus_error_handler)
- (*mus_error_handler)(error, mus_error_buffer);
- else
- {
- fprintf(stderr, mus_error_buffer);
- fputc('\n', stderr);
- }
- return(MUS_ERROR);
-}
-
-static mus_print_handler_t *mus_print_handler = NULL;
-
-mus_print_handler_t *mus_print_set_handler(mus_print_handler_t *new_print_handler)
-{
- mus_print_handler_t *old_handler;
- old_handler = mus_print_handler;
- mus_print_handler = new_print_handler;
- return(old_handler);
-}
-
-void mus_print(const char *format, ...)
-{
- va_list ap;
- if (mus_error_buffer == NULL)
- mus_error_buffer = (char *)CALLOC(MUS_ERROR_BUFFER_SIZE, sizeof(char));
- if (mus_print_handler)
- {
- va_start(ap, format);
-#if HAVE_VSNPRINTF
- vsnprintf(mus_error_buffer, MUS_ERROR_BUFFER_SIZE, format, ap);
-#else
- vsprintf(mus_error_buffer, format, ap);
-#endif
- va_end(ap);
- (*mus_print_handler)(mus_error_buffer);
- }
- else
- {
- va_start(ap, format);
- vfprintf(stdout, format, ap);
- va_end(ap);
- }
-}
-
-static const char *mus_initial_error_names[] = {
- "no error", "no frequency method", "no phase method", "null gen arg to method", "no length method",
- "no free method", "no describe method", "no data method", "no scaler method",
- "memory allocation failed", "unstable two pole error",
- "can't open file", "no sample input", "no sample output",
- "no such channel", "no file name provided", "no location method", "no channel method",
- "no such fft window", "unsupported data format", "header read failed",
- "unsupported header type", "file descriptors not initialized", "not a sound file", "file closed", "write error",
- "header write failed", "can't open temp file", "interrupted", "bad envelope",
-
- "audio channels not available", "audio srate not available", "audio format not available",
- "no audio input available", "audio configuration not available",
- "no audio lines available", "audio write error", "audio size not available", "audio device not available",
- "can't close audio", "can't open audio", "audio read error", "audio amp not available",
- "can't write audio", "can't read audio", "no audio read permission",
- "can't close file", "arg out of range",
-
- "midi open error", "midi read error", "midi write error", "midi close error", "midi init error", "midi misc error",
-
- "no channels method", "no hop method", "no width method", "no file-name method", "no ramp method", "no run method",
- "no increment method", "no offset method",
- "no xcoeff method", "no ycoeff method", "no xcoeffs method", "no ycoeffs method",
-};
-
-static char **mus_error_names = NULL;
-static int mus_error_names_size = 0;
-
-static int mus_error_tag = MUS_INITIAL_ERROR_TAG;
-int mus_make_error(char *error_name)
-{
- int new_error, err, len, i;
- new_error = mus_error_tag++;
- err = new_error - MUS_INITIAL_ERROR_TAG;
- if (error_name)
- {
- if (err >= mus_error_names_size)
- {
- if (mus_error_names_size == 0)
- {
- mus_error_names_size = 8;
- mus_error_names = (char **)CALLOC(mus_error_names_size, sizeof(char *));
- }
- else
- {
- len = mus_error_names_size;
- mus_error_names_size += 8;
- mus_error_names = (char **)REALLOC(mus_error_names, mus_error_names_size * sizeof(char *));
- for (i = len; i < mus_error_names_size; i++) mus_error_names[i] = NULL;
- }
- }
- len = strlen(error_name);
- mus_error_names[err] = (char *)CALLOC(len + 1, sizeof(char));
- strcpy(mus_error_names[err], error_name);
- }
- return(new_error);
-}
-
-const char *mus_error_type_to_string(int err)
-{
- if (err >= 0)
- {
- if (err < MUS_INITIAL_ERROR_TAG)
- return(mus_initial_error_names[err]);
- else
- {
- err -= MUS_INITIAL_ERROR_TAG;
- if ((mus_error_names) && (err < mus_error_names_size))
- return(mus_error_names[err]);
- }
- }
- return("unknown mus error");
-}
-
-static void default_mus_error(int ignore, char *msg)
-{
- /* default error handler simply prints the error message */
- fprintf(stderr, msg);
-}
-
-static time_t local_file_write_date(const char *filename)
-{
- struct stat statbuf;
- int err;
- err = stat(filename, &statbuf);
- if (err < 0) return((time_t)0);
- return((time_t)(statbuf.st_mtime));
-}
-
-static bool sndlib_initialized = false;
-
-int mus_sound_initialize(void)
-{
- int err = MUS_NO_ERROR;
- if (!sndlib_initialized)
- {
- sndlib_initialized = true;
- mus_error_handler = default_mus_error;
- err = mus_header_initialize();
- if (err == MUS_NO_ERROR)
- err = mus_audio_initialize();
- return(err);
- }
- return(MUS_NO_ERROR);
-}
-
-int mus_sample_bits(void)
-{
- /* this to check for inconsistent loads */
-#if SNDLIB_USE_FLOATS
- return(sizeof(Float));
-#else
- return(MUS_SAMPLE_BITS);
-#endif
-}
-
-typedef struct {
- char *file_name; /* full path -- everything is keyed to this name */
- int table_pos;
- off_t *aux_comment_start, *aux_comment_end;
- int *loop_modes, *loop_starts, *loop_ends;
- int markers, base_detune, base_note;
- int *marker_ids, *marker_positions;
- off_t samples, true_file_length;
- off_t data_location;
- int srate, chans, header_type, data_format, original_sound_format, datum_size;
- off_t comment_start, comment_end;
- int type_specifier, bits_per_sample, block_align, fact_samples;
- time_t write_date;
- mus_sample_t *maxamps;
- off_t *maxtimes;
-} sound_file;
-
-static int sound_table_size = 0;
-static sound_file **sound_table = NULL;
-static sound_file *previous_sf = NULL; /* memoized search */
-static int previous_freed_sf = -1;
-
-static void free_sound_file(sound_file *sf)
-{
- previous_sf = NULL;
- if (sf)
- {
- sound_table[sf->table_pos] = NULL;
- previous_freed_sf = sf->table_pos;
- if (sf->aux_comment_start) FREE(sf->aux_comment_start);
- if (sf->aux_comment_end) FREE(sf->aux_comment_end);
- if (sf->file_name) FREE(sf->file_name);
- if (sf->loop_modes) FREE(sf->loop_modes);
- if (sf->loop_starts) FREE(sf->loop_starts);
- if (sf->loop_ends) FREE(sf->loop_ends);
- if (sf->marker_ids) FREE(sf->marker_ids);
- if (sf->marker_positions) FREE(sf->marker_positions);
- if (sf->maxamps) FREE(sf->maxamps);
- if (sf->maxtimes) FREE(sf->maxtimes);
- FREE(sf);
- }
-}
-
-static sound_file *add_to_sound_table(const char *name)
-{
- int i, pos;
- pos = previous_freed_sf;
- if (pos == -1)
- {
- for (i = 0; i < sound_table_size; i++)
- if (sound_table[i] == NULL)
- {
- pos = i;
- break;
- }
- if (pos == -1)
- {
- pos = sound_table_size;
- sound_table_size += 16;
- if (sound_table == NULL)
- sound_table = (sound_file **)CALLOC(sound_table_size, sizeof(sound_file *));
- else
- {
- sound_table = (sound_file **)REALLOC(sound_table, sound_table_size * sizeof(sound_file *));
- for (i = pos; i < sound_table_size; i++) sound_table[i] = NULL;
- }
- }
- }
- else previous_freed_sf = -1;
- sound_table[pos] = (sound_file *)CALLOC(1, sizeof(sound_file));
- sound_table[pos]->table_pos = pos;
- sound_table[pos]->file_name = (char *)CALLOC(strlen(name) + 1, sizeof(char));
- strcpy(sound_table[pos]->file_name, name);
- return(sound_table[pos]);
-}
-
-int mus_sound_prune(void)
-{
- int i, pruned = 0;
- for (i = 0; i < sound_table_size; i++)
- if ((sound_table[i]) &&
- (!(mus_file_probe(sound_table[i]->file_name))))
- {
- free_sound_file(sound_table[i]);
- sound_table[i] = NULL;
- pruned++;
- }
- return(pruned);
-}
-
-int mus_sound_forget(const char *name)
-{
- int i, len;
- bool free_name = false;
- char *short_name = NULL;
- if (name == NULL) return(MUS_ERROR);
- if (name[0] == '/')
- {
- len = strlen(name);
- for (i = 0; i < len; i++)
- if (name[i] == '/')
- short_name = (char *)(name + i + 1);
- }
- else
- {
- short_name = mus_expand_filename(name);
- free_name = true;
- }
- previous_sf = NULL;
- if (name)
- for (i = 0; i < sound_table_size; i++)
- if ((sound_table[i]) &&
- ((strcmp(name, sound_table[i]->file_name) == 0) ||
- ((short_name) &&
- (strcmp(short_name, sound_table[i]->file_name) == 0))))
- {
- free_sound_file(sound_table[i]);
- sound_table[i] = NULL;
- }
- if (free_name) FREE(short_name);
- return(MUS_NO_ERROR);
-}
-
-static sound_file *check_write_date(const char *name, sound_file *sf)
-{
- if (sf)
- {
- time_t date;
- date = local_file_write_date(name);
- if (date == sf->write_date)
- return(sf);
- else
- {
- if ((sf->header_type == MUS_RAW) && (mus_header_no_header(name)))
- {
- int chan;
- off_t data_size;
- /* sound has changed since we last read it, but it has no header, so
- * the only sensible thing to check is the new length (i.e. caller
- * has set other fields by hand)
- */
- sf->write_date = date;
- chan = mus_file_open_read(name);
- data_size = lseek(chan, 0L, SEEK_END);
- sf->true_file_length = data_size;
- sf->samples = mus_bytes_to_samples(sf->data_format, data_size);
- CLOSE(chan, name);
- return(sf);
- }
- /* otherwise our data base is out-of-date, so clear it out */
- free_sound_file(sf);
- }
- }
- return(NULL);
-}
-
-static sound_file *find_sound_file(const char *name)
-{
- int i;
- /* perhaps we already have the needed data... (90% hit rate here) */
- if ((previous_sf) &&
- (strcmp(previous_sf->file_name, name) == 0) &&
- (previous_sf->write_date == local_file_write_date(name)))
- return(previous_sf);
- if (name)
- for (i = 0; i < sound_table_size; i++)
- if ((sound_table[i]) &&
- (strcmp(name, sound_table[i]->file_name) == 0))
- {
- previous_sf = check_write_date(name, sound_table[i]);
- return(previous_sf);
- }
- return(NULL);
-}
-
-static void display_sound_file_entry(FILE *fp, const char *name, sound_file *sf)
-{
- int i, lim;
- time_t date;
- char timestr[64];
- char *comment;
- date = sf->write_date;
- if (date != 0)
- {
-#if HAVE_STRFTIME
- strftime(timestr, 64, "%a %d-%b-%Y %H:%M:%S", localtime(&date));
-#else
- sprintf(timestr, "%d", (int)date);
-#endif
- }
- else sprintf(timestr, "(date cleared)");
- fprintf(fp, " %s: %s, chans: %d, srate: %d, type: %s, format: %s, samps: " OFF_TD,
- name,
- timestr,
- sf->chans,
- sf->srate,
- mus_header_type_name(sf->header_type),
- mus_data_format_name(sf->data_format),
- sf->samples);
- if (sf->loop_modes)
- {
- if (sf->loop_modes[0] != 0)
- fprintf(fp, ", loop mode %d: %d to %d", sf->loop_modes[0], sf->loop_starts[0], sf->loop_ends[0]);
- if (sf->loop_modes[1] != 0)
- fprintf(fp, ", loop mode %d: %d to %d, ", sf->loop_modes[1], sf->loop_starts[1], sf->loop_ends[1]);
- fprintf(fp, ", base: %d, detune: %d", sf->base_note, sf->base_detune);
- }
- if (sf->maxamps)
- {
- lim = sf->chans;
- if (lim > 0)
- {
- if (lim > 64)
- lim = 64;
- for (i = 0; i < lim; i++)
- {
- if (i > 1) fprintf(fp, ", ");
- fprintf(fp, " %.3f at %.3f ",
- MUS_SAMPLE_TO_FLOAT(sf->maxamps[i]),
- (sf->srate > 0.0) ? (float)((double)(sf->maxtimes[i]) / (double)(sf->srate)) : (float)(sf->maxtimes[i]));
- }
- }
- }
- if (mus_file_probe(name))
- {
- comment = mus_sound_comment(name);
- if (comment)
- {
- fprintf(fp, "\n comment: %s", comment);
- FREE(comment);
- }
- }
- else fprintf(fp, " [defunct]");
- fprintf(fp, "\n");
-}
-
-void mus_sound_report_cache(FILE *fp)
-{
- sound_file *sf;
- int entries = 0;
- int i;
- fprintf(fp, "sound table:\n");
- for (i = 0; i < sound_table_size; i++)
- {
- sf = sound_table[i];
- if (sf)
- {
- display_sound_file_entry(fp, sf->file_name, sf);
- entries++;
- }
- }
- fprintf(fp, "\nentries: %d\n", entries);
- fflush(fp);
-}
-
-static sound_file *fill_sf_record(const char *name, sound_file *sf)
-{
- int i;
- sf->data_location = mus_header_data_location();
- sf->samples = mus_header_samples();
- sf->data_format = mus_header_format();
- sf->srate = mus_header_srate();
- /* if (sf->srate < 0) sf->srate = 0; */
- sf->chans = mus_header_chans();
- /* if (sf->chans < 0) sf->chans = 0; */
- sf->datum_size = mus_bytes_per_sample(sf->data_format);
- sf->header_type = mus_header_type();
- sf->original_sound_format = mus_header_original_format();
- sf->true_file_length = mus_header_true_length();
- sf->comment_start = mus_header_comment_start();
- sf->comment_end = mus_header_comment_end();
- if (((sf->header_type == MUS_AIFC) ||
- (sf->header_type == MUS_AIFF) ||
- (sf->header_type == MUS_RIFF)) &&
- (mus_header_aux_comment_start(0) != 0))
-
- {
- sf->aux_comment_start = (off_t *)CALLOC(4, sizeof(off_t));
- sf->aux_comment_end = (off_t *)CALLOC(4, sizeof(off_t));
- for (i = 0; i < 4; i++)
- {
- sf->aux_comment_start[i] = mus_header_aux_comment_start(i);
- sf->aux_comment_end[i] = mus_header_aux_comment_end(i);
- }
- }
- sf->type_specifier = mus_header_type_specifier();
- sf->bits_per_sample = mus_header_bits_per_sample();
- sf->fact_samples = mus_header_fact_samples();
- sf->block_align = mus_header_block_align();
- sf->write_date = local_file_write_date(name);
- if (mus_header_loop_mode(0) > 0)
- {
- sf->loop_modes = (int *)CALLOC(2, sizeof(int));
- sf->loop_starts = (int *)CALLOC(2, sizeof(int));
- sf->loop_ends = (int *)CALLOC(2, sizeof(int));
- for (i = 0; i < 2; i++)
- {
- sf->loop_modes[i] = mus_header_loop_mode(i);
- if ((sf->header_type == MUS_AIFF) ||
- (sf->header_type == MUS_AIFC))
- {
- sf->loop_starts[i] = mus_header_mark_position(mus_header_loop_start(i));
- sf->loop_ends[i] = mus_header_mark_position(mus_header_loop_end(i));
- }
- else
- {
- sf->loop_starts[i] = mus_header_loop_start(i);
- sf->loop_ends[i] = mus_header_loop_end(i);
- }
- }
- sf->base_detune = mus_header_base_detune();
- sf->base_note = mus_header_base_note();
- }
- previous_sf = sf;
- return(sf);
-}
-
-static sound_file *read_sound_file_header(const char *name)
-{
- mus_sound_initialize();
- if (mus_header_read(name) != MUS_ERROR)
- return(fill_sf_record(name, add_to_sound_table(name)));
- return(NULL);
-}
-
-static sound_file *getsf(const char *arg)
-{
- sound_file *sf = NULL;
- if (arg == NULL) return(NULL);
- sf = find_sound_file(arg);
- if (sf) return(sf);
- return(read_sound_file_header(arg));
-}
-
-#define MUS_SF(Filename, Expression) \
- sound_file *sf; \
- sf = getsf(Filename); \
- if (sf) return(Expression); \
- return(MUS_ERROR)
-
-off_t mus_sound_samples(const char *arg) {MUS_SF(arg, sf->samples);}
-off_t mus_sound_frames(const char *arg) {MUS_SF(arg, (sf->chans > 0) ? (sf->samples / sf->chans) : 0);}
-int mus_sound_datum_size(const char *arg) {MUS_SF(arg, sf->datum_size);}
-off_t mus_sound_data_location(const char *arg) {MUS_SF(arg, sf->data_location);}
-int mus_sound_chans(const char *arg) {MUS_SF(arg, sf->chans);}
-int mus_sound_srate(const char *arg) {MUS_SF(arg, sf->srate);}
-int mus_sound_header_type(const char *arg) {MUS_SF(arg, sf->header_type);}
-int mus_sound_data_format(const char *arg) {MUS_SF(arg, sf->data_format);}
-int mus_sound_original_format(const char *arg) {MUS_SF(arg, sf->original_sound_format);}
-off_t mus_sound_comment_start(const char *arg) {MUS_SF(arg, sf->comment_start);}
-off_t mus_sound_comment_end(const char *arg) {MUS_SF(arg, sf->comment_end);}
-off_t mus_sound_length(const char *arg) {MUS_SF(arg, sf->true_file_length);}
-int mus_sound_fact_samples(const char *arg) {MUS_SF(arg, sf->fact_samples);}
-time_t mus_sound_write_date(const char *arg) {MUS_SF(arg, sf->write_date);}
-int mus_sound_type_specifier(const char *arg) {MUS_SF(arg, sf->type_specifier);}
-int mus_sound_block_align(const char *arg) {MUS_SF(arg, sf->block_align);}
-int mus_sound_bits_per_sample(const char *arg) {MUS_SF(arg, sf->bits_per_sample);}
-
-float mus_sound_duration(const char *arg)
-{
- float val = -1.0;
- sound_file *sf;
- sf = getsf(arg);
- if (sf)
- {
- if ((sf->chans > 0) && (sf->srate > 0))
- val = (float)((double)(sf->samples) / ((float)(sf->chans) * (float)(sf->srate)));
- else val = 0.0;
- }
- return(val);
-}
-
-int *mus_sound_loop_info(const char *arg)
-{
- sound_file *sf;
- int *info;
- sf = getsf(arg);
- if ((sf) && (sf->loop_modes))
- {
- info = (int *)CALLOC(MUS_LOOP_INFO_SIZE, sizeof(int));
- if (sf->loop_modes[0] != 0)
- {
- info[0] = sf->loop_starts[0];
- info[1] = sf->loop_ends[0];
- info[6] = sf->loop_modes[0];
- }
- if (sf->loop_modes[1] != 0)
- {
- info[2] = sf->loop_starts[1];
- info[3] = sf->loop_ends[1];
- info[7] = sf->loop_modes[1];
- }
- info[4] = sf->base_note;
- info[5] = sf->base_detune;
- return(info);
- }
- else return(NULL);
-}
-
-void mus_sound_set_loop_info(const char *arg, int *loop)
-{
- sound_file *sf;
- sf = getsf(arg);
- if (sf)
- {
- if (sf->loop_modes == NULL)
- {
- sf->loop_modes = (int *)CALLOC(2, sizeof(int));
- sf->loop_starts = (int *)CALLOC(2, sizeof(int));
- sf->loop_ends = (int *)CALLOC(2, sizeof(int));
- }
- sf->loop_modes[0] = loop[6];
- if (loop[6] != 0)
- {
- sf->loop_starts[0] = loop[0];
- sf->loop_ends[0] = loop[1];
- }
- else
- {
- sf->loop_starts[0] = 0;
- sf->loop_ends[0] = 0;
- }
- sf->loop_modes[1] = loop[7];
- if (loop[7] != 0)
- {
- sf->loop_starts[1] = loop[2];
- sf->loop_ends[1] = loop[3];
- }
- else
- {
- sf->loop_starts[1] = 0;
- sf->loop_ends[1] = 0;
- }
- sf->base_note = loop[4];
- sf->base_detune = loop[5];
- }
-}
-
-char *mus_sound_comment(const char *name)
-{
- off_t start, end, len;
- int fd, full_len; /* comment string lengths */
- char *sc = NULL, *auxcom;
- sound_file *sf = NULL;
- sf = getsf(name);
- if (sf == NULL) return(NULL);
- start = mus_sound_comment_start(name);
- end = mus_sound_comment_end(name);
- if (end == 0)
- {
- if (sf->aux_comment_start)
- {
- if (mus_sound_header_type(name) == MUS_RIFF)
- return(mus_header_riff_aux_comment(name,
- sf->aux_comment_start,
- sf->aux_comment_end));
- if ((mus_sound_header_type(name) == MUS_AIFF) ||
- (mus_sound_header_type(name) == MUS_AIFC))
- return(mus_header_aiff_aux_comment(name,
- sf->aux_comment_start,
- sf->aux_comment_end));
- }
- return(NULL);
- }
- if (end > mus_sound_length(name)) return(NULL);
- len = end - start + 1;
- if (len > 0)
- {
- /* open and get the comment */
- size_t bytes;
- fd = mus_file_open_read(name);
- if (fd == -1) return(NULL);
- lseek(fd, start, SEEK_SET);
- sc = (char *)CALLOC(len + 1, sizeof(char));
- bytes = read(fd, sc, len);
- CLOSE(fd, name);
- if (((mus_sound_header_type(name) == MUS_AIFF) ||
- (mus_sound_header_type(name) == MUS_AIFC)) &&
- (sf->aux_comment_start) &&
- (bytes != 0))
- {
- auxcom = mus_header_aiff_aux_comment(name,
- sf->aux_comment_start,
- sf->aux_comment_end);
- if (auxcom)
- {
- full_len = strlen(auxcom) + strlen(sc) + 2;
- sc = (char *)REALLOC(sc, full_len * sizeof(char));
- strcat(sc, "\n");
- strcat(sc, auxcom);
- }
- }
- }
- return(sc);
-}
-
-int mus_sound_open_input(const char *arg)
-{
- int fd = -1;
- if (!(mus_file_probe(arg)))
- mus_error(MUS_CANT_OPEN_FILE, S_mus_sound_open_input " can't open %s: %s", arg, STRERROR(errno));
- else
- {
- sound_file *sf = NULL;
- mus_sound_initialize();
- sf = find_sound_file(arg);
- if (!sf)
- sf = read_sound_file_header(arg);
- if (sf)
- {
- fd = mus_file_open_read(arg);
- mus_file_open_descriptors(fd, arg, sf->data_format, sf->datum_size, sf->data_location, sf->chans, sf->header_type);
- lseek(fd, sf->data_location, SEEK_SET);
- }
- }
- return(fd);
-}
-
-int mus_sound_open_output(const char *arg, int srate, int chans, int data_format, int header_type, const char *comment)
-{
- int fd = MUS_ERROR, err, comlen = 0;
- if (comment) comlen = strlen(comment);
- mus_sound_initialize();
- mus_sound_forget(arg);
- err = mus_header_write(arg, header_type, srate, chans, 0, 0, data_format, comment, comlen);
- if (err != MUS_ERROR)
- {
- fd = mus_file_open_write(arg);
- if (fd != -1)
- mus_file_open_descriptors(fd,
- arg,
- data_format,
- mus_bytes_per_sample(data_format),
- mus_header_data_location(),
- chans,
- header_type);
- }
- return(fd);
-}
-
-int mus_sound_reopen_output(const char *arg, int chans, int format, int type, off_t data_loc)
-{
- int fd;
- mus_sound_initialize();
- fd = mus_file_reopen_write(arg);
- if (fd != -1)
- mus_file_open_descriptors(fd, arg, format, mus_bytes_per_sample(format), data_loc, chans, type);
- return(fd);
-}
-
-int mus_sound_close_input(int fd)
-{
- return(mus_file_close(fd)); /* this closes the clm file descriptors */
-}
-
-int mus_sound_close_output(int fd, off_t bytes_of_data)
-{
- char *name;
- name = mus_file_fd_name(fd);
- if (name)
- {
- int err = MUS_ERROR, old_type;
- char *fname;
- fname = strdup(name); /* strdup defined, if necessary, in io.c */
- old_type = mus_file_header_type(fd);
- err = mus_file_close(fd); /* this frees the original fd->name, so we copied above */
- /* fd is NULL now */
- mus_sound_forget(fname);
- mus_header_change_data_size(fname, old_type, bytes_of_data);
- free(fname);
- return(err);
- }
- return(MUS_ERROR);
-}
-
-typedef enum {SF_CHANS, SF_SRATE, SF_TYPE, SF_FORMAT, SF_LOCATION, SF_SIZE} sf_field_t;
-
-static int mus_sound_set_field(const char *arg, sf_field_t field, int val)
-{
- sound_file *sf;
- sf = getsf(arg);
- if (sf)
- {
- switch (field)
- {
- case SF_CHANS: sf->chans = val; break;
- case SF_SRATE: sf->srate = val; break;
- case SF_TYPE: sf->header_type = val; break;
- case SF_FORMAT: sf->data_format = val; sf->datum_size = mus_bytes_per_sample(val); break;
- default: return(MUS_ERROR); break;
- }
- return(MUS_NO_ERROR);
- }
- return(MUS_ERROR);
-}
-
-static int mus_sound_set_off_t_field(const char *arg, sf_field_t field, off_t val)
-{
- sound_file *sf;
- sf = getsf(arg);
- if (sf)
- {
- switch (field)
- {
- case SF_SIZE: sf->samples = val; break;
- case SF_LOCATION: sf->data_location = val; break;
- default: return(MUS_ERROR); break;
- }
- return(MUS_NO_ERROR);
- }
- return(MUS_ERROR);
-}
-
-int mus_sound_set_chans(const char *arg, int val) {return(mus_sound_set_field(arg, SF_CHANS, val));}
-int mus_sound_set_srate(const char *arg, int val) {return(mus_sound_set_field(arg, SF_SRATE, val));}
-int mus_sound_set_header_type(const char *arg, int val) {return(mus_sound_set_field(arg, SF_TYPE, val));}
-int mus_sound_set_data_format(const char *arg, int val) {return(mus_sound_set_field(arg, SF_FORMAT, val));}
-int mus_sound_set_data_location(const char *arg, off_t val) {return(mus_sound_set_off_t_field(arg, SF_LOCATION, val));}
-int mus_sound_set_samples(const char *arg, off_t val) {return(mus_sound_set_off_t_field(arg, SF_SIZE, val));}
-
-int mus_sound_override_header(const char *arg, int srate, int chans, int format, int type, off_t location, off_t size)
-{
- sound_file *sf;
- /* perhaps once a header has been over-ridden, we should not reset the relevant fields upon re-read? */
- sf = getsf(arg);
- if (sf)
- {
- if (location != -1) sf->data_location = location;
- if (size != -1) sf->samples = size;
- if (format != -1)
- {
- sf->data_format = format;
- sf->datum_size = mus_bytes_per_sample(format);
- }
- if (srate != -1) sf->srate = srate;
- if (chans != -1) sf->chans = chans;
- if (type != -1) sf->header_type = type;
- return(MUS_NO_ERROR);
- }
- return(MUS_ERROR);
-}
-
-bool mus_sound_maxamp_exists(const char *ifile)
-{
- sound_file *sf;
- bool val = false;
- sf = getsf(ifile);
- val = ((sf) && (sf->maxamps));
- return(val);
-}
-
-off_t mus_sound_maxamps(const char *ifile, int chans, mus_sample_t *vals, off_t *times)
-{
- int ifd, ichans, chn, j;
- int i, bufnum;
- off_t n, frames, curframes;
- mus_sample_t abs_samp;
- mus_sample_t *buffer, *samp;
- off_t *time;
- mus_sample_t **ibufs;
- sound_file *sf;
- sf = getsf(ifile);
- if (sf->chans <= 0) return(MUS_ERROR);
- if ((sf) && (sf->maxamps))
- {
- if (chans > sf->chans) ichans = sf->chans; else ichans = chans;
- for (chn = 0; chn < ichans; chn++)
- {
- times[chn] = sf->maxtimes[chn];
- vals[chn] = sf->maxamps[chn];
- }
- frames = sf->samples / sf->chans;
- return(frames);
- }
- ifd = mus_sound_open_input(ifile);
- if (ifd == MUS_ERROR) return(MUS_ERROR);
- ichans = mus_sound_chans(ifile);
- frames = mus_sound_frames(ifile);
- if (frames == 0)
- {
- mus_sound_close_input(ifd);
- return(0);
- }
- mus_file_seek_frame(ifd, 0);
- ibufs = (mus_sample_t **)CALLOC(ichans, sizeof(mus_sample_t *));
- bufnum = 8192;
- for (j = 0; j < ichans; j++)
- ibufs[j] = (mus_sample_t *)CALLOC(bufnum, sizeof(mus_sample_t));
- time = (off_t *)CALLOC(ichans, sizeof(off_t));
- samp = (mus_sample_t *)CALLOC(ichans, sizeof(mus_sample_t));
- for (n = 0; n < frames; n += bufnum)
- {
- if ((n + bufnum) < frames)
- curframes = bufnum;
- else curframes = (frames - n);
- mus_file_read(ifd, 0, curframes - 1, ichans, ibufs);
- for (chn = 0; chn < ichans; chn++)
- {
- buffer = (mus_sample_t *)(ibufs[chn]);
- for (i = 0; i < curframes; i++)
- {
- abs_samp = mus_sample_abs(buffer[i]);
- if (abs_samp > samp[chn])
- {
- time[chn] = i + n;
- samp[chn] = abs_samp;
- }
- }
- }
- }
- mus_sound_close_input(ifd);
- mus_sound_set_maxamps(ifile, ichans, samp, time); /* save the complete set */
- if (ichans > chans) ichans = chans;
- for (chn = 0; chn < ichans; chn++)
- {
- times[chn] = time[chn];
- vals[chn] = samp[chn];
- }
- FREE(time);
- FREE(samp);
- for (j = 0; j < ichans; j++) FREE(ibufs[j]);
- FREE(ibufs);
- return(frames);
-}
-
-int mus_sound_set_maxamps(const char *ifile, int chans, mus_sample_t *vals, off_t *times)
-{
- sound_file *sf;
- sf = getsf(ifile);
- if (sf)
- {
- int i, ichans = 0;
- if (sf->maxamps)
- {
- if (chans > sf->chans) ichans = sf->chans; else ichans = chans;
- for (i = 0; i < ichans; i++)
- {
- sf->maxtimes[i] = times[i];
- sf->maxamps[i] = vals[i];
- }
- }
- else
- {
- ichans = mus_sound_chans(ifile);
- if (sf->maxamps == NULL)
- {
- sf->maxamps = (mus_sample_t *)CALLOC(ichans, sizeof(mus_sample_t));
- sf->maxtimes = (off_t *)CALLOC(ichans, sizeof(off_t));
- }
- if (ichans > chans) ichans = chans;
- for (i = 0; i < ichans; i++)
- {
- sf->maxtimes[i] = times[i];
- sf->maxamps[i] = vals[i];
- }
- }
- return(MUS_NO_ERROR);
- }
- return(MUS_ERROR);
-}
-
-int mus_file_to_array(const char *filename, int chan, int start, int samples, mus_sample_t *array)
-{
- int ifd, chans, total_read;
- mus_sample_t **bufs;
- ifd = mus_sound_open_input(filename);
- if (ifd == MUS_ERROR) return(MUS_ERROR);
- chans = mus_sound_chans(filename);
- if (chan >= chans)
- {
- mus_sound_close_input(ifd);
- return(mus_error(MUS_NO_SUCH_CHANNEL, "mus_file_to_array can't read %s channel %d (file has %d chans)", filename, chan, chans));
- }
- bufs = (mus_sample_t **)CALLOC(chans, sizeof(mus_sample_t *));
- bufs[chan] = array;
- mus_file_seek_frame(ifd, start);
- total_read = mus_file_read_any(ifd, 0, chans, samples, bufs, bufs);
- mus_sound_close_input(ifd);
- FREE(bufs);
- return(total_read);
-}
-
-char *mus_array_to_file_with_error(const char *filename, mus_sample_t *ddata, int len, int srate, int channels)
-{
- /* put ddata into a sound file, taking byte order into account */
- /* assume ddata is interleaved already if more than one channel */
- int fd, err = MUS_NO_ERROR;
- mus_sample_t *bufs[1];
- mus_sound_forget(filename);
- fd = mus_file_create(filename);
- if (fd == -1)
- return("mus_array_to_file can't create output file");
- err = mus_file_open_descriptors(fd, filename,
- MUS_OUT_FORMAT,
- mus_bytes_per_sample(MUS_OUT_FORMAT),
- 28, channels, MUS_NEXT);
- if (err != MUS_ERROR)
- {
- err = mus_header_write_next_header(fd, srate, channels, 28, len /* out chans = 1?? */, MUS_OUT_FORMAT, NULL, 0);
- if (err != MUS_ERROR)
- {
- bufs[0] = ddata;
- err = mus_file_write(fd, 0, len - 1, 1, bufs); /* 1 = chans?? */
- }
- }
- mus_file_close(fd);
- if (err == MUS_ERROR)
- return("mus_array_to_file write error");
- return(NULL);
-}
-
-int mus_array_to_file(const char *filename, mus_sample_t *ddata, int len, int srate, int channels)
-{
- char *errmsg;
- errmsg = mus_array_to_file_with_error(filename, ddata, len, srate, channels);
- if (errmsg)
- return(mus_error(MUS_CANT_OPEN_FILE, errmsg));
- return(MUS_NO_ERROR);
-}
-
-int mus_file_to_float_array(const char *filename, int chan, off_t start, int samples, Float *array)
-{
-#if SNDLIB_USE_FLOATS
- return(mus_file_to_array(filename, chan, start, samples, array));
-#else
- mus_sample_t *idata;
- int i, len;
- idata = (mus_sample_t *)CALLOC(samples, sizeof(mus_sample_t));
- len = mus_file_to_array(filename, chan, start, samples, idata);
- if (len != -1)
- for (i = 0; i < samples; i++)
- array[i] = MUS_SAMPLE_TO_FLOAT(idata[i]);
- FREE(idata);
- return(len);
-#endif
-}
-
-int mus_float_array_to_file(const char *filename, Float *ddata, int len, int srate, int channels)
-{
- char *errmsg;
-#if SNDLIB_USE_FLOATS
- errmsg = mus_array_to_file_with_error(filename, ddata, len, srate, channels);
-#else
- mus_sample_t *idata;
- int i;
- idata = (mus_sample_t *)CALLOC(len, sizeof(mus_sample_t));
- for (i = 0; i < len; i++)
- idata[i] = MUS_FLOAT_TO_SAMPLE(ddata[i]);
- errmsg = mus_array_to_file_with_error(filename, idata, len, srate, channels);
- FREE(idata);
-#endif
- if (errmsg)
- return(mus_error(MUS_CANT_OPEN_FILE, errmsg));
- return(MUS_NO_ERROR);
-}