Dac32.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. // ----------------------------------------------
  2. // - DAC32.DLL Header Datei -
  3. // - Written 1996-1998 by Christoph Schmelnik -
  4. // ----------------------------------------------
  5. // Changes
  6. // ===========
  7. // Version 1.2 :
  8. // -CMapDrive supports now up to 34 Host Adapters, because now it could access the drives under
  9. // NT with the DeviceControl Interface
  10. // The required information for this is coded as:
  11. // Drives accessed over the new Interface have a HostAdapterNumber above or equal to the
  12. // NumberOfHostAdapters (global Information).
  13. // The ID consists of the good old drive number, like in DOS.
  14. // The LUN is not used for the configuration, but it is used to hold the open handle to the device
  15. // The Burstmodus couldn't be used with the new access mode, so the default setting for those
  16. // drives is the Normal-mode. (For those drives is no difference between Burst- and Normal-mode)
  17. // -LoadASPI checks now the Windows Version and hold this result global in the DLL
  18. // -The Constructor of CSCSCD opens the handles to the new devices
  19. // -The destructor closes those handles
  20. // Interface changes are not required but some values must be handled differnt to avoid
  21. // misconfiguring, e.g. it is not allowed to configure the new drives ID, LUN, and HostAdapterNumber
  22. // -A bug in CWaveSave regarding conversion to mixed mono has been fixed.
  23. //
  24. // Version 1.33 : 18.01.1998
  25. // Changes:
  26. // Added speed selection support for all current Plextor drives
  27. //
  28. // Version 1.40 : 24.02.1998
  29. // Changes:
  30. // Set correct direction flags, to work with NT device IO interface and ATAPI drives
  31. // Changed main CD detection to TestUnitReady
  32. // Removed CD detection from Audio Status Info
  33. // Added hopefully correct read command for Matsushita/Panasonic drives
  34. // Added Parameters to CDAC class to allow the disabling of the audio test and to spin up the drive for a specified time
  35. // in seconds to avoid spin up problems on some drives. Both parameters have default values so it behaves like the old version
  36. // without the additional parameters
  37. // Added Parameter to the constructor of CWaveSave to disable writing any Headers. Also this parameter has a default to work like
  38. // before.
  39. // Added virtual function in CDAC to report buffer underruns in Burst Copy Mode
  40. // For the last feature an immediate parameter in WaitCDDA is added
  41. // GetLastSense function added to return the sense information for the last read audio command
  42. // Configuration in CMapDrive extended by new features
  43. // Fixed GetRedBook operator in CCDAdress
  44. // Added function to CD Class to read Media Cataloge Number
  45. //
  46. // Version 1.41 : 28.04.1998
  47. // Changes:
  48. // New GetInfoEx() function in CMapDrive, to allow a better result checking.
  49. //
  50. // Version 1.42 : 02.08.1998
  51. // Changes:
  52. // Added GetLastReadableAddress function to get the last readable Sektor of a session.
  53. // Added a flag in the drive properties for the function.
  54. // Added this function to the CDAC object.
  55. //
  56. // Version 1.43 : 23.12.1998
  57. // Changes:
  58. // Added Wave and DAC classes are now available in a MT version, the old versions will not longer be updated.
  59. //
  60. // Version 1.44 : 10.03.1999
  61. // Changes:
  62. // Added Support for current Plextor CDROM drives and CD-Writers.
  63. // Added Support for Jukeboxes
  64. // Changed Handling of the Ringbuffer
  65. //
  66. // Version 1.45 : 15.08.1999
  67. // Changes:
  68. // Added Enhanced error detection for Plextor drives.
  69. // Several Bugfixes (initialising under NT and Ringbuffer specific)
  70. //
  71. // Version 1.45-Build 11 : 11.11.1999
  72. // Changes:
  73. // Added a check for the MaxSektor parameter in CBaseWaveMT to avoid Program failures even if the applications provides an invalid value.
  74. // Changed source to comile with Borland compiler
  75. // Added MMC-2 Type which will be default for Sony CD-Writers 140 and 928
  76. // Skip Virtual CD devices in Bus scan
  77. // Fixed Array out of bound bug in drive detection.
  78. #ifndef _DAC32_H
  79. #define _DAC32_H
  80. #ifndef STRICT
  81. #define STRICT // Use strct typechecking
  82. #define WIN32_LEAN_AND_MEAN // compile only important Headerfiles
  83. #endif
  84. #include <windows.h>
  85. #include <stdio.h>
  86. #include "aspifunc.h"
  87. /*#ifdef DLL
  88. #define DACDLL __declspec(dllexport)
  89. #else
  90. #define DACDLL __declspec(dllimport)
  91. #endif*/
  92. #define DACDLL
  93. #ifdef _DEBUG
  94. #define DBGOUT(sz) OutputDebugString(sz)
  95. #else
  96. #define DBGOUT(sz)
  97. #endif
  98. //The Errormessages for the CD and DAC Classes
  99. #define CDOK 0x000
  100. #define CDUnknownDrive 0x001
  101. #define CDDriveNotReady 0x002
  102. #define CDUnknownCommand 0x003
  103. #define CDSeekError 0x006
  104. #define CDSectorNotFound 0x008
  105. #define CDReadError 0x00B
  106. #define CDGeneralError 0x00C
  107. #define CDNoCD 0x00E
  108. #define CDIllegalCDChange 0x00F
  109. #define CDDriveNotFound 0x100
  110. #define CDNoMemory 0x101
  111. #define CDDACUnable 0x102
  112. #define CDASPIError 0x103
  113. #define CDUserBreak 0x104
  114. #define CDTimeOut 0x105
  115. //The Errormessage for the wave classes
  116. #define WAVEFileOpenError 0x200
  117. #define WAVEFileWriteError 0x201
  118. #define WAVEChannelError 0x202
  119. #define WAVEBitsError 0x203
  120. #define WAVEFreqError 0x204
  121. #define WAVENameError 0x205
  122. #define WAVEMemoryError 0x206
  123. //The supported base drive types
  124. #define CDTYPE_TOSHIBA 0
  125. #define CDTYPE_SONY 1
  126. #define CDTYPE_NEC 2
  127. #define CDTYPE_PHILIPS 3
  128. #define CDTYPE_ATAPI 4
  129. #define CDTYPE_TOSHNEW 5
  130. #define CDTYPE_RICOH 6
  131. #define CDTYPE_MATSHITA 7
  132. #define CDTYPE_PLEXTOR 8
  133. #define CDTYPE_CYBERDRV 9
  134. #define JUKETYPE_SONY 0
  135. #define JUKETYPE_PIONEER 1
  136. //Amount of predefined drive mappings (relationship between real drives and base drive types)
  137. #define MaxMappings 22 // pgo
  138. //Amount of predefined jukebox mappings (relationship between real jukeboxes and base jukebox types)
  139. #define MaxMappingsJuke 2
  140. //The possible Copy modes
  141. #define ModeNormal 0
  142. #define ModeSynch 1
  143. #define ModeBurst 2
  144. //The possible Values for the DA Test
  145. #define DATEST_ALLWAYS 0
  146. #define DATEST_FIRSTTRACK 1
  147. #define DATEST_NEVER 2
  148. //The possible SpinUp modes
  149. #define SPINUP_ALLWAYS 0
  150. #define SPINUP_FIRSTTRACK 1
  151. #define SPINUP_NEVER 2
  152. // Amount of DWORD for the synchronisation
  153. #define SynLen 512
  154. // The Class for the Addressformats
  155. class DACDLL CCDAdress
  156. {
  157. public:
  158. void SetRedbook(long Value);
  159. void SetHSG(long Value)
  160. {
  161. Adresse=Value;
  162. };
  163. long GetHSG()
  164. {
  165. return Adresse;
  166. };
  167. long GetRedbook()
  168. {
  169. long t;
  170. t=(Adresse % 75)<<24;
  171. t+=((Adresse / 75) % 60)<<16;
  172. t+=((Adresse / 75) / 60)<<8;
  173. return t;
  174. };
  175. CCDAdress &operator = (const CCDAdress &other)
  176. {
  177. Adresse=other.Adresse;
  178. return (*this);
  179. };
  180. CCDAdress &operator + (const long Value)
  181. {
  182. Adresse+=Value;
  183. return (*this);
  184. };
  185. CCDAdress &operator - (const long Value)
  186. {
  187. Adresse-=Value;
  188. return (*this);
  189. };
  190. CCDAdress &operator += (const long Value)
  191. {
  192. Adresse+=Value;
  193. return (*this);
  194. };
  195. CCDAdress &operator -= (const long Value)
  196. {
  197. Adresse-=Value;
  198. return (*this);
  199. };
  200. private:
  201. long Adresse;
  202. };
  203. // Typendeclarations
  204. struct TDriveStatus
  205. {
  206. int DoorOpen; //Door open/closed
  207. int DoorLocked; //Door locked/unlocked
  208. int Cooked_RAW; //supports Cooked and RAW or Cooked
  209. int Read_Write; //supports read and write
  210. int Data_Audio_Video; //supports Data/Audio/Video or only Data
  211. int Interleave; //supports Interleave regarding ISO
  212. int CommandPrefetch; //supports Command Prefetching
  213. int AudioChannelManipulation; //supports Audio-Channel Manipulation
  214. int HSG_Redbook; //supports HSG and Redbook Addressing or only HSG
  215. int CDPresent; //CD inserted or not
  216. int RWSupport; //supports R-W-Sub Channels
  217. };
  218. struct TAudioStatus
  219. {
  220. BOOL Pause; //Play is paused
  221. BOOL IsPlaying; //CD is playing
  222. BOOL IsDone; //Play is stopped
  223. BOOL PlayError; //Play completed with error
  224. int TrackNummer; //Number of actual track
  225. CCDAdress AbsSektor,RelSektor; //Startsector and Endsector of last/next Play
  226. };
  227. struct TTrackFlag
  228. {
  229. BYTE AudioChannels; //Amount of Audio Channels (2/4)
  230. BOOL PreEmphasis; //Audio Channel with or without...
  231. BOOL DataTrack; //Data track or Audio track
  232. BOOL CopyProhibeted; //Digital copy prohibited
  233. };
  234. struct TTrackList
  235. {
  236. BYTE TrackNummer; //Number of Track
  237. CCDAdress StartSektor; //First sector in HSG Format
  238. long Laenge; //Amount of Sectors
  239. TTrackFlag Flags;
  240. };
  241. struct TTrackListeMem
  242. {
  243. TTrackList Info;
  244. TTrackListeMem *Prev,*Next;
  245. };
  246. struct TDriveInfo
  247. {
  248. int ID;
  249. int LUN;
  250. int HostAdapterNumber;
  251. int Type;
  252. int MaxSektors;
  253. int SynchSektors;
  254. int Mode;
  255. char VendorID[9];
  256. char ProductID[17];
  257. int Speed;
  258. int PerformDATest;
  259. int SpinUpMode;
  260. DWORD dwSpinUpTime;
  261. BOOL bUseLastReadableAddress;
  262. BOOL bUseC2ErrorInfo;
  263. BOOL bSpinDown;
  264. };
  265. struct TJukeInfo
  266. {
  267. int ID;
  268. int LUN;
  269. int HostAdapterNumber;
  270. int Type;
  271. int MaxDrives;
  272. int *pConnectedDrives;
  273. int MaxDiscs;
  274. char VendorID[9];
  275. char ProductID[17];
  276. };
  277. // The class with the infos for the type mapping
  278. class DACDLL CMapInfo
  279. {
  280. public:
  281. CMapInfo();
  282. char *GetTypName(int Index);
  283. int GetTypMapping(int Index);
  284. int GetTypMappingRev(int CDType);
  285. private:
  286. char TypNamen[MaxMappings][9];
  287. int TypMapping[MaxMappings];
  288. };
  289. // The class with the infos for the type mapping
  290. class DACDLL CMapInfoJuke
  291. {
  292. public:
  293. CMapInfoJuke();
  294. char *GetTypName(int Index);
  295. int GetTypMapping(int Index);
  296. int GetTypMappingRev(int JukeType);
  297. private:
  298. char TypNamen[MaxMappingsJuke][9];
  299. int TypMapping[MaxMappingsJuke];
  300. };
  301. // The base class (pure virtual) for the CD access
  302. class DACDLL CBaseCD
  303. {
  304. public:
  305. int Lasterror();
  306. virtual void PrepareCDDA()=0;
  307. virtual void ReadCDDA(CCDAdress StartSektor,long Sektoranzahl,void *Buffer,BOOL bUseC2ErrorInfo=FALSE)=0;
  308. virtual BOOL WaitCDDA(BOOL bImmediate=FALSE)=0;
  309. virtual void FinishCDDA()=0;
  310. virtual void SortWaveData(DWORD *Data,int Samples)=0;
  311. virtual CCDAdress GetErrorAdress()=0;
  312. virtual void Play_Audio(CCDAdress StartSektor,long Sektoranzahl)=0;
  313. virtual void Stop_Audio()=0;
  314. virtual void Pause_Audio()=0;
  315. virtual void Resume_Audio()=0;
  316. virtual TDriveStatus Get_DriveStatus()=0;
  317. virtual BOOL MediaChanged()=0;
  318. virtual void Get_MediaCatalogNumber(char szUPC[16])=0;
  319. virtual void EjectDisk()=0;
  320. virtual void LockDoor(int Lock)=0;
  321. virtual void CloseTray()=0;
  322. virtual void ReRead()=0;
  323. virtual CCDAdress GetLastReadableAddress(CCDAdress StartSektor)=0;
  324. virtual int GetMaxSektors()=0;
  325. virtual int GetSynchSektors()=0;
  326. virtual int GetMode()=0;
  327. virtual int GetSpeed()=0;
  328. virtual void InitSpeedTable()=0;
  329. virtual BYTE GetSupportedSpeeds()=0;
  330. virtual int GetCurrentSpeed()=0;
  331. virtual void SetCurrentSpeed(int Speed)=0;
  332. virtual int GetSpeed(BYTE Index)=0;
  333. int ReadFirstTrackInfo(TTrackList &Infos);
  334. int ReadNextTrackInfo(TTrackList &Infos);
  335. int ReadPrevTrackInfo(TTrackList &Infos);
  336. int ReadTrackInfo(TTrackList &Infos);
  337. int ReadMaxTracks();
  338. protected:
  339. int Error,BusyFlag,DoneFlag;
  340. TTrackListeMem *FirstTrack,*AktTrack;
  341. void DeleteTrackList();
  342. private:
  343. CBaseCD& operator = (const CBaseCD &other);
  344. };
  345. // The class for the access to SCSI drives
  346. class DACDLL CSCSICD:public CBaseCD
  347. {
  348. public:
  349. CSCSICD (char drive, TDriveInfo &xInfo);
  350. ~CSCSICD();
  351. virtual void PrepareCDDA();
  352. virtual void ReadCDDA(CCDAdress StartSektor,long Sektoranzahl,void *Buffer,BOOL bUseC2ErrorInfo=FALSE);
  353. virtual BOOL WaitCDDA(BOOL bImmediate=FALSE);
  354. virtual void FinishCDDA();
  355. virtual void SortWaveData(DWORD *Data,int Samples);
  356. virtual CCDAdress GetErrorAdress();
  357. virtual void Play_Audio(CCDAdress StartSektor,long Sektoranzahl);
  358. virtual void Stop_Audio();
  359. virtual void Pause_Audio();
  360. virtual void Resume_Audio();
  361. virtual TDriveStatus Get_DriveStatus();
  362. virtual BOOL MediaChanged();
  363. virtual TAudioStatus Get_AudioStatus_Info();
  364. virtual void Get_MediaCatalogNumber(char szUPC[16]);
  365. virtual void EjectDisk();
  366. virtual void LockDoor(int Lock);
  367. virtual void CloseTray();
  368. virtual void ReRead();
  369. virtual CCDAdress GetLastReadableAddress(CCDAdress StartSektor);
  370. virtual int GetMaxSektors();
  371. virtual int GetSynchSektors();
  372. virtual int GetMode();
  373. virtual int GetSpeed();
  374. virtual void InitSpeedTable();
  375. virtual BYTE GetSupportedSpeeds();
  376. virtual int GetCurrentSpeed();
  377. virtual void SetCurrentSpeed(int Speed);
  378. virtual int GetSpeed(BYTE Index);
  379. TDriveInfo &GetInfo()
  380. {
  381. return Config;
  382. };
  383. TSenseInfo GetSense();
  384. TSenseInfo GetLastSenseInfo();
  385. private:
  386. CSCSICD& operator = (const CSCSICD &other);
  387. TDriveInfo &Config; // Drive Configuration
  388. BOOL CDPresentLast,Changed; // Helpvariables for the MediaChanged function
  389. SRB_ExecSCSICmd ReadSRB; // SCSI Commando Block
  390. TDriveMode ModeData;
  391. BYTE NECRotationSpeed;
  392. CMapInfo MapInfo;
  393. DWORD StartReadTime;
  394. int SpeedTable[256];
  395. BYTE SupportedSpeeds;
  396. HANDLE m_hDriveEvent;
  397. TSenseInfo m_SenseInfo;
  398. BOOL m_bSpeedTableInitialized;
  399. };
  400. // The base class for saving/converting the audio data
  401. class DACDLL CBaseWave
  402. {
  403. public:
  404. int Lasterror();
  405. virtual void WritePuffer(long Samples,DWORD *Buffer)=0;
  406. protected:
  407. int Error; //last occured error
  408. private:
  409. CBaseWave& operator = (const CBaseWave &other);
  410. };
  411. typedef struct
  412. {
  413. BOOL bIsUsed; //Is Buffer used?
  414. BOOL bReady; //Is Nuffer ready to write?
  415. int nSamples; //Number of Samples in Buffer.
  416. int nZeroSamples; //Number of Silence Samples to insert before the buffer
  417. DWORD *dwBuffer; //Buffer for Audio Data
  418. } WAVEBUFFER, *PWAVEBUFFER;
  419. typedef struct _WAVEBUFFERLIST
  420. {
  421. PWAVEBUFFER pWaveBuffer;
  422. _WAVEBUFFERLIST *pNext;
  423. } WAVEBUFFERLIST, *PWAVEBUFFERLIST;
  424. typedef struct
  425. {
  426. HANDLE hEvent;
  427. LPVOID pData;
  428. } TWAVEMTSTRUCT;
  429. // The base class for saving/converting the audio data as its own thread
  430. class DACDLL CBaseWaveMT
  431. {
  432. public:
  433. CBaseWaveMT(DWORD dwBufferSize,BOOL bUseHighPriority=FALSE,int MaxSektors=27,DWORD dwExtraBytes=0);
  434. ~CBaseWaveMT();
  435. void SetFadeInOut(int dwTotalSamples,int dwFadeSamples);
  436. PWAVEBUFFER GetBuffer(); //returns NULL if no Buffer is available
  437. void SignalBuffer(); //signal if a buffer is filled;
  438. int Lasterror();
  439. double GetBufferFullRatio();
  440. DWORD GetBytesInBuffer();
  441. virtual void WritePuffer(long Samples,DWORD *Buffer)=0;
  442. friend unsigned _stdcall WaveThreadProc(LPVOID pUserData);
  443. protected:
  444. int Error; //last occured error
  445. void StartThread(); //call this from your own initialisation function
  446. BOOL WriteData();
  447. void StopThread(BOOL bImmediate=FALSE); //call this from your own cleanup function
  448. private:
  449. CBaseWaveMT& operator = (const CBaseWaveMT &other);
  450. DWORD m_Nullen[256];
  451. PWAVEBUFFERLIST m_pFirstBuffer, m_pReadBuffer, m_pWriteBuffer;
  452. TWAVEMTSTRUCT m_WaveInfo;
  453. BOOL m_bStopThread,m_bAbortThread,m_bIsWorking;
  454. HANDLE m_hWaveThread;
  455. BOOL m_bUseHighPriority;
  456. int m_dwTotalSamples,m_dwFadeSamples,m_dwCurrentSample;
  457. int m_nBufferNum,m_nReadBufferNum,m_nWriteBufferNum;
  458. int m_nMaxSektors;
  459. };
  460. // The class for saving audio data in a wave file
  461. class DACDLL CWaveSave:public CBaseWave
  462. {
  463. public:
  464. CWaveSave(const char *DateiName,BYTE Freq,BYTE Channels,BYTE Bits,BOOL bWriteHeaders=TRUE);
  465. ~CWaveSave();
  466. virtual void WritePuffer(long Samples,DWORD *Buffer);
  467. private:
  468. void WMono8(long Samples,DWORD *Buffer);
  469. void WStereo8(long Samples,DWORD *Buffer);
  470. void WMono16(long Samples,DWORD *Buffer);
  471. void WStereo16(long Samples,DWORD *Buffer);
  472. void WLR8(long Samples,int Mode,DWORD *Buffer);
  473. void WLR16(long Samples,int Mode,DWORD *Buffer);
  474. CWaveSave& operator = (const CWaveSave &other);
  475. BYTE ConvertType; //CodeNumber of the conversion type
  476. FILE *Datei; //file variable to access the wave file
  477. WORD *DPM16; //Pointer to the file data buffer
  478. BYTE *DPM8; //Pointer to the file data buffer
  479. DWORD *DPS16; //Pointer to the file data buffer
  480. BYTE *DPS8; //Pointer to the file data buffer
  481. int DatenCount; //Counter of data in buffer
  482. long WaveBytes; //Counts all written bytes
  483. BYTE SAdd; //Value to increment the source counter
  484. BOOL m_bWriteHeaders; //Write Headers of Wave file
  485. };
  486. // The class for saving audio data in a wave file in its own thread
  487. class DACDLL CWaveSaveMT:public CBaseWaveMT
  488. {
  489. public:
  490. CWaveSaveMT(DWORD dwBufferSize,BOOL bUseHighPriority=FALSE,int MaxSektors=27,DWORD dwExtraBytes=0):CBaseWaveMT(dwBufferSize,bUseHighPriority,MaxSektors,dwExtraBytes)
  491. {
  492. };
  493. void Init(const char *DateiName,BYTE Freq,BYTE Channels,BYTE Bits,BOOL bWriteHeaders=TRUE);
  494. void Done(BOOL bImmediate=FALSE);
  495. virtual void WritePuffer(long Samples,DWORD *Buffer);
  496. private:
  497. void WMono8(long Samples,DWORD *Buffer);
  498. void WStereo8(long Samples,DWORD *Buffer);
  499. void WMono16(long Samples,DWORD *Buffer);
  500. void WStereo16(long Samples,DWORD *Buffer);
  501. void WLR8(long Samples,int Mode,DWORD *Buffer);
  502. void WLR16(long Samples,int Mode,DWORD *Buffer);
  503. CWaveSave& operator = (const CWaveSave &other);
  504. BYTE ConvertType; //CodeNumber of the conversion type
  505. FILE *Datei; //file variable to access the wave file
  506. WORD *DPM16; //Pointer to the file data buffer
  507. BYTE *DPM8; //Pointer to the file data buffer
  508. DWORD *DPS16; //Pointer to the file data buffer
  509. BYTE *DPS8; //Pointer to the file data buffer
  510. int DatenCount; //Counter of data in buffer
  511. long WaveBytes; //Counts all written bytes
  512. BYTE SAdd; //Value to increment the source counter
  513. BOOL m_bWriteHeaders; //Write Headers of Wave file
  514. };
  515. // The class for copying the audio data from CD.
  516. class DACDLL CDAC
  517. {
  518. public:
  519. CDAC(CBaseCD *pDrive,CBaseWave *pWave,
  520. CCDAdress Start,long Laenge,BOOL xKillZeros,BOOL bPerformDATest=TRUE,DWORD dwSpinUpTime=0,BOOL bUseLastReadableAddress=FALSE);
  521. ~CDAC();
  522. int Lasterror();
  523. void Copy();
  524. int Errors();
  525. void StopCopy();
  526. // The following member functions are declared as virtual. They could be used to display
  527. // information to the user. They do nothing by default.
  528. virtual void WriteInit();
  529. virtual void WritePercent(float Percent);
  530. virtual void WriteReading();
  531. virtual void WriteReadingEnd();
  532. virtual void WriteSynch();
  533. virtual void WriteSynchEnd();
  534. virtual void WriteFlushing();
  535. virtual void WriteFlushingEnd();
  536. virtual void WriteSynchError();
  537. virtual void WriteBufferUnderrun(CCDAdress Start);
  538. virtual void WriteReRead(CCDAdress Start,long Laenge);
  539. virtual void WriteSektorsSkipped(CCDAdress Start,long Laenge);
  540. virtual void WriteDone();
  541. virtual void OnIdle();
  542. protected:
  543. CCDAdress StartSektor,StartOld;
  544. int SynchErrors,Error;
  545. long Anzahl,AnzahlOld,Remain;
  546. private:
  547. CBaseCD *m_pCD;
  548. BOOL RunCopy,KillFirst,KillLast,KillZero,Found;
  549. DWORD m_dwSpinUpTime;
  550. CBaseWave *m_pWaveSave;
  551. long SektorAnzahl,Retries,SynchDiff,ZeroCount;
  552. DWORD *MemBlocks[2];
  553. int BlockCount,S_Offset;
  554. int SpeedSave;
  555. DWORD m_Nullen[256];
  556. void ReadCDDA(CCDAdress Start,long Sektoranzahl,void *Buffer);
  557. void FlushWave();
  558. void FlushSynch(int Samples,DWORD *Data);
  559. void MakeTable(DWORD *Werte,DWORD *Table);
  560. int SynchSearch(DWORD *String1,DWORD *String2,DWORD *Table);
  561. void SynchWave();
  562. CDAC& operator = (const CDAC &other);
  563. };
  564. // The class for copying the audio data from CD.
  565. class DACDLL CDACMT
  566. {
  567. public:
  568. CDACMT(CBaseCD *pDrive,CBaseWaveMT *pWave,
  569. CCDAdress Start,long Laenge,BOOL xKillZeros,BOOL bPerformDATest=TRUE,DWORD dwSpinUpTime=0,BOOL bUseHighPriority=FALSE,BOOL bUseC2ErrorInfo=FALSE,BOOL bSpinDown=FALSE,BOOL bUseLastReadableAddress=FALSE);
  570. ~CDACMT();
  571. int Lasterror();
  572. void Copy();
  573. int Errors();
  574. void StopCopy();
  575. // The following member functions are declared as virtual. They could be used to display
  576. // information to the user. They do nothing by default.
  577. virtual void WriteInit();
  578. virtual void WritePercent(float Percent);
  579. virtual void WriteReading();
  580. virtual void WriteReadingEnd();
  581. virtual void WriteSynch();
  582. virtual void WriteSynchEnd();
  583. virtual void WriteFlushing();
  584. virtual void WriteFlushingEnd();
  585. virtual void WriteSynchError();
  586. virtual void WriteBufferUnderrun(CCDAdress Start);
  587. virtual void WriteReRead(CCDAdress Start,long Laenge);
  588. virtual void WriteSektorsSkipped(CCDAdress Start,long Laenge);
  589. virtual void WriteDone();
  590. virtual void OnIdle(BOOL bReturnFast=TRUE);
  591. friend unsigned _stdcall DACThreadProc(LPVOID pUserData);
  592. protected:
  593. CCDAdress StartSektor,StartOld;
  594. int SynchErrors,Error;
  595. long Anzahl,AnzahlOld,Remain;
  596. void CopyMT();
  597. private:
  598. CBaseCD *m_pCD;
  599. BOOL RunCopy,KillFirst,KillLast,KillZero,Found;
  600. DWORD m_dwSpinUpTime;
  601. CBaseWaveMT *m_pWaveSave;
  602. BOOL m_bUseC2ErrorInfo;
  603. BOOL m_bSpinDown;
  604. long SektorAnzahl,Retries,SynchDiff,ZeroCount;
  605. PWAVEBUFFER MemBlocks[2];
  606. int BlockCount,S_Offset;
  607. int SpeedSave;
  608. int m_MaxSektors;
  609. int m_SynchSektors;
  610. void ReadCDDA(CCDAdress Start,long Sektoranzahl,void *Buffer);
  611. void FlushWave(int nMax=2);
  612. void FlushSynch(int Samples,PWAVEBUFFER Data);
  613. void MakeTable(DWORD *Werte,DWORD *Table);
  614. int SynchSearch(DWORD *String1,DWORD *String2,DWORD *Table);
  615. void SynchWave();
  616. CDACMT& operator = (const CDACMT &other);
  617. HANDLE m_hDACThread;
  618. BOOL m_bUseHighPriority;
  619. };
  620. // The class for configuring the SCSI CDROM drives
  621. class DACDLL CMapDrive
  622. {
  623. public:
  624. CMapDrive(BOOL bDoReset=TRUE);
  625. ~CMapDrive();
  626. void Reset();
  627. int GetMaxDrives();
  628. TDriveInfo &GetInfo(int index);
  629. BOOL GetInfoEx(int index, TDriveInfo *&pInfo);
  630. void DeleteInfo(int index);
  631. int GetMaxHostAdapters();
  632. int GetSupportedHostAdapterMemory(int index);
  633. void SetSupportedHostAdapterMemory(int index,int Memory);
  634. int GetMaxSektors(int HostAdapterNumber);
  635. protected:
  636. void DeleteAll();
  637. private:
  638. struct TDriveInfoMem
  639. {
  640. TDriveInfo Info;
  641. TDriveInfoMem *Next;
  642. };
  643. TDriveInfoMem *First;
  644. int HostAdapterMemory[34];
  645. HANDLE m_hDriveEvent;
  646. };
  647. // The class for configuring the SCSI Jukeboxes
  648. class DACDLL CMapJuke
  649. {
  650. public:
  651. CMapJuke(BOOL bDoReset=TRUE);
  652. ~CMapJuke();
  653. void Reset();
  654. int GetMaxJukes();
  655. TJukeInfo &GetInfo(int index);
  656. BOOL IsWorking(int index);
  657. void SetWorking(int index,BOOL bIsWorking);
  658. void DeleteInfo(int index);
  659. protected:
  660. void DeleteAll();
  661. private:
  662. struct TJukeInfoMem
  663. {
  664. TJukeInfo Info;
  665. BOOL bIsWorking;
  666. TJukeInfoMem *Next;
  667. };
  668. TJukeInfoMem *First;
  669. HANDLE m_hJukeEvent;
  670. };
  671. //The class to access Jukeboxes
  672. class DACDLL CJukeBox
  673. {
  674. public:
  675. CJukeBox (TJukeInfo &xInfo);
  676. ~CJukeBox();
  677. //use following defines to address an item in the jukebox:
  678. //drive0..x : 0x4000...0x400x
  679. //storage1..xxx : 0x0001...0x0xxx
  680. BOOL MoveMedium(int Source,int Destination);
  681. TJukeInfo &GetInfo()
  682. {
  683. return Config;
  684. };
  685. private:
  686. TJukeInfo &Config; // Drive Configuration
  687. CMapInfoJuke MapInfo;
  688. HANDLE m_hJukeEvent;
  689. };
  690. // ----------------------
  691. // function declarations
  692. // ----------------------
  693. // initialize and deinatialize the WNASPI32.DLL and some internal flags
  694. int DACDLL LoadASPI();
  695. int DACDLL FreeASPI();
  696. int DACDLL CheckASPI();
  697. #endif //_DAC32_H