Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

431 lines
8.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: cdapi.h
  3. *
  4. *
  5. *
  6. *
  7. * Created: 02-11-93
  8. * Author: Stephen Estrop [StephenE]
  9. *
  10. * Copyright (c) 1993 Microsoft Corporation
  11. \**************************************************************************/
  12. #ifdef USE_IOCTLS
  13. #include <ntddcdrm.h>
  14. #else
  15. #include <mmsystem.h>
  16. #endif
  17. #define MAX_CD_DEVICES 50
  18. /* -------------------------------------------------------------------------
  19. ** Defines for cdrom state
  20. **
  21. ** These are bit flags
  22. ** -------------------------------------------------------------------------
  23. */
  24. #define CD_PLAYING 0x0001
  25. #define CD_STOPPED 0x0002
  26. #define CD_PAUSED 0x0004
  27. #define CD_SKIP_F 0x0008
  28. #define CD_SKIP_B 0x0010
  29. #define CD_FF 0x0020
  30. #define CD_RW 0x0040
  31. #define CD_SEEKING (CD_FF | CD_RW)
  32. #define CD_LOADED 0x0080
  33. #define CD_NO_CD 0x0100
  34. #define CD_DATA_CD_LOADED 0x0200
  35. #define CD_EDITING 0x0400
  36. #define CD_PAUSED_AND_MOVED 0x0800
  37. #define CD_PLAY_PENDING 0x1000
  38. #define CD_WAS_PLAYING 0x2000
  39. #define CD_IN_USE 0x4000
  40. #define CD_BEING_SCANNED 0x8000
  41. /* -------------------------------------------------------------------------
  42. ** Some MACROS
  43. ** -------------------------------------------------------------------------
  44. */
  45. #ifdef USE_IOCTLS
  46. #define CDHANDLE HANDLE
  47. #else
  48. #define CDHANDLE MCIDEVICEID
  49. #endif
  50. #define CDTIME(x) g_Devices[x]->time
  51. #define CURRTRACK(x) g_Devices[x]->time.CurrTrack
  52. #ifdef USE_IOCTLS
  53. #define TRACK_M(x,y) g_Devices[x]->toc.TrackData[y].Address[1]
  54. #define TRACK_S(x,y) g_Devices[x]->toc.TrackData[y].Address[2]
  55. #define TRACK_F(x,y) g_Devices[x]->toc.TrackData[y].Address[3]
  56. #else
  57. #define TRACK_M(x,y) MCI_MSF_MINUTE(g_Devices[x]->toc.TrackData[y].Address)
  58. #define TRACK_S(x,y) MCI_MSF_SECOND(g_Devices[x]->toc.TrackData[y].Address)
  59. #define TRACK_F(x,y) MCI_MSF_FRAME(g_Devices[x]->toc.TrackData[y].Address)
  60. #endif
  61. #define FIRSTTRACK(x) g_Devices[x]->toc.FirstTrack
  62. #define LASTTRACK(x) g_Devices[x]->toc.LastTrack
  63. #define ALLTRACKS(x) g_Devices[x]->CdInfo.AllTracks
  64. #define PLAYLIST(x) g_Devices[x]->CdInfo.PlayList
  65. #define SAVELIST(x) g_Devices[x]->CdInfo.SaveList
  66. #define TITLE(x) g_Devices[x]->CdInfo.Title
  67. #define ARTIST(x) g_Devices[x]->CdInfo.Artist
  68. #define NUMTRACKS(x) g_Devices[x]->CdInfo.NumTracks
  69. #define STATE(x) g_Devices[x]->State
  70. #define g_State (g_Devices[g_CurrCdrom]->State)
  71. #define ABS(x) ((x) < 0 ? (-(x)) : (x))
  72. /* -------------------------------------------------------------------------
  73. ** Type definitions for CD database entries, etc.
  74. **
  75. ** -------------------------------------------------------------------------
  76. */
  77. #define TITLE_LENGTH 128
  78. #define ARTIST_LENGTH 128
  79. #define TRACK_TITLE_LENGTH 128
  80. #define MAX_TRACKS 100
  81. #define NEW_FRAMEOFFSET 1234567
  82. #ifndef USE_IOCTLS
  83. //
  84. // Maximum CD Rom size
  85. //
  86. #define MAXIMUM_NUMBER_TRACKS 100
  87. #define MAXIMUM_CDROM_SIZE 804
  88. //
  89. // Used with StatusTrackPos call
  90. //
  91. #define MCI_STATUS_TRACK_POS 0xBEEF
  92. typedef struct
  93. {
  94. DWORD dwStatus;
  95. DWORD dwTrack;
  96. DWORD dwDiscTime;
  97. } STATUSTRACKPOS, *PSTATUSTRACKPOS;
  98. //
  99. // CD ROM Table OF Contents (TOC)
  100. //
  101. // Format 0 - Get table of contents
  102. //
  103. typedef struct _TRACK_DATA {
  104. UCHAR TrackNumber;
  105. DWORD Address;
  106. DWORD AddressF;
  107. } TRACK_DATA, *PTRACK_DATA;
  108. typedef struct _CDROM_TOC {
  109. //
  110. // Header
  111. //
  112. UCHAR Length[2];
  113. UCHAR FirstTrack;
  114. UCHAR LastTrack;
  115. //
  116. // Track data
  117. //
  118. TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS];
  119. } CDROM_TOC, *PCDROM_TOC;
  120. #define CDROM_TOC_SIZE sizeof(CDROM_TOC)
  121. #endif
  122. typedef struct _TRACK_INF {
  123. struct _TRACK_INF *next;
  124. int TocIndex;
  125. TCHAR name[TRACK_TITLE_LENGTH];
  126. } TRACK_INF, *PTRACK_INF;
  127. typedef struct _TRACK_PLAY {
  128. struct _TRACK_PLAY *prevplay;
  129. struct _TRACK_PLAY *nextplay;
  130. int TocIndex;
  131. int min;
  132. int sec;
  133. } TRACK_PLAY, *PTRACK_PLAY;
  134. typedef struct _TIMES {
  135. PTRACK_PLAY CurrTrack;
  136. int TotalMin;
  137. int TotalSec;
  138. int RemMin;
  139. int RemSec;
  140. int TrackCurMin;
  141. int TrackCurSec;
  142. int TrackTotalMin;
  143. int TrackTotalSec;
  144. int TrackRemMin;
  145. int TrackRemSec;
  146. } TIMES, *PTIMES;
  147. typedef struct _ENTRY {
  148. PTRACK_INF AllTracks;
  149. PTRACK_PLAY PlayList;
  150. PTRACK_PLAY SaveList;
  151. int NumTracks;
  152. DWORD Id;
  153. BOOL save;
  154. BOOL IsVirginCd;
  155. int iFrameOffset;
  156. TCHAR Title[TITLE_LENGTH];
  157. TCHAR Artist[TITLE_LENGTH];
  158. } ENTRY, *PENTRY;
  159. typedef struct _CDROM {
  160. CDHANDLE hCd;
  161. HANDLE hThreadToc;
  162. BOOL fIsTocValid;
  163. TCHAR drive;
  164. DWORD State;
  165. CDROM_TOC toc;
  166. ENTRY CdInfo;
  167. TIMES time;
  168. BOOL fShowLeadIn;
  169. BOOL fProcessingLeadIn;
  170. BOOL fKilledPlayList; // Used to prevent bug with -track option
  171. } CDROM, *PCDROM;
  172. typedef struct _CURRPOS {
  173. #ifdef USE_IOCTLS
  174. UCHAR AudioStatus;
  175. #else
  176. DWORD AudioStatus;
  177. #endif
  178. int Track;
  179. int Index;
  180. int m;
  181. int s;
  182. int f;
  183. int ab_m;
  184. int ab_s;
  185. int ab_f;
  186. } CURRPOS, *PCURRPOS;
  187. /* -------------------------------------------------------------------------
  188. ** High level function declarations
  189. **
  190. ** -------------------------------------------------------------------------
  191. */
  192. #ifdef __cplusplus
  193. extern "C" {
  194. #endif
  195. void
  196. CheckStatus(
  197. LPSTR szCaller,
  198. DWORD status,
  199. int cdrom
  200. );
  201. void
  202. NoMediaUpdate(
  203. int cdrom
  204. );
  205. void
  206. CheckUnitCdrom(
  207. int cdrom,
  208. BOOL fForceRescan
  209. );
  210. BOOL
  211. EjectTheCdromDisc(
  212. INT cdrom
  213. );
  214. BOOL
  215. PlayCurrTrack(
  216. int cdrom
  217. );
  218. BOOL
  219. StopTheCdromDrive(
  220. int cdrom
  221. );
  222. BOOL
  223. PauseTheCdromDrive(
  224. int cdrom
  225. );
  226. BOOL
  227. ResumeTheCdromDrive(
  228. int cdrom
  229. );
  230. BOOL
  231. SeekToCurrSecond(
  232. int cdrom
  233. );
  234. BOOL
  235. GetCurrPos(
  236. int cdrom,
  237. PCURRPOS CpPtr
  238. );
  239. BOOL
  240. SeekToTrackAndHold(
  241. int cdrom,
  242. int tindex
  243. );
  244. /* -------------------------------------------------------------------------
  245. ** NT Layer Function Declarations
  246. **
  247. ** These are the low-level functions that manipulate the specified CD-ROM
  248. ** device.
  249. ** -------------------------------------------------------------------------
  250. */
  251. DWORD
  252. GetCdromTOC(
  253. CDHANDLE,
  254. PCDROM_TOC
  255. );
  256. DWORD
  257. StopCdrom(
  258. CDHANDLE
  259. );
  260. DWORD
  261. PauseCdrom(
  262. CDHANDLE
  263. );
  264. #ifdef USE_IOCTLS
  265. DWORD
  266. ResumeCdrom(
  267. CDHANDLE
  268. );
  269. DWORD
  270. PlayCdrom(
  271. CDHANDLE,
  272. PCDROM_PLAY_AUDIO_MSF
  273. );
  274. DWORD
  275. SeekCdrom(
  276. CDHANDLE,
  277. PCDROM_SEEK_AUDIO_MSF
  278. );
  279. DWORD
  280. GetCdromSubQData(
  281. CDHANDLE,
  282. PSUB_Q_CHANNEL_DATA,
  283. PCDROM_SUB_Q_DATA_FORMAT
  284. );
  285. #else
  286. DWORD
  287. ResumeCdrom(
  288. CDHANDLE,
  289. int
  290. );
  291. CDHANDLE
  292. OpenCdRom(
  293. TCHAR chDrive,
  294. LPDWORD lpdwErrCode
  295. );
  296. void
  297. CloseCdRom(
  298. CDHANDLE DevHandle
  299. );
  300. DWORD
  301. GetCdromMode(
  302. CDHANDLE DevHandle
  303. );
  304. DWORD
  305. GetCdromCurrentTrack(
  306. CDHANDLE DevHandle
  307. );
  308. BOOL
  309. IsCdromTrackAudio(
  310. CDHANDLE DevHandle,
  311. int iTrackNumber
  312. );
  313. DWORD
  314. PlayCdrom(
  315. CDHANDLE DeviceHandle,
  316. MCI_PLAY_PARMS *mciPlay
  317. );
  318. DWORD
  319. SeekCdrom(
  320. CDHANDLE DeviceHandle,
  321. MCI_SEEK_PARMS *mciSeek
  322. );
  323. DWORD
  324. GetCdromCurrentPosition(
  325. CDHANDLE DevHandle,
  326. DWORD *lpdwPosition
  327. );
  328. #endif
  329. DWORD
  330. EjectCdrom(
  331. CDHANDLE
  332. );
  333. DWORD
  334. TestUnitReadyCdrom(
  335. CDHANDLE DeviceHandle
  336. );
  337. #if 0
  338. DWORD
  339. GetCdromVolume(
  340. CDHANDLE DeviceHandle
  341. );
  342. #endif
  343. DWORD
  344. StatusTrackPosCdrom(
  345. MCIDEVICEID DevHandle,
  346. DWORD * pStatus,
  347. DWORD * pTrack,
  348. DWORD * pPos
  349. );
  350. #ifdef __cplusplus
  351. };
  352. #endif
  353. /* -------------------------------------------------------------------------
  354. ** Public Globals - Most of these should be treated as read only.
  355. ** -------------------------------------------------------------------------
  356. */
  357. #ifndef GLOBAL
  358. #define GLOBAL extern
  359. #endif
  360. GLOBAL PCDROM g_Devices[MAX_CD_DEVICES];