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.

949 lines
20 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: database.c
  3. *
  4. * This module implements the database routines for the CD Audio app.
  5. * The information is stored in the ini file "cdaudio.ini" which should
  6. * be located in the nt\windows directory.
  7. *
  8. * Warning:
  9. * These functions ARE NOT THREAD safe.
  10. * The functions in this file MUST only be called on the UI thread. Before
  11. * calling any of the functions the CALLER MUST call LockTableOfContents
  12. * for the specified cdrom device.
  13. *
  14. * Author:
  15. * Rick Turner (ricktu) 31-Jan-1992
  16. *
  17. *
  18. * Revision History:
  19. *
  20. * 04-Aug-1992 (ricktu) Incorperated routines from old cdaudio.c,
  21. * and made work w/new child window framework.
  22. *
  23. *
  24. * Copyright (c) 1993 - 1995 Microsoft Corporation. All rights reserved.
  25. \**************************************************************************/
  26. #pragma warning( once : 4201 4214 )
  27. #define NOOLE
  28. #include <windows.h>
  29. #include "playres.h"
  30. #include "cdapi.h"
  31. #include "cdplayer.h"
  32. #include "database.h"
  33. #include "literals.h"
  34. #include <string.h>
  35. #include <stdio.h>
  36. #include <tchar.h>
  37. #include "trklst.h"
  38. #include "..\cdnet\cdnet.h"
  39. #include "..\cdopt\cdopt.h"
  40. /* -------------------------------------------------------------------------
  41. ** Private entry points
  42. ** -------------------------------------------------------------------------
  43. */
  44. DWORD
  45. ComputeOldDiscId(
  46. int cdrom
  47. );
  48. BOOL
  49. ReadEntry(
  50. int cdrom,
  51. DWORD dwId);
  52. /*****************************Private*Routine******************************\
  53. * ComputeOldDiscId
  54. *
  55. * This routine computes a unique ID based on the information
  56. * in the table of contexts a given disc.
  57. *
  58. *
  59. * History:
  60. * 18-11-93 - ricktu - Created
  61. *
  62. \**************************************************************************/
  63. DWORD
  64. ComputeOldDiscId(
  65. int cdrom
  66. )
  67. {
  68. int NumTracks,i;
  69. DWORD DiscId = 0;
  70. NumTracks = g_Devices[ cdrom ]->toc.LastTrack -
  71. g_Devices[ cdrom ]->toc.FirstTrack;
  72. for ( i = 0; i < NumTracks; i++ ) {
  73. DiscId += ( (TRACK_M(cdrom,i) << 16) +
  74. (TRACK_S(cdrom,i) << 8) +
  75. TRACK_F(cdrom,i) );
  76. }
  77. return DiscId;
  78. }
  79. /******************************Public*Routine******************************\
  80. * ComputeNewDiscId
  81. *
  82. * Just call mci to get the product ID.
  83. *
  84. * History:
  85. * dd-mm-94 - StephenE - Created
  86. *
  87. \**************************************************************************/
  88. DWORD
  89. ComputeNewDiscId(
  90. int cdrom
  91. )
  92. {
  93. #ifdef USE_IOCTLS
  94. return ComputeOrgDiscId( cdrom );
  95. #else
  96. MCI_INFO_PARMS mciInfo;
  97. TCHAR szBuffer[32];
  98. DWORD dwRet;
  99. mciInfo.lpstrReturn = szBuffer;
  100. mciInfo.dwRetSize = sizeof(szBuffer)/sizeof(TCHAR);
  101. dwRet = mciSendCommand( g_Devices[cdrom]->hCd, MCI_INFO,
  102. MCI_INFO_MEDIA_IDENTITY,
  103. (DWORD_PTR)(LPVOID)&mciInfo );
  104. if ( dwRet != MMSYSERR_NOERROR ) {
  105. return 0L;
  106. }
  107. _stscanf(szBuffer, TEXT("%ld"), &dwRet );
  108. return dwRet;
  109. #endif
  110. }
  111. /*****************************Private*Routine******************************\
  112. * ComputeOrgDiscId
  113. *
  114. * This routine computes a unique ID based on the information
  115. * in the table of contexts a given disc. This is done by taking
  116. * the TMSF value for each track and XOR'ing it with the previous
  117. * quantity shifted left one bit.
  118. *
  119. *
  120. * History:
  121. * 18-11-93 - ricktu - Created
  122. *
  123. \**************************************************************************/
  124. DWORD
  125. ComputeOrgDiscId(
  126. int cdrom
  127. )
  128. {
  129. int NumTracks,i;
  130. DWORD DiscId = 0;
  131. NumTracks = g_Devices[ cdrom ]->toc.LastTrack -
  132. g_Devices[ cdrom ]->toc.FirstTrack + 1;
  133. for ( i = 0; i < NumTracks; i++ ) {
  134. DiscId = (DiscId << 1) ^
  135. ((i<<24) +
  136. (TRACK_M(cdrom,i) << 16) +
  137. (TRACK_S(cdrom,i) << 8) +
  138. TRACK_F(cdrom,i) );
  139. }
  140. return DiscId;
  141. }
  142. /*****************************Private*Routine******************************\
  143. * ErasePlayList
  144. *
  145. * Erases the current play list. This includes freeing the memory
  146. * for the nodes in the play list, and resetting the current track
  147. * pointer to NULL.
  148. *
  149. *
  150. * History:
  151. * 18-11-93 - ricktu - Created
  152. *
  153. \**************************************************************************/
  154. VOID
  155. ErasePlayList(
  156. int cdrom
  157. )
  158. {
  159. PTRACK_PLAY temp, temp1;
  160. //
  161. // Free memory for each track in play list
  162. //
  163. temp = PLAYLIST( cdrom );
  164. while (temp!=NULL) {
  165. temp1 = temp->nextplay;
  166. LocalFree( (HLOCAL)temp );
  167. temp = temp1;
  168. }
  169. //
  170. // Reset pointers
  171. //
  172. PLAYLIST( cdrom ) = NULL;
  173. CURRTRACK( cdrom ) = NULL;
  174. }
  175. /******************************Public*Routine******************************\
  176. * EraseSaveList
  177. *
  178. * Erases the current save list. This includes freeing the memory
  179. * for the nodes in the save list.
  180. *
  181. *
  182. * History:
  183. * 18-11-93 - ricktu - Created
  184. *
  185. \**************************************************************************/
  186. VOID
  187. EraseSaveList(
  188. int cdrom
  189. )
  190. {
  191. PTRACK_PLAY temp, temp1;
  192. //
  193. // Free memory for each track in play list
  194. //
  195. temp = SAVELIST( cdrom );
  196. while ( temp != NULL ) {
  197. temp1 = temp->nextplay;
  198. LocalFree( (HLOCAL)temp );
  199. temp = temp1;
  200. }
  201. //
  202. // Reset pointers
  203. //
  204. SAVELIST( cdrom ) = NULL;
  205. }
  206. /*****************************Private*Routine******************************\
  207. * EraseTrackList
  208. *
  209. * Erases the current track list. This includes freeing the memory
  210. * for the nodes in the track list, and resetting the track list
  211. * pointer to NULL.
  212. *
  213. *
  214. * History:
  215. * 18-11-93 - ricktu - Created
  216. *
  217. \**************************************************************************/
  218. VOID
  219. EraseTrackList(
  220. int cdrom
  221. )
  222. {
  223. PTRACK_INF temp, temp1;
  224. //
  225. // Free memory for each track in track list
  226. //
  227. temp = ALLTRACKS( cdrom );
  228. while ( temp != NULL ) {
  229. temp1 = temp->next;
  230. LocalFree( (HLOCAL)temp );
  231. temp = temp1;
  232. }
  233. //
  234. // Reset pointers
  235. //
  236. ALLTRACKS( cdrom ) = NULL;
  237. }
  238. /******************************Public*Routine******************************\
  239. * CopyPlayList
  240. *
  241. * Returns a copy of the playlist pointed to by p.
  242. *
  243. *
  244. * History:
  245. * 18-11-93 - ricktu - Created
  246. *
  247. \**************************************************************************/
  248. PTRACK_PLAY
  249. CopyPlayList(
  250. PTRACK_PLAY p
  251. )
  252. {
  253. PTRACK_PLAY t,t1,tend,tret;
  254. tret = tend = NULL;
  255. //
  256. // Duplicate list pointed to by p.
  257. //
  258. t = p;
  259. while( t!=NULL ) {
  260. t1 = (PTRACK_PLAY)AllocMemory( sizeof(TRACK_PLAY) );
  261. t1->TocIndex = t->TocIndex;
  262. t1->min = t->min;
  263. t1->sec = t->sec;
  264. t1->nextplay = NULL;
  265. t1->prevplay = tend;
  266. if (tret==NULL) {
  267. tret = tend = t1;
  268. }
  269. else {
  270. tend->nextplay = t1;
  271. tend = t1;
  272. }
  273. t = t->nextplay;
  274. }
  275. return(tret);
  276. }
  277. /*****************************Private*Routine******************************\
  278. * ResetPlayList
  279. *
  280. * Resets play order for the disc. Used to initialize/reset
  281. * the play list. This is done by reseting the doubly-linked list
  282. * of tracks in the g_Devices[...]->CdInfo.PlayList.[prevplay,nextplay]
  283. * pointers. All the tracks on the CD are stored in a singly linked list
  284. * pointed to by g_Devices[...]->CdInfo.AllTracks pointer.
  285. *
  286. *
  287. * History:
  288. * 18-11-93 - ricktu - Created
  289. *
  290. \**************************************************************************/
  291. VOID
  292. ResetPlayList(
  293. int cdrom
  294. )
  295. {
  296. PTRACK_INF t;
  297. PTRACK_PLAY temp, prev;
  298. //
  299. // Kill old play list
  300. //
  301. ErasePlayList( cdrom );
  302. EraseSaveList( cdrom );
  303. //
  304. // Duplicate each node in AllTracks and insert in-order
  305. // in SaveList list. The SaveList is the master which is
  306. // used for the playlist.
  307. //
  308. t = ALLTRACKS( cdrom );
  309. prev = NULL;
  310. while (t!=NULL) {
  311. temp = (PTRACK_PLAY)AllocMemory( sizeof(TRACK_PLAY) );
  312. temp->TocIndex = t->TocIndex;
  313. temp->min = 0;
  314. temp->sec = 0;
  315. temp->prevplay = prev;
  316. temp->nextplay = NULL;
  317. if (prev!=NULL) {
  318. prev->nextplay = temp;
  319. }
  320. else {
  321. SAVELIST( cdrom ) = temp;
  322. }
  323. prev = temp;
  324. t=t->next;
  325. }
  326. PLAYLIST( cdrom ) = CopyPlayList( SAVELIST( cdrom) );
  327. }
  328. void CreateNewEntry(int cdrom, DWORD key, PCDROM_TOC lpTOC)
  329. {
  330. /*
  331. ** This is a new entry, fill it in but don't store it in the database.
  332. */
  333. PTRACK_INF temp, temp1;
  334. PTRACK_PLAY pTempCurrTrack = CURRTRACK(cdrom);
  335. int i, num;
  336. int nSaveTrack = -1;
  337. if (CURRTRACK(cdrom))
  338. {
  339. nSaveTrack = CURRTRACK(cdrom)->TocIndex;
  340. }
  341. ErasePlayList( cdrom );
  342. EraseSaveList( cdrom );
  343. EraseTrackList( cdrom );
  344. g_Devices[ cdrom ]->CdInfo.iFrameOffset = NEW_FRAMEOFFSET;
  345. g_Devices[ cdrom ]->CdInfo.IsVirginCd = TRUE;
  346. g_Devices[ cdrom ]->CdInfo.Id = key;
  347. wsprintf( (LPTSTR)ARTIST( cdrom ), IdStr( STR_NEW_ARTIST ) );
  348. wsprintf( (LPTSTR)TITLE( cdrom ), IdStr( STR_NEW_TITLE ) );
  349. if (lpTOC)
  350. {
  351. NUMTRACKS( cdrom ) = num = lpTOC->LastTrack - lpTOC->FirstTrack + 1;
  352. }
  353. else
  354. {
  355. num = NUMTRACKS( cdrom );
  356. }
  357. /*
  358. ** Create generic playlist, which is all audio tracks
  359. ** played in the order they are on the CD. First, create
  360. ** a singly linked list that contains all the tracks.
  361. ** Then, create a double linked list, using the nodes of
  362. ** from the single linked list for the play list.
  363. */
  364. for( i = 0; i < num; i++ ) {
  365. /*
  366. ** Create storage for track
  367. */
  368. temp = (PTRACK_INF)AllocMemory( sizeof(TRACK_INF) );
  369. /*
  370. ** Initialize information (storage already ZERO initialized)
  371. */
  372. wsprintf( (LPTSTR)temp->name, IdStr( STR_INIT_TRACK ), i+1 );
  373. temp->TocIndex = i;
  374. temp->next = NULL;
  375. /*
  376. ** Add node to singly linked list of all tracks
  377. */
  378. if (i == 0) {
  379. temp1 = ALLTRACKS( cdrom ) = temp;
  380. }
  381. else {
  382. temp1->next = temp;
  383. temp1 = temp;
  384. }
  385. }
  386. /*
  387. ** Generate generic play list (all tracks in order)
  388. */
  389. ResetPlayList( cdrom );
  390. if (nSaveTrack > -1)
  391. {
  392. PTRACK_PLAY playlist;
  393. for( playlist = PLAYLIST(cdrom);
  394. playlist != NULL;
  395. playlist = playlist->nextplay )
  396. {
  397. if (playlist->TocIndex == nSaveTrack)
  398. {
  399. CURRTRACK(cdrom) = playlist;
  400. }
  401. }
  402. }
  403. }
  404. void RecomputePlayTimes(int dCdrom)
  405. {
  406. /*
  407. ** Compute PLAY length
  408. */
  409. PTRACK_PLAY pp;
  410. int m, s, mtemp, stemp;
  411. m = s = 0;
  412. for( pp = PLAYLIST(dCdrom); pp != NULL; pp = pp->nextplay )
  413. {
  414. FigureTrackTime( dCdrom, pp->TocIndex, &mtemp, &stemp );
  415. m+=mtemp;
  416. s+=stemp;
  417. pp->min = mtemp;
  418. pp->sec = stemp;
  419. }
  420. //also refresh the savelist
  421. for( pp = SAVELIST(dCdrom); pp != NULL; pp = pp->nextplay )
  422. {
  423. FigureTrackTime( dCdrom, pp->TocIndex, &mtemp, &stemp );
  424. pp->min = mtemp;
  425. pp->sec = stemp;
  426. }
  427. m += (s / 60);
  428. s = (s % 60);
  429. CDTIME(dCdrom).TotalMin = m;
  430. CDTIME(dCdrom).TotalSec = s;
  431. /*
  432. ** Make sure that the track time displayed in the LED and the
  433. ** status bar is correct. If we have a current track and the
  434. ** CD is playing or paused then everything is OK. Otherwise, we
  435. ** have to reset the track times.
  436. */
  437. if ( CURRTRACK( dCdrom ) != NULL ) {
  438. if ( STATE(dCdrom) & CD_STOPPED ) {
  439. CDTIME(dCdrom).TrackTotalMin = CURRTRACK( dCdrom )->min;
  440. CDTIME(dCdrom).TrackRemMin = CURRTRACK( dCdrom )->min;
  441. CDTIME(dCdrom).TrackTotalSec = CURRTRACK( dCdrom )->sec;
  442. CDTIME(dCdrom).TrackRemSec = CURRTRACK( dCdrom )->sec;
  443. }
  444. }
  445. else {
  446. CDTIME(dCdrom).TrackTotalMin = 0;
  447. CDTIME(dCdrom).TrackRemMin = 0;
  448. CDTIME(dCdrom).TrackTotalSec = 0;
  449. CDTIME(dCdrom).TrackRemSec = 0;
  450. }
  451. if (dCdrom == g_CurrCdrom)
  452. {
  453. UpdateDisplay( DISPLAY_UPD_DISC_TIME );
  454. }
  455. }
  456. BOOL GetInternetDatabase(int cdrom, DWORD key, BOOL fHitNet, BOOL fManual, HWND hwndCallback, void* pData)
  457. {
  458. if (!g_fBlockNetPrompt)
  459. {
  460. if (fHitNet)
  461. {
  462. ICDNet* pICDNet = NULL;
  463. if (SUCCEEDED(CDNET_CreateInstance(NULL, IID_ICDNet, (void**)&pICDNet)))
  464. {
  465. pICDNet->SetOptionsAndData((void*)g_pSink->GetOptions(),(void*)g_pSink->GetData());
  466. pICDNet->Download(g_Devices[ cdrom ]->hCd,g_Devices[cdrom]->drive,key,(LPCDTITLE)pData,fManual,hwndCallback);
  467. pICDNet->Release();
  468. }
  469. return FALSE; //couldn't find title just now, catch it on the callback
  470. }
  471. }
  472. if ( ReadEntry(cdrom, key))
  473. {
  474. return TRUE;
  475. }
  476. if (!fHitNet)
  477. {
  478. CreateNewEntry(cdrom, key, NULL);
  479. RecomputePlayTimes(cdrom);
  480. }
  481. return FALSE;
  482. }
  483. /*****************************Private*Routine******************************\
  484. * ReadEntry
  485. *
  486. * Try to read entry for new disc from database ini file.
  487. * The section name we are trying to read is a hex
  488. * value of the disc id. If the sections is found,
  489. * fill in the data for the disc in the cdrom drive.
  490. *
  491. * This function uses over 16K of stack space !!
  492. *
  493. * History:
  494. * 18-11-93 - ricktu - Created
  495. *
  496. \**************************************************************************/
  497. BOOL
  498. ReadEntry(
  499. int cdrom,
  500. DWORD dwId)
  501. {
  502. UINT i;
  503. int numtracks, numplay;
  504. PTRACK_INF temp, curr;
  505. PTRACK_PLAY temp1, prev;
  506. BOOL fRewriteEntry = FALSE;
  507. LPCDDATA pData = NULL;
  508. g_Devices[ cdrom ]->CdInfo.iFrameOffset = NEW_FRAMEOFFSET;
  509. pData = (LPCDDATA)g_pSink->GetData();
  510. if( !pData )
  511. {
  512. //Can't create the options object, so fail
  513. return (FALSE);
  514. }
  515. pData->AddRef();
  516. //
  517. // Try to read in title from the options database
  518. //
  519. if (!pData->QueryTitle(dwId))
  520. {
  521. pData->Release();
  522. return (FALSE);
  523. }
  524. //
  525. // We found an entry for this disc, so copy all the information
  526. // from the title database
  527. LPCDTITLE pCDTitle = NULL;
  528. if (FAILED(pData->LockTitle(&pCDTitle,dwId)))
  529. {
  530. pData->Release();
  531. return FALSE;
  532. }
  533. _tcscpy(g_Devices[ cdrom ]->CdInfo.Title,pCDTitle->szTitle);
  534. numtracks = pCDTitle->dwNumTracks;
  535. // Make sure there is at least one track!!!
  536. if (0 == numtracks)
  537. {
  538. fRewriteEntry = TRUE;
  539. }
  540. g_Devices[ cdrom ]->CdInfo.NumTracks = numtracks;
  541. _tcscpy(g_Devices[ cdrom ]->CdInfo.Artist,pCDTitle->szArtist);
  542. //
  543. // Validate the stored track numbers
  544. //
  545. if (g_Devices[cdrom]->fIsTocValid)
  546. {
  547. int maxTracks; // validate the high point in database
  548. maxTracks = g_Devices[cdrom]->toc.LastTrack;
  549. if (numtracks > maxTracks)
  550. {
  551. // Current database contains invalid data
  552. // this can result in the CD not playing at all as the end
  553. // point is likely to be invalid
  554. g_Devices[ cdrom ]->CdInfo.NumTracks
  555. = numtracks
  556. = maxTracks;
  557. fRewriteEntry = TRUE;
  558. }
  559. }
  560. //
  561. // Read the track list information
  562. //
  563. for (i=0, curr = NULL; i < (UINT)numtracks; i++)
  564. {
  565. temp = (PTRACK_INF)AllocMemory( sizeof(TRACK_INF) );
  566. temp->TocIndex = i;
  567. temp->next = NULL;
  568. _tcscpy(temp->name,pCDTitle->pTrackTable[i].szName);
  569. if (curr==NULL)
  570. {
  571. ALLTRACKS( cdrom ) = curr = temp;
  572. } else
  573. {
  574. curr->next = temp;
  575. curr = temp;
  576. }
  577. }
  578. // Make sure there is at least one entry in TRACK list
  579. if (ALLTRACKS(cdrom) == NULL)
  580. {
  581. fRewriteEntry = TRUE;
  582. }
  583. //
  584. // if we detected a problem in the ini file, or the entry is an
  585. // old format, rewrite the section.
  586. //
  587. if (fRewriteEntry)
  588. {
  589. //
  590. // Generate generic play list (all tracks in order)
  591. //
  592. ResetPlayList( cdrom );
  593. }
  594. else
  595. {
  596. //
  597. // Read play list (order) information and construct play list doubly
  598. // linked list
  599. //
  600. numplay = pCDTitle->dwNumPlay;
  601. if (numplay == 0)
  602. {
  603. numplay = pCDTitle->dwNumTracks;
  604. }
  605. prev = NULL;
  606. int iCurrTrack = -1;
  607. if (CURRTRACK(cdrom)!=NULL)
  608. {
  609. iCurrTrack = CURRTRACK(cdrom)->TocIndex;
  610. }
  611. EraseSaveList(cdrom);
  612. ErasePlayList(cdrom);
  613. for (int tr_index = 0; tr_index < numplay; tr_index++)
  614. {
  615. /*
  616. ** Assert that i is a valid index.
  617. ** ie 0 <= i <= (numtracks - 1)
  618. */
  619. if (pCDTitle->dwNumPlay > 0)
  620. {
  621. i = pCDTitle->pPlayList[tr_index];
  622. }
  623. else
  624. {
  625. i = tr_index;
  626. }
  627. i = min( ((UINT)numtracks - 1), max( 0, i ) );
  628. temp1 = (PTRACK_PLAY)AllocMemory( sizeof(TRACK_PLAY) );
  629. temp1->TocIndex = (int)i;
  630. temp1->min = 0;
  631. temp1->sec = 0;
  632. temp1->prevplay = prev;
  633. temp1->nextplay = NULL;
  634. if (prev==NULL)
  635. {
  636. SAVELIST( cdrom ) = temp1;
  637. }
  638. else
  639. {
  640. prev->nextplay = temp1;
  641. }
  642. prev = temp1;
  643. }
  644. // Make sure there is at least one entry in SAVED list
  645. if (SAVELIST(cdrom) == NULL)
  646. {
  647. // Nope, use default list instead
  648. ResetPlayList( cdrom );
  649. }
  650. PLAYLIST( cdrom ) = CopyPlayList( SAVELIST( cdrom ) );
  651. //reset current track if necessary
  652. if (iCurrTrack != -1)
  653. {
  654. BOOL fFound = FALSE;
  655. for (PTRACK_PLAY pp = PLAYLIST(cdrom); pp != NULL; pp = pp->nextplay )
  656. {
  657. if ( pp->TocIndex == iCurrTrack )
  658. {
  659. fFound = TRUE;
  660. break;
  661. }
  662. } //end for
  663. if (fFound)
  664. {
  665. CURRTRACK(cdrom) = pp;
  666. }
  667. else
  668. {
  669. /*
  670. ** If the track was not found in the new track list and this
  671. ** cd is currently playing then stop it.
  672. */
  673. if ( (STATE(cdrom) & (CD_PLAYING | CD_PAUSED)) )
  674. {
  675. SendDlgItemMessage( g_hwndApp, IDM_PLAYBAR_STOP,
  676. WM_LBUTTONDOWN, 1, 0 );
  677. SendDlgItemMessage( g_hwndApp, IDM_PLAYBAR_STOP,
  678. WM_LBUTTONUP, 1, 0 );
  679. }
  680. CURRTRACK(cdrom) = PLAYLIST(cdrom);
  681. }
  682. }
  683. /*
  684. ** If we were previously in "Random" mode shuffle the new
  685. ** playlist.
  686. */
  687. if (!g_fSelectedOrder)
  688. {
  689. ComputeSingleShufflePlayList(cdrom);
  690. }
  691. RecomputePlayTimes(cdrom);
  692. }
  693. //unlock title data, don't persist it
  694. pData->UnlockTitle(pCDTitle,FALSE);
  695. pData->Release();
  696. return TRUE;
  697. }
  698. /******************************Public*Routine******************************\
  699. * AddFindEntry
  700. *
  701. * Search the database file for the current disc, if found, read the
  702. * information, otherwise, generate some default artist and track names etc.
  703. * but don't store this in the database. A new entry is only added to the
  704. * database after the user has used the "Edit Track Titles" dialog box.
  705. *
  706. * The design of this function is complicated by the fact that we have to
  707. * support two previous attempts at generating CDplayer keys. Also, we try
  708. * to support the MusicBox key format now that it is compatible with the
  709. * new CDplayer format.
  710. *
  711. *
  712. * History:
  713. * 18-11-93 - ricktu - Created
  714. *
  715. \**************************************************************************/
  716. VOID
  717. AddFindEntry(
  718. int cdrom,
  719. DWORD key,
  720. PCDROM_TOC lpTOC
  721. )
  722. {
  723. /*
  724. ** Kill off old PlayList, Save lists if they exists.
  725. */
  726. ErasePlayList( cdrom );
  727. EraseSaveList( cdrom );
  728. EraseTrackList( cdrom );
  729. /*
  730. ** Check ini file for an existing entry
  731. **
  732. ** First Look in cdplayer.ini using the new key, return if found
  733. */
  734. // We initialize this field early, otherwise ReadEntry will not be
  735. // able to save any new information (or lose invalid).
  736. g_Devices[ cdrom ]->CdInfo.save = TRUE;
  737. if ( ReadEntry(cdrom, key) )
  738. {
  739. return;
  740. }
  741. /*
  742. ** Initialize these fields
  743. */
  744. g_Devices[ cdrom ]->CdInfo.IsVirginCd = FALSE;
  745. g_Devices[ cdrom ]->CdInfo.Id = key;
  746. /*
  747. ** dstewart: Try to get the info from the net
  748. */
  749. if ( GetInternetDatabase(cdrom, key, TRUE, FALSE, GetParent(g_hwndApp),NULL) )
  750. {
  751. return;
  752. }
  753. /*
  754. ** end dstewart
  755. */
  756. CreateNewEntry(cdrom,key,lpTOC);
  757. }