📄 wavplay.h
字号:
/* $Header: /home/cvs/wavplay/wavplay.h,v 1.3 1999/12/04 00:05:34 wwg Exp $ * Warren W. Gay VE3WWG Sun Feb 16 18:17:17 1997 * * WAVPLAY OPTION SETTINGS: * * X LessTif WAV Play : * * Copyright (C) 1997 Warren W. Gay VE3WWG * * 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 version 2 of the License. * * 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 (see enclosed file COPYING). * * 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., * 675 Mass Ave, Cambridge, MA 02139, USA. * * Send correspondance to: * * Warren W. Gay VE3WWG * * Email: * ve3wwg@yahoo.com * wgay@mackenziefinancial.com * * $Log: wavplay.h,v $ * Revision 1.3 1999/12/04 00:05:34 wwg * Fixed release number * * Revision 1.2 1999/12/04 00:01:20 wwg * Implement wavplay-1.4 release changes * * Revision 1.1.1.1 1999/11/21 19:50:56 wwg * Import wavplay-1.3 into CVS * * Revision 1.4 1997/04/17 23:39:26 wwg * Now at 1.0pl2 : attempting to fix Linux 2.0.29 compile problems * with the way errno and sys_errlist[] are handled for thread * safety.. here we removed our incompatible extern sys_errlist[] * * Revision 1.3 1997/04/17 01:59:37 wwg * Added version change to reflect patch level "1.0pl1" * * Revision 1.2 1997/04/17 00:27:36 wwg * Fixed references to the name errno. For thread safety * this name has been macro-ized, which I should have * anticipated, since I knew it was coming. * * Revision 1.1 1997/04/14 00:56:48 wwg * Initial revision * */#ifndef _wavplay_h_#define _wavplay_h_ "$Id: wavplay.h,v 1.3 1999/12/04 00:05:34 wwg Exp $"#define WAVPLAY_VERSION "1.4"#include <stdarg.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/stat.h>/* * From the man page semctl(2) : */#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) /* union semun is defined by including <sys/sem.h> */#else /* according to X/OPEN we have to define it ourselves */ union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short *array; /* array for GETALL, SETALL */ struct seminfo *__buf; /* buffer for IPC_INFO */ };#endiftypedef void (*ErrFunc)(const char *format,va_list ap);#include "wavfile.h"/* * Default location of the wavplay server program if not overrided by the Makefile */#ifndef WAVPLAYPATH#define WAVPLAYPATH "/usr/local/bin/wavplay" /* Default location of wavplay server */#endif/* * Default pathname for recordings if not overriden by the Makefile: */#ifndef RECORD_PATH#define RECORD_PATH "recorded.wav"#endif/* * Default lowest sampling rate unless overriden by the Makefile: */#ifndef DSP_MIN#define DSP_MIN 4000 /* Lowest acceptable sample rate */#endif/* * Default maximum sampling rate unless overrided by the Makefile: */#ifndef DSP_MAX#define DSP_MAX 48000 /* Highest acceptable sample rate */#endif/* * Default pathname of the audio device, unless overrided by the Makefile: */#ifndef AUDIODEV#define AUDIODEV "/dev/dsp" /* Default pathname for audio device */#endif/* * Default locking semaphore IPC Key, unless overrided by the Makefile: */#ifndef AUDIOLCK#define AUDIOLCK 0x33333333 /* Default IPC Key for semaphores */#endif/* * Short option flag characters: */#define OPF_DEVICE 'd' /* -d device ; Override /dev/dsp default */#define OPF_INFO 'i' /* -i ; info mode option */#define OPF_HELP 'h' /* -h ; help optino */#define OPF_QUIET 'q' /* -q ; quiet mode */#define OPF_SAMPRATE 's' /* -s rate ; Sampling rate */#define OPF_STEREO 'S' /* -S ; Stereo */#define OPF_MONO 'M' /* -M ; Mono */#define OPF_TIME 't' /* -t seconds ; Time option */#define OPF_DATABITS 'b' /* -b data_bits; sample bits */#define OPF_IPCKEY 'k' /* -k key ; IPC Key */#define OPF_RESET 'R' /* -r ; reset semaphores option */#define OPF_PLAY_LOCK 'l' /* -l ; lock for play option */#define OPF_PLAY_UNLOCK 'u' /* -u ; unlock play option */#define OPF_RECD_LOCK 'L' /* -L ; lock for record option */#define OPF_RECD_UNLOCK 'U' /* -U ; unlock record option */#define OPF_DEBUG 'x' /* -x ; debug option */#define OPF_VERSION 'V' /* -V ; version and copyright *//* * Types internal to wavplay, in an attempt to isolate ourselves from * a dependance on a particular platform. */typedef unsigned char Byte;typedef short Int16;typedef long Int32;typedef unsigned long UInt32;typedef unsigned short UInt16;/* * This value sets buffer sizes for temporary buffers that sprintf() * uses, and for copying pathnames around in. You probably don't want * to mess with this. */#define MAXTXTLEN 2048 /* Must allow for long pathnames *//* * These are the wavplay command operation modes. */typedef enum { OprNoMode=0, /* No mode given (not determined yet) */ OprRecord=1, /* wavplay command is in "Record Mode" */ OprPlay=2, /* wavplay command is in "Play Mode" */ OprServer=3, /* wavplay is accting in "Server Mode" */} OprMode;/* * This enumerated type, selects between monophonic sound and * stereo sound (1 or 2 channels). */typedef enum { Mono, /* Monophonic sound (1 channel) */ Stereo /* Stereo sound (2 channels) */} Chan;/* * This type is used for those options that can be one or another * option flags (represented as the ASCII character), or no option * flags at all (zero value, ie. 0x00). */typedef struct { char optChar; /* Option character */} FlgOpt;/* * This type represents any unsigned 32 bit option value, if the member * optChar is non-zero (usually holds the ASCII flag option character). * If optChar is zero, then no value is present (or specified). */typedef struct { char optChar; /* Zero if not valid, else non-zero if active */ UInt32 optValue; /* The unsigned 32 bit value if optChar is true */} U32Opt;typedef struct { char optChar; /* Zero if not valid, else non-zero if active */ UInt16 optValue; /* The unsigned 16 bit value if optChar is true */} U16Opt;typedef struct { char optChar; /* Zero if not valid, else non-zero if active */ Chan optValue; /* The enumerated value for Stereo/Mono */} ChnOpt;/* * This structure holds the command line options for the wavplay command. * It is also used to pass option values around (in server mode etc.) */typedef struct { key_t IPCKey; /* Default IPC Key for lock */ OprMode Mode; /* Operation Mode: OprRecord or OprPlay */ FlgOpt PlayLock; /* -l or -u option flag */ FlgOpt RecdLock; /* -L or -U option flag */ char bResetLocks; /* True if semaphores are to be reset */ char bQuietMode; /* True if quiet mode is requested */ char bInfoMode; /* True if only wav header info is to be printed */ U32Opt SamplingRate; /* -s rate ; sampling rate in Hz */ ChnOpt Channels; /* -S ; or no -S option (stereo/mono respectively) */ U16Opt DataBits; /* -b bits ; number of bits per sample */ UInt32 Seconds; /* Time limited to this many seconds, else zero */ UInt32 StartSample; /* Sample to start playback with */ int ipc; /* Semaphore IPC ID */} WavPlayOpts;/* * These values represent values found in/or destined for a * WAV file. */typedef struct { UInt32 SamplingRate; /* Sampling rate in Hz */ Chan Channels; /* Mono or Stereo */ UInt32 Samples; /* Sample count */ UInt16 DataBits; /* Sample bit size (8/12/16) */ UInt32 DataStart; /* Offset to wav data */ UInt32 DataBytes; /* Data bytes in current chunk */ char bOvrSampling; /* True if sampling_rate overrided */ char bOvrMode; /* True if chan_mode overrided */ char bOvrBits; /* True if data_bits is overrided */} WAVINF;/* * This structure manages an open WAV file. */typedef struct { char rw; /* 'R' for read, 'W' for write */ char *Pathname; /* Pathname of wav file */ int fd; /* Open file descriptor or -1 */ WAVINF wavinfo; /* WAV file hdr info */ UInt32 num_samples; /* Total number of samples */ UInt32 StartSample; /* First sample to play */} WAVFILE;/* * This macro is used to return the system file descriptor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -