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.

498 lines
9.1 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: cdplayer.h
  3. *
  4. *
  5. *
  6. *
  7. * Created: dd-mm-93
  8. * Author: Stephen Estrop [StephenE]
  9. *
  10. * Copyright (c) 1993 Microsoft Corporation
  11. \**************************************************************************/
  12. //#ifdef CHICAGO
  13. #include <shellapi.h>
  14. //#endif
  15. /* -------------------------------------------------------------------------
  16. ** Replace the WM_MENUSELECT message craker because it contains a bug.
  17. ** -------------------------------------------------------------------------
  18. */
  19. #ifdef HANDLE_WM_MENUSELECT
  20. #undef HANDLE_WM_MENUSELECT
  21. #define HANDLE_WM_MENUSELECT(hwnd, wParam, lParam, fn) \
  22. ((fn)( (hwnd), (HMENU)(lParam), \
  23. (UINT)LOWORD(wParam), NULL, (UINT)HIWORD(wParam)), 0L)
  24. #endif
  25. #ifndef NUMELEMS
  26. #define NUMELEMS(a) (sizeof((a))/sizeof((a)[0]))
  27. #endif // NUMELEMS
  28. #define NUM_OF_CONTROLS (IDC_CDPLAYER_LAST - IDC_CDPLAYER_FIRST + 1)
  29. #define NUM_OF_BUTTONS (IDC_BUTTON8 - IDC_BUTTON1 + 1)
  30. #define INDEX( _x_ ) ((_x_) - IDC_CDPLAYER_FIRST)
  31. #if DBG
  32. void
  33. dprintf(
  34. char *lpszFormat,
  35. ...
  36. );
  37. void CDAssert( LPSTR x, LPSTR file, int line );
  38. #undef ASSERT
  39. #define ASSERT(_x_) if (!(_x_)) CDAssert( #_x_, __FILE__, __LINE__ )
  40. #else
  41. #undef ASSERT
  42. #define ASSERT(_x_)
  43. #endif
  44. #define WM_CDPLAYER_MSG_BASE (WM_USER + 0x1000)
  45. #define WM_NOTIFY_CDROM_COUNT (WM_CDPLAYER_MSG_BASE)
  46. #define WM_NOTIFY_TOC_READ (WM_CDPLAYER_MSG_BASE+1)
  47. #define HEARTBEAT_TIMER_ID 0x3243
  48. #ifdef DAYTONA
  49. #define HEARTBEAT_TIMER_RATE 250 /* 4 times a second */
  50. #else
  51. #define HEARTBEAT_TIMER_RATE 500 /* 2 times a second */
  52. #endif
  53. #define SKIPBEAT_TIMER_ID 0x3245
  54. #define SKIPBEAT_TIMER_RATE 200 /* 5 times a second */
  55. #define SKIPBEAT_TIMER_RATE2 100 /* 10 times a second */
  56. #define SKIPBEAT_TIMER_RATE3 50 /* 20 times a second */
  57. #define SKIP_ACCELERATOR_LIMIT1 5 /* 5 seconds */
  58. #define SKIP_ACCELERATOR_LIMIT2 20 /* 20 seconds */
  59. #define FRAMES_PER_SECOND 75
  60. #define FRAMES_PER_MINUTE (60*FRAMES_PER_SECOND)
  61. #define DISPLAY_UPD_LED 0x00000001
  62. #define DISPLAY_UPD_TITLE_NAME 0x00000002
  63. #define DISPLAY_UPD_TRACK_NAME 0x00000004
  64. #define DISPLAY_UPD_TRACK_TIME 0x00000008
  65. #define DISPLAY_UPD_DISC_TIME 0x00000010
  66. #define DISPLAY_UPD_CDROM_STATE 0x00000020
  67. #define DISPLAY_UPD_LEADOUT_TIME 0x80000000
  68. #define INTRO_LOWER_LEN 5
  69. #define INTRO_DEFAULT_LEN 10
  70. #define INTRO_UPPER_LEN 15
  71. // Audio Play Files consist completely of this header block. These
  72. // files are readable in the root of any audio disc regardless of
  73. // the capabilities of the drive.
  74. //
  75. // The "Unique Disk ID Number" is a calculated value consisting of
  76. // a combination of parameters, including the number of tracks and
  77. // the starting locations of those tracks.
  78. //
  79. // Applications interpreting CDDA RIFF files should be advised that
  80. // additional RIFF file chunks may be added to this header in the
  81. // future in order to add information, such as the disk and song title.
  82. #define RIFF_RIFF 0x46464952
  83. #define RIFF_CDDA 0x41444443
  84. typedef struct {
  85. DWORD dwRIFF; // 'RIFF'
  86. DWORD dwSize; // Chunk size = (file size - 8)
  87. DWORD dwCDDA; // 'CDDA'
  88. DWORD dwFmt; // 'fmt '
  89. DWORD dwCDDASize; // Chunk size of 'fmt ' = 24
  90. WORD wFormat; // Format tag
  91. WORD wTrack; // Track number
  92. DWORD DiscID; // Unique disk id
  93. DWORD lbnTrackStart; // Track starting sector (LBN)
  94. DWORD lbnTrackLength; // Track length (LBN count)
  95. DWORD msfTrackStart; // Track starting sector (MSF)
  96. DWORD msfTrackLength; // Track length (MSF)
  97. } RIFFCDA;
  98. BOOL
  99. InitInstance(
  100. HANDLE hInstance
  101. );
  102. BOOL CALLBACK
  103. MainWndProc(
  104. HWND hwnd,
  105. UINT message,
  106. WPARAM wParam,
  107. LPARAM lParam
  108. );
  109. BOOL
  110. CDPlay_OnInitDialog(
  111. HWND hwnd,
  112. HWND hwndFocus,
  113. LPARAM lParam
  114. );
  115. void
  116. CDPlay_OnInitMenuPopup(
  117. HWND hwnd,
  118. HMENU hMenu,
  119. UINT item,
  120. BOOL fSystemMenu
  121. );
  122. #ifdef DAYTONA
  123. void
  124. CDPlay_OnPaint(
  125. HWND hwnd
  126. );
  127. #endif
  128. void
  129. CDPlay_OnSysColorChange(
  130. HWND hwnd
  131. );
  132. void
  133. CDPlay_OnWinIniChange(
  134. HWND hwnd,
  135. LPCTSTR lpszSectionName
  136. );
  137. LRESULT CALLBACK
  138. SubClassedToolTips(
  139. HWND hwnd,
  140. UINT uMsg,
  141. WPARAM wParam,
  142. LPARAM lParam
  143. );
  144. LRESULT
  145. CDPlay_OnNotify(
  146. HWND hwnd,
  147. int idFrom,
  148. NMHDR *pnmhdr
  149. );
  150. void
  151. CDPlay_OnLButtonDown(
  152. HWND hwnd,
  153. BOOL fDoubleClick,
  154. int x,
  155. int y,
  156. UINT keyFlags
  157. );
  158. UINT
  159. CDPlay_OnNCHitTest(
  160. HWND hwnd,
  161. int x,
  162. int y
  163. );
  164. BOOL
  165. CDPlay_OnCopyData(
  166. HWND hwnd,
  167. PCOPYDATASTRUCT lpcpds
  168. );
  169. BOOL
  170. CDPlay_OnTocRead(
  171. int iDriveRead
  172. );
  173. BOOL
  174. CDPlay_OnDeviceChange(
  175. HWND hwnd,
  176. WPARAM wParam,
  177. LPARAM lParam);
  178. void
  179. CDPlay_OnDropFiles(
  180. HWND hwnd,
  181. HDROP hdrop
  182. );
  183. void
  184. CDPlay_OnMenuSelect(
  185. HWND hwnd,
  186. HMENU hmenu,
  187. int item,
  188. HMENU hmenuPopup,
  189. UINT flags
  190. );
  191. BOOL
  192. CDPlay_OnDrawItem(
  193. HWND hwnd,
  194. const DRAWITEMSTRUCT *lpdis
  195. );
  196. void
  197. CDPlay_OnCommand(
  198. HWND hwnd,
  199. int id,
  200. HWND hwndCtl,
  201. UINT codeNotify
  202. );
  203. void
  204. CDPlay_OnDestroy(
  205. HWND hwnd
  206. );
  207. BOOL
  208. CDPlay_OnClose(
  209. HWND hwnd,
  210. BOOL fShuttingDown
  211. );
  212. void
  213. CDPlay_OnEndSession(
  214. HWND hwnd,
  215. BOOL fEnding
  216. );
  217. void
  218. CDPlay_OnSize(
  219. HWND hwnd,
  220. UINT state,
  221. int cx,
  222. int cy
  223. );
  224. void
  225. ShowStatusbar(
  226. void
  227. );
  228. void
  229. ShowToolbar(
  230. void
  231. );
  232. void
  233. ShowTrackInfo(
  234. void
  235. );
  236. BOOL CALLBACK
  237. ChildEnumProc(
  238. HWND hwndChild,
  239. LPARAM lp
  240. );
  241. BOOL
  242. CreateToolbarsAndStatusbar(
  243. HWND hwnd
  244. );
  245. void
  246. AdjustChildButtons(
  247. HWND hwnd
  248. );
  249. void
  250. FatalApplicationError(
  251. INT uIdStringResource,
  252. ...
  253. );
  254. void
  255. LED_ToggleDisplayFont(
  256. HWND hwnd,
  257. BOOL fFont
  258. );
  259. LPTSTR
  260. IdStr(
  261. int idResource
  262. );
  263. void
  264. CheckMenuItemIfTrue(
  265. HMENU hMenu,
  266. UINT idItem,
  267. BOOL flag
  268. );
  269. void
  270. ReadSettings(
  271. void
  272. );
  273. void
  274. UpdateToolbarButtons(
  275. void
  276. );
  277. void
  278. UpdateToolbarTimeButtons(
  279. void
  280. );
  281. BOOL
  282. LockTableOfContents(
  283. int cdrom
  284. );
  285. BOOL
  286. LockALLTableOfContents(
  287. void
  288. );
  289. LPVOID
  290. AllocMemory(
  291. UINT uSize
  292. );
  293. void
  294. SetPlayButtonsEnableState(
  295. void
  296. );
  297. void CALLBACK
  298. HeartBeatTimerProc(
  299. HWND hwnd,
  300. UINT uMsg,
  301. UINT idEvent,
  302. DWORD dwTime
  303. );
  304. void CALLBACK
  305. SkipBeatTimerProc(
  306. HWND hwnd,
  307. UINT uMsg,
  308. UINT idEvent,
  309. DWORD dwTime
  310. );
  311. void
  312. UpdateDisplay(
  313. DWORD Flags
  314. );
  315. HBRUSH
  316. Common_OnCtlColor(
  317. HWND hwnd,
  318. HDC hdc,
  319. HWND hwndChild,
  320. int type
  321. );
  322. BOOL
  323. Common_OnMeasureItem(
  324. HWND hwnd,
  325. MEASUREITEMSTRUCT *lpMeasureItem
  326. );
  327. void
  328. DrawTrackItem(
  329. HDC hdc,
  330. const RECT *r,
  331. DWORD item,
  332. BOOL selected
  333. );
  334. void
  335. DrawDriveItem(
  336. HDC hdc,
  337. const RECT *r,
  338. DWORD item,
  339. BOOL selected
  340. );
  341. void
  342. EnableToolTips(
  343. BOOL fEnable
  344. );
  345. void
  346. CdPlayerAlreadyRunning(
  347. void
  348. );
  349. void
  350. CdPlayerStartUp(
  351. void
  352. );
  353. void
  354. CompleteCdPlayerStartUp(
  355. void
  356. );
  357. BOOL
  358. IsPlayOptionGiven(
  359. LPTSTR lpCmdLine
  360. );
  361. BOOL
  362. IsUpdateOptionGiven(
  363. LPTSTR lpCmdLine
  364. );
  365. /* -------------------------------------------------------------------------
  366. ** Public Globals - Most of these should be treated as read only.
  367. ** -------------------------------------------------------------------------
  368. */
  369. #ifndef GLOBAL
  370. #define GLOBAL extern
  371. #endif
  372. GLOBAL HINSTANCE g_hInst;
  373. GLOBAL HWND g_hwndApp;
  374. GLOBAL HWND g_hwndToolbar;
  375. GLOBAL HWND g_hwndStatusbar;
  376. GLOBAL HWND g_hwndControls[NUM_OF_CONTROLS];
  377. GLOBAL BOOL g_fStatusbarVisible;
  378. GLOBAL BOOL g_fToolbarVisible;
  379. GLOBAL BOOL g_fSelectedOrder;
  380. GLOBAL BOOL g_fSingleDisk;
  381. GLOBAL BOOL g_fIntroPlay;
  382. GLOBAL BOOL g_fContinuous;
  383. GLOBAL BOOL g_fSaveOnExit;
  384. GLOBAL BOOL g_fDisplayT;
  385. GLOBAL BOOL g_fDisplayTr;
  386. GLOBAL BOOL g_fDisplayDr;
  387. GLOBAL BOOL g_fMultiDiskAvailable;
  388. GLOBAL BOOL g_fIsIconic;
  389. GLOBAL BOOL g_fSmallLedFont;
  390. GLOBAL BOOL g_fToolTips;
  391. GLOBAL BOOL g_fStopCDOnExit;
  392. GLOBAL BOOL g_fPlay;
  393. GLOBAL int g_NumCdDevices;
  394. GLOBAL int g_LastCdrom;
  395. GLOBAL int g_CurrCdrom;
  396. GLOBAL int g_IntroPlayLength;
  397. GLOBAL TCHAR g_szArtistTxt[50];
  398. GLOBAL TCHAR g_szTitleTxt[50];
  399. GLOBAL TCHAR g_szUnknownTxt[50];
  400. GLOBAL TCHAR g_szTrackTxt[50];
  401. GLOBAL TCHAR g_szEmpty[];
  402. GLOBAL BOOL g_fFlashLed;
  403. GLOBAL HBITMAP g_hbmTrack;
  404. GLOBAL HBITMAP g_hbmInsertPoint;
  405. GLOBAL HBITMAP g_hbmEditBtns;
  406. GLOBAL HFONT g_hDlgFont;
  407. GLOBAL HFONT hLEDFontS;
  408. GLOBAL HFONT hLEDFontL;
  409. GLOBAL LPSTR g_lpCmdLine;
  410. extern BOOL g_fTrackInfoVisible;
  411. GLOBAL CRITICAL_SECTION g_csTOCSerialize;