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.

424 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 50
  78. #define ARTIST_LENGTH 50
  79. #define TRACK_TITLE_LENGTH 40
  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. void
  193. CheckStatus(
  194. LPSTR szCaller,
  195. DWORD status,
  196. int cdrom
  197. );
  198. void
  199. NoMediaUpdate(
  200. int cdrom
  201. );
  202. void
  203. CheckUnitCdrom(
  204. int cdrom,
  205. BOOL fForceRescan
  206. );
  207. BOOL
  208. EjectTheCdromDisc(
  209. INT cdrom
  210. );
  211. BOOL
  212. PlayCurrTrack(
  213. int cdrom
  214. );
  215. BOOL
  216. StopTheCdromDrive(
  217. int cdrom
  218. );
  219. BOOL
  220. PauseTheCdromDrive(
  221. int cdrom
  222. );
  223. BOOL
  224. ResumeTheCdromDrive(
  225. int cdrom
  226. );
  227. BOOL
  228. SeekToCurrSecond(
  229. int cdrom
  230. );
  231. BOOL
  232. GetCurrPos(
  233. int cdrom,
  234. PCURRPOS CpPtr
  235. );
  236. BOOL
  237. SeekToTrackAndHold(
  238. int cdrom,
  239. int tindex
  240. );
  241. /* -------------------------------------------------------------------------
  242. ** NT Layer Function Declarations
  243. **
  244. ** These are the low-level functions that manipulate the specified CD-ROM
  245. ** device.
  246. ** -------------------------------------------------------------------------
  247. */
  248. DWORD
  249. GetCdromTOC(
  250. CDHANDLE,
  251. PCDROM_TOC
  252. );
  253. DWORD
  254. StopCdrom(
  255. CDHANDLE
  256. );
  257. DWORD
  258. PauseCdrom(
  259. CDHANDLE
  260. );
  261. #ifdef USE_IOCTLS
  262. DWORD
  263. ResumeCdrom(
  264. CDHANDLE
  265. );
  266. DWORD
  267. PlayCdrom(
  268. CDHANDLE,
  269. PCDROM_PLAY_AUDIO_MSF
  270. );
  271. DWORD
  272. SeekCdrom(
  273. CDHANDLE,
  274. PCDROM_SEEK_AUDIO_MSF
  275. );
  276. DWORD
  277. GetCdromSubQData(
  278. CDHANDLE,
  279. PSUB_Q_CHANNEL_DATA,
  280. PCDROM_SUB_Q_DATA_FORMAT
  281. );
  282. #else
  283. DWORD
  284. ResumeCdrom(
  285. CDHANDLE,
  286. int
  287. );
  288. CDHANDLE
  289. OpenCdRom(
  290. TCHAR chDrive,
  291. LPDWORD lpdwErrCode
  292. );
  293. void
  294. CloseCdRom(
  295. CDHANDLE DevHandle
  296. );
  297. DWORD
  298. GetCdromMode(
  299. CDHANDLE DevHandle
  300. );
  301. DWORD
  302. GetCdromCurrentTrack(
  303. CDHANDLE DevHandle
  304. );
  305. BOOL
  306. IsCdromTrackAudio(
  307. CDHANDLE DevHandle,
  308. int iTrackNumber
  309. );
  310. DWORD
  311. PlayCdrom(
  312. CDHANDLE DeviceHandle,
  313. MCI_PLAY_PARMS *mciPlay
  314. );
  315. DWORD
  316. SeekCdrom(
  317. CDHANDLE DeviceHandle,
  318. MCI_SEEK_PARMS *mciSeek
  319. );
  320. DWORD
  321. GetCdromCurrentPosition(
  322. CDHANDLE DevHandle,
  323. DWORD *lpdwPosition
  324. );
  325. #endif
  326. DWORD
  327. EjectCdrom(
  328. CDHANDLE
  329. );
  330. DWORD
  331. TestUnitReadyCdrom(
  332. CDHANDLE DeviceHandle
  333. );
  334. #if 0
  335. DWORD
  336. GetCdromVolume(
  337. CDHANDLE DeviceHandle
  338. );
  339. #endif
  340. DWORD
  341. StatusTrackPosCdrom(
  342. MCIDEVICEID DevHandle,
  343. DWORD * pStatus,
  344. DWORD * pTrack,
  345. DWORD * pPos
  346. );
  347. /* -------------------------------------------------------------------------
  348. ** Public Globals - Most of these should be treated as read only.
  349. ** -------------------------------------------------------------------------
  350. */
  351. #ifndef GLOBAL
  352. #define GLOBAL extern
  353. #endif
  354. GLOBAL PCDROM g_Devices[MAX_CD_DEVICES];