eaxac3.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /************************************************************************************************
  2. /
  3. / EAX-AC3 Open AL Extension Header file
  4. /
  5. / Description : The EAX-AC3 extension to Open AL provides a way to playback Dolby Digital AC3
  6. / files on systems equipped with a SB Live! card. The packaged AC3 data is output
  7. / via the MMSYSTEM Wave device.
  8. / If a SB Live! 5.1 card is installed then the AC3 data will be decoded by the
  9. / audio card.
  10. / If a legacy SB Live! card is installed then the AC3 data will be sent directly
  11. / to the S/PDIF Out.
  12. / The API supports multiple EAX-AC3 devices, and multiple AC3 streams. However
  13. / the current implementation provides one EAX-AC3 device capable of playing
  14. / one AC3 Stream at a time.
  15. /
  16. / Programmer : Daniel Peacock Creative Labs, Inc February 2001
  17. /
  18. /************************************************************************************************/
  19. #ifndef _EAXAC3_H_
  20. #define _EAXAC3_H_
  21. // Do not define the symbol EAXAC3_EXPORTS in any projects that use the EAX-AC3 Open AL Extension
  22. #ifdef EAXAC3_EXPORTS
  23. #define EAXAC3_API __declspec(dllexport)
  24. #else
  25. #define EAXAC3_API __declspec(dllimport)
  26. #endif
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #ifndef _HRESULT_DEFINED
  31. #define _HRESULT_DEFINED
  32. typedef signed long HRESULT;
  33. #endif
  34. enum POSFORMAT { MILLISECONDS, BYTES, AC3FRAMES };
  35. enum SOURCE { AC3FILE, MEMORY };
  36. // Success Codes
  37. #define EAXAC3_OK 0
  38. #define EAXAC3_ALREADYPLAYING 1
  39. #define EAXAC3_EOF 2
  40. // Error Codes
  41. #define EAXAC3ERR_UNABLETOOPENEAXAC3DEVICE -1
  42. #define EAXAC3ERR_WAVEOUTPREPAREHEADERFAILURE -2
  43. #define EAXAC3ERR_OUTOFMEMORY -3
  44. #define EAXAC3ERR_FILENOTFOUND -4
  45. #define EAXAC3ERR_AC3FILETOBIG -5
  46. #define EAXAC3ERR_AC3FRAMENOTFOUND -6
  47. #define EAXAC3ERR_AC3NOTAT48KHZ -7
  48. #define EAXAC3ERR_INVALIDAC3FRAME -8
  49. #define EAXAC3ERR_AC3FILENOTOPEN -9
  50. #define EAXAC3ERR_BUFFERNOTMULTIPLEOFAC3FRAMESIZE -10
  51. #define EAXAC3ERR_WAVEOUTERROR -11
  52. #define EAXAC3ERR_FAILEDTOCREATEEVENT -12
  53. #define EAXAC3ERR_EAXAC3DEVICENOTOPEN -13
  54. #define EAXAC3ERR_AC3STREAMALREADYOPEN -14
  55. #define EAXAC3ERR_POSITIONOUTOFRANGE -15
  56. #define EAXAC3ERR_NOTATSTARTOFAC3FRAME -16
  57. #define EAXAC3ERR_AC3STREAMNOTOPEN -17
  58. #define EAXAC3ERR_SETPOSITIONONLYWORKSONAC3FILES -18
  59. #define EAXAC3ERR_WRITEDATAONLYWORKSWITHMEMORYSTREAMS -19
  60. #define EAXAC3ERR_INVALIDPARAMETER -20
  61. #define EAXAC3ERR_NOTENOUGHAC3DATAINAC3DATABUFFER -21
  62. #define EAXAC3ERR_NOTENOUGHDATA -22
  63. #define EAXAC3ERR_EAXAC3DEVICEALREADYOPEN -23
  64. #define EAXAC3ERR_EAXAC3DEVICENOTFOUND -24
  65. #define EAXAC3ERR_UNSUPPORTED -25
  66. #define EAXAC3ERR_FAILEDTOCREATEFNTABLE -26
  67. #define DEFAULTEAXAC3DEVICE 0
  68. #define ENTIREBUFFER 0
  69. #define FROMWRITECURSOR 1
  70. #define LOOPING 1
  71. #define ENDOFDATA 1
  72. typedef unsigned int EAXAC3HANDLE;
  73. typedef unsigned int AC3STREAM;
  74. // Callback function
  75. typedef void (__stdcall *LPAC3CALLBACK)(AC3STREAM AC3Stream, int msg);
  76. // Callback messages
  77. #define EAXAC3NEEDMOREDATA 0
  78. #define EAXAC3REACHEDEND 1
  79. typedef struct
  80. {
  81. unsigned int nNumOfAC3Frames;
  82. unsigned int nAC3FrameSize;
  83. unsigned int nSizeOfFile;
  84. unsigned int nDuration;
  85. unsigned int nFrequency;
  86. } AC3FILEINFO, *LPAC3FILEINFO;
  87. #define UNKNOWN 1
  88. #define SPDIFPASSTHRU 2
  89. #define FULLDECODE 4
  90. typedef struct
  91. {
  92. char szDeviceName[256];
  93. unsigned int uFlags;
  94. unsigned int uStreams;
  95. unsigned int uReserved;
  96. } EAXAC3DEVICEINFO, *LPEAXAC3DEVICEINFO;
  97. // Function typedefs
  98. typedef int (*LPEAXAC3QUERYNUMBEROFDEVICES) (void);
  99. typedef HRESULT (*LPEAXAC3QUERYFILE) (char *, LPAC3FILEINFO, int);
  100. typedef HRESULT (*LPEAXAC3QUERYMEMORY) (char *, int, LPAC3FILEINFO, int);
  101. typedef int (*LPEAXAC3QUERYNOOFFRAMESREQFORPLAYBACK) (AC3STREAM);
  102. typedef HRESULT (*LPEAXAC3OPENPLAYBACKDEVICE) (EAXAC3HANDLE);
  103. typedef HRESULT (*LPEAXAC3CLOSEPLAYBACKDEVICE) (EAXAC3HANDLE);
  104. typedef HRESULT (*LPEAXAC3QUERYDEVICECAPS) (EAXAC3HANDLE, LPEAXAC3DEVICEINFO, int);
  105. typedef HRESULT (*LPEAXAC3GETPOSITION) (AC3STREAM, enum POSFORMAT, int *);
  106. typedef HRESULT (*LPEAXAC3SETFILEPOSITION) (AC3STREAM, enum POSFORMAT, int);
  107. typedef HRESULT (*LPEAXAC3OPENSTREAM) (EAXAC3HANDLE, AC3STREAM *, LPAC3CALLBACK, char *, enum SOURCE);
  108. typedef HRESULT (*LPEAXAC3CLOSESTREAM) (AC3STREAM);
  109. typedef HRESULT (*LPEAXAC3PREPLAYSTREAM) (AC3STREAM);
  110. typedef HRESULT (*LPEAXAC3PLAYSTREAM) (AC3STREAM, int);
  111. typedef HRESULT (*LPEAXAC3STOPSTREAM) (AC3STREAM);
  112. typedef HRESULT (*LPEAXAC3PAUSESTREAM) (AC3STREAM);
  113. typedef HRESULT (*LPEAXAC3RESUMESTREAM) (AC3STREAM);
  114. typedef HRESULT (*LPEAXAC3LOCKBUFFER) (AC3STREAM, unsigned long, void **, unsigned long *, void **,
  115. unsigned long *, unsigned long);
  116. typedef HRESULT (*LPEAXAC3UNLOCKBUFFER) (AC3STREAM, void *, unsigned long, void *, unsigned long, int);
  117. typedef HRESULT (*LPEAXAC3SETPLAYBACKMODE) (EAXAC3HANDLE, unsigned int);
  118. typedef char * (*LPEAXAC3GETERRORSTRING) (HRESULT, char *, int);
  119. typedef HRESULT (*LPEAXAC3GETLASTERROR) (HRESULT *);
  120. // Function table declaration
  121. typedef struct
  122. {
  123. LPEAXAC3QUERYNUMBEROFDEVICES EAXAC3QueryNumberOfDevices;
  124. LPEAXAC3QUERYFILE EAXAC3QueryFile;
  125. LPEAXAC3QUERYMEMORY EAXAC3QueryMemory;
  126. LPEAXAC3QUERYNOOFFRAMESREQFORPLAYBACK EAXAC3QueryNoOfFramesReqForPlayback;
  127. LPEAXAC3OPENPLAYBACKDEVICE EAXAC3OpenPlaybackDevice;
  128. LPEAXAC3CLOSEPLAYBACKDEVICE EAXAC3ClosePlaybackDevice;
  129. LPEAXAC3QUERYDEVICECAPS EAXAC3QueryDeviceCaps;
  130. LPEAXAC3GETPOSITION EAXAC3GetPosition;
  131. LPEAXAC3SETFILEPOSITION EAXAC3SetFilePosition;
  132. LPEAXAC3OPENSTREAM EAXAC3OpenStream;
  133. LPEAXAC3CLOSESTREAM EAXAC3CloseStream;
  134. LPEAXAC3PREPLAYSTREAM EAXAC3PrePlayStream;
  135. LPEAXAC3PLAYSTREAM EAXAC3PlayStream;
  136. LPEAXAC3STOPSTREAM EAXAC3StopStream;
  137. LPEAXAC3PAUSESTREAM EAXAC3PauseStream;
  138. LPEAXAC3RESUMESTREAM EAXAC3ResumeStream;
  139. LPEAXAC3LOCKBUFFER EAXAC3LockBuffer;
  140. LPEAXAC3UNLOCKBUFFER EAXAC3UnLockBuffer;
  141. LPEAXAC3SETPLAYBACKMODE EAXAC3SetPlaybackMode;
  142. LPEAXAC3GETERRORSTRING EAXAC3GetErrorString;
  143. LPEAXAC3GETLASTERROR EAXAC3GetLastError;
  144. } EAXAC3FNTABLE, *LPEAXAC3FNTABLE;
  145. #ifndef OPENAL
  146. typedef EAXAC3_API HRESULT (*LPEAXAC3GETFUNCTIONTABLE) (LPEAXAC3FNTABLE);
  147. #else
  148. typedef ALboolean (*LPALEAXAC3GETFUNCTIONTABLE) (LPEAXAC3FNTABLE);
  149. #endif
  150. // Functions exposed in the DLL
  151. EAXAC3_API HRESULT EAXAC3GetFunctionTable(LPEAXAC3FNTABLE lpEAXAC3FnTable);
  152. EAXAC3_API int EAXAC3QueryNumberOfDevices();
  153. EAXAC3_API HRESULT EAXAC3QueryFile(char *szAC3Filename, LPAC3FILEINFO lpAC3Caps, int nSizeOfAC3FileInfoStruct);
  154. EAXAC3_API HRESULT EAXAC3QueryMemory(char *lpBuffer, int nSizeOfBuffer, LPAC3FILEINFO lpAC3FileInfo,
  155. int nSizeOfAC3FileInfoStruct);
  156. EAXAC3_API int EAXAC3QueryNoOfFramesReqForPlayback(AC3STREAM AC3Stream);
  157. EAXAC3_API HRESULT EAXAC3OpenPlaybackDevice(EAXAC3HANDLE EAXAC3Handle);
  158. EAXAC3_API HRESULT EAXAC3ClosePlaybackDevice(EAXAC3HANDLE EAXAC3Handle);
  159. EAXAC3_API HRESULT EAXAC3QueryDeviceCaps(EAXAC3HANDLE EAXAC3Handle, LPEAXAC3DEVICEINFO lpEAXAC3DeviceInfo,
  160. int nSizeOfAC3DeviceInfoStruct);
  161. EAXAC3_API HRESULT EAXAC3GetPosition(AC3STREAM AC3Stream, enum POSFORMAT posFormat, int *lpAmount);
  162. EAXAC3_API HRESULT EAXAC3SetFilePosition(AC3STREAM AC3Stream, enum POSFORMAT posFormat, int nAmount);
  163. EAXAC3_API HRESULT EAXAC3OpenStream(EAXAC3HANDLE EAXAC3Handle, AC3STREAM *lpAC3Stream,
  164. LPAC3CALLBACK pAC3CallbackFn, char *szAC3Filename, enum SOURCE src);
  165. EAXAC3_API HRESULT EAXAC3CloseStream(AC3STREAM AC3Stream);
  166. EAXAC3_API HRESULT EAXAC3PrePlayStream(AC3STREAM AC3Stream);
  167. EAXAC3_API HRESULT EAXAC3PlayStream(AC3STREAM AC3Stream, int nLooping);
  168. EAXAC3_API HRESULT EAXAC3StopStream(AC3STREAM AC3Stream);
  169. EAXAC3_API HRESULT EAXAC3PauseStream(AC3STREAM AC3Stream);
  170. EAXAC3_API HRESULT EAXAC3ResumeStream(AC3STREAM AC3Stream);
  171. EAXAC3_API HRESULT EAXAC3LockBuffer(AC3STREAM AC3Stream, unsigned long ulBytes, void **ppvPointer1,
  172. unsigned long *pdwBytes1, void **ppvPointer2, unsigned long *pdwBytes2,
  173. unsigned long ulFlags);
  174. EAXAC3_API HRESULT EAXAC3UnLockBuffer(AC3STREAM AC3Stream, void *pvPointer1, unsigned long ulSize1,
  175. void *pvPointer2, unsigned long ulSize2, int nFinished);
  176. EAXAC3_API HRESULT EAXAC3SetPlaybackMode(EAXAC3HANDLE EAXAC3Handle, unsigned int ulPlayMode);
  177. EAXAC3_API char * EAXAC3GetErrorString(HRESULT hr, char *szErrorString, int nSizeOfErrorString);
  178. EAXAC3_API HRESULT EAXAC3GetLastError(HRESULT *hr);
  179. #ifdef __cplusplus
  180. }
  181. #endif
  182. #endif