home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / software / sviluppo / ahisrc / device / device.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-22  |  6.2 KB  |  186 lines

  1. /* $Id: device.h,v 4.5 1999/04/22 19:42:00 lcs Exp $ */
  2.  
  3. /*
  4.      AHI - Hardware independent audio subsystem
  5.      Copyright (C) 1996-1999 Martin Blom <martin@blom.org>
  6.      
  7.      This library is free software; you can redistribute it and/or
  8.      modify it under the terms of the GNU Library General Public
  9.      License as published by the Free Software Foundation; either
  10.      version 2 of the License, or (at your option) any later version.
  11.      
  12.      This library is distributed in the hope that it will be useful,
  13.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.      Library General Public License for more details.
  16.      
  17.      You should have received a copy of the GNU Library General Public
  18.      License along with this library; if not, write to the
  19.      Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge,
  20.      MA 02139, USA.
  21. */
  22.  
  23. #ifndef _DEVICE_H_
  24. #define _DEVICE_H_
  25.  
  26. /*** New Style Device definitions ***/
  27.  
  28. #define NSCMD_DEVICEQUERY   0x4000
  29.  
  30. #define NSDEVTYPE_UNKNOWN       0   /* No suitable category, anything */
  31. #define NSDEVTYPE_GAMEPORT      1   /* like gameport.device */
  32. #define NSDEVTYPE_TIMER         2   /* like timer.device */
  33. #define NSDEVTYPE_KEYBOARD      3   /* like keyboard.device */
  34. #define NSDEVTYPE_INPUT         4   /* like input.device */
  35. #define NSDEVTYPE_TRACKDISK     5   /* like trackdisk.device */
  36. #define NSDEVTYPE_CONSOLE       6   /* like console.device */
  37. #define NSDEVTYPE_SANA2         7   /* A >=SANA2R2 networking device */
  38. #define NSDEVTYPE_AUDIOARD      8   /* like audio.device */
  39. #define NSDEVTYPE_CLIPBOARD     9   /* like clipboard.device */
  40. #define NSDEVTYPE_PRINTER       10  /* like printer.device */
  41. #define NSDEVTYPE_SERIAL        11  /* like serial.device */
  42. #define NSDEVTYPE_PARALLEL      12  /* like parallel.device */
  43.  
  44. struct NSDeviceQueryResult
  45. {
  46.   /*
  47.   ** Standard information
  48.   */
  49.   ULONG   DevQueryFormat;         /* this is type 0               */
  50.   ULONG   SizeAvailable;          /* bytes available              */
  51.  
  52.   /*
  53.   ** Common information (READ ONLY!)
  54.   */
  55.   UWORD   DeviceType;             /* what the device does         */
  56.   UWORD   DeviceSubType;          /* depends on the main type     */
  57.   UWORD   *SupportedCommands;     /* 0 terminated list of cmd's   */
  58.  
  59.   /* May be extended in the future! Check SizeAvailable! */
  60. };
  61.  
  62. #define DRIVE_NEWSTYLE  (0x4E535459L)   /* 'NSTY' */
  63. #define NSCMD_TD_READ64     0xc000
  64. #define NSCMD_TD_WRITE64    0xc001
  65. #define NSCMD_TD_SEEK64     0xc002
  66. #define NSCMD_TD_FORMAT64   0xc003
  67.  
  68.  
  69. /*** My own stuff ***/
  70.  
  71. #define AHI_PRI         50      /* Priority for the device process */
  72.  
  73. #define PLAYERFREQ      100     /* How often the PlayerFunc is called */
  74.  
  75. #define AHICMD_END      CMD_NONSTD
  76.  
  77. #define AHICMD_WRITTEN  (0x8000 | CMD_WRITE)
  78.  
  79. #define ahir_Extras     ahir_Private[0]
  80. #define GetExtras(req)  ((struct Extras *) req->ahir_Private[0])
  81. #define NOCHANNEL       65535
  82.  
  83. struct Extras
  84. {
  85.         UWORD   Channel;
  86.         UWORD   Sound;
  87.         LONG    BuffSamples;
  88.         LONG    Count;
  89. };
  90.  
  91. /* Voice->Flags definitions */
  92.  
  93. /* Set by the interrupt when a new sound has been started */
  94. #define VB_STARTED              0
  95. #define VF_STARTED              (1<<0)
  96.  
  97. struct Voice
  98. {
  99.         UWORD                    NextSound;
  100.         UBYTE                    Flags;
  101.         UBYTE                    Pad;
  102.         Fixed                    NextVolume;
  103.         Fixed                    NextPan;
  104.         ULONG                    NextFrequency;
  105.         ULONG                    NextOffset;
  106.         ULONG                    NextLength;
  107.         struct AHIRequest       *NextRequest;
  108.         
  109.         struct AHIRequest       *QueuedRequest;
  110.         struct AHIRequest       *PlayingRequest;
  111. };
  112.  
  113. /* Special Offset values */
  114.  
  115. #define FREE    -1      /* Channel is not playing anything */
  116. #define MUTE    -2      /* Channel will be muted when current sound is finished */
  117. #define PLAY    -3      /* Channel will play more when current sound is finished */
  118.  
  119. #define MAXSOUNDS       128
  120. #define SOUND_FREE      0
  121. #define SOUND_IN_USE    1
  122.  
  123. struct AHIDevUnit
  124. {
  125.         struct Unit              Unit;
  126.         UBYTE                    UnitNum;
  127.         BYTE                     PlaySignal;
  128.         BYTE                     RecordSignal;
  129.         BYTE                     SampleSignal;
  130.         struct Process          *Process;
  131.         struct Process          *Master;
  132.         struct Hook              PlayerHook;
  133.         struct Hook              RecordHook;
  134.         struct Hook              SoundHook;
  135.         struct Hook              ChannelInfoHook;
  136.         
  137.         struct AHIEffChannelInfo *ChannelInfoStruct;
  138.  
  139.         WORD                     RecordOffDelay;
  140.         WORD                    *RecordBuffer;
  141.         ULONG                    RecordSize;
  142.  
  143.         BOOL                     IsPlaying;     // Currently playing (or want to)
  144.         BOOL                     IsRecording;   // Currently recording
  145.         BOOL                     ValidRecord;   // The record buffer contains valid data
  146.         BOOL                     FullDuplex;    // Mode is full duplex
  147.         UWORD                    StopCnt;       // CMD_STOP count
  148.  
  149.         struct SignalSemaphore   ListLock;
  150.         struct MinList           ReadList;
  151.         struct MinList           PlayingList;
  152.         struct MinList           SilentList;
  153.         struct MinList           WaitingList;
  154.  
  155.         struct MinList           RequestQueue;  // Not locked by ListLock!
  156.  
  157.         struct Voice            *Voices;
  158.  
  159.         struct AHIAudioCtrl     *AudioCtrl;
  160.         ULONG                    AudioMode;
  161.         ULONG                    Frequency;
  162.         UWORD                    Channels;
  163.         UWORD                    Pad2;
  164.         Fixed                    MonitorVolume;
  165.         Fixed                    InputGain;
  166.         Fixed                    OutputVolume;
  167.         ULONG                    Input;
  168.         ULONG                    Output;
  169.  
  170.         UBYTE                    Sounds[MAXSOUNDS];
  171. };
  172.  
  173. BOOL
  174. ReadConfig ( struct AHIDevUnit *iounit,
  175.              struct AHIBase *AHIBase );
  176.  
  177. BOOL
  178. AllocHardware ( struct AHIDevUnit *iounit,
  179.                 struct AHIBase *AHIBase );
  180.  
  181. void
  182. FreeHardware ( struct AHIDevUnit *iounit,
  183.                struct AHIBase *AHIBase );
  184.  
  185. #endif /* _DEVICE_H_ */
  186.