shithub: sox

Download patch

ref: a30de9ea3744f99cbc73148ea98dbcd4f048ff6f
parent: ae555c6c82df79e75cbeb91018c0a00f2acfa9f0
author: robs <robs>
date: Sun Feb 8 08:04:11 EST 2009

stubs for bit-rot detection

diff: cannot open b/src/CoreAudio//null: file does not exist: 'b/src/CoreAudio//null' diff: cannot open b/src/sys//null: file does not exist: 'b/src/sys//null'
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,6 +77,7 @@
   endif(HAVE_OPENMP)
 endif(CMAKE_COMPILER_IS_GNUCC)
 optional(HAVE_ID3TAG id3tag.h id3tag id3_file_open "")
+optional(HAVE_SNDIO CoreAudio/CoreAudio.h CoreAudio AudioHardwareGetProperty coreaudio)
 optional(HAVE_SNDIO sndio.h sndio sio_open sndio)
 optional(HAVE_LIBAO ao/ao.h ao ao_play ao)
 optional(HAVE_FLAC FLAC/all.h FLAC FLAC__stream_encoder_new flac)
--- a/ChangeLog
+++ b/ChangeLog
@@ -112,6 +112,8 @@
   o Rationalise use of and make repeatable across different platforms
     pseudo random number generators.  (robs)
   o Rationalise effects' options interface (getopt compatible).  (robs)
+  o Added stub headers to allow test compilation of all sources on
+    linux.  (robs)
 
 
 sox-14.2.0	2008-11-09
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -53,6 +53,10 @@
   cvsd            hcom            s1-fmt          u1-fmt
   cvsd-fmt        htk             s2-fmt          u2-fmt
 )
+
+# Uncomment for bit-rot detection on linux
+#set(formats_srcs ${formats_srcs} coreaudio sndio sunaudio)
+
 add_library(lib${PROJECT_NAME}
   effects                 formats_i               libsox_i
   effects_i               ${formats_srcs}         ${optional_srcs}
--- /dev/null
+++ b/src/CoreAudio/CoreAudio.h
@@ -1,0 +1,266 @@
+#ifndef HAVE_COREAUDIO
+/*
+ * SoX bit-rot detection file; cobbled together
+ */
+
+enum {
+  kAudioHardwarePropertyProcessIsMaster,
+  kAudioHardwarePropertyIsInitingOrExiting,
+  kAudioHardwarePropertyDevices,
+  kAudioHardwarePropertyDefaultInputDevice,
+  kAudioHardwarePropertyDefaultOutputDevice,
+  kAudioHardwarePropertyDefaultSystemOutputDevice,
+  kAudioHardwarePropertyDeviceForUID,
+  kAudioHardwarePropertySleepingIsAllowed,
+  kAudioHardwarePropertyUnloadingIsAllowed,
+  kAudioHardwarePropertyHogModeIsAllowed,
+  kAudioHardwarePropertyRunLoop,
+  kAudioHardwarePropertyPlugInForBundleID
+};
+
+enum {
+  kAudioObjectPropertyClass,
+  kAudioObjectPropertyOwner,
+  kAudioObjectPropertyCreator,
+  kAudioObjectPropertyName,
+  kAudioObjectPropertyManufacturer,
+  kAudioObjectPropertyElementName,
+  kAudioObjectPropertyElementCategoryName,
+  kAudioObjectPropertyElementNumberName,
+  kAudioObjectPropertyOwnedObjects,
+  kAudioObjectPropertyListenerAdded,
+  kAudioObjectPropertyListenerRemoved
+};
+
+enum {
+  kAudioDevicePropertyDeviceName,
+  kAudioDevicePropertyDeviceNameCFString = kAudioObjectPropertyName,
+  kAudioDevicePropertyDeviceManufacturer,
+  kAudioDevicePropertyDeviceManufacturerCFString =
+      kAudioObjectPropertyManufacturer,
+  kAudioDevicePropertyRegisterBufferList,
+  kAudioDevicePropertyBufferSize,
+  kAudioDevicePropertyBufferSizeRange,
+  kAudioDevicePropertyChannelName,
+  kAudioDevicePropertyChannelNameCFString = kAudioObjectPropertyElementName,
+  kAudioDevicePropertyChannelCategoryName,
+  kAudioDevicePropertyChannelCategoryNameCFString =
+      kAudioObjectPropertyElementCategoryName,
+  kAudioDevicePropertyChannelNumberName,
+  kAudioDevicePropertyChannelNumberNameCFString =
+      kAudioObjectPropertyElementNumberName,
+  kAudioDevicePropertySupportsMixing,
+  kAudioDevicePropertyStreamFormat,
+  kAudioDevicePropertyStreamFormats,
+  kAudioDevicePropertyStreamFormatSupported,
+  kAudioDevicePropertyStreamFormatMatch,
+  kAudioDevicePropertyDataSourceNameForID,
+  kAudioDevicePropertyClockSourceNameForID,
+  kAudioDevicePropertyPlayThruDestinationNameForID,
+  kAudioDevicePropertyChannelNominalLineLevelNameForID
+};
+
+enum {
+  kAudioDevicePropertyPlugIn,
+  kAudioDevicePropertyConfigurationApplication,
+  kAudioDevicePropertyDeviceUID,
+  kAudioDevicePropertyModelUID,
+  kAudioDevicePropertyTransportType,
+  kAudioDevicePropertyRelatedDevices,
+  kAudioDevicePropertyClockDomain,
+  kAudioDevicePropertyDeviceIsAlive,
+  kAudioDevicePropertyDeviceHasChanged,
+  kAudioDevicePropertyDeviceIsRunning,
+  kAudioDevicePropertyDeviceIsRunningSomewhere,
+  kAudioDevicePropertyDeviceCanBeDefaultDevice,
+  kAudioDevicePropertyDeviceCanBeDefaultSystemDevice,
+  kAudioDeviceProcessorOverload,
+  kAudioDevicePropertyHogMode,
+  kAudioDevicePropertyLatency,
+  kAudioDevicePropertyBufferFrameSize,
+  kAudioDevicePropertyBufferFrameSizeRange,
+  kAudioDevicePropertyUsesVariableBufferFrameSizes,
+  kAudioDevicePropertyStreams,
+  kAudioDevicePropertySafetyOffset,
+  kAudioDevicePropertyIOCycleUsage,
+  kAudioDevicePropertyStreamConfiguration,
+  kAudioDevicePropertyIOProcStreamUsage,
+  kAudioDevicePropertyPreferredChannelsForStereo,
+  kAudioDevicePropertyPreferredChannelLayout,
+  kAudioDevicePropertyNominalSampleRate,
+  kAudioDevicePropertyAvailableNominalSampleRates,
+  kAudioDevicePropertyActualSampleRate
+};
+
+enum {
+  kAudioFormatLinearPCM,
+  kAudioFormatAC3,
+  kAudioFormat60958AC3,
+  kAudioFormatAppleIMA4,
+  kAudioFormatMPEG4AAC,
+  kAudioFormatMPEG4CELP,
+  kAudioFormatMPEG4HVXC,
+  kAudioFormatMPEG4TwinVQ,
+  kAudioFormatMACE3,
+  kAudioFormatMACE6,
+  kAudioFormatULaw,
+  kAudioFormatALaw,
+  kAudioFormatQDesign,
+  kAudioFormatQDesign2,
+  kAudioFormatQUALCOMM,
+  kAudioFormatMPEGLayer1,
+  kAudioFormatMPEGLayer2,
+  kAudioFormatMPEGLayer3,
+  kAudioFormatDVAudio,
+  kAudioFormatVariableDurationDVAudio,
+  kAudioFormatTimeCode,
+  kAudioFormatMIDIStream,
+  kAudioFormatParameterValueStream,
+  kAudioFormatAppleLossless
+};
+
+enum {
+  kAudioFormatFlagIsFloat = (1L << 0),
+  kAudioFormatFlagIsBigEndian = (1L << 1),
+  kAudioFormatFlagIsSignedInteger = (1L << 2),
+  kAudioFormatFlagIsPacked = (1L << 3),
+  kAudioFormatFlagIsAlignedHigh = (1L << 4),
+  kAudioFormatFlagIsNonInterleaved = (1L << 5),
+  kAudioFormatFlagIsNonMixable = (1L << 6),
+  kAudioFormatFlagsAreAllClear = (1L << 31),
+
+  kLinearPCMFormatFlagIsFloat = kAudioFormatFlagIsFloat,
+  kLinearPCMFormatFlagIsBigEndian = kAudioFormatFlagIsBigEndian,
+  kLinearPCMFormatFlagIsSignedInteger = kAudioFormatFlagIsSignedInteger,
+  kLinearPCMFormatFlagIsPacked = kAudioFormatFlagIsPacked,
+  kLinearPCMFormatFlagIsAlignedHigh = kAudioFormatFlagIsAlignedHigh,
+  kLinearPCMFormatFlagIsNonInterleaved = kAudioFormatFlagIsNonInterleaved,
+  kLinearPCMFormatFlagIsNonMixable = kAudioFormatFlagIsNonMixable,
+  kLinearPCMFormatFlagsAreAllClear = kAudioFormatFlagsAreAllClear,
+
+  kAppleLosslessFormatFlag_16BitSourceData = 1,
+  kAppleLosslessFormatFlag_20BitSourceData = 2,
+  kAppleLosslessFormatFlag_24BitSourceData = 3,
+  kAppleLosslessFormatFlag_32BitSourceData = 4
+};
+
+enum {
+  kAudioFormatFlagsNativeEndian = kAudioFormatFlagIsBigEndian,
+  kAudioFormatFlagsNativeFloatPacked =
+      kAudioFormatFlagIsFloat | kAudioFormatFlagsNativeEndian |
+      kAudioFormatFlagIsPacked
+};
+
+enum {
+  kAudioDeviceUnknown
+};
+
+enum {
+  kVariableLengthArray = 1
+};
+
+enum {
+  kAudioHardwareNoError = 0
+};
+
+typedef double Float64;
+typedef float Float32;
+typedef int SInt32;
+typedef int Boolean;
+typedef int OSErr;
+typedef short SInt16;
+typedef unsigned int UInt32;
+typedef unsigned long int UInt64;
+
+typedef SInt32 OSStatus;
+typedef UInt32 AudioObjectID;
+typedef UInt32 AudioHardwarePropertyID;
+typedef UInt32 AudioDevicePropertyID;
+typedef AudioObjectID AudioDeviceID;
+
+struct AudioStreamBasicDescription {
+  Float64 mSampleRate;
+  UInt32 mFormatID;
+  UInt32 mFormatFlags;
+  UInt32 mBytesPerPacket;
+  UInt32 mFramesPerPacket;
+  UInt32 mBytesPerFrame;
+  UInt32 mChannelsPerFrame;
+  UInt32 mBitsPerChannel;
+  UInt32 mReserved;
+};
+typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
+
+
+
+struct SMPTETime {
+  SInt16 mSubframes;
+  SInt16 mSubframeDivisor;
+  UInt32 mCounter;
+  UInt32 mType;
+  UInt32 mFlags;
+  SInt16 mHours;
+  SInt16 mMinutes;
+  SInt16 mSeconds;
+  SInt16 mFrames;
+};
+typedef struct SMPTETime SMPTETime;
+
+struct AudioTimeStamp {
+  Float64 mSampleTime;
+  UInt64 mHostTime;
+  Float64 mRateScalar;
+  UInt64 mWordClockTime;
+  SMPTETime mSMPTETime;
+  UInt32 mFlags;
+  UInt32 mReserved;
+};
+typedef struct AudioTimeStamp AudioTimeStamp;
+
+struct AudioBuffer {
+  UInt32 mNumberChannels;
+  UInt32 mDataByteSize;
+  void *mData;
+};
+typedef struct AudioBuffer AudioBuffer;
+
+struct AudioBufferList {
+  UInt32 mNumberBuffers;
+  AudioBuffer mBuffers[kVariableLengthArray];
+};
+typedef struct AudioBufferList AudioBufferList;
+
+typedef OSStatus(*AudioDeviceIOProc) (AudioDeviceID inDevice,
+                                      const AudioTimeStamp * inNow,
+                                      const AudioBufferList * inInputData,
+                                      const AudioTimeStamp * inInputTime,
+                                      AudioBufferList * outOutputData,
+                                      const AudioTimeStamp * inOutputTime,
+                                      void *inClientData);
+
+
+
+OSStatus AudioHardwareGetProperty(AudioHardwarePropertyID inPropertyID,
+                                  UInt32 * ioPropertyDataSize,
+                                  void *outPropertyData);
+
+OSStatus AudioDeviceSetProperty(AudioDeviceID inDevice,
+                                const AudioTimeStamp * inWhen,
+                                UInt32 inChannel, Boolean isInput,
+                                AudioDevicePropertyID inPropertyID,
+                                UInt32 inPropertyDataSize,
+                                const void *inPropertyData);
+OSStatus AudioDeviceGetProperty(AudioDeviceID inDevice, UInt32 inChannel,
+                                Boolean isInput,
+                                AudioDevicePropertyID inPropertyID,
+                                UInt32 * ioPropertyDataSize,
+                                void *outPropertyData);
+
+
+OSStatus AudioDeviceAddIOProc(AudioDeviceID inDevice,
+                              AudioDeviceIOProc inProc, void *inClientData);
+OSStatus AudioDeviceStart(AudioDeviceID inDevice, AudioDeviceIOProc inProc);
+
+
+OSStatus AudioDeviceStop(AudioDeviceID inDevice, AudioDeviceIOProc inProc);
+#endif
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -208,6 +208,9 @@
 libsox_la_LIBADD += @GSM_LIBS@ @LIBGSM_LIBADD@
 libsox_la_LIBADD += @LPC10_LIBS@ @LIBLPC10_LIBADD@
 
+# Uncomment for bit-rot detection on linux
+#libsox_la_SOURCES += coreaudio.c sndio.c sunaudio.c
+
 if STATIC_FLAC
     libsox_la_SOURCES += flac.c
     libsox_la_LIBADD += @FLAC_LIBS@
--- a/src/sndio.c
+++ b/src/sndio.c
@@ -15,9 +15,9 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "sox_i.h"
 #include <string.h>
 #include <sndio.h>
-#include "sox_i.h"
 
 struct sndio_priv {
   struct sio_hdl *hdl;             /* handle to speak to libsndio */
@@ -30,7 +30,7 @@
  * convert ``count'' samples from sox encoding to sndio encoding
  */
 static void encode(struct sio_par *par,
-    sox_sample_t *idata, unsigned char *odata, unsigned count)
+    sox_sample_t const *idata, unsigned char *odata, unsigned count)
 {
   int obnext, osnext, s, osigbit;
   unsigned oshift, obps, i;
--- /dev/null
+++ b/src/sndio.h
@@ -1,0 +1,160 @@
+#ifndef HAVE_SNDIO
+/*
+ * SoX bit-rot detection file, obtained from:
+ * http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libsndio/sndio.h
+ */
+#if defined __GNUC__
+  #pragma GCC system_header
+#endif
+
+/*	$OpenBSD: sndio.h,v 1.7 2009/02/03 19:44:58 ratchov Exp $	*/
+/*
+ * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef SNDIO_H
+#define SNDIO_H
+
+#include <sys/param.h>
+
+/*
+ * private ``handle'' structure
+ */
+struct sio_hdl;
+
+/*
+ * parameters of a full-duplex stream
+ */
+struct sio_par {
+	unsigned bits;		/* bits per sample */
+	unsigned bps;		/* bytes per sample */
+	unsigned sig;		/* 1 = signed, 0 = unsigned */
+	unsigned le;		/* 1 = LE, 0 = BE byte order */
+	unsigned msb;		/* 1 = MSB, 0 = LSB aligned */
+	unsigned rchan;		/* number channels for recording direction */
+	unsigned pchan;		/* number channels for playback direction */
+	unsigned rate;		/* frames per second */
+	unsigned bufsz;		/* end-to-end buffer size */
+#define SIO_IGNORE	0	/* pause during xrun */
+#define SIO_SYNC	1	/* resync after xrun */
+#define SIO_ERROR	2	/* terminate on xrun */
+	unsigned xrun;		/* what to do on overruns/underruns */
+	unsigned round;		/* optimal bufsz divisor */
+	unsigned appbufsz;	/* minimum buffer size */
+	int __pad[3];		/* for future use */
+	int __magic;		/* for internal/debug purposes only */
+};
+
+/*
+ * capabilities of a stream
+ */
+struct sio_cap {
+#define SIO_NENC	8
+#define SIO_NCHAN	8
+#define SIO_NRATE	16
+#define SIO_NCONF	4
+	struct sio_enc {			/* allowed sample encodings */
+		unsigned bits;
+		unsigned bps;
+		unsigned sig;
+		unsigned le;
+		unsigned msb;
+	} enc[SIO_NENC];
+	unsigned rchan[SIO_NCHAN];	/* allowed values for rchan */
+	unsigned pchan[SIO_NCHAN];	/* allowed values for pchan */
+	unsigned rate[SIO_NRATE];	/* allowed rates */
+	int __pad[7];			/* for future use */
+	unsigned nconf;			/* number of elements in confs[] */
+	struct sio_conf {
+		unsigned enc;		/* mask of enc[] indexes */
+		unsigned rchan;		/* mask of chan[] indexes (rec) */
+		unsigned pchan;		/* mask of chan[] indexes (play) */
+		unsigned rate;		/* mask of rate[] indexes */
+	} confs[SIO_NCONF];
+};
+
+#define SIO_XSTRINGS { "ignore", "sync", "error" }
+
+/*
+ * mode bitmap
+ */
+#define SIO_PLAY	1
+#define SIO_REC		2
+
+/*
+ * maximum size of the encording string (the longest possible
+ * encoding is ``s24le3msb'')
+ */
+#define SIO_ENCMAX	10
+
+/*
+ * default bytes per sample for the given bits per sample
+ */
+#define SIO_BPS(bits) (((bits) <= 8) ? 1 : (((bits) <= 16) ? 2 : 4))
+
+/*
+ * default value of "sio_par->le" flag
+ */
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define SIO_LE_NATIVE 1
+#else
+#define SIO_LE_NATIVE 0
+#endif
+
+/*
+ * default device for the sun audio(4) back-end
+ */
+#define SIO_SUN_PATH	"/dev/audio"
+
+/*
+ * default socket name for the aucat(1) back-end
+ */
+#define SIO_AUCAT_PATH	"default"
+
+/*
+ * maximum value of volume, eg. for sio_setvol()
+ */
+#define SIO_MAXVOL 127
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int sio_strtoenc(struct sio_par *, char *);
+int sio_enctostr(struct sio_par *, char *);
+void sio_initpar(struct sio_par *);
+
+struct sio_hdl *sio_open(char *, unsigned, int);
+void sio_close(struct sio_hdl *);
+int sio_setpar(struct sio_hdl *, struct sio_par *);
+int sio_getpar(struct sio_hdl *, struct sio_par *);
+int sio_getcap(struct sio_hdl *, struct sio_cap *);
+void sio_onmove(struct sio_hdl *, void (*)(void *, int), void *);
+size_t sio_write(struct sio_hdl *, void *, size_t);
+size_t sio_read(struct sio_hdl *, void *, size_t);
+int sio_start(struct sio_hdl *);
+int sio_stop(struct sio_hdl *);
+int sio_nfds(struct sio_hdl *);
+int sio_pollfd(struct sio_hdl *, struct pollfd *, int);
+int sio_revents(struct sio_hdl *, struct pollfd *);
+int sio_eof(struct sio_hdl *);
+int sio_setvol(struct sio_hdl *, unsigned);
+void sio_onvol(struct sio_hdl *, void (*)(void *, unsigned), void *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined(SNDIO_H) */
+#endif
--- a/src/soxconfig.h.cmake
+++ b/src/soxconfig.h.cmake
@@ -5,6 +5,7 @@
 #cmakedefine HAVE_AMRNB               1
 #cmakedefine HAVE_AMRWB               1
 #cmakedefine HAVE_BYTESWAP_H          1
+#cmakedefine HAVE_COREAUDIO           1
 #cmakedefine HAVE_FFMPEG              1
 #cmakedefine HAVE_FLAC                1
 #cmakedefine HAVE_FSEEKO              1
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -22,9 +22,7 @@
 #ifdef HAVE_SUN_AUDIOIO_H
   #include <sun/audioio.h>
 #else
-#ifdef HAVE_SYS_AUDIOIO_H
   #include <sys/audioio.h>
-#endif
 #endif
 #include <errno.h>
 #if !defined(__NetBSD__) && !defined(__OpenBSD__)
--- /dev/null
+++ b/src/sys/audioio.h
@@ -1,0 +1,284 @@
+#ifndef HAVE_SYS_AUDIOIO_H
+/*
+ * SoX bit-rot detection file, obtained from: Solaris 9 /usr/include/sys
+ */
+#if defined __GNUC__
+  #pragma GCC system_header
+#endif
+
+/*
+ * Copyright (c) 1995-2001 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef	_SYS_AUDIOIO_H
+#define	_SYS_AUDIOIO_H
+
+#pragma ident	"@(#)audioio.h	1.30	01/01/10 SMI"
+
+#include <sys/types.h>
+#if 0
+#include <sys/types32.h>
+#include <sys/time.h>
+#include <sys/ioccom.h>
+#else
+#define ushort_t unsigned short
+#define uint_t unsigned int
+#define uchar_t unsigned char
+#endif
+
+/*
+ * These are the ioctl calls for all Solaris audio devices, including
+ * the x86 and SPARCstation audio devices.
+ *
+ * You are encouraged to design your code in a modular fashion so that
+ * future changes to the interface can be incorporated with little
+ * trouble.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This structure contains state information for audio device IO streams.
+ */
+struct audio_prinfo {
+	/*
+	 * The following values describe the audio data encoding.
+	 */
+	uint_t sample_rate;	/* samples per second */
+	uint_t channels;	/* number of interleaved channels */
+	uint_t precision;	/* bit-width of each sample */
+	uint_t encoding;	/* data encoding method */
+
+	/*
+	 * The following values control audio device configuration
+	 */
+	uint_t gain;		/* gain level: 0 - 255 */
+	uint_t port;		/* selected I/O port (see below) */
+	uint_t avail_ports;	/* available I/O ports (see below) */
+	uint_t mod_ports;	/* I/O ports that are modifiable (see below) */
+	uint_t _xxx;		/* Reserved for future use */
+
+	uint_t buffer_size;	/* I/O buffer size */
+
+	/*
+	 * The following values describe driver state
+	 */
+	uint_t samples;		/* number of samples converted */
+	uint_t eof;		/* End Of File counter (play only) */
+
+	uchar_t	pause;		/* non-zero for pause, zero to resume */
+	uchar_t	error;		/* non-zero if overflow/underflow */
+	uchar_t	waiting;	/* non-zero if a process wants access */
+	uchar_t balance;	/* stereo channel balance */
+
+	ushort_t minordev;
+
+	/*
+	 * The following values are read-only state flags
+	 */
+	uchar_t open;		/* non-zero if open access permitted */
+	uchar_t active;		/* non-zero if I/O is active */
+};
+typedef struct audio_prinfo audio_prinfo_t;
+
+
+/*
+ * This structure describes the current state of the audio device.
+ */
+struct audio_info {
+	/*
+	 * Per-stream information
+	 */
+	audio_prinfo_t play;	/* output status information */
+	audio_prinfo_t record;	/* input status information */
+
+	/*
+	 * Per-unit/channel information
+	 */
+	uint_t monitor_gain;	/* input to output mix: 0 - 255 */
+	uchar_t output_muted;	/* non-zero if output is muted */
+	uchar_t ref_cnt;	/* driver reference count, read only */
+	uchar_t _xxx[2];	/* Reserved for future use */
+	uint_t hw_features;	/* hardware features this driver supports */
+	uint_t sw_features;	/* supported SW features */
+	uint_t sw_features_enabled;	/* supported SW feat. enabled */
+};
+typedef struct audio_info audio_info_t;
+
+
+/*
+ * Audio encoding types
+ */
+#define	AUDIO_ENCODING_NONE	(0)	/* no encoding assigned	*/
+#define	AUDIO_ENCODING_ULAW	(1)	/* u-law encoding	*/
+#define	AUDIO_ENCODING_ALAW	(2)	/* A-law encoding	*/
+#define	AUDIO_ENCODING_LINEAR	(3)	/* Signed Linear PCM encoding	*/
+#define	AUDIO_ENCODING_DVI	(104)	/* DVI ADPCM		*/
+#define	AUDIO_ENCODING_LINEAR8	(105)	/* 8 bit UNSIGNED	*/
+
+/*
+ * These ranges apply to record, play, and monitor gain values
+ */
+#define	AUDIO_MIN_GAIN	(0)	/* minimum gain value */
+#define	AUDIO_MAX_GAIN	(255)	/* maximum gain value */
+#define	AUDIO_MID_GAIN	(AUDIO_MAX_GAIN / 2)
+
+/*
+ * These values apply to the balance field to adjust channel gain values
+ */
+#define	AUDIO_LEFT_BALANCE	(0)	/* left channel only	*/
+#define	AUDIO_MID_BALANCE	(32)	/* equal left/right channel */
+#define	AUDIO_RIGHT_BALANCE	(64)	/* right channel only	*/
+#define	AUDIO_BALANCE_SHIFT	(3)
+
+/*
+ * Generic minimum/maximum limits for number of channels, both modes
+ */
+#define	AUDIO_CHANNELS_MONO	(1)
+#define	AUDIO_CHANNELS_STEREO	(2)
+#define	AUDIO_MIN_PLAY_CHANNELS	(AUDIO_CHANNELS_MONO)
+#define	AUDIO_MAX_PLAY_CHANNELS	(AUDIO_CHANNELS_STEREO)
+#define	AUDIO_MIN_REC_CHANNELS	(AUDIO_CHANNELS_MONO)
+#define	AUDIO_MAX_REC_CHANNELS	(AUDIO_CHANNELS_STEREO)
+
+/*
+ * Generic minimum/maximum limits for sample precision
+ */
+#define	AUDIO_PRECISION_8		(8)
+#define	AUDIO_PRECISION_16		(16)
+
+#define	AUDIO_MIN_PLAY_PRECISION	(8)
+#define	AUDIO_MAX_PLAY_PRECISION	(32)
+#define	AUDIO_MIN_REC_PRECISION		(8)
+#define	AUDIO_MAX_REC_PRECISION		(32)
+
+/*
+ * Define some convenient names for typical audio ports
+ */
+#define	AUDIO_NONE		0x00	/* all ports off */
+/*
+ * output ports (several may be enabled simultaneously)
+ */
+#define	AUDIO_SPEAKER		0x01	/* output to built-in speaker */
+#define	AUDIO_HEADPHONE		0x02	/* output to headphone jack */
+#define	AUDIO_LINE_OUT		0x04	/* output to line out	*/
+#define	AUDIO_SPDIF_OUT		0x08	/* output to SPDIF port	*/
+#define	AUDIO_AUX1_OUT		0x10	/* output to aux1 out	*/
+#define	AUDIO_AUX2_OUT		0x20	/* output to aux2 out	*/
+
+/*
+ * input ports (usually only one at a time)
+ */
+#define	AUDIO_MICROPHONE	0x01	/* input from microphone */
+#define	AUDIO_LINE_IN		0x02	/* input from line in	*/
+#define	AUDIO_CD		0x04	/* input from on-board CD inputs */
+#define	AUDIO_INTERNAL_CD_IN	AUDIO_CD	/* input from internal CDROM */
+#define	AUDIO_SPDIF_IN		0x08	/* input from SPDIF port */
+#define	AUDIO_AUX1_IN		0x10	/* input from aux1 in	*/
+#define	AUDIO_AUX2_IN		0x20	/* input from aux2 in	*/
+#define	AUDIO_CODEC_LOOPB_IN	0x40	/* input from Codec internal loopback */
+#define	AUDIO_SUNVTS		0x80	/* SunVTS input setting-internal LB */
+
+/*
+ * Define the hw_features
+ */
+#define	AUDIO_HWFEATURE_DUPLEX	0x00000001u	/* simult. play & rec support */
+#define	AUDIO_HWFEATURE_MSCODEC	0x00000002u	/* multi-stream Codec */
+#define	AUDIO_HWFEATURE_IN2OUT	0x00000004u	/* input to output loopback */
+#define	AUDIO_HWFEATURE_PLAY	0x00000008u	/* device supports play */
+#define	AUDIO_HWFEATURE_RECORD	0x00000010u	/* device supports record */
+
+/*
+ * Define the sw_features
+ */
+#define	AUDIO_SWFEATURE_MIXER	0x00000001u	/* audio mixer audio pers mod */
+
+/*
+ * This macro initializes an audio_info structure to 'harmless' values.
+ * Note that (~0) might not be a harmless value for a flag that was
+ * a signed int.
+ */
+#define	AUDIO_INITINFO(i)	{					\
+	uint_t	*__x__;						\
+	for (__x__ = (uint_t *)(i);				\
+	    (char *)__x__ < (((char *)(i)) + sizeof (audio_info_t));	\
+	    *__x__++ = ~0);						\
+}
+
+
+/*
+ * Parameter for the AUDIO_GETDEV ioctl to determine current
+ * audio devices.
+ */
+#define	MAX_AUDIO_DEV_LEN	(16)
+struct audio_device {
+	char name[MAX_AUDIO_DEV_LEN];
+	char version[MAX_AUDIO_DEV_LEN];
+	char config[MAX_AUDIO_DEV_LEN];
+};
+typedef struct audio_device audio_device_t;
+
+
+/*
+ * Ioctl calls for the audio device.
+ */
+
+/*
+ * AUDIO_GETINFO retrieves the current state of the audio device.
+ *
+ * AUDIO_SETINFO copies all fields of the audio_info structure whose
+ * values are not set to the initialized value (-1) to the device state.
+ * It performs an implicit AUDIO_GETINFO to return the new state of the
+ * device.  Note that the record.samples and play.samples fields are set
+ * to the last value before the AUDIO_SETINFO took effect.  This allows
+ * an application to reset the counters while atomically retrieving the
+ * last value.
+ *
+ * AUDIO_DRAIN suspends the calling process until the write buffers are
+ * empty.
+ *
+ * AUDIO_GETDEV returns a structure of type audio_device_t which contains
+ * three strings.  The string "name" is a short identifying string (for
+ * example, the SBus Fcode name string), the string "version" identifies
+ * the current version of the device, and the "config" string identifies
+ * the specific configuration of the audio stream.  All fields are
+ * device-dependent -- see the device specific manual pages for details.
+ */
+#define	AUDIO_GETINFO	_IOR('A', 1, audio_info_t)
+#define	AUDIO_SETINFO	_IOWR('A', 2, audio_info_t)
+#define	AUDIO_DRAIN	_IO('A', 3)
+#define	AUDIO_GETDEV	_IOR('A', 4, audio_device_t)
+
+/*
+ * The following ioctl sets the audio device into an internal loopback mode,
+ * if the hardware supports this.  The argument is TRUE to set loopback,
+ * FALSE to reset to normal operation.  If the hardware does not support
+ * internal loopback, the ioctl should fail with EINVAL.
+ */
+#define	AUDIO_DIAG_LOOPBACK	_IOW('A', 101, int)
+
+
+/*
+ * Structure sent up as a M_PROTO message on trace streams
+ */
+struct audtrace_hdr {
+	uint_t seq;		/* Sequence number (per-aud_stream) */
+	int type;		/* device-dependent */
+#if defined(_LP64) || defined(_I32LPx)
+	struct timeval32 timestamp;
+#else
+	struct timeval timestamp;
+#endif
+	char _f[8];		/* filler */
+};
+typedef struct audtrace_hdr audtrace_hdr_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_AUDIOIO_H */
+#endif