nav_svcd.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:253k
源码类别:

DVD

开发平台:

Others

  1. if (! (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS) {
  2. // Measure the Elapsed-Time based on the Current MSF
  3. #ifdef SVCD_USE_ABSOLUTE_TIME
  4. if (SHARED_INFO.bIsElapsedTimeValid)
  5. {
  6. // Update with Global Elapsed Time
  7. //gns.svcd.wTotalElpasedTime = (WORD)(dwCurrentLocation/g_pSVCDNav->m_aCurrTrack[2] );
  8. gns.svcd.wTotalElpasedTime = ((dwCurrentLocation - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
  9. if (!g_pSVCDNav->m_bIsUsingPSD)
  10. {
  11. if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track) {
  12. // For AV Tracks, use the Track's beginning as a reference-point; assume a relation
  13. // of 75-Sectors per Second (Fixed-Bitrate).
  14. iElapsedTime= ((dwCurrentLocation - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
  15. }
  16. else {
  17. // For CDDA Tracks, use the Decoder's MSF
  18. int iSign;
  19. UINT8 uMinute, uSecond, uFrame;
  20. //The relative measurment is more accurate, so we use it instead of the
  21. //absolute one cause otherwise the check for position B encounter fails.
  22. if (PE_CD_GetDecoderCurrentLocationMSF(eRelativeLocation, 
  23.    &uMinute, &uSecond, &uFrame, &iSign))
  24. {
  25. iElapsedTime= (60 * uMinute) + uSecond;
  26. iElapsedTime+= ((g_pSVCDNav->m_aCurrTrack[0]  - g_pSVCDNav->m_dwSecondTrackAddress) 
  27. / SVCD_BLOCKS_PER_SECOND);
  28. }
  29. }
  30. }
  31. else
  32. {
  33. //On PSD mode the time is calculated as a relative time
  34. if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track) {
  35. // For AV Tracks, use the Track's beginning as a reference-point; assume a relation
  36. // of 75-Sectors per Second (Fixed-Bitrate).
  37. iElapsedTime= (int)((dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
  38. }
  39. else {
  40. // For CDDA Tracks, use the Decoder's MSF
  41. int iSign;
  42. UINT8 uMinute, uSecond, uFrame;
  43. if (PE_CD_GetDecoderCurrentLocationMSF(eRelativeLocation, 
  44.    &uMinute, &uSecond, &uFrame, &iSign))
  45. {
  46. iElapsedTime= (int)(iSign * ((60 * uMinute) + uSecond));
  47. if (iSign < 0)
  48. iElapsedTime--;
  49. }
  50. }
  51. }
  52. }
  53. else
  54. iElapsedTime = 0;
  55. #else //SVCD_USE_ABSOLUTE_TIME
  56. if (SHARED_INFO.bIsElapsedTimeValid)
  57. {
  58. #ifdef PARSE_ENTRY_INFO
  59. if ( ( NULL != g_hEntriesTable ) && ( 0 != g_pSVCDNav->m_wEntriesUsedCnt ) 
  60. && ( PST_STOP != gcs.pstate ) && ( SHARED_INFO.uCurrentTrackNumber > 1 ) )
  61. {
  62. WORD i;
  63. BYTE aucBuffer[4];
  64. DWORD dwEntriesStartAddress;
  65. if ( 1 == g_pSVCDNav->m_wEntriesUsedCnt )
  66. {
  67. gns.svcd.wCurrentEntryNumber = 1;
  68. // tr_printf(("Current Entry Number is %04xn", gns.svcd.wCurrentEntryNumber));
  69. }
  70. else
  71. {
  72. for ( i = 0; i < g_pSVCDNav->m_wEntriesUsedCnt; i++)
  73. {
  74. Array_getAt(g_hEntriesTable, (UINT16)i, aucBuffer);
  75. dwEntriesStartAddress= drv_msf2lbn(drv_bcd2bin(aucBuffer[1]), drv_bcd2bin(aucBuffer[2]), drv_bcd2bin(aucBuffer[3]));
  76. if ( dwCurrentLocation < dwEntriesStartAddress  )
  77. {
  78. for(j=0;j<=g_pSVCDNav->m_wEntriesUsedCnt;j++)
  79. {
  80. Array_getAt(g_hEntriesTable, (UINT16)j, aucBuffer);
  81. dwEntriesStartAddress = drv_msf2lbn(drv_bcd2bin(aucBuffer[1]), drv_bcd2bin(aucBuffer[2]), drv_bcd2bin(aucBuffer[3]));
  82.     if(dwEntriesStartAddress>=g_pSVCDNav->m_aCurrTrack[0])
  83.      break;
  84. }
  85. i=i-j;
  86. gns.svcd.wCurrentEntryNumber = i;
  87. // tr_printf(("Current Entry Number is %04xn", gns.svcd.wCurrentEntryNumber));
  88. break;
  89. }
  90. }
  91. }
  92. }
  93. else
  94. gns.svcd.wCurrentEntryNumber = 0xFFFF;
  95. #endif
  96. // Update with Global Elapsed Time
  97. //gns.svcd.wTotalElpasedTime = (WORD)(dwCurrentLocation/g_pSVCDNav->m_aCurrTrack[2] );
  98. gns.svcd.wTotalElpasedTime = ((dwCurrentLocation - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
  99. if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track) {
  100. // For AV Tracks, use the Track's beginning as a reference-point; assume a relation
  101. // of 75-Sectors per Second (Fixed-Bitrate).
  102. //<<<LX091202
  103. if (SHARED_INFO.m_iScanSpeed > 0){ 
  104. //<<<LX090602: Check if in the range
  105. if( ( dwCurrentLocation >= g_pSVCDNav->m_aCurrTrack[0] ) && ( dwCurrentLocation <= g_pSVCDNav->m_aCurrTrack[1] ))
  106. iElapsedTime= (int)((dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
  107. else
  108. //LX090602>>>
  109. iElapsedTime = 0;
  110. }
  111. else
  112. //LX091202>>>
  113. iElapsedTime = (int)((dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
  114. }
  115. else {
  116. // For CDDA Tracks, use the Decoder's MSF
  117. int iSign;
  118. UINT8 uMinute, uSecond, uFrame;
  119. if (PE_CD_GetDecoderCurrentLocationMSF(eRelativeLocation, 
  120.    &uMinute, &uSecond, &uFrame, &iSign))
  121. {
  122. iElapsedTime= (int)(iSign * ((60 * uMinute) + uSecond));
  123. if (iSign < 0)
  124. iElapsedTime--;
  125. }
  126. }
  127. }
  128. #endif //SVCD_USE_ABSOLUTE_TIME
  129. }
  130. //Updating the remaining time
  131. #ifdef SVCD_USE_ABSOLUTE_TIME
  132. if (SHARED_INFO.bIsElapsedTimeValid) 
  133. {
  134. if (!g_pSVCDNav->m_bIsUsingPSD)
  135. SHARED_INFO.wRemainingPlaybackTime = SHARED_INFO.wTotalPlaybackTime - iElapsedTime;
  136. else
  137. {
  138. WORD wTotalTime = (g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2];
  139. SHARED_INFO.wRemainingPlaybackTime = (WORD)(wTotalTime - iElapsedTime);
  140. }
  141. }
  142. else
  143. SHARED_INFO.wRemainingPlaybackTime = 0;
  144. #else
  145. if (SHARED_INFO.bIsElapsedTimeValid) 
  146. {
  147. WORD wTotalTime = (WORD)((g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
  148. if ( SHARED_INFO.uCurrentTrackNumber == 1 )
  149. wTotalTime = (WORD)((g_pSVCDNav->m_aCurrSegment[1] - g_pSVCDNav->m_aCurrSegment[0])/g_pSVCDNav->m_aCurrTrack[2]);
  150. iElapsedTime = (iElapsedTime > wTotalTime)? wTotalTime: iElapsedTime;
  151. SHARED_INFO.wRemainingPlaybackTime = (WORD)(wTotalTime - iElapsedTime);
  152. }
  153. else
  154. SHARED_INFO.wRemainingPlaybackTime = 0;
  155. #endif //SVCD_USE_ABSOLUTE_TIME
  156. // Actually update the Elapsed-Time only if we are not in stop mode
  157. if (PST_STOP != gcs.pstate
  158. #ifdef D_ENABLE_ELAPSEDTIME_FOR_SLIDESHOW
  159. && !((g_pSVCDNav->m_iCurrVideoType == STILL_HIRES)||(g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES))
  160. #endif
  161. )
  162. SHARED_INFO.iCurrentTime = iElapsedTime;
  163. // Calculate the Current-Location based on the Current-Time, if possible
  164. if (SHARED_INFO.bIsElapsedTimeValid) {
  165. #ifdef SVCD_USE_ABSOLUTE_TIME
  166. dwCurrentLocation= (g_pSVCDNav->m_dwSecondTrackAddress + (iElapsedTime * g_pSVCDNav->m_aCurrTrack[2]));
  167. #else
  168. dwCurrentLocation= (g_pSVCDNav->m_aCurrTrack[0] + (iElapsedTime * g_pSVCDNav->m_aCurrTrack[2]));
  169. #endif //SVCD_USE_ABSOLUTE_TIME
  170. }
  171. else {
  172. dwCurrentLocation= PE_CD_GetCurrentLocation();
  173. }
  174. //ZKR JK0210 #6 : FLT time display for VCD PBC on johnkim
  175. #ifdef S1_GUI
  176. SHARED_INFO.dwCurrentLocation= dwCurrentLocation;
  177. #endif
  178. //updating the operation mask in case digest mode is on
  179. #ifdef SVCD_DIGEST_SUPPORT
  180. if (g_pSVCDNav->m_bDigestMode) {
  181. enDIGEST_VALID_OP eValidOpOnDigest = Digest_getValidOp();
  182. if (eValidOpOnDigest & eDIGEST_OP_NEXT)
  183. SET_COP_MASK(COP_NEXT_CHAPTER);
  184. else
  185. CLEAR_COP_MASK(COP_NEXT_CHAPTER);
  186. if (eValidOpOnDigest & eDIGEST_OP_PREV)
  187. SET_COP_MASK(COP_PREVIOUS_CHAPTER);
  188. else
  189. CLEAR_COP_MASK(COP_PREVIOUS_CHAPTER);
  190. }
  191. #endif //SVCD_DIGEST_SUPPORT
  192. if (! g_pSVCDNav->m_bIsUsingPSD) {
  193. // Update the COP_MASK with regard to the Next-Chapter operation
  194. SET_COP_MASK(COP_NEXT_CHAPTER);
  195. // Update the COP_MASK with regard to the Pre-Chapter operation
  196. SET_COP_MASK(COP_PREVIOUS_CHAPTER);
  197. #ifndef SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
  198. if (! PM_IsRepeatAll() && 
  199. ((SHARED_INFO.m_CurrPosition).uListItem == (PM_GetProgramSize() - 1))) 
  200. {
  201. // If the Current-Item is the last one on the Program-List, then Next is not allowed
  202. CLEAR_COP_MASK(COP_NEXT_CHAPTER);
  203. }
  204. #ifndef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
  205. if (! PM_IsRepeatAll() && 
  206. ((SHARED_INFO.m_CurrPosition).uListItem == 1)) 
  207. {
  208. // If the Current-Item is the first one on the Program-List, then Pre is not allowed
  209. CLEAR_COP_MASK(COP_PREVIOUS_CHAPTER);
  210. }
  211. #endif
  212. #endif //SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
  213. }
  214. // Update various information
  215. if (CDDA_SID == g_pSVCDNav->m_uCurrAudioSID) {
  216. BYTE ucCtrlField, ucTrackNumber;
  217. // For CDDA Tracks, update the Track-Info
  218. if (PE_CD_GetDecoderCurrentTrackInfo(&ucCtrlField, &ucTrackNumber)) {
  219. SHARED_INFO.ucCurrentTrackInfo= ucCtrlField;
  220. }
  221. }
  222. // Update S/PDIF information
  223. PE_CD_UpdateAudioSPDIF();
  224. // Check for Finished condition: This check is only relevant for the following play-
  225. // states: PLAY, SLOW and PAUSE (assuming usage of the Step function).
  226. // In addition, this condition should be checked for SCAN of a CDDA track (NOT relevant
  227. // for AV).
  228. if ( ((PST_PLAY == gcs.pstate) || (PST_SLOW == gcs.pstate) || (PST_PAUSE == gcs.pstate) ||
  229.  ((PST_SCAN == gcs.pstate) && (CDDA_SID == g_pSVCDNav->m_uCurrAudioSID))) &&
  230.  PE_CD_IsPlaybackFinished() )
  231. {
  232. //<<<LX091202
  233. if ( ( g_pSVCDNav->m_iCurrVideoType == STILL_HIRES ) || ( g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES ) ){
  234. g_pSVCDNav->ucStillPicturePlaybackFinishedGapCounter--;
  235. if ( !g_pSVCDNav->ucStillPicturePlaybackFinishedGapCounter )
  236. ie_send(IE_CORE_CDNAV_FINISHED);
  237. }
  238. else
  239. //LX091202>>>
  240. ie_send(IE_CORE_CDNAV_FINISHED);
  241. }
  242. if (SHARED_INFO.m_iScanSpeed > 0)
  243. {
  244. if (( SHARED_INFO.wRemainingPlaybackTime < abs(SHARED_INFO.m_iScanSpeed)) && (0 == SVCDMessageGap.ScanFinishGap))
  245. {
  246. ie_send(IE_CORE_CDNAV_FINISHED);
  247. SVCDMessageGap.ScanFinishGap = SCAN_FINISH_GAP;
  248. }
  249. if (SVCDMessageGap.ScanFinishGap > 0)
  250. SVCDMessageGap.ScanFinishGap--;
  251. }
  252. // Check whether a Location-Change is in progress
  253. if (g_pSVCDNav->m_bLocationChanging) {
  254. // Check whether the Change has completed
  255. if ((dwCurrentLocation >= g_pSVCDNav->m_dwTargetLocation) &&
  256. (dwCurrentLocation < (g_pSVCDNav->m_dwTargetLocation + SVCD_LOCATION_TOLERANCE))) {
  257. g_pSVCDNav->m_bLocationChanging= FALSE;
  258. }
  259. }
  260. // Check for a Position-Rendezvous condition, provided that there is no Location-Change in progress
  261. if (! g_pSVCDNav->m_bLocationChanging) {
  262. // Take care of A-B Repeat
  263. if (PM_GetRepeatAB() & PM_REPEAT_AB_B) {
  264. if ((PST_SCAN == gcs.pstate) && (SHARED_INFO.m_iScanSpeed < 0)) {
  265. // Handle a Backwards-scan (in this case, look for Position-A, rather than Position-B):
  266. // If not scanning, make sure that there is a perfect match between the PositionB Marker and
  267. // the current location.
  268. if ( (dwCurrentLocation <= (g_pSVCDNav->m_PositionA).dwStartAddress) &&
  269.  ((g_pSVCDNav->m_PositionA).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
  270.  ((g_pSVCDNav->m_PositionA).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
  271.  ((g_pSVCDNav->m_PositionA).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
  272. {
  273.  ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)ePositionA);
  274. }
  275. }
  276. else if ((g_pSVCDNav->m_PositionB).dwStartAddress < dwCurrentLocation) {
  277. // For Forward-scan, or Normal speed playback, look for Position-B:
  278. // Make sure that there is a perfect match between the PositionB Marker and
  279. // the current location.
  280. if ( ((g_pSVCDNav->m_PositionB).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
  281.  ((g_pSVCDNav->m_PositionB).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
  282.  ((g_pSVCDNav->m_PositionB).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
  283. {
  284.  ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)ePositionB);
  285. }
  286. }
  287. }
  288. else if (PM_GetRepeatAB() & PM_REPEAT_AB_A) {
  289. // Only Position-A is set:
  290. // If the Current position precedes Position-A (e.g. during Backwards-scan),
  291. // then cancel the setting.
  292. if ((dwCurrentLocation < (g_pSVCDNav->m_PositionA).dwStartAddress) &&
  293. ((SHARED_INFO.m_CurrPosition).uListItem == (g_pSVCDNav->m_PositionA).uListItem))
  294. {
  295. CancelRepeatModes(PM_REPEAT_AB_MASK);
  296. }
  297. }
  298. }
  299. if (g_pSVCDNav->m_dwWaitTime > 0) {
  300. if (0 == --(g_pSVCDNav->m_dwWaitTime))
  301. ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)eWaitTimeExpired);
  302. }
  303. if (g_pSVCDNav->m_dwPausePeriod > 0) {
  304. if (0 == --(g_pSVCDNav->m_dwPausePeriod))
  305. ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)ePausePeriodExpired);
  306. }
  307. if (g_pSVCDNav->m_dwTimeout > 0) {
  308. if (0 == --(g_pSVCDNav->m_dwTimeout))
  309. ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)eTimeout);
  310. }
  311. if ( ( SHARED_INFO.bIsIntroPlayMode ) && ( SHARED_INFO.iCurrentTime == 10 ) 
  312. && ( PE_CD_GetCurrentLocation() > (g_pSVCDNav->m_aCurrTrack[0] + 10*SVCD_BLOCKS_PER_SECOND) ) ) {
  313. dbg_printf(("Intro Playaback Finished for current Trackn"));
  314. ie_send(IE_CORE_CDNAV_FINISHED);
  315. }
  316. #ifndef WATCHDOG_TRIGGERED_BY_FE
  317. // Call for Error-Recovery
  318. PerformErrorRecovery();
  319. #endif
  320. #if defined(MPP_SUPPORT) && defined(VCD_MPP_ENABLE)
  321. DEC_SetMPP( gcst.mMPP_Enable );
  322. #endif
  323. return;
  324. }
  325. #ifdef D_ENABLE_ELAPSEDTIME_FOR_SLIDESHOW
  326. /////////////////////////////////////////////////////////////////////////////////////////////////
  327. // void OnTickOneSec() -
  328. // Handels an IE_CORE_TICK_ONE_SEC Event.
  329. //
  330. // Input:
  331. // None
  332. //
  333. // Output:
  334. // Display still pictures elapsed time.
  335. //
  336. static void OnTickOneSec(void)
  337. {
  338. if(gcs.pstate == PST_PLAY)
  339. {
  340. //jeanz_0302_2005 Update time just for still pictures.
  341. if (( PlayList == (SHARED_INFO.m_CurrPosition).ListType) && ((g_pSVCDNav->m_iCurrVideoType == STILL_HIRES)||(g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES)))
  342. {
  343. int iElapsedTime= SHARED_INFO.iCurrentTime;
  344. WORD wTotalTime = (WORD)((g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
  345. if ( SHARED_INFO.uCurrentTrackNumber == 1 )
  346. wTotalTime = (WORD)((g_pSVCDNav->m_aCurrSegment[1] - g_pSVCDNav->m_aCurrSegment[0])/g_pSVCDNav->m_aCurrTrack[2]);
  347. iElapsedTime ++;
  348. iElapsedTime = (iElapsedTime > wTotalTime)? wTotalTime: iElapsedTime;
  349. SHARED_INFO.iCurrentTime = iElapsedTime;
  350. SHARED_INFO.wRemainingPlaybackTime = (WORD)(wTotalTime - iElapsedTime);
  351. }
  352. }
  353. return;
  354. }
  355. #endif
  356. /////////////////////////////////////////////////////////////////////////////////////////////////
  357. // void OnPlay() -
  358. // Handels an IE_CORE_PLAY Event.
  359. //
  360. // Input:
  361. // None
  362. //
  363. // Output:
  364. // Playback is resumed.
  365. //
  366. static void OnPlay(void)
  367. {
  368. dbg_printf(("OnPlay()n"));
  369. if(/*(gcs.pstate == PST_STOP )&&*/(! IS_COP_ENABLE( COP_SETUP )))
  370. SET_COP_MASK( COP_SETUP);
  371. // Check if a Paused playback is being resumed
  372. if (PST_PAUSE == gcs.pstate) {
  373. OnPausePeriodExpired();
  374. return;
  375. }
  376. //in case we were on digest mode we terminate the digest operation
  377. #ifdef SVCD_DIGEST_SUPPORT
  378. if (g_pSVCDNav->m_bDigestMode)
  379. _terminateDigestMode();
  380. #endif //SVCD_DIGEST_SUPPORT
  381. // If Scanning or Slow-Motion is in progress, eliminate it
  382. if ((PST_SCAN == gcs.pstate) || (PST_SLOW == gcs.pstate)) {
  383. BOOL bScan = FALSE;//jeanz_0306_2005 Set a value to the variable to prohibit it is given a invalid value.
  384. if ((PST_SCAN == gcs.pstate) || (SHARED_INFO.m_iSlowSpeed < 0))
  385. bScan = TRUE;
  386. if (SHARED_INFO.m_iSlowSpeed < 0)
  387. #ifdef USE_PTS_TO_MEASURE_TIME
  388. (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= TRUE; // By default, measuer using PTS's
  389. #else
  390. (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE; // Measuer not using PTS's
  391. #endif
  392. gcs.pstate= PST_PLAY;
  393. if (bScan)
  394. OnScan(0);
  395. else
  396. OnSlow(0);
  397. // For AV Tracks only, adjust the Time-measurement
  398. if (CDDA_SID != g_pSVCDNav->m_uCurrAudioSID) {
  399. //updating the time offset value
  400. #ifdef SVCD_USE_ABSOLUTE_TIME
  401. if (! g_pSVCDNav->m_bIsUsingPSD) {
  402. if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track)
  403. //calculating the absolute time offset from the beginning of track #2
  404. (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)((g_pSVCDNav->m_aCurrSegment[0] - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
  405. else
  406. (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)(g_pSVCDNav->m_aCurrSegment[0] / g_pSVCDNav->m_aCurrTrack[2]);
  407. }
  408. else
  409. (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)((g_pSVCDNav->m_aCurrSegment[0] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
  410. #else
  411. // (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)((g_pSVCDNav->m_aCurrSegment[0] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
  412. #endif //SVCD_USE_ABSOLUTE_TIME
  413. // Resume Time-Measurement according to PTS's; continue to use the last-acquired
  414. // PTS as a base. The last acquired PTS is the last PTS seen before transition to
  415. // the Scan mode.
  416. #ifdef USE_PTS_TO_MEASURE_TIME
  417. (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= TRUE; // By default, measuer using PTS's
  418. #else
  419. (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE; // Measuer not using PTS's
  420. #endif
  421. (g_pSVCDNav->m_TimeMeasurementInfo).bAcquireStartPTS= FALSE;
  422. }
  423. return;
  424. }
  425. if (! g_pSVCDNav->m_bIsUsingPSD) {
  426. if (PST_PLAY == gcs.pstate) {
  427. dbg_printf(("Already playing. Ignored.n"));
  428.   return;
  429. }
  430. // Check if the playback needs to be resumed from a previously recorded position
  431. if (-1 != (g_pSVCDNav->m_ResumePlayback).dwStartAddress) {
  432. dbg_printf(("Resuming playback.n"));
  433. memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_ResumePlayback), 
  434.    sizeof(SVCD_Marker));
  435. ClearMarker(eResumePlayback, 0); // Mark that this Marker has been used
  436. }
  437. // Now actually invoke playback of the List
  438. gcs.pstate= PST_PLAY;
  439. if (! InvokePlayback()) {
  440. dbg_printf(("Failed to play-back the current Track.n"));
  441. gcs.pstate= PST_STOP;
  442. }
  443. return;
  444. }
  445. // Check if the playback needs to be resumed from a previously recorded position
  446. if (-1 != (g_pSVCDNav->m_ResumePlayback).dwPSD_Offset) {
  447. dbg_printf(("Resuming playback.n"));
  448. memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_ResumePlayback), sizeof(SVCD_Marker));
  449. ClearMarker(eResumePlayback, 0); // Mark that this Marker has been used
  450. // Check the current value of the Repeat-Counter. If it is Zero or negative, then force a
  451. // single iteration of the Selection-List Play-Item when resuming playback.
  452. if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && 
  453. (((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt <= 0)) {
  454. ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
  455. }
  456. }
  457. // Check the type of the current List
  458. if ( (PlayList == (SHARED_INFO.m_CurrPosition).ListType) && (PST_PLAY == gcs.pstate) ) {
  459. // This is a Play-List: if there is already playback in progress, ignore.
  460. dbg_printf(("Already playing a PlayList Item. Ignored.n"));
  461. return;
  462. }
  463. else if ( (SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && 
  464.   ((PST_PLAY == gcs.pstate) || (PST_STILL == gcs.pstate)) ) 
  465. {
  466. // This is a Selection-List: if the Play-Item is already displaying, then this is a Default
  467. // selection.
  468. DWORD dwCurrLocation;
  469. WORD uDefaultOffset;
  470. // First, verify that the Default-Selection is allowed at this time, or should be postponed
  471. if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
  472. g_pSVCDNav->m_bPendingEvent= TRUE;
  473. g_pSVCDNav->m_PendingEvent= IE_CORE_PLAY;
  474. g_pSVCDNav->m_uPendingEventParam= NULL;
  475. return;
  476. }
  477.         dwCurrLocation= PE_CD_GetCurrentLocation();
  478. //<<<LX090202: Check if the selection counter is zero in case get "divided by zero" error
  479. if (gns.svcd.m_CurrList.SelectionList.uSelectionsCnt == 0 )
  480. if ( (0xFFFD == gns.svcd.m_CurrList.SelectionList.uDefaultOffset) || (0xFFFE == gns.svcd.m_CurrList.SelectionList.uDefaultOffset) ||
  481. (0xFFFF == gns.svcd.m_CurrList.SelectionList.uDefaultOffset) )
  482. return;
  483. //LX090202>>>
  484. dbg_printf(("Activating the Default selection.n"));
  485. if (PST_PLAY == gcs.pstate)
  486. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  487. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  488. (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
  489. if ((0xFFFD == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset) ||
  490. (0xFFFE == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset)) 
  491. {
  492. dbg_printf(("Multi-Default Mode engaged.n"));
  493. uDefaultOffset= FindDefaultSelectionOffset(dwCurrLocation);
  494. if ((WORD)-1 == uDefaultOffset) {
  495. gcs.pstate= PST_STILL;
  496. return;
  497. }
  498. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  499.    (UINT32)uDefaultOffset;
  500. }
  501. else if (0xFFFF == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset) {
  502. dbg_printf(("No Default-List was defined.n"));
  503. uDefaultOffset= FindDefaultSelectionOffset(-1);
  504. if ((WORD)-1 == uDefaultOffset) {
  505. gcs.pstate= PST_STILL;
  506. return;
  507. }
  508. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  509.    (UINT32)uDefaultOffset;
  510. }
  511. else {
  512. dbg_printf(("The Default-List is at offset: %04xn", ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset));
  513. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  514. (UINT32)((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset;
  515. }
  516. }
  517. // Now actually invoke playback of the List
  518. gcs.pstate= PST_PLAY;
  519. if (! InvokePlayback()) {
  520. dbg_printf(("Failed to play-back the current List.n"));
  521. gcs.pstate= PST_STOP;
  522. }
  523. return;
  524. }
  525. /////////////////////////////////////////////////////////////////////////////////////////////////
  526. // void OnRendezvousPoint(enSVCD_RendezvousType eType) -
  527. // Handels an IE_CORE_CDNAV_RENDEZVOUS Event.
  528. //
  529. // Input:
  530. // eType - Specifies the type of Rendezvous point encountered.
  531. //
  532. // Output:
  533. // According to the type of Rendezvous detected, playback flow is changed.
  534. //
  535. // Remarks:
  536. // The handler examines the type of Rendezvous encountered;
  537. // for timer-expiration events, the handler calls the approriate sub-handlers.
  538. // For a PositionB encounter, the handler aborts the current playback and resumes it 
  539. // from PositionA.
  540. static void OnRendezvousPoint(enSVCD_RendezvousType eType)
  541. {
  542. switch (eType) 
  543. {
  544. case eTimeout:
  545. OnTimeout();
  546. break;
  547. case eWaitTimeExpired:
  548. OnWaitTimeExpired();
  549. break;
  550. case ePausePeriodExpired:
  551. OnPausePeriodExpired();
  552. break;
  553. case ePositionA: // Fall-Through!
  554. case ePositionB:
  555. dbg_printf(("Position%c Encountered.n", (ePositionA == eType) ? 'A' : 'B'));
  556. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  557. memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_PositionA), sizeof(SVCD_Marker));
  558. // Eliminate any on-going Scanning
  559. if (PST_SCAN == gcs.pstate) {
  560. OnScan(0);
  561. gcs.pstate= PST_PLAY;
  562. ie_send(IE_UI_STATE_CHANGE);
  563. }
  564. // Do some book-keeping for Selection-Lists in PBC mode
  565. if (g_pSVCDNav->m_bIsUsingPSD) {
  566. // Check the current value of the Repeat-Counter. If it is Zero or negative, then
  567. // force a single iteration of the Selection-List Play-Item when resuming playback.
  568. if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && 
  569. (0 >= ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt)) {
  570. ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
  571. }
  572. }
  573. // Resume playback
  574. // <<< SEC shKang051304 : for Supporting the Slow Repeat A-B
  575. #ifdef EXINO2
  576. if( !( SHARED_INFO.m_iSlowSpeed != 0 && gcs.pstate == PST_SLOW ) ) 
  577. #endif 
  578. // SEC shKang080703 >>>
  579. gcs.pstate= PST_PLAY;
  580. if (! InvokePlayback()) {
  581. dbg_printf(("Failed to play-back the current List.n"));
  582. gcs.pstate= PST_STOP;
  583. }
  584. break;
  585. }
  586. return;
  587. }
  588. /////////////////////////////////////////////////////////////////////////////////////////////////
  589. // void OnPlaybackFinished() -
  590. // Handels an IE_CORE_CDNAV_FINISHED Event.
  591. //
  592. // Input:
  593. // None
  594. //
  595. // Output:
  596. // Taking into account the current Playback-Mode and the current position, playback is
  597. // either repeated, continued or halted.
  598. static void OnPlaybackFinished(void)
  599. {
  600. WORD wListTimeField;
  601. DWORD dwTimePeriod;
  602. BOOL bListBoundariesReached = FALSE;
  603. dbg_printf(("OnPlaybackFinished()n"));
  604. // Cancel Error-Recovery Mechanism(s)
  605. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
  606. (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= 0;
  607. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
  608. #ifdef WATCHDOG_TRIGGERED_BY_FE
  609. PE_CD_CancelNotification( StuckTrigger );
  610. #endif
  611. #ifdef SVCD_DIGEST_SUPPORT
  612. //no need to proccess this event on digest mode
  613. if (g_pSVCDNav->m_bDigestMode)
  614. return;
  615. #endif //SVCD_DIGEST_SUPPORT
  616. if ((PM_REPEAT_AB_A == PM_GetRepeatAB()) && PM_IsPBC(PM_GetPlaybackMode()))
  617. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_REPEAT_AB_PROHIBIT );
  618. // When not using a PSD, advance to the next Program-List Item, provided that the end
  619. // of the Program-List has not been reached and the the Playback-Mode is not "Repeat Single".
  620. if (! g_pSVCDNav->m_bIsUsingPSD) {
  621. dbg_printf(("PSD is not being used.n"));
  622. if (PM_IsRepeatSingle()) {
  623. dbg_printf(("Repeating the current Program-List Item.n"));
  624. // Resume Normal playback, if scanning
  625. if (PST_SCAN == gcs.pstate) {
  626. OnScan(0);
  627. gcs.pstate= PST_PLAY;
  628. ie_send(IE_UI_STATE_CHANGE);
  629. }
  630. if (! InvokePlayback()) {
  631. dbg_printf(("Failed to play-back the current Item.n"));
  632. gcs.pstate= PST_STOP;
  633. }
  634. return;
  635. }
  636. //NOTE: Usually OnPlaybackFinished is called when a forward scan has reached its item
  637. //boundary. But, when scanning BACKWARDS from a CDDA track to a VCD track, the 
  638. //Playback finished event occurrs as well. So we need to update the list item 
  639. //accordingly, meaning reduce its number, and not only increase it.
  640. if (SHARED_INFO.m_iScanSpeed < 0)
  641. {
  642. #ifndef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  643. //moving to previous item
  644. (SHARED_INFO.m_CurrPosition).uListItem--;
  645. if ((SHARED_INFO.m_CurrPosition).uListItem <= 0) {
  646. (SHARED_INFO.m_CurrPosition).uListItem= PM_GetProgramSize();
  647. bListBoundariesReached = TRUE;
  648. }
  649. #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  650. }
  651. else 
  652. {
  653. //moving to next item on the play list
  654. (SHARED_INFO.m_CurrPosition).uListItem++;
  655. if ((SHARED_INFO.m_CurrPosition).uListItem > (PM_GetProgramSize() - 1)) {
  656. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  657. bListBoundariesReached = TRUE;
  658. }
  659. }
  660. // Check if the end of the Program-List has been reached. If so, rewind the Program-List.
  661. // If the Playback-Mode is "Repeat All", then also re-invoke the playback.
  662. if (bListBoundariesReached) {
  663. // Cancel A-B Repeat, in case only Position-A was set
  664. CancelRepeatModes(PM_REPEAT_AB_MASK);
  665. // If the current playback-mode is not "Repeat All", then don't re-invoke the playback
  666. if (! PM_IsRepeatAll()
  667. #ifdef D_REPEAT_PROGRAM_MODE
  668. && (PM_GetPlaybackMode() != PM_PLAYBACK_PROGRAM) 
  669. #endif
  670. ){
  671. OnStop(eFullStop);
  672. ie_send(IE_UI_STATE_CHANGE);
  673. return;
  674. }
  675. // Resume Normal playback, if Scanning
  676. if (PST_SCAN == gcs.pstate) {
  677. OnScan(0);
  678. gcs.pstate= PST_PLAY;
  679. ie_send(IE_UI_STATE_CHANGE);
  680. }
  681. }
  682. if (! InvokePlayback()) {
  683. dbg_printf(("Failed to play-back the next Item.n"));
  684. gcs.pstate= PST_STOP;
  685. }
  686. return;
  687. }
  688. // The PSD information is being used:
  689. // Check whether the current Playback-Mode is "Single-Repeat", in which case
  690. // there's need to repeat the current item provided that the current List is a Play-List.
  691. if ((PlayList == (SHARED_INFO.m_CurrPosition).ListType) && PM_IsRepeatSingle()) {
  692. dbg_printf(("Repeating the current Play-Item...n"));
  693. // Resume Normal playback, if scanning
  694. if (PST_SCAN == gcs.pstate) {
  695. OnScan(0);
  696. gcs.pstate= PST_PLAY;
  697. ie_send(IE_UI_STATE_CHANGE);
  698. }
  699. if (! InvokePlayback()) {
  700. dbg_printf(("Failed to play-back the current List.n"));
  701. gcs.pstate= PST_STOP;
  702. }
  703. return;
  704. }
  705. // Check the type of the current List, and extract the appropriate field
  706. if (PlayList == (SHARED_INFO.m_CurrPosition).ListType)
  707. wListTimeField= ((SHARED_INFO.m_CurrList).PlayList).wWaitTime;
  708. else
  709. wListTimeField= ((SHARED_INFO.m_CurrList).SelectionList).wTimeoutWaitTime;
  710. // Calculate the equivalent amount of Ticks
  711. if (0xFF == wListTimeField)
  712. dwTimePeriod= SVCD_INFINITE; // Wait forever
  713. else if (0 == wListTimeField)
  714. dwTimePeriod= 1; // Engage immediately (i.e. on the next Tick)
  715. else if ((1 <= wListTimeField) && (60 >= wListTimeField))
  716. dwTimePeriod= (DWORD)wListTimeField * SVCD_TICKS_PER_SECOND;
  717. else
  718. dwTimePeriod= (60 + (((DWORD)wListTimeField - 60) * 10)) * SVCD_TICKS_PER_SECOND;
  719. // Check the type of the current List again.
  720. // If the current List is a PlayList, then engage the Waiting-Time counter;
  721. // Otherwise, the current List is a SelectionList -- engage the Timeout-Period counter,
  722. // provided that no more iterations are left
  723. if (PlayList == (SHARED_INFO.m_CurrPosition).ListType) {
  724. g_pSVCDNav->m_dwWaitTime= dwTimePeriod;
  725. #ifdef _DEBUG
  726. if (SVCD_INFINITE == dwTimePeriod)
  727. dbg_printf(("Infinite Wait-Time engaged for the current PlayList Item.n"));
  728. else
  729. dbg_printf(("Engaged a Wait-Time of %lu Seconds for the current PlayList Item.n", (dwTimePeriod/SVCD_TICKS_PER_SECOND)));
  730. #endif //_DEBUG
  731. }
  732. else {
  733. // Check if there's a Pending-Event. This would occur in the case of finishing the playback of
  734. // a SelectionList Play-Item, whose Jump-Timing is set to "After playback finish".
  735. // If there is a Pending-Event, reschedule that event first.
  736. if (g_pSVCDNav->m_bPendingEvent) {
  737. gcs.pstate= PST_STILL;
  738. dbg_printf(("Executing Pending-Event: %un", g_pSVCDNav->m_PendingEvent));
  739. g_pSVCDNav->m_bPendingEvent= FALSE;
  740. ie_send_ex(g_pSVCDNav->m_PendingEvent, (void *)g_pSVCDNav->m_uPendingEventParam);
  741. return;
  742. }
  743. // Check the Repeat-Counter: If it is Zero, start measuring the Timeout period.
  744. // Otherwise, invoke an additional playback of the same Item.
  745. if (0 != ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt) {
  746. if (! InvokePlayback()) {
  747. dbg_printf(("Failed to invoke repeated playback.n"));
  748. gcs.pstate= PST_STOP;
  749. }
  750. return;
  751. }
  752. else {
  753. g_pSVCDNav->m_dwTimeout= dwTimePeriod;
  754. #ifdef _DEBUG
  755. if (SVCD_INFINITE == dwTimePeriod)
  756. dbg_printf(("Infinite Timeout-Period engaged for the current SelectionList.n"));
  757. else
  758. dbg_printf(("Engaged a Timeout-Period of %lu Seconds for the current SelectionList.n", (dwTimePeriod/SVCD_TICKS_PER_SECOND)));
  759. #endif //_DEBUG
  760. }
  761. }
  762. // Cancel any current CDDA Scanning (unnecessary for AV streams, since I-Frame notification
  763. // has already been cancelled).
  764. // if ((PST_SCAN == gcs.pstate) && (CDDA_SID == g_pSVCDNav->m_uCurrAudioSID))
  765. if (PST_SCAN == gcs.pstate)
  766. OnScan(0);
  767. gcs.pstate= PST_STILL;
  768. return;
  769. }
  770. /////////////////////////////////////////////////////////////////////////////////////////////////
  771. // void OnAutoPauseEngaged() -
  772. // Handels an Auto-Pause Event, issued by the OnRendezvous() handler.
  773. //
  774. // Input: 
  775. // None
  776. //
  777. // Output:
  778. // According to the value of the Pause-Period as defined by the current List, the internal
  779. // Auto-Pause-Period Timer is set.
  780. static void OnAutoPauseEngaged(void)
  781. {
  782. BYTE uPausePeriod;
  783. dbg_printf(("OnAutoPauseEngaged()n"));
  784. // Ignore this event if PBC is not being used (meaningless)
  785. if (! g_pSVCDNav->m_bIsUsingPSD)
  786. return;
  787. // Check if there's still a point in starting an Auto-Pause
  788. if ((PST_PLAY != gcs.pstate) && (PST_SLOW != gcs.pstate))
  789. return;
  790. // The Auto-Pause can only be engaged inside a PlayList Item; therefore, the current List
  791. // must be a Play-List.
  792. // Examine the value of the Auto-Pause Period Field, and act accoringly.
  793. uPausePeriod= ((SHARED_INFO.m_CurrList).PlayList).wAutoPausePeriod;
  794. if (0 == uPausePeriod) {
  795. // No need to execute any Pause. Continue playback.
  796. dbg_printf(("Zero Pause-Period defined for the current PlayList. Ignored.n"));
  797. return;
  798. }
  799. // Pause the playback
  800. PE_CD_PausePlayback(TRUE, g_pSVCDNav->m_uCurrAudioSID);
  801. gcs.pstate= PST_PAUSE;
  802. // Enable Play, Next and Previous
  803. SET_COP_MASK(COP_PLAY | COP_PREVIOUS_CHAPTER | COP_NEXT_CHAPTER);
  804. // Start the Pause-Period Counter
  805. if (0xFF == uPausePeriod)
  806. g_pSVCDNav->m_dwPausePeriod= SVCD_INFINITE;
  807. else
  808. g_pSVCDNav->m_dwPausePeriod= SVCD_TICKS_PER_SECOND * (((WORD)uPausePeriod <= 60) ? uPausePeriod: (60 + (((WORD)uPausePeriod - 60) * 10)));
  809. return;
  810. }
  811. /////////////////////////////////////////////////////////////////////////////////////////////////
  812. // void OnStop(enSVCD_StopType eStopType) -
  813. // Handels an IE_CORE_PAUSE and an IE_CORE_STOP Event.
  814. //
  815. // Input:
  816. // eStopType - The type of Stopping requested
  817. //
  818. // Output:
  819. // Playback is stopped or paused, depending on the type of event that was received.
  820. // For a STOP event, the current position is also recorded in order to allow playback
  821. // to resume from that point in the future.
  822. static void OnStop(enSVCD_StopType eStopType)
  823. {
  824. BOOL bResumeOnDigest = TRUE;
  825. dbg_printf(("OnStop()n"));
  826. // <<< ZKR GL050104 : Eliminate unnecessary sequence header reads.
  827. #if defined(ENHANCED_SEQ_HDR_READING) || defined(EXINO2)
  828. g_ucReadSeqHdr = FALSE;
  829. #endif 
  830. // >>>
  831. #ifdef SVCD_DIGEST_SUPPORT
  832. //checking if we are on digest mode
  833. if (g_pSVCDNav->m_bDigestMode) {
  834. //The stop resume mechanism should only work when we were on Track-digest
  835. //because when we are on stop mode the address is -1
  836. if (eTrackView != Digest_getDigestMode())
  837. bResumeOnDigest = FALSE;
  838. _terminateDigestMode();
  839. }
  840. #endif //SVCD_DIGEST_SUPPORT
  841. // Cancel Error-Recovery Mechanism(s)
  842. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
  843. (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= 0;
  844. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
  845. #ifdef WATCHDOG_TRIGGERED_BY_FE
  846. PE_CD_CancelNotification( StuckTrigger );
  847. #endif
  848.     PE_CD_CancelNotification(TriggerBit);
  849. //DAC_SetMute(TRUE);
  850. #ifdef DIGITAL_AMPLIFIER_ENABLE
  851. amplifier_mute(TRUE);
  852. #endif //DIGITAL_AMPLIFIER_ENABLE
  853. // If Scanning is in progress, eliminate it
  854. if (PST_SCAN == gcs.pstate)
  855. {
  856. OnScan(0);
  857. //<<<Hannah_0923_2004 To wait for the DVP decode one picture before Send pause command.  //jeanz_1115_2004 Move the patch from I64
  858. {
  859. UINT8  uPictureCnt;
  860. UINT16 uStatus2;
  861. UINT16 utry =  5;
  862. // Extract the value of the Picture-Counter
  863. while (utry--)
  864. {
  865. uStatus2 = inport(I64_STATUS_2);
  866. uPictureCnt = (UINT8)((uStatus2 & (UINT16)DEC_LL_STATUS2_DEC_PIC_CNTR_MASK) >> DEC_LL_STATUS2_DEC_PIC_CNTR_SHIFT);
  867. printf("n****** Wait for the DVP to docoder the picture before pause.uPictureCnt = %d   utry = %dn",uPictureCnt,utry);
  868. if(uPictureCnt<2)
  869. usleep(250000UL);
  870. else
  871. break;
  872. }
  873. if(!utry)
  874. printf("n Time out to wait for the DVP decoder one Picture!!!  n");
  875. }
  876. }
  877. // If Slow-Motion is in progress, cancel it
  878. if (PST_SLOW == gcs.pstate)
  879. {
  880. OnSlow(0);
  881. //<<<Hannah_0923_2004 To wait for the DVP decode one picture before Send pause command.  //jeanz_1115_2004 Move the patch from I64
  882. {
  883. UINT8  uPictureCnt;
  884. UINT16 uStatus2;
  885. UINT16 utry =  5;
  886. // Extract the value of the Picture-Counter
  887. while (utry--)
  888. {
  889. uStatus2 = inport(I64_STATUS_2);
  890. uPictureCnt = (UINT8)((uStatus2 & (UINT16)DEC_LL_STATUS2_DEC_PIC_CNTR_MASK) >> DEC_LL_STATUS2_DEC_PIC_CNTR_SHIFT);
  891. printf("n****** Wait for the DVP to docoder the picture before pause.uPictureCnt = %d   utry = %dn",uPictureCnt,utry);
  892. if(uPictureCnt<2)
  893. usleep(250000UL);
  894. else
  895. break;
  896. }
  897. if(!utry)
  898. printf("n Time out to wait for the DVP decoder one Picture!!!  n");
  899. }
  900. }
  901. switch (eStopType) 
  902. {
  903. case ePause:
  904. // Make sure that there's need to pause
  905. if (PST_STILL == gcs.pstate) {
  906. dbg_printf(("Cannot Pause during a Still Image. Ignored.n"));
  907. if (PS_GET_ANALOG_AUDIO_SETTING() != NO_ANALOG_AUDIO)
  908. {
  909. //DAC_SetMute(FALSE);
  910. #ifdef DIGITAL_AMPLIFIER_ENABLE
  911. amplifier_mute(FALSE);
  912. #endif //DIGITAL_AMPLIFIER_ENABLE
  913. }
  914. return;
  915. }
  916. dbg_printf(("Pausing current playback.n"));
  917. PE_CD_PausePlayback(TRUE, g_pSVCDNav->m_uCurrAudioSID);
  918. gcs.pstate= PST_PAUSE;
  919. break;
  920. case eStopResume:
  921. // <<< ZKR GL050104 : Eliminate unnecessary sequence header reads.
  922. #if defined(ENHANCED_SEQ_HDR_READING) || defined(EXINO2)
  923. g_ucReadSeqHdr = TRUE;
  924. #endif 
  925. // >>>
  926. case eFullStop:
  927. // Record the current position
  928. dbg_printf(("Stopping playback. Current-position recorded.n"));
  929. // Cancel Intro Playmode
  930. SHARED_INFO.bIsIntroPlayMode = FALSE;
  931. if ((eStopResume == eStopType) && bResumeOnDigest)
  932. SetMarker(eResumePlayback, 0);
  933. else {
  934. #ifndef K1_WL
  935. ClearMarker(eResumePlayback,0);
  936. #endif
  937. //add by wl033004 for set the play mode to normal after full stop
  938. #ifdef K1_WL
  939. if ( PM_IsPlaybackProgram(PM_GetPlaybackMode()) || PM_IsPlaybackIntro(PM_GetPlaybackMode())
  940. #ifdef D_ENABLE_SHUFFLE_MODE
  941. || PM_IsPlaybackShuffle(PM_GetPlaybackMode())
  942. #endif
  943. )
  944. {
  945. PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
  946.   mode_set_private_program_size(0);
  947. OnModeChange();
  948. }
  949. #endif
  950. //add by wl033004 for set the play mode to normal after full stop
  951. // Rewind the Current-Position to the Program-Beginning
  952. (SHARED_INFO.m_CurrPosition).ListType= Undetermined; // The type of the first List is yet undetermined
  953. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= 0; // The first List is at the beginning of the PSD
  954. (SHARED_INFO.m_CurrPosition).uListItem= 1; // By default, begin with the first item in the List
  955. (SHARED_INFO.m_CurrPosition).dwStartAddress= -1; // The address is yet undefined
  956. }
  957. PE_CD_AbortPlayback((eStopResume == eStopType) ? TRUE : FALSE);
  958. if (PST_STOP != gcs.pstate) {
  959. gcs.pstate= PST_STOP;
  960. CLEAR_COP_MASK(COP_PAUSE | COP_SLOW | COP_SCAN | COP_SCAN_BACKWARD | COP_STEP);
  961. // Cancel any current Repeat-Modes
  962. if (eStopResume != eStopType) //BT0407: only full stop cancel repeat mode
  963. CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
  964. // Display Logo
  965. PE_CD_DisplayLogo();
  966. }
  967. break;
  968. }
  969. if (PS_GET_ANALOG_AUDIO_SETTING()!=NO_ANALOG_AUDIO)
  970. {
  971. //DAC_SetMute(FALSE);
  972. #ifdef DIGITAL_AMPLIFIER_ENABLE
  973. amplifier_mute(FALSE);
  974. #endif //DIGITAL_AMPLIFIER_ENABLE
  975. }
  976. // Enable Play, Next and Previous
  977. SET_COP_MASK(COP_PLAY | COP_PREVIOUS_CHAPTER | COP_NEXT_CHAPTER);
  978. // Terminate any pending Rendezvous events
  979. g_pSVCDNav->m_dwTimeout= SVCD_INFINITE;
  980. g_pSVCDNav->m_dwWaitTime= SVCD_INFINITE;
  981. g_pSVCDNav->m_dwPausePeriod= SVCD_INFINITE;
  982. return;
  983. }
  984. /////////////////////////////////////////////////////////////////////////////////////////////////
  985. // void OnStep() -
  986. // Handels an IE_CORE_STEP Event.
  987. //
  988. // Input:
  989. // None
  990. //
  991. // Output:
  992. // The appropriate PE method is called to step forward.
  993. static void OnStep(void)
  994. {
  995. dbg_printf(("OnStep()n"));
  996. if (PST_PAUSE != gcs.pstate) {
  997. dbg_printf(("Step is illegal when not Pausing. Ignored.n"));
  998. return;
  999. }
  1000. // Cancel Intro Playmode
  1001. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  1002. PE_CD_Step();
  1003. return;
  1004. }
  1005. /////////////////////////////////////////////////////////////////////////////////////////////////
  1006. // void OnModeChange() -
  1007. // Handels an IE_CORE_SEAMLESS_MODE_CHANGE Event.
  1008. //
  1009. // Input:
  1010. // None
  1011. //
  1012. // Output:
  1013. // The playback flow is changed according to the exact Mode that has changed.
  1014. //
  1015. // Remarks:
  1016. // This handler first determines what kind of Mode change has occurred.
  1017. // According to the change, different actions are taken:
  1018. // - If PBC has been turned Off, a seamless transition is performed, and the current
  1019. //   item continues playback;
  1020. // - If PBC has been turned On, the current playback is unconditionally stopped and restarted
  1021. //   from the first List.
  1022. // - If Shuffle has been turned On, then: if the current state is Playing, the transition
  1023. //   is seamless by suffling everything except the current item, and placing the current item
  1024. //   at the beginning of the Program-List.
  1025. //   If the current state is not Playing, a complete shuffle is performed.
  1026. // - If Program has been turned On, the current playback is unconditionally stopped and
  1027. //   restarted from the first Program-List item.
  1028. // - If Normal has been turned On, the current Program-List is purged and replaced with
  1029. //   a sequential Track-list (PBC must be Off).
  1030. //   Playback is then continued from that point on seamlessly.
  1031. static void OnModeChange(void)
  1032. {
  1033. BYTE GetCurrentPlaybackMode = PM_GetPlaybackMode();
  1034. dbg_printf(("OnModeChange()n"));
  1035. // Cancel Intro Playmode
  1036. SHARED_INFO.bIsIntroPlayMode = FALSE;
  1037. // Detect a transition of type: PBC -> Non-PBC
  1038. if (PM_IsPBC(g_pSVCDNav->m_uCurrPlaybackMode) && ! PM_IsPBC(GetCurrentPlaybackMode)) {
  1039. WORD uEntry;
  1040. BOOL bReinvokePlayback= FALSE;
  1041. dbg_printf(("PBC -> No PBCn"));
  1042. g_pSVCDNav->m_bIsUsingPSD= FALSE;
  1043. PE_CD_CancelNotification(TriggerBit);
  1044. // Rebuild the Normal Program-List (sequential playback of the Tracks)
  1045. PM_InitializeProgramList();
  1046. for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
  1047. PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
  1048. PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
  1049. // Reset the Resumption-point
  1050. ClearMarker(eResumePlayback, 0);
  1051. core_clear_bookmark_info( 0 ); // clear all bookmarks
  1052. // If the current List is a Selection-List and there's an image displaying, then
  1053. // re-invoke playback from the beginning.
  1054. // if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && (PST_STILL == gcs.pstate)) {
  1055. if ( SHARED_INFO.uCurrentTrackNumber == 1 ){
  1056. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  1057. bReinvokePlayback= TRUE;
  1058. }
  1059. // If the current List is a Play-List, and the current Playback-Status is not Stopped,
  1060. // then:
  1061. // - If the current Play-Item is a Track or an Entry, and the Playing time is not set,
  1062. //   continue playback of the current Item, but set the Current-Position to the
  1063. //   corresponding Track.
  1064. // - Otherwise, stop the current playback and re-invoke playback from the beginning.
  1065. if ((PlayList == (SHARED_INFO.m_CurrPosition).ListType) && (PST_STOP != gcs.pstate)) {
  1066. // If the Playing-Time is not "Play until finish", then the current playback must be
  1067. // stopped and re-invoked from the beginning.
  1068. if (0 != ((SHARED_INFO.m_CurrList).PlayList).uPlayingTime) {
  1069. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  1070. bReinvokePlayback= TRUE;
  1071. }
  1072. else {
  1073. // Since the current Play-Item will play until its end, it is safe to perform a truely
  1074. // seamless transition (provided that the current Play-Item is either a Track or an Entry).
  1075. BYTE aBuffer[2];
  1076. WORD uPlayItemNumber;
  1077. DWORD dwPSD_Offset= ((SHARED_INFO.m_CurrPosition).dwPSD_Offset + SVCD_PLAYLIST_HDR_SIZE 
  1078. + (2 * ((SHARED_INFO.m_CurrPosition).uListItem - 1)));
  1079. // Find-out which Track is being played-back
  1080. if (! _getPSDRecord(dwPSD_Offset, 2, aBuffer)) {
  1081. dbg_printf(("Failed to retrieve PSD information.n"));
  1082. return;
  1083. }
  1084. uPlayItemNumber= (((WORD)aBuffer[0] << 8) | aBuffer[1]);
  1085. if ((uPlayItemNumber >= 2) && (uPlayItemNumber <= 99)) {
  1086. // The current Play-Item is a Track
  1087. (SHARED_INFO.m_CurrPosition).uListItem= (uPlayItemNumber - 1);
  1088. }
  1089. else if ((uPlayItemNumber >= 100) && (uPlayItemNumber <= 599)) {
  1090. // The current Play-Item is an Entry
  1091. BYTE aBuffer[4];
  1092. //sc_Read(g_uEntriesTableOffset + (SVCD_ENTRY_SIZE * (uPlayItemNumber-100) / BYTE_PER_CONTAINER), 
  1093. // (SVCD_ENTRY_SIZE / BYTE_PER_CONTAINER), (Sc_cont*)aBuffer);
  1094. Array_getAt(g_hEntriesTable, (uPlayItemNumber - 100), (BYTE *)aBuffer);
  1095. (SHARED_INFO.m_CurrPosition).uListItem= ((WORD)drv_bcd2bin(aBuffer[0]) - 1);
  1096. }
  1097. else {
  1098. // The current Play-Item is a Segment - the playback must be restarted
  1099. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  1100. bReinvokePlayback= TRUE;
  1101. }
  1102. }
  1103. }
  1104. if ( ( SelectionList == ( SHARED_INFO.m_CurrPosition).ListType ) && ( PST_STOP != gcs.pstate ) ) {
  1105. if ( ( gns.svcd.m_CurrList.SelectionList.uPlayItemNumber > 1 )
  1106. && ( gns.svcd.m_CurrList.SelectionList.uPlayItemNumber <= 99 ) ){
  1107. gns.svcd.m_CurrPosition.dwPSD_Offset = 0xFFFF;
  1108. gns.svcd.m_CurrPosition.dwStartAddress = -1;
  1109. gns.svcd.m_CurrPosition.uListItem = gns.svcd.m_CurrList.SelectionList.uPlayItemNumber - 1;
  1110. }
  1111. }
  1112. if (bReinvokePlayback) {
  1113. // Re-invoke playback, if necessary
  1114. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  1115. gcs.pstate= PST_PLAY;
  1116. if (! InvokePlayback()) {
  1117. dbg_printf(("Failed to re-invoke playback after PBC change.n"));
  1118. gcs.pstate= PST_STOP;
  1119. }
  1120. }
  1121. // Update the current Playback-Mode
  1122. g_pSVCDNav->m_uCurrPlaybackMode= GetCurrentPlaybackMode;
  1123. return;
  1124. }
  1125. // Continue checking for other Mode-Transitions only if the PSD information is not being
  1126. // used.
  1127. if (g_pSVCDNav->m_bIsUsingPSD) {
  1128. dbg_printf(("Mode-Changes are disabled when PSD Information is being used. Ignored.n"));
  1129. return;
  1130. }
  1131. ClearMarker(eResumePlayback, 0);
  1132. core_clear_bookmark_info( 0 ); // clear all bookmarks
  1133. // Find-out what kind of mode has changed: the Playback-Mode or the Repeat-Mode
  1134. // If the change is not in Playback-Mode, then nothing to do.
  1135. if (g_pSVCDNav->m_uCurrPlaybackMode == GetCurrentPlaybackMode) {
  1136.    //Dm061902 prevent using empty playlist
  1137. if(PM_GetProgramSize() <= 0)
  1138. {
  1139. WORD uEntry;
  1140. // Rebuild the Normal Program-List (sequential playback of the Tracks)
  1141. PM_InitializeProgramList();
  1142. for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
  1143. PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
  1144. }
  1145. dbg_printf(("No Playback-Mode change detected.n"));
  1146. return;
  1147. }
  1148. // Cancel any current Repeat-Modes
  1149. CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
  1150. // Detect a transition of type: Non-Shuffle -> Shuffle
  1151. if (! PM_IsPlaybackShuffle(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPlaybackShuffle(GetCurrentPlaybackMode)) {
  1152. dbg_printf(("Non-Shuffle -> Shufflen"));
  1153. if(PM_GetProgramSize() <= 0)
  1154. {
  1155. WORD uEntry;
  1156. // Rebuild the Normal Program-List (sequential playback of the Tracks)
  1157. PM_InitializeProgramList();
  1158. for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
  1159. PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
  1160. }
  1161. // If the current Playback-Status is other than Stopped, shuffle the Program-List while
  1162. // keeping the current item as the first item
  1163. if (PST_STOP != gcs.pstate)
  1164. PM_ShuffleProgramList(TRUE, (SHARED_INFO.m_CurrPosition).uListItem);
  1165. else
  1166. PM_ShuffleProgramList(FALSE, 0);
  1167. // Now set the Current-Item to Item #1
  1168. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  1169. }
  1170. // Detect a transition of type: Non-Normal -> Normal
  1171. if (! PM_IsPlaybackNormal(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPlaybackNormal(GetCurrentPlaybackMode)) {
  1172. WORD uEntry;
  1173. WORD uCurrTrack= (WORD) PM_GetProgramListEntry((SHARED_INFO.m_CurrPosition).uListItem);
  1174. dbg_printf(("Non-Normal -> Normaln"));
  1175. // Rebuild the Normal Program-List (sequential playback of the Tracks)
  1176. PM_InitializeProgramList();
  1177. for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
  1178. PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
  1179. // Now update the Current-Position to point at the Entry holding the current-Track,
  1180. // if playback is currently in progress
  1181. if (PST_STOP != gcs.pstate)
  1182. (SHARED_INFO.m_CurrPosition).uListItem= (uCurrTrack - 1);
  1183. else
  1184. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  1185. }
  1186. // Detect a transition of type: Non-Program -> Program
  1187. if (! PM_IsPlaybackProgram(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPlaybackProgram(GetCurrentPlaybackMode)) {
  1188. dbg_printf(("Non-Program -> Programn"));
  1189. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  1190. if (PST_STOP != gcs.pstate) {
  1191. // Abort current playback, if any
  1192. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  1193. gcs.pstate= PST_PLAY;
  1194. if (! InvokePlayback()) {
  1195. dbg_printf(("Failed to re-invoke playback after Playback-Mode change.n"));
  1196. gcs.pstate= PST_STOP;
  1197. }
  1198. }
  1199. }
  1200. // Detect a transition of type: Non-PBC -> PBC
  1201. if (! PM_IsPBC(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPBC(GetCurrentPlaybackMode)) {
  1202. dbg_printf(("Non PBC -> PBCn"));
  1203. if (0 == (g_pSVCDNav->m_NavigationInfo).ulPSD_Size) {
  1204. dbg_printf(("PBC Cannot be turned-on for this Disc. Ignored.n"));
  1205. PM_SetPBC(FALSE);
  1206. return;
  1207. }
  1208. g_pSVCDNav->m_bIsUsingPSD= TRUE;
  1209. PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
  1210. PM_ReConstructProgramListEntry();/*Stivenz_0201_2005:need reconstruct progm list, in case play mode change from shuff mode and it will shuff the progm list*/
  1211. // Reset the Current-Position
  1212. (SHARED_INFO.m_CurrPosition).ListType= Undetermined; // The type of the first List is yet undetermined
  1213. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= 0; // The first List is at the beginning of the PSD
  1214. (SHARED_INFO.m_CurrPosition).uListItem= 1; // By default, begin with the first item in the List
  1215. (SHARED_INFO.m_CurrPosition).dwStartAddress= -1; // The address is yet undefined
  1216. if (PST_STOP != gcs.pstate) {
  1217. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  1218. gcs.pstate= PST_PLAY;
  1219. if (! InvokePlayback()) {
  1220. dbg_printf(("Failed to re-invoke playback after PBC change.n"));
  1221. gcs.pstate= PST_STOP;
  1222. }
  1223. }
  1224. }
  1225. // Update the current Playback-Mode
  1226. g_pSVCDNav->m_uCurrPlaybackMode= GetCurrentPlaybackMode;
  1227. return;
  1228. }
  1229. /////////////////////////////////////////////////////////////////////////////////////////////////
  1230. // void OnSetMarkerA() -
  1231. // Sets the PositionA marker.
  1232. //
  1233. // Input:
  1234. // None
  1235. //
  1236. // Output:
  1237. // None. PositionA marker is set.
  1238. static void OnSetMarkerA(void)
  1239. {
  1240. dbg_printf(("OnSetMarkerA()n"));
  1241. // Allow setting of Marker-A only for Non-PBC playback; or for PBC playback, provided that:
  1242. // the current List is a Play-List, or the current list is a Selection-List and the Elapsed
  1243. // Time is Valid (i.e. the current PIN is not a Segment).
  1244. if (! g_pSVCDNav->m_bIsUsingPSD || (PlayList == (SHARED_INFO.m_CurrPosition).ListType) ||
  1245. ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && SHARED_INFO.bIsElapsedTimeValid))
  1246. {
  1247. if(SHARED_INFO.iCurrentTime !=0 )
  1248. {
  1249. // Cancel Intro Playmode
  1250. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  1251. SetMarker(eMarkerA, 0);
  1252. PM_SetRepeatAB(PM_REPEAT_AB_A);
  1253. ie_send(IE_UI_STATE_CHANGE);
  1254. }
  1255. }
  1256. return;
  1257. }
  1258. /////////////////////////////////////////////////////////////////////////////////////////////////
  1259. // void OnSetMarkerB() -
  1260. // Sets the PositionB marker.
  1261. //
  1262. // Input:
  1263. // None
  1264. //
  1265. // Output:
  1266. // None. PositionB marker is set, and then playback is stopped and resumed from the 
  1267. // PositionA marker.
  1268. static void OnSetMarkerB(void)
  1269. {
  1270. dbg_printf(("OnSetMarkerB()n"));
  1271. SetMarker(eMarkerB, 0);
  1272. // Prohibit an A-B Segment of less than 2 Second
  1273. if (((g_pSVCDNav->m_PositionB).dwStartAddress - (g_pSVCDNav->m_PositionA).dwStartAddress) < 2*SVCD_BLOCKS_PER_SECOND)
  1274. {
  1275. // Force a 2 Second gap between Point-A and Point-B
  1276. (g_pSVCDNav->m_PositionB).dwStartAddress= (g_pSVCDNav->m_PositionA).dwStartAddress + 2*SVCD_BLOCKS_PER_SECOND;
  1277. }
  1278. //<<<ZCH MikeX_0905_2003_A: make the mark B point not at the last 2 second of current track
  1279. if( g_pSVCDNav->m_aCurrTrack[1] - (g_pSVCDNav->m_PositionB).dwStartAddress < 2*SVCD_BLOCKS_PER_SECOND)
  1280. {//forbit mark B point at the last 2 second of current track 
  1281. (g_pSVCDNav->m_PositionB).dwStartAddress = g_pSVCDNav->m_aCurrTrack[1] - 2*SVCD_BLOCKS_PER_SECOND;
  1282. if (((g_pSVCDNav->m_PositionB).dwStartAddress - (g_pSVCDNav->m_PositionA).dwStartAddress) < 2*SVCD_BLOCKS_PER_SECOND)
  1283. //Force a 2 Second gap between Point-A and Point-B
  1284. (g_pSVCDNav->m_PositionA).dwStartAddress= (g_pSVCDNav->m_PositionB).dwStartAddress - 2*SVCD_BLOCKS_PER_SECOND;
  1285. }
  1286. //ZCH MikeX_0905_2003_A>>>
  1287. // Stop Playback
  1288. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  1289. // Move the Current-Position to Point-A
  1290. memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_PositionA), sizeof(SVCD_Marker));
  1291. if (g_pSVCDNav->m_bIsUsingPSD) {
  1292. // Check the current value of the Repeat-Counter. If it is Zero or negative, then force a
  1293. // single iteration of the Selection-List Play-Item when resuming playback.
  1294. if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && 
  1295. (0 >= ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt)) {
  1296. ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
  1297. }
  1298. }
  1299. // Invoke A-B Repeat mode, and start Playback
  1300. PM_SetRepeatAB(PM_REPEAT_AB_B);
  1301. // <<< SEC shKang051304 : for Supporting the Slow Repeat A-B
  1302. #ifdef EXINO2
  1303. if( !( SHARED_INFO.m_iSlowSpeed != 0 && gcs.pstate == PST_SLOW ) ) 
  1304. #endif 
  1305. // SEC shKang051304 >>>
  1306. gcs.pstate= PST_PLAY;
  1307. if (! InvokePlayback()) {
  1308. dbg_printf(("Failed to play-back the current List.n"));
  1309. gcs.pstate= PST_STOP;
  1310. }
  1311. ie_send(IE_UI_STATE_CHANGE);
  1312. return;
  1313. }
  1314. /////////////////////////////////////////////////////////////////////////////////////////////////
  1315. // void OnCancelABRepeat(void) -
  1316. // Clears the current REPEAT_AB mode.
  1317. //
  1318. // Input:
  1319. // None
  1320. //
  1321. // Output:
  1322. // Both PositionA and PositionB are cleared, and the REPEAT_AB mode is explicitly turned Off.
  1323. static void OnCancelABRepeat(void)
  1324. {
  1325. dbg_printf(("OnCancelABRepeat()n"));
  1326. ClearMarker(eMarkerA, 0);
  1327. ClearMarker(eMarkerB, 0);
  1328. PM_SetRepeatAB(0);
  1329. ie_send(IE_UI_STATE_CHANGE);
  1330. return;
  1331. }
  1332. /////////////////////////////////////////////////////////////////////////////////////////////////
  1333. // void OnGoToBookmark(WORD uBookmarkNumber) -
  1334. // Handles an IE_CORE_GOTO_BOOKMARK Event.
  1335. //
  1336. // Input:
  1337. // uBookmarkNumber - The number of Bookmark to go to.
  1338. //
  1339. // Output:
  1340. // None. Playback is restarted from the desired Bookmark.
  1341. //
  1342. // Remarks:
  1343. // The handler checks validity of the selected Bookmark. If the Bookmark number is legal
  1344. // and the requested Bookmark is valid, then the current playback is unconditionally
  1345. // stopped and resumed from the position recorded by the requested Bookmark.
  1346. static void OnGoToBookmark(WORD uBookmarkNumber)
  1347. {
  1348. dbg_printf(("OnGoToBookmark(%d)n", uBookmarkNumber));
  1349. // Make sure that the requested Bookmark is still valid
  1350. if ((uBookmarkNumber >= SVCD_MAX_BOOKMARKS) ||
  1351. (-1 == (g_pSVCDNav->m_Bookmarks[uBookmarkNumber]).dwPSD_Offset)) {
  1352. dbg_printf(("Bookmark #%d is invalid. Ignored.n", uBookmarkNumber));
  1353. return;
  1354. }
  1355. // Cancel Intro Playmode
  1356. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  1357. // Stop any ongoing playback
  1358. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  1359. // Cancel any current Repeat-Modes
  1360. CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
  1361. // Set the Current-Position to hold the selected Bookmark
  1362. memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_Bookmarks[uBookmarkNumber]), sizeof(SVCD_Marker));
  1363. (SHARED_INFO.m_CurrPosition).ListType= Undetermined; // Force re-parsing of the current List
  1364. if (g_pSVCDNav->m_bIsUsingPSD) {
  1365. // Check the current value of the Repeat-Counter. If it is Zero or negative, then force a
  1366. // single iteration of the Selection-List Play-Item when resuming playback.
  1367. if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && 
  1368. (0 >= ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt)) {
  1369. ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
  1370. }
  1371. }
  1372. if (PST_SCAN == gcs.pstate) {
  1373. // Cancel the on-going Scan
  1374. OnScan(0);
  1375. }
  1376. gcs.pstate= PST_PLAY;
  1377. if (! InvokePlayback()) {
  1378. dbg_printf(("Failed to play-back the current List.n"));
  1379. gcs.pstate= PST_STOP;
  1380. }
  1381. return;
  1382. }
  1383. /////////////////////////////////////////////////////////////////////////////////////////////////
  1384. // void OnScan(int iSpeed) -
  1385. // Handles an IE_CORE_SCAN Event.
  1386. //
  1387. // Input:
  1388. // iSpeed - Holds the speed to scan at.
  1389. //
  1390. // Output:
  1391. // None. Scanning is started, if possible.
  1392. //
  1393. // Remarks:
  1394. // The handler verifies that there is some Play-Item currently in playback, and
  1395. // then switches the Playback-state to SCAN, sets the scanning-speed and requests
  1396. // notification of the next I-Frame.
  1397. static void OnScan(int iSpeed)
  1398. {
  1399. DWORD dwCurrLocationForCDDA;
  1400. dbg_printf(("OnScan(%d)n", iSpeed));
  1401. if ((PST_STOP == gcs.pstate) || (PST_STILL == gcs.pstate)) {
  1402. dbg_printf(("Cannot scan during a Stop. Ignored.n"));
  1403. return;
  1404. }
  1405. // Cancel Intro Playmode
  1406. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  1407. dwCurrLocationForCDDA= PE_CD_GetDecoderCurrentLocationLBN();
  1408. //setting the operation mask to enable/disable play while scanning
  1409. if (0 != iSpeed)
  1410. SET_COP_MASK(COP_PLAY);
  1411. else if (!g_pSVCDNav->m_bIsUsingPSD)
  1412. CLEAR_COP_MASK(COP_PLAY);
  1413. // If currently Pausing, first resume playback
  1414. if (PST_PAUSE == gcs.pstate)
  1415. PE_CD_PausePlayback(FALSE, g_pSVCDNav->m_uCurrAudioSID);
  1416. if ((0 != iSpeed) && (0 != SHARED_INFO.m_iScanSpeed) && (CDDA_SID != g_pSVCDNav->m_uCurrAudioSID))//Leon.He_1002_05: To avoid  the problem can't FR after FF for CDDA track on VCD
  1417. {
  1418. //If only change scan speed
  1419. SHARED_INFO.m_iScanSpeed= ((iSpeed >= 0) ? iSpeed : (iSpeed - 1));
  1420. return;
  1421. }
  1422. // Switch to Time-Measurement based on the MSF
  1423. (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE;
  1424. // Record the current Scanning-speed, and issue a request for I-Frame notification
  1425. // Note: if the speed is Negative, then increase it by one, to prevent getting stuck at the
  1426. // same position.
  1427. SHARED_INFO.m_iScanSpeed= ((iSpeed >= 0) ? iSpeed : (iSpeed - 1));
  1428. if (0 != iSpeed) 
  1429. {
  1430. CLEAR_COP_MASK(COP_ABREPEAT);
  1431. // Start Scanning
  1432. PE_CD_SetScan(TRUE, g_pSVCDNav->m_uCurrAudioSID, SHARED_INFO.m_iScanSpeed);
  1433. gcs.pstate= PST_SCAN;
  1434. if (CDDA_SID != g_pSVCDNav->m_uCurrAudioSID) {
  1435. // For AV Tracks only, request I-Frame notification
  1436. PE_CD_RequestNotification(IFrame);
  1437. //cancel Trigger Bit notification
  1438. PE_CD_CancelNotification(TriggerBit);
  1439. // Engage the Error-Recovery mehcanism for I-Frame Display Miss
  1440. (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_IFRAME_MISS_TIMEOUT;
  1441. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eIFrameDisplayMiss;
  1442. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302: Not acutual needed here
  1443. #ifdef WATCHDOG_TRIGGERED_BY_FE
  1444. PE_CD_RequestNotification( StuckTrigger );
  1445. #endif
  1446. }
  1447. else {
  1448. DWORD dwScanStart;
  1449. ULONG ulBlocksCnt;
  1450. // For CDDA Tracks, first stop the playback, and then renew from the same
  1451. // position. This is required for correct Scanning of CDDA.
  1452. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  1453. if (iSpeed > 0) {
  1454. dwScanStart= dwCurrLocationForCDDA;
  1455. ulBlocksCnt= (g_pSVCDNav->m_aCurrTrack[1] - dwCurrLocationForCDDA);
  1456. }
  1457. else {
  1458. dwScanStart= g_pSVCDNav->m_aCurrTrack[0];
  1459. ulBlocksCnt= (dwCurrLocationForCDDA - g_pSVCDNav->m_aCurrTrack[0]);
  1460. }
  1461. // Initiate the Error-Recovery Mechanism for Playback-Hangup
  1462. (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_PB_HANGUP_TIMEOUT;
  1463. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= ePlaybackHangup;
  1464. (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= dwScanStart;
  1465. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
  1466. #ifdef CDDA_MUTE_ON_SCAN
  1467. PE_CD_SetMute(TRUE);
  1468. #endif //CDDA_MUTE_ON_SCAN
  1469. if (! PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID, 
  1470. dwScanStart, ulBlocksCnt, eSearch, iSpeed))
  1471. {
  1472. dbg_printf(("Failed to re-invoke Playback.n"));
  1473. return;
  1474. }
  1475. PE_CD_SetCurrentLocationLBN_Bakcup(dwScanStart);
  1476. }
  1477. dbg_printf(("Scanning-Speed: %d.n", SHARED_INFO.m_iScanSpeed));
  1478. }
  1479. else 
  1480. {
  1481. SET_COP_MASK(COP_ABREPEAT);
  1482. // Stop Scanning
  1483. PE_CD_SetScan(FALSE, g_pSVCDNav->m_uCurrAudioSID, SHARED_INFO.m_iScanSpeed);
  1484. #ifdef K1_WL
  1485. gcs.pstate= PST_PLAY; //add by wl032404
  1486. #endif
  1487. // Initiate the Error-Recovery Mechanism for Playback-Hangup
  1488. (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_PB_HANGUP_TIMEOUT;
  1489. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= ePlaybackHangup;
  1490. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
  1491. if (CDDA_SID != g_pSVCDNav->m_uCurrAudioSID) {
  1492. (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= PE_CD_GetCurrentLocation();
  1493. if (g_pSVCDNav->m_bIsUsingPSD) 
  1494. PE_CD_RequestNotification(TriggerBit);
  1495. #ifdef WATCHDOG_TRIGGERED_BY_FE
  1496. PE_CD_RequestNotification( StuckTrigger );
  1497. #endif
  1498. }
  1499. else {
  1500. // For CDDA Tracks, first stop the playback, and then renew from the same
  1501. // position. This is required for correct Scanning of CDDA.
  1502. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  1503. // Adjust the Error-Recovery Mechanism for Playback-Hangup
  1504. (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= dwCurrLocationForCDDA;
  1505. #ifdef CDDA_MUTE_ON_SCAN)
  1506. PE_CD_SetMute(FALSE);
  1507. #endif //CDDA_MUTE_ON_SCAN
  1508. if (! PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID, 
  1509. dwCurrLocationForCDDA, 
  1510. (g_pSVCDNav->m_aCurrTrack[1] - dwCurrLocationForCDDA),
  1511. eNormalSpeed, iSpeed))
  1512. {
  1513. dbg_printf(("Failed to re-invoke Playback.n"));
  1514. return;
  1515. }
  1516. PE_CD_SetCurrentLocationLBN_Bakcup(dwCurrLocationForCDDA);
  1517. }
  1518. dbg_printf(("Scanning stopped.n"));
  1519. }
  1520. return;
  1521. }
  1522. /////////////////////////////////////////////////////////////////////////////////////////////////
  1523. // void OnIFrameDisplayed() -
  1524. // Handles an IE_CORE_I_FRAME Event.
  1525. //
  1526. // Input:
  1527. // None
  1528. //
  1529. // Output:
  1530. // None. The playback is skipped forward/backwards in order to seek and present the next
  1531. // I-Frame.
  1532. //
  1533. // Remarks:
  1534. // The handler checks the direction of the current Scan.
  1535. // In case of a forward scan, the current playback is halted and restarted from a position
  1536. // further down the stream.
  1537. // In the case of a backwards scan, the current playback is halted and restarted from a 
  1538. // position preceding the current one.
  1539. // In both cases, if the next position is outside the boundaries of the current Playing-Segment,
  1540. // the appropriate action is performed; i.e.: the next item (in forward scan) or the previous
  1541. // item (in backwards scan) is invoked.
  1542. static void OnIFrameDisplayed(void)
  1543. {
  1544. BOOL bInsideSegmentBoundaries= TRUE;
  1545. DWORD dwCurrLocation= -1;
  1546. DWORD dwNextLocation;
  1547. BOOL bLocationFromDriveValid = FALSE;
  1548. dbg_printf(("OnIFrameDisplayed()n"));
  1549. SET_COP_MASK(COP_SCAN);//LX090502
  1550. //<<<LX051302: Clear retry coutner since we got one Iframe
  1551. if ( 0 != (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter ){
  1552. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;
  1553. // (g_pSVCDNav->m_ErrorRecoveryInfo).dw
  1554. dbg_printf(("Clear error retry countern"));
  1555. }
  1556. //LX051302>>>
  1557. // Make sure that Scanning is still active
  1558. if (  ((PST_SCAN != gcs.pstate) || (0 == SHARED_INFO.m_iScanSpeed))
  1559. &&(PST_SLOW != gcs.pstate)
  1560. ){
  1561. dbg_printf(("Scanning cancelled. Ignored.n"));
  1562. dwCurrLocation= -1; // Reset the Scan position
  1563. return;
  1564. }
  1565. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
  1566. #ifdef WATCHDOG_TRIGGERED_BY_FE
  1567. PE_CD_CancelNotification( StuckTrigger );
  1568. #endif
  1569. dwCurrLocation=PE_CD_GetCurrentLocation();
  1570. (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= dwCurrLocation;
  1571. // Abort the current Playback, without changing Decoder mode
  1572. PE_CD_AbortPlayback(TRUE);//LX090502
  1573. // Check if dwCurrentLocation valid
  1574. bLocationFromDriveValid = ( ( g_pSVCDNav->m_aCurrTrack[0] <= dwCurrLocation ) && 
  1575. ( g_pSVCDNav->m_aCurrTrack[1] >= dwCurrLocation ) ) ?
  1576. TRUE : FALSE;
  1577. // If this is the first I-Frame of the current Scan, use the Beginning/End address
  1578. // of the Current Segment as the reference for scanning, depending on the Scanning direction.
  1579. // if (-1 == dwCurrLocation) {
  1580. if ( !bLocationFromDriveValid ){
  1581. if (SHARED_INFO.bIsElapsedTimeValid) {
  1582. #ifdef SVCD_USE_ABSOLUTE_TIME
  1583. if (!g_pSVCDNav->m_bIsUsingPSD)
  1584. dwCurrLocation = (g_pSVCDNav->m_dwSecondTrackAddress + (SHARED_INFO.iCurrentTime * g_pSVCDNav->m_aCurrTrack[2]));
  1585. else
  1586. dwCurrLocation = (g_pSVCDNav->m_aCurrTrack[0] + (SHARED_INFO.iCurrentTime * g_pSVCDNav->m_aCurrTrack[2]));
  1587. #else
  1588. dwCurrLocation = (g_pSVCDNav->m_aCurrTrack[0] + (SHARED_INFO.iCurrentTime * g_pSVCDNav->m_aCurrTrack[2]));
  1589. #endif //SVCD_USE_ABSOLUTE_TIME
  1590. }
  1591. }
  1592. // Calculate the Next target location; avoid slipping over the edge
  1593. if (SHARED_INFO.m_iScanSpeed != 0)
  1594. {
  1595. dwNextLocation= (dwCurrLocation + (SHARED_INFO.m_iScanSpeed * g_pSVCDNav->m_aCurrTrack[2]));
  1596. }
  1597. else if (SHARED_INFO.m_iSlowSpeed != 0)
  1598. {
  1599. DWORD dwSlowBackGap;
  1600. dwSlowBackGap = (abs(SLOW_SCAN_SPEED) * g_pSVCDNav->m_aCurrTrack[2])>>2;
  1601. (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS = 0;
  1602. dwNextLocation= g_pSVCDNav->dwSlowRCurrentPosition - dwSlowBackGap;
  1603. g_pSVCDNav->dwSlowRCurrentPosition = dwNextLocation;
  1604. }
  1605. if ((INT32)dwNextLocation < 0)
  1606. dwNextLocation= 0;
  1607. // Check the Scanning-direction, and act accordingly
  1608. if (SHARED_INFO.m_iScanSpeed > 0) {
  1609. // Forward-scan: Check for a Rendezvous-condition during A-B Repeat
  1610. if ((PM_GetRepeatAB() & PM_REPEAT_AB_B) && 
  1611. ((g_pSVCDNav->m_PositionB).dwStartAddress < dwNextLocation)) 
  1612. {
  1613. // Make sure that there is a perfect match between the PositionB Marker and
  1614. // the current location.
  1615. if ( ((g_pSVCDNav->m_PositionB).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
  1616.  ((g_pSVCDNav->m_PositionB).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
  1617.  ((g_pSVCDNav->m_PositionB).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
  1618. {
  1619.  OnRendezvousPoint(ePositionB);
  1620.  return;
  1621. }
  1622. }
  1623. // Continue Scanning
  1624. if (dwNextLocation < g_pSVCDNav->m_aCurrSegment[1]) {
  1625. // The next sub-segment to skip to is within the boundaries of the current segment
  1626. dwCurrLocation= dwNextLocation;
  1627. }
  1628. else {
  1629. bInsideSegmentBoundaries= FALSE;
  1630. dwCurrLocation= -1;
  1631. // The next sub-segment to skip to is beyond the current segment -- jumpt to the next
  1632. // item, via reporting a Playback-Finish event.
  1633. #ifdef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  1634. // Cancel the on-going Scanning
  1635. OnScan(0);
  1636. gcs.pstate= PST_PLAY;
  1637. #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  1638. OnPlaybackFinished();
  1639. #ifndef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  1640. OnScan(SHARED_INFO.m_iScanSpeed);
  1641. #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  1642. }
  1643. }
  1644. else if ( ( SHARED_INFO.m_iScanSpeed < 0 ) || ( SHARED_INFO.m_iSlowSpeed < 0 )){
  1645. // Backwards-scan: Check for a Rendezvous-condition during A-B Repeat
  1646. if ((PM_GetRepeatAB() & PM_REPEAT_AB_B) && 
  1647. (dwNextLocation <= (g_pSVCDNav->m_PositionA).dwStartAddress)) 
  1648. {
  1649. // Make sure that there is a perfect match between the PositionA Marker and
  1650. // the current location.
  1651. if ( ((g_pSVCDNav->m_PositionA).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
  1652.  ((g_pSVCDNav->m_PositionA).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
  1653.  ((g_pSVCDNav->m_PositionA).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
  1654. {
  1655.  OnRendezvousPoint(ePositionA);
  1656.  return;
  1657. }
  1658. }
  1659. // Continue Scanning
  1660. if (dwNextLocation > g_pSVCDNav->m_aCurrSegment[0]) {
  1661. // The previous sub-segment to skip to is within the boundaries of the current segment
  1662. dwCurrLocation= dwNextLocation;
  1663. }
  1664. else {
  1665. bInsideSegmentBoundaries= FALSE;
  1666. dwCurrLocation= -1;
  1667. #ifdef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  1668. // The previous sub-segment to skip to precedes the current segment -- restart playback
  1669. // of the Current item
  1670. OnScan(0);
  1671. gcs.pstate= PST_PLAY;
  1672. // If PBC is in use, force re-parsing of the Current List in order to accurately
  1673. // play it from its beginning.
  1674. if (g_pSVCDNav->m_bIsUsingPSD)
  1675. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  1676. if (! InvokePlayback()) {
  1677. dbg_printf(("Failed to re-invoke Playback.n"));
  1678. gcs.pstate= PST_STOP;
  1679. }
  1680. #else //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  1681. // The previous sub-segment to skip to precedes the current segment -- jump to the previous item
  1682. if ( ((! g_pSVCDNav->m_bIsUsingPSD) && (1 == (SHARED_INFO.m_CurrPosition).uListItem)) ||
  1683.  ((g_pSVCDNav->m_bIsUsingPSD && (PlayList == (SHARED_INFO.m_CurrPosition).ListType) &&
  1684.  (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset))) ||
  1685.  PM_IsRepeatSingle() ) 
  1686. {
  1687. // The beginning of the Program has been reached, or there is no Previous
  1688. // item defined, or Single-Repeat is on: resume Normal Speed playback of the 
  1689. // First/Current item.
  1690. OnScan(0);
  1691. gcs.pstate= PST_PLAY;
  1692. if (! InvokePlayback()) {
  1693. dbg_printf(("Failed to re-invoke Playback.n"));
  1694. gcs.pstate= PST_STOP;
  1695. }
  1696. ie_send(IE_UI_STATE_CHANGE);
  1697. }
  1698. else 
  1699. {
  1700. // Move to the Previous item, while preserving the Scan mode
  1701. if (! g_pSVCDNav->m_bIsUsingPSD) {
  1702. UINT16 uPrevTrackNum;
  1703. TrackInfo prevTrack;
  1704. DWORD dwPlaybackStartAddress;
  1705. int iScanSlowSpeed;
  1706. if ( PST_SLOW == gcs.pstate  )
  1707. iScanSlowSpeed = gns.svcd.m_iSlowSpeed;
  1708. else
  1709. iScanSlowSpeed = gns.svcd.m_iScanSpeed;
  1710. // Move to the previous Item unconditionally, and re-invoke the Playback
  1711. // while preserving the Scan mode.
  1712. (SHARED_INFO.m_CurrPosition).uListItem--;
  1713. uPrevTrackNum= PM_GetProgramListEntry((SHARED_INFO.m_CurrPosition).uListItem);
  1714. if (! PE_CD_GetTrackInfo(uPrevTrackNum, &prevTrack)) {
  1715. dbg_printf(("Failed to retrieve information for a Track.n"));
  1716. return;
  1717. }
  1718. // Update the boundries of the Previous Track and Segment
  1719. g_pSVCDNav->m_aCurrTrack[0] = prevTrack.dwStartAddress;
  1720. g_pSVCDNav->m_aCurrTrack[1] = (g_pSVCDNav->m_aCurrTrack[0] + prevTrack.ulBlocksCnt);
  1721. g_pSVCDNav->m_aCurrTrack[2] = _getBlocksPerSecond(uPrevTrackNum, prevTrack.ulBlocksCnt);
  1722. g_pSVCDNav->m_aCurrSegment[0]= g_pSVCDNav->m_aCurrTrack[0];
  1723. g_pSVCDNav->m_aCurrSegment[1]= g_pSVCDNav->m_aCurrTrack[1];
  1724. tr_printf(("track range is between %lx an d%lxn", g_pSVCDNav->m_aCurrTrack[0], g_pSVCDNav->m_aCurrTrack[1]));
  1725. // if ( PST_SLOW == gcs.pstate ){
  1726. // dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[1] + (DWORD)(iScanSlowSpeed * (int)g_pSVCDNav->m_aCurrTrack[2]*64);
  1727. // tr_printf(("slow dwstart addres is %lxn", dwPlaybackStartAddress ));
  1728. // }
  1729. // else{
  1730. dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[1] + (DWORD)(iScanSlowSpeed * (int)g_pSVCDNav->m_aCurrTrack[2]*4);
  1731. tr_printf(("scan dwstart addres is %lxn", dwPlaybackStartAddress ));
  1732. // }
  1733. if ( dwPlaybackStartAddress <= g_pSVCDNav->m_aCurrTrack[0] ){
  1734. dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[0];
  1735. tr_printf(("Set to track start addressn"));
  1736. }
  1737.                                    g_pSVCDNav->dwSlowRCurrentPosition = dwPlaybackStartAddress;
  1738. // if (!( ( 0 > gns.svcd.m_iScanSpeed ) && ( PST_SLOW == gcs.pstate ) && ( dwPlaybackStartAddress >= g_pSVCDNav->m_aCurrTrack[0] ) ))
  1739. // dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[1] + SHARED_INFO.m_iScanSpeed * g_pSVCDNav->m_aCurrTrack[2];
  1740. // Invoke the playback, while preserving the Scan mode
  1741. PE_CD_RequestNotification(IFrame);
  1742. if (! PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID,
  1743. dwPlaybackStartAddress,
  1744. (iScanSlowSpeed * g_pSVCDNav->m_aCurrTrack[2] * -1),
  1745. eScan, SHARED_INFO.m_iScanSpeed))
  1746. {
  1747. dbg_printf(("Failed to play.n"));
  1748. return;
  1749. }
  1750. PE_CD_SetCurrentLocationLBN_Bakcup(dwPlaybackStartAddress);
  1751. // Update the Global Information
  1752. SHARED_INFO.uCurrentTrackNumber= uPrevTrackNum;
  1753. // Switch to Time-Measurement based on the MSF
  1754. (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE;
  1755. // Engage the Error-Recovery mehcanism for I-Frame Display Miss
  1756. (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_IFRAME_MISS_TIMEOUT;
  1757. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eIFrameDisplayMiss;
  1758. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302: Not actual needed here
  1759. }
  1760. else {
  1761. // For PBC mode, abort Scanning and move to the Previous item
  1762. OnScan(0);
  1763. gcs.pstate= PST_PLAY;
  1764. OnPreviousItem();
  1765. }
  1766. }
  1767. #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
  1768. }
  1769. }
  1770. if (bInsideSegmentBoundaries) {
  1771. if (SHARED_INFO.m_iScanSpeed != 0)
  1772. gcs.pstate= PST_SCAN;
  1773. else 
  1774. if (SHARED_INFO.m_iSlowSpeed != 0)
  1775. gcs.pstate= PST_SLOW;
  1776. // Arrange for an additional I-Frame notification
  1777. PE_CD_RequestNotification(IFrame);
  1778. // Engage the Error-Recovery mehcanism for I-Frame Display Miss
  1779. (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_IFRAME_MISS_TIMEOUT;
  1780. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eIFrameDisplayMiss;
  1781. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302:Not actual needed here
  1782. // Invoke playback of the next sub-segment within the current segment
  1783. if (SHARED_INFO.m_iScanSpeed != 0)
  1784. PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID, 
  1785. dwCurrLocation, (g_pSVCDNav->m_aCurrSegment[1] - dwCurrLocation),
  1786. eScan, (ULONG)SHARED_INFO.m_iScanSpeed);
  1787. else 
  1788. if (SHARED_INFO.m_iSlowSpeed != 0)
  1789. PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID, 
  1790. dwCurrLocation, (g_pSVCDNav->m_aCurrSegment[1] - dwCurrLocation),
  1791. eScan, 0/*(ULONG)SLOW_SCAN_SPEED*/);
  1792. PE_CD_SetCurrentLocationLBN_Bakcup(dwCurrLocation);
  1793. }
  1794. return;
  1795. }
  1796. /////////////////////////////////////////////////////////////////////////////////////////////////
  1797. // void OnNextItem() -
  1798. // Handles an IE_CORE_NEXT_CHAPTER Event.
  1799. //
  1800. // Input: None
  1801. //
  1802. // Output:
  1803. // The next appropriate Item is invoked.
  1804. /////////////////////////////////////////////////////////////////////////////////////////////////
  1805. static void OnNextItem(void)
  1806. {
  1807. dbg_printf(("OnNextItem()n"));
  1808. OnCancelABRepeat();
  1809. // Cancel Intro Playmode
  1810. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  1811. // Check the current Playback-Status. If in Stop-mode, then resume playback.
  1812. if (PST_STOP == gcs.pstate) {
  1813. // Resume playback from the Item's beginning
  1814. (g_pSVCDNav->m_ResumePlayback).dwStartAddress= -1;
  1815. OnPlay();
  1816. return;
  1817. }
  1818. // Actually move to the next Item
  1819. if (! g_pSVCDNav->m_bIsUsingPSD) {
  1820. // Take care of A-B Repeat
  1821. if (PM_GetRepeatAB() & PM_REPEAT_AB_B) {
  1822. // If the Current Playlist Item contains Position-B, then cancel A-B Repeat (A-B Loop
  1823. // scope has been exceeded).
  1824. if ((SHARED_INFO.m_CurrPosition).uListItem == (g_pSVCDNav->m_PositionB).uListItem)
  1825. CancelRepeatModes(PM_REPEAT_AB_MASK);
  1826. }
  1827. if ((SHARED_INFO.m_CurrPosition).uListItem == (PM_GetProgramSize() - 1)) {
  1828. #ifdef SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
  1829. // Set the Current Item to Zero, so that the first Item on the Play-List
  1830. // will be used (i.e. a wrap-around is performed).
  1831. (SHARED_INFO.m_CurrPosition).uListItem= 0;
  1832. #else
  1833. // Wrap-around if Repeat-All is on
  1834. if (PM_IsRepeatAll()) {
  1835. (SHARED_INFO.m_CurrPosition).uListItem= 0;
  1836. }
  1837. else
  1838. if(PM_IsRepeatSingle())
  1839. {
  1840. ;         //add this though we prohibit skipf at the last track upper already.
  1841. }
  1842. else {
  1843. dbg_printf(("Already playing the last item on the Playlist. Ignored.n"));
  1844. return;
  1845. }
  1846. #endif //SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
  1847. }
  1848. if(!PM_IsRepeatSingle())                       // if repeat track, return to current track start
  1849. (SHARED_INFO.m_CurrPosition).uListItem++;
  1850. }
  1851. else {
  1852. // Cancel existing A-B Repeat, if any, unconditionally
  1853. CancelRepeatModes(PM_REPEAT_AB_MASK);
  1854. switch ((SHARED_INFO.m_CurrPosition).ListType) 
  1855. {
  1856. case PlayList:
  1857. if(!PM_IsRepeatSingle())
  1858. if (((SHARED_INFO.m_CurrList).PlayList).uItemsCnt <= (SHARED_INFO.m_CurrPosition).uListItem++) {
  1859. dbg_printf(("PlayList playback is done. Switching to the next list.n"));
  1860. if (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uNextOffset) {
  1861. dbg_printf(("Invalid Next List Offset for a Play-List. Ignored.n"));
  1862. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );//jeanz_0318_2005 Add OSD prohibit logo.
  1863. return;
  1864. }
  1865. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  1866. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  1867. (UINT32)((SHARED_INFO.m_CurrList).PlayList).uNextOffset;
  1868. (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
  1869. }
  1870. break;
  1871. case SelectionList:
  1872. //if(!PM_IsRepeatSingle())//mikex_0821_2003_b: add a judgement for the single repeat
  1873. {
  1874. if (0xFFFF == ((SHARED_INFO.m_CurrList).SelectionList).uNextOffset) {
  1875. dbg_printf(("No Next-List defined. Ignored.n"));
  1876. return;
  1877. }
  1878. if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
  1879. g_pSVCDNav->m_bPendingEvent= TRUE;
  1880. g_pSVCDNav->m_PendingEvent= IE_CORE_NEXT_CHAPTER;
  1881. return;
  1882. }
  1883. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  1884. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  1885. (UINT32)((SHARED_INFO.m_CurrList).SelectionList).uNextOffset;
  1886. (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
  1887. }
  1888. break;
  1889. }
  1890. }
  1891. //canceling the scanning mode when moving to another track
  1892. if (PST_SCAN == gcs.pstate)
  1893. OnScan(0);
  1894. if (PST_SLOW == gcs.pstate)
  1895. {
  1896. //DAC_SetMute(TRUE);
  1897. #ifdef DIGITAL_AMPLIFIER_ENABLE
  1898. amplifier_mute(TRUE);
  1899. #endif //DIGITAL_AMPLIFIER_ENABLE
  1900. OnSlow(0);
  1901. if (PS_GET_ANALOG_AUDIO_SETTING()!=NO_ANALOG_AUDIO)
  1902. {
  1903. //DAC_SetMute(FALSE);
  1904. #ifdef DIGITAL_AMPLIFIER_ENABLE
  1905. amplifier_mute(FALSE);
  1906. #endif //DIGITAL_AMPLIFIER_ENABLE
  1907. }
  1908. }
  1909. // Invoke playback of the next Item
  1910. if (! InvokePlayback()) {
  1911. dbg_printf(("Failed to invoke playback.n"));
  1912. gcs.pstate= PST_STOP;
  1913. }
  1914. return;
  1915. }
  1916. /////////////////////////////////////////////////////////////////////////////////////////////////
  1917. // void OnPreviousItem() -
  1918. // Handles an IE_CORE_PREVIOUS_CHAPTER Event.
  1919. //
  1920. // Input:
  1921. // None
  1922. //
  1923. // Output:
  1924. // The previous appropriate Item is invoked.
  1925. static void OnPreviousItem(void)
  1926. {
  1927. int iTimeFromTrackStart = 0;
  1928. OnCancelABRepeat();
  1929. // Cancel Intro Playmode
  1930. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  1931. dbg_printf(("OnPreviousItem()n"));
  1932. // Check the current Playback-Status. If in Stop-mode, then resume playback.
  1933. if (PST_STOP == gcs.pstate) {
  1934. // Resume playback from the Item's beginning
  1935. (g_pSVCDNav->m_ResumePlayback).dwStartAddress= -1;
  1936. OnPlay();
  1937. return;
  1938. }
  1939. //canceling the scanning mode when moving to another track
  1940. if (PST_SCAN == gcs.pstate)
  1941. OnScan(0);
  1942. if (PST_SLOW == gcs.pstate)
  1943. {
  1944. DAC_SetMute(TRUE);
  1945. #ifdef DIGITAL_AMPLIFIER_ENABLE
  1946. amplifier_mute(TRUE);
  1947. #endif //DIGITAL_AMPLIFIER_ENABLE
  1948. OnSlow(0);
  1949. //if (PS_GET_ANALOG_AUDIO_SETTING(gcst.mAudioStream)!=NO_ANALOG_AUDIO)
  1950. if (PS_GET_ANALOG_AUDIO_SETTING()!=NO_ANALOG_AUDIO)
  1951. {
  1952. DAC_SetMute(FALSE);
  1953. #ifdef DIGITAL_AMPLIFIER_ENABLE
  1954. amplifier_mute(FALSE);
  1955. #endif //DIGITAL_AMPLIFIER_ENABLE
  1956. }
  1957. }
  1958. // Actually move to the previous Item
  1959. if (! g_pSVCDNav->m_bIsUsingPSD) {
  1960. // Check the time elapsed from the beginning of the Current Item.
  1961. // If it is less than or equals SKIP_BACK_THRESHOLD seconds, skip
  1962. // to the previous Item. Otherwise, maintain Current position.
  1963. #ifdef SVCD_USE_ABSOLUTE_TIME
  1964. if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track)
  1965. iTimeFromTrackStart = SHARED_INFO.iCurrentTime - ((g_pSVCDNav->m_aCurrTrack[0] - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]); 
  1966. else
  1967. //in case this is a CDDA track, the current time is the absolute time on the disc
  1968. iTimeFromTrackStart = SHARED_INFO.iCurrentTime - (g_pSVCDNav->m_aCurrTrack[0] / g_pSVCDNav->m_aCurrTrack[2]); 
  1969. #else
  1970. iTimeFromTrackStart = SHARED_INFO.iCurrentTime;
  1971. #endif //SVCD_USE_ABSOLUTE_TIME
  1972. #ifdef D_USE_VARIABLE_FOR_LIB
  1973. if (iTimeFromTrackStart <= svcd_skip_back_threshold)
  1974. #else
  1975. if (iTimeFromTrackStart <= SVCD_SKIP_BACK_THRESHOLD)
  1976. #endif
  1977. {
  1978. if (1 == (SHARED_INFO.m_CurrPosition).uListItem) {
  1979. // Cancel A-B Repeat (if any)
  1980. CancelRepeatModes(PM_REPEAT_AB_MASK);
  1981. #ifdef SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
  1982. // Set the Current Item to one past the Last item on the Play-List (i.e.
  1983. // wrap-around is performed).
  1984. (SHARED_INFO.m_CurrPosition).uListItem= PM_GetProgramSize() - 1;
  1985. #endif //SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
  1986. }
  1987. else
  1988.         if(!PM_IsRepeatSingle())                       // if repeat track, return to current track start
  1989. (SHARED_INFO.m_CurrPosition).uListItem--;
  1990. }
  1991. // Take care of A-B Repeat
  1992. if (PM_GetRepeatAB() & PM_REPEAT_AB_B) {
  1993. // If the Previous Playlist Item contains Position-B, then cancel A-B Repeat (A-B Loop
  1994. // scope has been exceeded).
  1995. if ((SHARED_INFO.m_CurrPosition).uListItem == (g_pSVCDNav->m_PositionA).uListItem)
  1996. CancelRepeatModes(PM_REPEAT_AB_MASK);
  1997. }
  1998. }
  1999. else {
  2000. // Cancel existing A-B Repeat, if any, unconditionally
  2001. CancelRepeatModes(PM_REPEAT_AB_MASK);
  2002. switch ((SHARED_INFO.m_CurrPosition).ListType) 
  2003. {
  2004. case PlayList:
  2005. #ifdef SVCD_FORCE_PERVIOUS_ITEM
  2006. if ((0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset) &&
  2007. (1 != (SHARED_INFO.m_CurrPosition).uListItem))
  2008. {
  2009. (SHARED_INFO.m_CurrPosition).uListItem--;
  2010. break;
  2011. }
  2012. #endif //SVCD_FORCE_PERVIOUS_ITEM
  2013. #ifndef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
  2014. if (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset) 
  2015. {
  2016. dbg_printf(("No Previous-List defined. Ignored.n"));
  2017. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP ); //jeanz_0318_2005 Add OSD prohibit logo.
  2018. return;
  2019. }
  2020. #endif
  2021. if(!PM_IsRepeatSingle())
  2022. if (0 == --(SHARED_INFO.m_CurrPosition).uListItem) {
  2023. (SHARED_INFO.m_CurrPosition).uListItem= 1;
  2024. #ifndef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
  2025. if (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset)
  2026. {
  2027. dbg_printf(("No Previous-List defined, at First PlayList Item. Ignored.n"));
  2028. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP ); //jeanz_0318_2005 Add OSD prohibit logo.
  2029. return;
  2030. }
  2031. #endif
  2032. dbg_printf(("Switching to the previous list.n"));
  2033. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  2034. #ifdef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
  2035. if (0xFFFF != ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset)
  2036. #endif
  2037. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  2038. (UINT32)((SHARED_INFO.m_CurrList).PlayList).uPrevOffset;
  2039. }
  2040. break;
  2041. case SelectionList:
  2042. if (0xFFFF == ((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset) {
  2043. dbg_printf(("No Previous-List defined. Ignored.n"));
  2044. return;
  2045. }
  2046. if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
  2047. g_pSVCDNav->m_bPendingEvent= TRUE;
  2048. g_pSVCDNav->m_PendingEvent= IE_CORE_PREVIOUS_CHAPTER;
  2049. return;
  2050. }
  2051. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  2052. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  2053. (UINT32)((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset;
  2054. (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
  2055. break;
  2056. }
  2057. }
  2058. // Invoke playback of the previous Item
  2059. if (! InvokePlayback()) {
  2060. dbg_printf(("Failed to invoke playback.n"));
  2061. gcs.pstate= PST_STOP;
  2062. }
  2063. return;
  2064. }
  2065. /////////////////////////////////////////////////////////////////////////////////////////////////
  2066. // void OnNumericSelection(WORD uSelection) -
  2067. // Handles an IE_CORE_MENU_NUMERICAL_SELECTION or an IE_CORE_GOTO_ENTRY Event.
  2068. //
  2069. // Input:
  2070. // uSelection - The serial number of the Selection.
  2071. //
  2072. // Output:
  2073. // None. If the selected number is inside the valid appropriate range, the corresponsing
  2074. // Play-Item is invoked.
  2075. //
  2076. // Remarks:
  2077. // When PBC is Off, Numeric-Selection is interpreted as jumping to a specific Track.
  2078. // For PBC On, Numeric-Selection is associated with the current Menu that is being displayed
  2079. // (the current Selection-List).
  2080. static void OnNumericSelection(WORD uSelection)
  2081. {
  2082. BYTE aBuffer[2];
  2083. DWORD dwPSD_Offset;
  2084. BOOL bNeedDisableScanOp = FALSE;//LX090502
  2085. dbg_printf(("OnNumericSelection(%d)n", uSelection));
  2086. #ifdef SVCD_DIGEST_SUPPORT
  2087. dbg_printf(("Current Digest Mode is %02xn", Digest_getDigestMode()));
  2088. //handling digest mode selection
  2089. if (g_pSVCDNav->m_bDigestMode) {
  2090. //first check if the selection is within the current displayed digest frames range
  2091. if ((uSelection -1) > (WORD)Digest_getCurrentDisplayed()) {
  2092. dbg_printf(("Digest: Given selection is outside digest range. Operation ignored.n"));
  2093. return;
  2094. }
  2095. // Setting the start address and the play item number
  2096. if (eTrackView == Digest_getDigestMode()) {
  2097. Digest_Unit m_DigestUnit;
  2098. Array_getAt(g_pSVCDNav->m_uiDigestUnits, (UINT16)(uSelection - 1), (BYTE *)&m_DigestUnit);
  2099. (SHARED_INFO.m_CurrPosition).dwStartAddress = m_DigestUnit.dwAddress;
  2100. }
  2101. #ifdef DISC_TRACK_DIGEST_VIEW_ENABLE
  2102. else if ( eTrackDiscView == Digest_getDigestMode() ){
  2103. Digest_Unit m_DigestUnit;
  2104. UINT16 uiCurrentItem = Digest_getCurrentDisplayed();
  2105. WORD wCurrentTrackNum = (WORD)(uiCurrentItem/DIGEST_MAX_FRAMES_ON_SCREEN);
  2106. Array_getAt(g_pSVCDNav->m_uiDigestUnits, (UINT16)(uSelection - 1), (BYTE *)&m_DigestUnit);
  2107. (SHARED_INFO.m_CurrPosition).uListItem= wCurrentTrackNum + 1;
  2108. (SHARED_INFO.m_CurrPosition).dwStartAddress= m_DigestUnit.dwAddress;
  2109. dbg_printf(("Starting from Track %02x, address %08xn", (SHARED_INFO.m_CurrPosition).uListItem, 
  2110. (SHARED_INFO.m_CurrPosition).dwStartAddress));
  2111. }
  2112. #endif
  2113. else {
  2114. (SHARED_INFO.m_CurrPosition).uListItem= uSelection; // By default, begin with the first item in the List
  2115. (SHARED_INFO.m_CurrPosition).dwStartAddress= -1; // The address is yet undefined
  2116. }
  2117. //terminating the on going digest mode
  2118. _terminateDigestMode();
  2119. if (! InvokePlayback()) {
  2120. dbg_printf(("Failed to play-back the current Track.n"));
  2121. gcs.pstate= PST_STOP;
  2122. }
  2123. return;
  2124. }
  2125. #endif //SVCD_DIGEST_SUPPORT
  2126. // Cancel Intro Playmode
  2127. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  2128. PE_CD_CancelNotification(IFrame);
  2129. // If currently in STOP state, then turn PBC Off
  2130. if (gcs.pstate == PST_STOP) {
  2131. PM_SetPBC(FALSE);
  2132. g_pSVCDNav->m_bIsUsingPSD= FALSE;
  2133. // Update the current Playback-Mode
  2134. g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
  2135. //canceling trigger bit notification
  2136. PE_CD_CancelNotification(TriggerBit);
  2137. }
  2138. if (! g_pSVCDNav->m_bIsUsingPSD) {
  2139. //BOOL bRepeatModeChanged= FALSE;
  2140. if (! PM_IsPlaybackNormal(PM_GetPlaybackMode())) {
  2141. dbg_printf(("Numeric-Selection is not allowed for Program or Shuffle. Ignored.n"));
  2142. return;
  2143. }
  2144. // Verify that the selected number is legal
  2145. if ((0 == uSelection) || (uSelection > (PM_GetProgramSize() - 1))) {
  2146. dbg_printf(("Illegal Selection Number. Ignored.n"));
  2147. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2148. return;
  2149. }
  2150. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  2151. // If Scanning or Slow-Motion is in progress, eliminate it
  2152. if (PST_SCAN == gcs.pstate)
  2153. OnScan(0);
  2154. else if (PST_SLOW == gcs.pstate)
  2155. OnSlow(0);
  2156. // Cancel any current Repeat-Modes
  2157. CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
  2158. (SHARED_INFO.m_CurrPosition).uListItem= uSelection;
  2159. if (! InvokePlayback()) {
  2160. dbg_printf(("Failed to invoke playback a SelectionList Item.n"));
  2161. gcs.pstate= PST_STOP;
  2162. }
  2163. return;
  2164. }
  2165. // Verify that there is some menu displaying or an Item playing
  2166. if ((PST_STILL != gcs.pstate) && (PST_PLAY != gcs.pstate)) {
  2167. dbg_printf(("Numeric-Selection disabled at this point. Ignored.n"));
  2168. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2169. return;
  2170. }
  2171. // The PSD information is being used:
  2172. if (PlayList == (SHARED_INFO.m_CurrPosition).ListType) {
  2173. dbg_printf(("Numeric-Selection is meaningless within a PlayList Item. Ignored.n"));
  2174. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2175. return;
  2176. }
  2177. // This is a SelectionList: find-out if the selection is within the legal range for this List
  2178. if ((uSelection < ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase) ||
  2179. (uSelection >= ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase + ((SHARED_INFO.m_CurrList).SelectionList).uSelectionsCnt)) {
  2180. dbg_printf(("Illegal Selection Number. Ignored.n"));
  2181. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2182. return;
  2183. }
  2184. // Check if a Numeric-Selection is allowed at this time, or should be postponed.
  2185. if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
  2186. g_pSVCDNav->m_bPendingEvent= TRUE;
  2187. g_pSVCDNav->m_PendingEvent= IE_CORE_NUM_SELECTION;
  2188. g_pSVCDNav->m_uPendingEventParam= uSelection;
  2189. return;
  2190. }
  2191. // Check if a Numeric-Selection is allowed, in case of Multi-Default Selections
  2192. if (0xFFFD == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset) {
  2193. dbg_printf(("Numeric-Selection disabled for Multi-Default in this SelectionList. Ignored.n"));
  2194. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2195. return;
  2196. }
  2197. // Abort any current playback before switching to another item
  2198. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  2199. // If Scanning or Slow-Motion is in progress, eliminate it
  2200. if (PST_SCAN == gcs.pstate)
  2201. OnScan(0);
  2202. else if (PST_SLOW == gcs.pstate)
  2203. OnSlow(0);
  2204. // Extract the appropriate PSD-Offset for the selected item
  2205. dwPSD_Offset= ((SHARED_INFO.m_CurrPosition).dwPSD_Offset + SVCD_SELECTIONLIST_HDR_SIZE 
  2206. + (2 * (uSelection - ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase)));
  2207. if (! _getPSDRecord(dwPSD_Offset, 2, aBuffer)) {
  2208. dbg_printf(("Failed to enumerate a SelectionList Selection Item.n"));
  2209. return;
  2210. }
  2211. //<<<LX090502
  2212. if ( gns.svcd.uCurrentTrackNumber == 1 ){
  2213. bNeedDisableScanOp = TRUE;
  2214. }
  2215. //LX090502>>>
  2216. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  2217. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= ((g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  2218. (UINT32)((aBuffer[0] << 8) | aBuffer[1]));
  2219. (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
  2220. if (! InvokePlayback()) {
  2221. dbg_printf(("Failed to invoke playback a SelectionList Item.n"));
  2222. gcs.pstate= PST_STOP;
  2223. }
  2224. //<<<LX090502
  2225. if ( bNeedDisableScanOp ){
  2226. CLEAR_COP_MASK(COP_SCAN);
  2227. PE_CD_RequestNotification(IFrame);
  2228. }
  2229. //LX090502>>>
  2230. return;
  2231. }
  2232. /////////////////////////////////////////////////////////////////////////////////////////////////
  2233. // void OnReturn() -
  2234. // Handles an IE_CORE_CDNAV_RETURN Event.
  2235. //
  2236. // Input:
  2237. // None
  2238. //
  2239. // Output:
  2240. // None. If a Return-Offset is defined for the current List, then the List pointed by
  2241. // that offset is invoked.
  2242. //
  2243. // Remarks:
  2244. // This event is only relevant for PBC On.
  2245. static void OnReturn(void)
  2246. {
  2247. WORD dwPSD_Offset= 0;
  2248. dbg_printf(("OnReturn()n"));
  2249. if (! g_pSVCDNav->m_bIsUsingPSD) {
  2250. dbg_printf(("Return is meaningless when PSD information is not being used!n"));
  2251. return;
  2252. }
  2253. // First of all, extract the value of the ReturnOffset in the Current-List
  2254. switch ((SHARED_INFO.m_CurrPosition).ListType) 
  2255. {
  2256. case PlayList:
  2257. dwPSD_Offset= ((SHARED_INFO.m_CurrList).PlayList).uReturnOffset;
  2258. break;
  2259. case SelectionList:
  2260. dwPSD_Offset= ((SHARED_INFO.m_CurrList).SelectionList).uReturnOffset;
  2261. break;
  2262. }
  2263. // Check if the Offset is valid. If not, ignore.
  2264. if (0xFFFF == dwPSD_Offset) {
  2265. dbg_printf(("No Return-List defined. Ignored.n"));
  2266. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2267. return;
  2268. }
  2269. // For a SelectionList, check if this is a good time for execution
  2270. if ((PST_PLAY == gcs.pstate) && (SelectionList == (SHARED_INFO.m_CurrPosition).ListType) &&
  2271. ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
  2272. g_pSVCDNav->m_bPendingEvent= TRUE;
  2273. g_pSVCDNav->m_PendingEvent= IE_CORE_RETURN;
  2274. return;
  2275. }
  2276. (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
  2277. (SHARED_INFO.m_CurrPosition).dwPSD_Offset= ((g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier * 
  2278. (UINT32)dwPSD_Offset);
  2279. (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
  2280. // If Scanning or Slow-Motion is in progress, eliminate it
  2281. if (PST_SCAN == gcs.pstate)
  2282. OnScan(0);
  2283. else if (PST_SLOW == gcs.pstate)
  2284. OnSlow(0);
  2285. // Cancel any current Repeat-Modes
  2286. CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
  2287. gcs.pstate= PST_PLAY;
  2288. if (! InvokePlayback()) {
  2289. dbg_printf(("Failed to invoke playback.n"));
  2290. gcs.pstate= PST_STOP;
  2291. }
  2292. return;
  2293. }
  2294. /////////////////////////////////////////////////////////////////////////////////////////////////
  2295. // OnAudioSelection(WORD uSelection) -
  2296. // Handles an IE_CORE_AUDIO_STREAM_SELECTION Event.
  2297. //
  2298. // Input:
  2299. // uSelection - The serial number of the Audio track to play.
  2300. //
  2301. // Output:
  2302. // None. If possible, the requested Audio-SID is played.
  2303. //
  2304. // Remarks:
  2305. // The handler will refuse switching the Audio-SID if the current Play-Item is a CDDA Track.
  2306. static void OnAudioSelection(WORD uSelection)
  2307. {
  2308. dbg_printf(("OnAudioSelection(%x)n", uSelection));
  2309. if (gns.svcd.uCurrentTrackNumber >= g_pSVCDNav->m_uFirstCDDA_Track) {
  2310. dbg_printf(("Currently playing a CDDA Track - cannot switch Audio SID. Ignored.n"));
  2311. return;
  2312. }
  2313. #ifdef ASSUME_SVCD_4_AUDIO_CHANNELS)
  2314. g_pSVCDNav->m_uCurrAudioSID = MPEG_SID0 | ((uSelection-1) & 0x3);
  2315. SHARED_INFO.uCurrentAudioSIDChannel = uSelection;
  2316. #else
  2317. g_pSVCDNav->m_uCurrAudioSID = (1 == uSelection) ? MPEG_SID0 : MPEG_SID1;
  2318. SHARED_INFO.uCurrentAudioSIDChannel = (1 == uSelection) ? 1 : 2;
  2319. #endif
  2320. PE_CD_SelectAudioStream(g_pSVCDNav->m_uCurrAudioSID);
  2321. return;
  2322. }
  2323. /////////////////////////////////////////////////////////////////////////////////////////////////
  2324. // void OnSlow(int iSpeed) -
  2325. // Handles an IE_CORE_SLOW Event.
  2326. //
  2327. // Input:
  2328. // iSpeed - Holds the requested Slow-Motion speed.
  2329. //
  2330. // Output:
  2331. // None. Slow forward is started, if possible.
  2332. //
  2333. // Remarks:
  2334. // Requests a Slow-Motion from the PE.
  2335. static void OnSlow(int iSpeed)
  2336. {
  2337. dbg_printf(("OnSlow(%d)n", iSpeed));
  2338. if (PST_STOP == gcs.pstate) {
  2339. dbg_printf(("Cannot slow forward during a stop. Ignored.n"));
  2340. return;
  2341. }
  2342. // SET_COP_MASK(COP_PLAY);
  2343. // Cancel Intro Playmode
  2344. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  2345. // Eliminate current Scanning
  2346. if ( (PST_SCAN == gcs.pstate) || ( ( PST_SLOW == gcs.pstate) && ( SHARED_INFO.m_iSlowSpeed < 0 ) ) )
  2347. OnScan(0);
  2348. SET_COP_MASK(COP_PLAY);
  2349. // First of all, resume Normal-Playback, if in Stop or Pause (essential for Slow-Motion),
  2350. // or if Scanning is being eliminated.
  2351. if ((PST_STOP == gcs.pstate) || (PST_PAUSE == gcs.pstate) || (0 == iSpeed))
  2352. PE_CD_SetSlowMotion(FALSE, 0);
  2353. // Now actually invoke Slow-Motion, if necessary
  2354. if (0 != iSpeed) {
  2355. if (iSpeed > 0) {
  2356. PE_CD_SetSlowMotion(TRUE, (UINT8)iSpeed);
  2357. PE_CD_CancelNotification(IFrame);
  2358. gcs.pstate= PST_SLOW;
  2359. }
  2360. else {
  2361. iSpeed = ((int)(iSpeed) + 9)*(-1);
  2362. g_pSVCDNav->dwSlowRCurrentPosition = PE_CD_GetCurrentLocation();
  2363. //This routine is like OnScan, we separate it with OnScan is becasue we don't want the gcs.pstate to be confused
  2364. PE_CD_RequestNotification(IFrame);
  2365. //cancel Trigger Bit notification
  2366. PE_CD_CancelNotification(TriggerBit);
  2367. PE_CD_SetScan(TRUE, g_pSVCDNav->m_uCurrAudioSID, 2);
  2368. gcs.pstate = PST_SLOW;
  2369. }
  2370. }
  2371. SHARED_INFO.m_iSlowSpeed= iSpeed;
  2372. return;
  2373. }
  2374. /////////////////////////////////////////////////////////////////////////////////////////////////
  2375. // OnGotoEntry(WORD uSelection) -
  2376. // Handles an IE_CORE_GOTO_ENTRY Event.
  2377. //
  2378. // Input:
  2379. // uSelection - The serial number of the Entry to play.
  2380. //
  2381. // Output:
  2382. // None. The requested Entry starts playback.
  2383. //
  2384. // Remarks:
  2385. // Jumpting to an Entry automatically turns PBC Off.
  2386. static void OnGotoEntry(WORD uSelection)
  2387. {
  2388. dbg_printf(("OnGotoEntry(%d)n", uSelection));
  2389. // Cancel Intro Playmode
  2390. //SHARED_INFO.bIsIntroPlayMode = FALSE;
  2391. if (PM_IsPBC(PM_GetPlaybackMode())) {
  2392. PM_SetPBC(FALSE);
  2393. g_pSVCDNav->m_bIsUsingPSD= FALSE;
  2394. //NOTE: canceling the trigger bit notification is done inside onNumericSelection()
  2395. g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
  2396. ie_send(IE_UI_STATE_CHANGE);
  2397. }
  2398. OnNumericSelection(uSelection);
  2399. return;
  2400. }
  2401. #ifdef D_ENABLE_DISC_TIMESEARCH
  2402. /////////////////////////////////////////////////////////////////////////////////////////////////
  2403. // static void OnGotoDiscTime(ULONG ulTime) -
  2404. // Handles an IE_CORE_GOTO_DISC_TIME Event.
  2405. //
  2406. // Input:
  2407. // ulTime - The absolute time, within the Whole Disc, to jump to.
  2408. //
  2409. // Output:
  2410. // None. The playback is resumed from the requested time, if possible.
  2411. //
  2412. // Remarks:
  2413. // None.
  2414. static void OnGotoDiscTime(ULONG ulTime)
  2415. {
  2416. TrackInfo Track;
  2417. DWORD dwStartAddress;
  2418. WORD uCurrTrackNumber= 2, uLastTrack = PE_CD_GetTracksCnt();
  2419. BOOL done = 0;
  2420. dbg_printf(("OnGotoDiscTime(%ld)n", ulTime));
  2421. if ( g_pSVCDNav->m_uDiscStandard == DEC_DISC_TYPE_SVCD )
  2422. ulTime = ulTime << 1;
  2423. // if (( g_pSVCDNav->m_bIsUsingPSD ) && ( gcs.pstate != PST_STOP) ){
  2424. // dbg_printf(("Disc Time Search invalidn"));
  2425. // core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2426. // return;
  2427. // }
  2428. if (! PE_CD_GetTrackInfo(uCurrTrackNumber, &Track)){
  2429. dbg_printf(("Failed to access the TOC for Track %d.n", (int)uCurrTrackNumber));
  2430. return;
  2431. }
  2432. dwStartAddress = ulTime*SVCD_BLOCKS_PER_SECOND + Track.dwStartAddress;
  2433. if ( !PE_CD_GetTrackInfo(uLastTrack, &Track)){
  2434. dbg_printf(("Failed to access the TOC for Track %d.n", (int)uLastTrack));
  2435. return;
  2436. }
  2437. if ( dwStartAddress > ( Track.dwStartAddress + Track.ulBlocksCnt ) ){
  2438. dbg_printf(("Search time is out of lead out area.n"));
  2439. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2440. return;
  2441. }
  2442. // Cancel Intro Playmode
  2443. SHARED_INFO.bIsIntroPlayMode = FALSE;
  2444. uCurrTrackNumber = 1;
  2445. while( ( uCurrTrackNumber <= uLastTrack ) && ( !done ) ){
  2446. uCurrTrackNumber ++;
  2447. if(!PE_CD_GetTrackInfo(uCurrTrackNumber, &Track)){
  2448. dbg_printf(("Failed to access the TOC for Track %d.n", (int)uCurrTrackNumber));
  2449. return;
  2450. }
  2451. if ( ( dwStartAddress >= Track.dwStartAddress ) && ( dwStartAddress < ( Track.dwStartAddress + Track.ulBlocksCnt ) ) ){
  2452. SHARED_INFO.m_CurrPosition.uListItem = uCurrTrackNumber - 1;
  2453. SHARED_INFO.m_CurrPosition.dwStartAddress = dwStartAddress;
  2454. SHARED_INFO.uCurrentTrackNumber = SHARED_INFO.m_CurrPosition.uListItem;
  2455. SHARED_INFO.m_CurrPosition.dwPSD_Offset = 0;
  2456. done = 1;
  2457. }
  2458. }
  2459. //we must cancel all the playmode and scan, initilaize the playlist
  2460. OnScan(0);
  2461. CancelRepeatModes((PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK));
  2462. PM_InitializeProgramList();
  2463. PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
  2464. PM_SetPBC(FALSE);
  2465. g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
  2466. for(uCurrTrackNumber = 1; uCurrTrackNumber < uLastTrack; uCurrTrackNumber++ ){
  2467. PM_SetProgramListEntry((WORD)uCurrTrackNumber, (WORD)(uCurrTrackNumber + 1));
  2468. }
  2469. // Clear all Markers and Bookmarks
  2470. ClearMarker(eResumePlayback, 0);
  2471. ClearMarker(eMarkerA, 0);
  2472. ClearMarker(eMarkerB, 0);
  2473. if ( gcs.pstate != PST_STOP ){
  2474. PE_CD_AbortPlayback(TRUE); // Maintain standby
  2475. gcs.pstate = PST_STOP;
  2476. }
  2477. g_pSVCDNav->m_bIsUsingPSD = FALSE;
  2478. if (!InvokePlayback()){
  2479. dbg_printf(("Can't invoke playback for Disc Time Search.n"));
  2480. }
  2481. return;
  2482. }
  2483. #endif
  2484. /////////////////////////////////////////////////////////////////////////////////////////////////
  2485. // static void OnGotoTime(ULONG ulTime) -
  2486. // Handles an IE_CORE_GOTO_TIME Event.
  2487. //
  2488. // Input:
  2489. // ulTime - The absolute time, within the Current Track, to jump to.
  2490. //
  2491. // Output:
  2492. // None. The playback is resumed from the requested time, if possible.
  2493. //
  2494. // Remarks:
  2495. // None.
  2496. static void OnGotoTime(ULONG ulTime)
  2497. {
  2498. DWORD dwStartAddress;
  2499. #ifdef SVCD_USE_ABSOLUTE_TIME
  2500. UINT16 uTracksCount,uCurrTrackNumber;
  2501. TrackInfo tiCurrTrack;
  2502. #endif //SVCD_USE_ABSOLUTE_TIME
  2503. dbg_printf(("OnGotoTime(%ld)n", ulTime));
  2504. #ifdef SVCD_USE_ABSOLUTE_TIME
  2505. //calculating the new play address
  2506. dwStartAddress = g_pSVCDNav->m_dwSecondTrackAddress + (ulTime * g_pSVCDNav->m_aCurrTrack[2]);
  2507. //checking the validity of the new address - not greater than the last track end address
  2508. if (ulTime > SHARED_INFO.wTotalPlaybackTime)
  2509. {
  2510. dbg_printf(("Illegal Time requested.n"));
  2511. core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
  2512.       
  2513. return;
  2514. }
  2515. // Cancel Intro Playmode
  2516. SHARED_INFO.bIsIntroPlayMode = FALSE;
  2517. // Rebuild the Normal Program-List (sequential playback of the Tracks)
  2518. PM_InitializeProgramList();
  2519. uTracksCount = (UINT16)PE_CD_GetTracksCnt();
  2520. // Initialize the Program-List to sequencial playback
  2521. for (uCurrTrackNumber = 1; uCurrTrackNumber < uTracksCount; uCurrTrackNumber++)
  2522. PM_SetProgramListEntry((WORD)(uCurrTrackNumber), (WORD)(uCurrTrackNumber + 1));
  2523. //setting the current play item according to the address 
  2524. uCurrTrackNumber = 2;
  2525. while (uCurrTrackNumber <= uTracksCount) 
  2526. {
  2527. //reading the track info from the disc
  2528. PE_CD_GetTrackInfo(uCurrTrackNumber, &tiCurrTrack);
  2529. // checking if the start address is within the current track bounderies
  2530. if ((dwStartAddress >= tiCurrTrack.dwStartAddress) &&
  2531. (dwStartAddress <= (tiCurrTrack.dwStartAddress + tiCurrTrack.ulBlocksCnt)))
  2532. {
  2533. (gns.svcd.m_CurrPosition).uListItem = uCurrTrackNumber - 1;
  2534. break;
  2535. }
  2536. uCurrTrackNumber++;
  2537. }
  2538. //setting the PBC off in case it was on
  2539. if (PM_IsPBC(g_pSVCDNav->m_uCurrPlaybackMode)) 
  2540. {
  2541. if (0 != (g_pSVCDNav->m_NavigationInfo).ulPSD_Size)
  2542. {
  2543. g_pSVCDNav->m_bIsUsingPSD= FALSE;
  2544. PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
  2545. if (PST_STOP != gcs.pstate) 
  2546. PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
  2547. gcs.pstate= PST_PLAY;
  2548. PM_SetPBC(FALSE);
  2549. // Update the current Playback-Mode
  2550. g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
  2551. //cancel trigger bit notification
  2552. PE_CD_CancelNotification(TriggerBit);
  2553. }
  2554. }
  2555. #else //SVCD_USE_ABSOLUTE_TIME
  2556. if (! SHARED_INFO.bIsElapsedTimeValid) 
  2557. {
  2558. dbg_printf(("Cannot jump to Time. Current Time is undefined.n"));
  2559. return;
  2560. }
  2561. //calculating the new play address
  2562. dwStartAddress = (g_pSVCDNav->m_aCurrTrack[0] + (ulTime * g_pSVCDNav->m_aCurrTrack[2]));
  2563. //checking the validity of the new address
  2564. if (dwStartAddress > g_pSVCDNav->m_aCurrTrack[1]) 
  2565. {
  2566. dbg_printf(("Illegal Time requested.n"));
  2567. return;
  2568. }
  2569. //The play item number stays as it was
  2570. #endif //SVCD_USE_ABSOLUTE_TIME
  2571. PE_CD_AbortPlayback(TRUE); // Maintain standby
  2572. gcs.pstate= PST_STOP;
  2573. // Cancel any Repeat mode
  2574. CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
  2575. // Record the Current Position
  2576. SetMarker(eResumePlayback, 0);
  2577. // Now manipulate the Start-Address and the play item number
  2578. g_pSVCDNav->m_ResumePlayback.dwStartAddress = dwStartAddress;
  2579. // Emulate Playback-invocation
  2580. OnPlay();
  2581. return;
  2582. }
  2583. //////////////////////////////////////////////////////////////////////////////////
  2584. // Function name : OnIntro
  2585. //
  2586. // Input Parameters : void
  2587. //
  2588. // Return Value : void 
  2589. //
  2590. // Description : Begin to start intro playback or stop it.
  2591. //////////////////////////////////////////////////////////////////////////////////
  2592. static void OnIntro(void)
  2593. {
  2594. if (TRUE != SHARED_INFO.bIsIntroPlayMode)
  2595. {
  2596. if ( PST_STOP == gcs.pstate ){
  2597. dbg_printf(("Cancel Playmode/Repeat moden"));
  2598. PM_SetPlaybackMode(0);
  2599. PM_ClearRepeat();
  2600. // SHARED_INFO.uCurrPlaylistItem = 1;
  2601. OnGotoEntry(1);
  2602. SHARED_INFO.bIsIntroPlayMode = TRUE;
  2603. // OnPlay();
  2604. }else
  2605. dbg_printf(("Can't Activate Intro Mode in non-stop moden"));
  2606. }else
  2607. dbg_printf((" Already in intro mode, ignoren"));
  2608. return;
  2609. }
  2610. //////////////////////////////////////////////////////////////////////////////////
  2611. // Digest related functions
  2612. #ifdef SVCD_DIGEST_SUPPORT
  2613. //////////////////////////////////////////////////////////////////////////////////
  2614. // Function name : _handleDigestUnit
  2615. //
  2616. // Purpose : Supplying a dedicated function for handling a digest item
  2617. //
  2618. // Input Parameters : 
  2619. // uUnitIndex - index of the item to be played 
  2620. // eQuery - a requested Query
  2621. //
  2622. // Return Value : static void 
  2623. //
  2624. // Description : A callback functon that is supplied to the digest in order 
  2625. // to provide a specific play/stop operations. 
  2626. //////////////////////////////////////////////////////////////////////////////////
  2627. static BOOL _handleDigestUnit(UINT16 uUnitIndex, enDigestQuery eQuery)
  2628. {
  2629. switch (eQuery)
  2630. {
  2631. case eDigestQuery_Start:
  2632.     {
  2633.          Digest_Unit m_DigestUnit;
  2634.          Array_getAt(g_pSVCDNav->m_uiDigestUnits, uUnitIndex, (BYTE *)&m_DigestUnit);
  2635.          PE_CD_StreamPortion( m_DigestUnit.dwAddress, m_DigestUnit.uSize);
  2636. // PE_CD_StreamPortion(g_pSVCDNav->m_uiDigestUnits[uUnitIndex].dwAddress,
  2637. // g_pSVCDNav->m_uiDigestUnits[uUnitIndex].uSize);
  2638. return TRUE;
  2639. }
  2640. case eDigestQuery_Stop:
  2641. PE_CD_AbortPlaybackEx();
  2642. return TRUE;
  2643. case eDigestQuery_IsFinished:
  2644. return drv_is_play_done();
  2645. }
  2646.    return FALSE;
  2647. }
  2648. //////////////////////////////////////////////////////////////////////////////////
  2649. // Function name : OnDigest
  2650. //
  2651. // Purpose : Initiate digest mode.
  2652. //
  2653. // Input Parameters : UINT16 Param - holds the parameters values of the digest mode 
  2654. // and the intro frames count. 
  2655. //
  2656. // Return Value : void 
  2657. //
  2658. // Description : Initialize the digest items array, and start performing the 
  2659. // digest.
  2660. //////////////////////////////////////////////////////////////////////////////////
  2661. static void OnDigest(UINT16 Param)
  2662. {
  2663. UINT16 uDigestItemsCnt = 0, uIndex;
  2664. UINT16 uTrackDigestUnitSize;
  2665. enDigestMode eDigestMode = (enDigestMode)(Param & 0x00FF);
  2666. UINT8  uIntroFramesCount = (Param >> 8);
  2667. dbg_printf(("OnDigest()n"));
  2668. //if already on digest mode ignoring the request
  2669. if (g_pSVCDNav->m_bDigestMode) {
  2670. dbg_printf(("Already on digest mode. Ignored.n"));
  2671. return;
  2672. }
  2673. OnScan(0);
  2674. // Cancel Intro Playmode
  2675. SHARED_INFO.bIsIntroPlayMode = FALSE;
  2676. PM_SetPBC(FALSE);
  2677. OnModeChange();
  2678. Logo_setBackgroundColor(0x65, 0xA4, 0x61);//LeonH_0827_2003_c:mode change will flush background color, so reset it
  2679. //saving the current position in order to resume the playback in the future
  2680. if (PST_STOP != gcs.pstate){
  2681. SetMarker(eResumePlayback, 0);
  2682. PE_CD_AbortPlayback(TRUE);
  2683. }
  2684. // Cancel Error-Recovery Mechanism(s)
  2685. (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
  2686. (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= 0;
  2687. (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302: Not actual needed here
  2688. #ifdef WATCHDOG_TRIGGERED_BY_FE
  2689. PE_CD_CancelNotification( StuckTrigger );
  2690. #endif
  2691. //If we are on play we initiate a Track-Digest: presenting 9 frames from the current track
  2692. if (eTrackView == eDigestMode)
  2693. {
  2694. DWORD dwCurrTrackSize = g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0];
  2695. DWORD dwTrackAddress = g_pSVCDNav->m_aCurrTrack[0];
  2696. Digest_Unit m_DigestUnit;
  2697. uDigestItemsCnt = DIGEST_MAX_FRAMES_ON_SCREEN;
  2698. g_pSVCDNav->m_uiDigestUnits = Array_construct(uDigestItemsCnt, sizeof(Digest_Unit), NULL);
  2699. if (NULL == g_pSVCDNav->m_uiDigestUnits) {
  2700. dbg_printf(("Failed to allocate digest items array!n"));
  2701. return;
  2702. }
  2703. uTrackDigestUnitSize = (UINT16)(dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
  2704. //initializing the array
  2705. for (uIndex = 0; uIndex < uDigestItemsCnt; uIndex++)
  2706. {
  2707. m_DigestUnit.dwAddress = dwTrackAddress;
  2708. dwTrackAddress += (dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
  2709. m_DigestUnit.uSize  = uTrackDigestUnitSize;
  2710. //fixing the last unit size to be the remaining of the track
  2711. if ( ( uDigestItemsCnt - 1) == uIndex )
  2712. m_DigestUnit.uSize = dwCurrTrackSize - 
  2713. (uTrackDigestUnitSize * (DIGEST_MAX_FRAMES_ON_SCREEN - 1));
  2714. Array_setAt(g_pSVCDNav->m_uiDigestUnits, uIndex, (CONST BYTE *)&m_DigestUnit);
  2715.   }
  2716. }
  2717. //Disc-digest: each frame is a track sample
  2718. else if (eDiscView == eDigestMode)
  2719. {
  2720. Digest_Unit m_DigestUnit;
  2721. //the digest items count is actually the number of tracks on the disc minues the info track 
  2722. //and minus the audio tracks
  2723. if (PE_CD_GetTracksCnt() > g_pSVCDNav->m_uFirstCDDA_Track)
  2724. uDigestItemsCnt = (UINT16)(g_pSVCDNav->m_uFirstCDDA_Track - 2);
  2725. else
  2726. uDigestItemsCnt = (UINT16)PE_CD_GetTracksCnt() - 1;
  2727. g_pSVCDNav->m_uiDigestUnits = Array_construct(uDigestItemsCnt, sizeof(Digest_Unit), NULL);
  2728. if (NULL == g_pSVCDNav->m_uiDigestUnits) {
  2729. dbg_printf(("Failed to allocate digest items array!n"));
  2730. return;
  2731. }
  2732. //initializing the array
  2733. for (uIndex = 0; uIndex < uDigestItemsCnt; uIndex++) {
  2734. TrackInfo tiTrackInfo;
  2735. PE_CD_GetTrackInfo((uIndex + 2), &tiTrackInfo);
  2736. m_DigestUnit.dwAddress = tiTrackInfo.dwStartAddress;
  2737. m_DigestUnit.uSize = (UINT16)tiTrackInfo.ulBlocksCnt;
  2738. Array_setAt(g_pSVCDNav->m_uiDigestUnits, uIndex, (CONST BYTE *)&m_DigestUnit);
  2739. }
  2740. }
  2741. #ifdef  DISC_TRACK_DIGEST_VIEW_ENABLE
  2742. else if ( eTrackDiscView == eDigestMode ){
  2743. DWORD dwCurrTrackSize;
  2744. DWORD dwTrackAddress;
  2745. BYTE ucNumOfTracks, ucTrackIndex;
  2746. Digest_Unit m_DigestUnit;
  2747. if (PE_CD_GetTracksCnt() > g_pSVCDNav->m_uFirstCDDA_Track)
  2748. ucNumOfTracks = (BYTE)(g_pSVCDNav->m_uFirstCDDA_Track - 2);
  2749. else
  2750. ucNumOfTracks = (BYTE)PE_CD_GetTracksCnt() - 1;
  2751. uDigestItemsCnt = DIGEST_MAX_FRAMES_ON_SCREEN * ucNumOfTracks;
  2752. dbg_printf(("Num of Digets Items for Disc_Track_View %04xn", uDigestItemsCnt ));
  2753. g_pSVCDNav->m_uiDigestUnits = Array_construct(uDigestItemsCnt, sizeof(Digest_Unit), NULL);
  2754. if (NULL == g_pSVCDNav->m_uiDigestUnits) {
  2755. dbg_printf(("Failed to allocate digest items array!n"));
  2756. return;
  2757. }
  2758. for ( ucTrackIndex = 0; ucTrackIndex < ucNumOfTracks; ucTrackIndex++ ){
  2759. TrackInfo m_TrackInfo;
  2760. if ( PE_CD_GetTrackInfo((int)(ucTrackIndex + 2), &m_TrackInfo) ){
  2761. dwTrackAddress = m_TrackInfo.dwStartAddress;
  2762. dwCurrTrackSize = m_TrackInfo.ulBlocksCnt;
  2763. }
  2764. else{
  2765. Array_destruct(g_pSVCDNav->m_uiDigestUnits);
  2766. dbg_printf(("Error, can't get Toc infon"));
  2767. return;
  2768. }
  2769. uTrackDigestUnitSize = (UINT16)(dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
  2770. for ( uIndex = 0; uIndex < DIGEST_MAX_FRAMES_ON_SCREEN; uIndex ++ ){
  2771. m_DigestUnit.dwAddress = dwTrackAddress;
  2772. m_DigestUnit.uSize = uTrackDigestUnitSize;
  2773. //fixing the last unit size to be the remaining of the track
  2774. if ( uIndex == ( DIGEST_MAX_FRAMES_ON_SCREEN - 1) )
  2775. m_DigestUnit.uSize = (UINT16)(dwCurrTrackSize - 
  2776. (uTrackDigestUnitSize * (DIGEST_MAX_FRAMES_ON_SCREEN - 1)));
  2777. Array_setAt(g_pSVCDNav->m_uiDigestUnits, (UINT16)(uIndex + ucTrackIndex*DIGEST_MAX_FRAMES_ON_SCREEN),
  2778. (const BYTE *)&m_DigestUnit);
  2779. dwTrackAddress += (dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
  2780. }
  2781. }
  2782. }
  2783. #endif//DISC_TRACK_DIGEST_VIEW_ENABLE
  2784. else
  2785. {
  2786. tr_printf(("Unsupported digest mode.n"));
  2787. return;
  2788. }
  2789. //setting the play state to PST_STILL
  2790. gcs.pstate = PST_STILL;
  2791. SHARED_INFO.bIsElapsedTimeValid = FALSE;
  2792. //initiating the digest operation
  2793. if (Digest_init(_handleDigestUnit, uDigestItemsCnt, eDigestMode, uIntroFramesCount)) 
  2794. {
  2795. //Setting the Digest mode indication
  2796. g_pSVCDNav->m_bDigestMode = TRUE;
  2797. //saving the operation mask
  2798. g_pSVCDNav->m_ulCOP_Mask = COP_MASK;
  2799. //start the actual digest process
  2800. Digest_start(0);
  2801. //setting the new operation mask
  2802. CLEAR_COP_MASK(COP_PLAY | COP_PAUSE | COP_STEP | COP_SLOW | COP_SCAN | 
  2803.    COP_SCAN_BACKWARD| COP_NEXT_CHAPTER | COP_PREVIOUS_CHAPTER);
  2804. SET_COP_MASK(COP_STOP | COP_NEXT_CHAPTER | COP_PREVIOUS_CHAPTER);
  2805. }
  2806. }
  2807. #endif //SVCD_DIGEST_SUPPORT
  2808. //////////////////////////////////////////////////////////////////////////////////
  2809. // Function name : IsSegmentPlay
  2810. //
  2811. // Purpose : Check if current disc is segment playback
  2812. //
  2813. // Input Parameters : none
  2814. //
  2815. // Return Value : 
  2816. //
  2817. // Description : 
  2818. //////////////////////////////////////////////////////////////////////////////////
  2819. BOOL IsSegmentPlay(void)
  2820. {
  2821. if(g_pSVCDNav->m_bIsSegment)
  2822. return TRUE;
  2823. else
  2824. return FALSE;
  2825. }
  2826. // <<< ZCO SH021403:Added to check Zoom availability
  2827. //////////////////////////////////////////////////////////////////////////////////
  2828. // Function name : IsSVCDUsingPSD
  2829. //
  2830. // Purpose : Check if current disc is using PSD
  2831. //
  2832. // Input Parameters : none
  2833. //
  2834. // Return Value : TRUE if current disc is using PSD, FALSE otherwise
  2835. //
  2836. // Description : 
  2837. //////////////////////////////////////////////////////////////////////////////////
  2838. BOOL IsSVCDUsingPSD(void)
  2839. {
  2840. if(g_pSVCDNav->m_bIsUsingPSD)
  2841. return TRUE;
  2842. else
  2843. return FALSE;
  2844. }
  2845. // ZCO SH021403 >>>
  2846. // <<< ZCO SH021403:Added to check Zoom availability
  2847. //////////////////////////////////////////////////////////////////////////////////
  2848. // Function name : GetCurrentSVCDRes
  2849. //
  2850. // Purpose : Return current Video SID use by navigator
  2851. //
  2852. // Input Parameters : none
  2853. //
  2854. // Return Value : current video sid 
  2855. //
  2856. // Description : 
  2857. //////////////////////////////////////////////////////////////////////////////////
  2858. int GetCurrentSVCDRes(void)
  2859. {
  2860. return g_pSVCDNav->m_iCurrVideoType;
  2861. }
  2862. // ZCO SH021403 >>>
  2863. // <<< SEC BK.LIM070203
  2864. #ifdef EXINO2
  2865. // <<< SEC BK.LIM090203: Give location changing value to UI
  2866. BOOL Is_VCD_Location_Changing(void)
  2867. {
  2868.  return g_pSVCDNav->m_bLocationChanging;
  2869. }
  2870. // SEC BK.090203>>>
  2871. //<<< SEC BK.LIM080703: Get current playback time
  2872. DWORD Get_Curr_Playbacktime(void)
  2873. {
  2874. return (((SHARED_INFO.dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / 75L) );
  2875. }
  2876. //>>>
  2877. BOOL CheckValidTime(void)
  2878. {
  2879.     //WORD wTrack = PM_IsPlaybackProgram(PM_GetPlaybackMode()) ? PM_GetProgramListEntry((gns.svcd.m_CurrPosition).uListItem) : (gns.svcd.m_CurrPosition).uListItem + 1;
  2880.          
  2881.     return ( ((SHARED_INFO.dwCurrentLocation >  g_pSVCDNav->m_aCurrTrack[0]) && (SHARED_INFO.dwCurrentLocation< g_pSVCDNav->m_aCurrTrack[1])) );
  2882. }
  2883. BOOL SVCD_Nav_Check_UOP(EVENT Event, void *Param)
  2884. {
  2885. BOOL bIsNextOp = FALSE;
  2886. WORD wtime = 0;
  2887. if(PM_IsPBC(PM_GetPlaybackMode()) )
  2888. wtime = SI_SVCD_ELAPSED_TIME_PBC_ON;
  2889. else
  2890. wtime = SI_SVCD_ELAPSED_TIME;
  2891. switch(Event){
  2892. case IE_CORE_NEXT_CHAPTER:
  2893. bIsNextOp = TRUE;
  2894. case IE_CORE_PREVIOUS_CHAPTER:
  2895. if ( gcs.pstate == PST_STOP )
  2896. return FALSE;
  2897. if ( !g_pSVCDNav->m_bIsUsingPSD){
  2898. if ((( gns.svcd.m_CurrPosition.uListItem == ( PM_GetProgramSize() - 1 )) && (bIsNextOp )) ||
  2899. ((gns.svcd.m_CurrPosition.uListItem == 1) && (wtime < (SVCD_PREV_THRESHOLD/SVCD_BLOCKS_PER_SECOND+1)) && (!bIsNextOp)) )
  2900.             if ( !PM_IsPlaybackShuffle(PM_GetPlaybackMode()))  //Added by Billt 081602
  2901.                 return FALSE;  //Added by Billt 081602
  2902. return TRUE;
  2903. }
  2904. else{
  2905. switch( (SHARED_INFO.m_CurrPosition).ListType){
  2906. case EndList:
  2907. return FALSE;
  2908. case PlayList:
  2909. if ((( ((SHARED_INFO.m_CurrList).PlayList).uNextOffset== 0xFFFF ) && (bIsNextOp)) ||
  2910. ( (((SHARED_INFO.m_CurrList).PlayList).uPrevOffset == 0xFFFF ) && (!bIsNextOp)) )
  2911. return FALSE;
  2912. return TRUE;
  2913. case SelectionList:
  2914. if ( bIsNextOp){
  2915. if ( ((SHARED_INFO.m_CurrList).SelectionList).uNextOffset == 0xFFFF )
  2916. return FALSE;
  2917. }
  2918. else{
  2919. if (((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset == 0xFFFF )
  2920. return FALSE;
  2921. }
  2922. return TRUE;
  2923. default:
  2924. return FALSE;
  2925. };
  2926. }
  2927. break;
  2928. case IE_CORE_RETURN:
  2929. if ( ( !g_pSVCDNav->m_bIsUsingPSD) || ( gcs.pstate == PST_STOP ))
  2930. return FALSE;
  2931. switch((SHARED_INFO.m_CurrPosition).ListType){
  2932. case EndList:
  2933. return FALSE;
  2934. case PlayList:
  2935. if (((SHARED_INFO.m_CurrList).PlayList).uReturnOffset== 0xFFFF )
  2936. return FALSE;
  2937. case SelectionList:
  2938. if (((SHARED_INFO.m_CurrList).SelectionList).uReturnOffset == 0xFFFF )
  2939. return FALSE;
  2940. }
  2941. return TRUE;
  2942. case IE_CORE_SCAN:
  2943. case IE_CORE_SLOW:
  2944. if ( gcs.pstate == PST_STOP )
  2945. return FALSE;
  2946. if (( g_pSVCDNav->m_bIsUsingPSD ) && ( (SHARED_INFO.m_CurrPosition).ListType == SelectionList)
  2947. && (g_pSVCDNav->m_aCurrTrack[1]== -1 ))
  2948. return FALSE;
  2949. return TRUE;
  2950. default:
  2951. return FALSE;
  2952. };
  2953. }
  2954. #endif
  2955. // SEC BK.LIM070203>>>
  2956. #ifdef _DEBUG
  2957. static void OnStatusReport(void)
  2958. {
  2959. dbg_printf(("Status Report for SVCD-Navigator:n"));
  2960. dbg_printf(("tPlayback-Sequence-Descriptor %s;n", (g_pSVCDNav->m_bIsUsingPSD ? "Used" : "Not Used")));
  2961. if (g_pSVCDNav->m_bIsUsingPSD) {
  2962. if (g_pSVCDNav->m_bPendingEvent) {
  2963. dbg_printf(("tPending Event: %lx, %u;n", g_pSVCDNav->m_PendingEvent, g_pSVCDNav->m_uPendingEventParam));
  2964. }
  2965. dbg_printf(("tRemaining Waiting-Time: %u Seconds;n", (g_pSVCDNav->m_dwWaitTime / SVCD_TICKS_PER_SECOND)));
  2966. dbg_printf(("tRemaining time until Timeout: %u Seconds;n", (g_pSVCDNav->m_dwTimeout / SVCD_TICKS_PER_SECOND)));
  2967. dbg_printf(("tRemaining Pause-Time: %u Seconds;n", (g_pSVCDNav->m_dwPausePeriod / SVCD_TICKS_PER_SECOND)));
  2968. switch ((SHARED_INFO.m_CurrPosition).ListType) {
  2969. case PlayList:
  2970.        dbg_printf(("tThe Current-List is a Play-List:n"));
  2971. dbg_printf(("ttNumber of items on the list: %u;n", ((SHARED_INFO.m_CurrList).PlayList).uItemsCnt));
  2972. dbg_printf(("ttCurrent Item: %u;n", ((SHARED_INFO.m_CurrPosition).uListItem)));
  2973. dbg_printf(("ttPlaying-Time: %u;n", ((SHARED_INFO.m_CurrList).PlayList).uPlayingTime));
  2974. dbg_printf(("ttWaiting-Time: %02x;n", ((SHARED_INFO.m_CurrList).PlayList).wWaitTime));
  2975. dbg_printf(("ttAuto-Pause Period: %02x;n", ((SHARED_INFO.m_CurrList).PlayList).wAutoPausePeriod));
  2976. dbg_printf(("ttPrevious: %04x;n", ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset));
  2977. dbg_printf(("ttNext:     %04x;n", ((SHARED_INFO.m_CurrList).PlayList).uNextOffset));
  2978. dbg_printf(("ttReturn:   %04x.n", ((SHARED_INFO.m_CurrList).PlayList).uReturnOffset));
  2979. break;
  2980. case SelectionList:
  2981. dbg_printf(("tThe Current-List is a Selection-List:n"));
  2982. dbg_printf(("ttNumber of selection-items: %u;n", ((SHARED_INFO.m_CurrList).SelectionList).uSelectionsCnt));
  2983. dbg_printf(("ttBase of selection: %u;n", ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase));
  2984. dbg_printf(("ttIterations Left: %u;n", ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt));
  2985. dbg_printf(("ttTimeout-Period: %02x;n", ((SHARED_INFO.m_CurrList).SelectionList).wTimeoutWaitTime));
  2986. dbg_printf(("ttPrevious: %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset));
  2987. dbg_printf(("ttNext:     %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uNextOffset));
  2988. dbg_printf(("ttReturn:   %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uReturnOffset));
  2989. dbg_printf(("ttTimeout:  %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uTimeoutOffset));
  2990. dbg_printf(("ttDefault:  %04x.n", ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset));
  2991. break;
  2992. case EndList:
  2993. dbg_printf(("tThe Current-List is an End-List.n"));
  2994. break;
  2995. case Undetermined:
  2996. dbg_printf(("tThe Current-List has not been determined yet.n"));
  2997. break;
  2998. }
  2999. }
  3000. else {
  3001. dbg_printf(("tTotal number of items on the Program-List is: %dn", (PM_GetProgramSize() - 1)));
  3002. dbg_printf(("tCurrent Program-List item: %d.n", (SHARED_INFO.m_CurrPosition).uListItem));
  3003. }
  3004. return;
  3005. }
  3006. #endif //_DEBUG
  3007. #ifdef EXINO2 //ZKR JK0331 : for power_on_resume in EEPROM
  3008. #ifdef HW_POWER_ON_RESUME
  3009. static WORD GetResumeLeadOutInfo(void)
  3010. {
  3011. WORD wLeadOut;
  3012. if (eeprom_read(SVCD_LeadOut_Info_ADDR, (BYTE *)&wLeadOut, sizeof(WORD) ))
  3013. return wLeadOut;
  3014.    else
  3015.     return 0;
  3016. }
  3017. static void GetCurretnLocationStructure(void)
  3018. {
  3019. if ( eeprom_read( SVCD_CurrentPosition_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrPosition), sizeof(SVCD_Marker) ) )
  3020. return;
  3021. }
  3022. static void GetPSDAvaiableInfo(void)
  3023. {
  3024. if ( eeprom_read(SVCD_UsingPSD_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_bIsUsingPSD), sizeof(BOOL) ))
  3025. return;
  3026. }
  3027. static void GetCurrentListInfo(void)
  3028. {
  3029. if ( eeprom_read(SVCD_CurrentList_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrList), sizeof(SVCD_PSDList) ) )
  3030. return;
  3031. else
  3032. dbg_printf(("Error on reading SVCD Current List Info to EEPROMn"));
  3033. }
  3034. static void GetVideoTypeInfo(void)
  3035. {
  3036. if ( eeprom_read(SVCD_VideoType_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_iCurrVideoType), sizeof(g_pSVCDNav->m_iCurrVideoType)) )
  3037. return;
  3038. else
  3039. dbg_printf(("Error on reading SVCD Current Video Type to EEPROMn"));
  3040. }
  3041. static void SetResumeLeadOutInfo(void)
  3042. {
  3043. if (eeprom_write (SVCD_LeadOut_Info_ADDR, (BYTE *)&((gns.svcd).wTotalPlaybackTime), sizeof(WORD) ))
  3044. return;
  3045. else
  3046. dbg_printf(("Error on writing Lead Out info to EEPROMn"));
  3047. }
  3048. static void SetCurretnLocationStructure(void)
  3049. {
  3050. if(gcs.pstate == PST_STOP)
  3051. gns.svcd.m_CurrPosition.dwStartAddress =g_pSVCDNav->m_ResumePlayback.dwStartAddress;
  3052. else
  3053. gns.svcd.m_CurrPosition.dwStartAddress = PE_CD_GetCurrentLocation();
  3054. if ( eeprom_write(SVCD_CurrentPosition_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrPosition), sizeof(SVCD_Marker)))
  3055. return;
  3056. else
  3057. dbg_printf(("Error on writing SVCD CurrentPosition info to EEPROMn"));
  3058. }
  3059. static void SetPSDAvaiableInfo(void)
  3060. {
  3061. if ( eeprom_write( SVCD_UsingPSD_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_bIsUsingPSD), sizeof(BOOL) ) )
  3062. return;
  3063. else
  3064. dbg_printf(("Error on writing SVCD IsUsingPSD info to EEPROMn"));
  3065. }
  3066. static void SetCurrentListInfo(void)
  3067. {
  3068. if ( eeprom_write(SVCD_CurrentList_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrList), sizeof(SVCD_PSDList) ) )
  3069. return;
  3070. else
  3071. dbg_printf(("Error on writing SVCD Current List Info to EEPROMn"));
  3072. }
  3073. static void SetVideoTypeInfo(void)
  3074. {
  3075. if ( eeprom_write(SVCD_VideoType_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_iCurrVideoType), sizeof(g_pSVCDNav->m_iCurrVideoType)) )
  3076. return;
  3077. else
  3078. dbg_printf(("Error on writing SVCD Current Video Type to EEPROMn"));
  3079. }
  3080. static void ClearResumeLeadOutInfo(void)
  3081. {
  3082. WORD wLeadOut;
  3083. wLeadOut = 0x0000;
  3084. // <<< ZKR GL021302 : Use eeprom_write()
  3085. //if (eeprom_read(SVCD_LeadOut_Info_ADDR, (BYTE *)&wLeadOut, sizeof(WORD) ))
  3086. if (eeprom_write(SVCD_LeadOut_Info_ADDR, (BYTE *)&wLeadOut, sizeof(WORD) ))
  3087. // ZKR GL021302 >>>
  3088. return;
  3089. else
  3090. dbg_printf(("Error on cleanning SVCD Lead Out info from EEPROM when eject tray n"));
  3091. }
  3092. // <<< ZKR GL012702 : To notify power-on resume for UI before restarting
  3093. BOOL IsPowerOnResumeAvailable(void)
  3094. {
  3095.    if ( /*bPowerResume &&*/ ( GetResumeLeadOutInfo() == gns.svcd.wTotalPlaybackTime ) ) {
  3096.       return TRUE;
  3097.    }
  3098.    else {
  3099.       return FALSE;
  3100.    }
  3101. }
  3102. BOOL IsPowerOnResumeUsingPSD(void)
  3103. {
  3104.    BOOL bIsUsingPSD;
  3105.   if ( !eeprom_read(SVCD_UsingPSD_Info_ADDR, (BYTE *)&bIsUsingPSD, sizeof(BOOL)) )
  3106.    printf("Error on reading SVCD IsUsingPSD info from EEPROMn");
  3107.    return bIsUsingPSD;
  3108. }
  3109. // ZKR GL012702 >>>
  3110. #endif//HW_POWER_ON_RESUME
  3111. #else //EXINO2
  3112. #ifdef HW_POWER_ON_RESUME
  3113. BOOL SVCDNAV_NvmBmk_Match(NVM_GENERIC_BMK* pGenric_bmk)
  3114. {
  3115. if (gns.svcd.wTotalPlaybackTime != pGenric_bmk->marker.svcd.wLeadOut)
  3116. return FALSE;
  3117. return TRUE;
  3118. }
  3119. void SVCDNAV_NvmBmk_Set( WORD sc_handle)
  3120. {
  3121. WORD wSCTmp;
  3122. BYTE b_temp;
  3123. int i, offset;
  3124. NVM_GENERIC_BMK* pGenric_bmk;
  3125. SVCD_Marker *pMarker= NULL;
  3126. offset = (int)&pGenric_bmk->marker.svcd.m_bIsUsingPSD - (int)pGenric_bmk;
  3127. sc_SetBytes(sc_handle, offset, sizeof(BYTE), (BYTE *)&(g_pSVCDNav->m_bIsUsingPSD));
  3128. offset = (int)&pGenric_bmk->marker.svcd.wLeadOut - (int)pGenric_bmk;
  3129. sc_SetBytes(sc_handle, offset, sizeof(WORD), (BYTE *)&((gns.svcd).wTotalPlaybackTime));
  3130. memcpy(pMarker, &(gns.svcd.m_CurrPosition), sizeof(SVCD_Marker));
  3131. if(gcs.pstate == PST_STOP)
  3132. pMarker->dwStartAddress =g_pSVCDNav->m_ResumePlayback.dwStartAddress;
  3133. else
  3134. pMarker->dwStartAddress = PE_CD_GetCurrentLocation();
  3135. offset = (int)&pGenric_bmk->marker.svcd.m_CurrPosition - (int)pGenric_bmk;
  3136. sc_SetBytes(sc_handle, offset, sizeof(SVCD_Marker), (BYTE *)pMarker);
  3137. offset = (int)&pGenric_bmk->marker.svcd.m_CurrList - (int)pGenric_bmk;
  3138. sc_SetBytes(sc_handle, offset, sizeof(SVCD_PSDList), (BYTE *)&(gns.svcd.m_CurrList));
  3139. offset = (int)&pGenric_bmk->marker.svcd.m_iCurrVideoType- (int)pGenric_bmk;
  3140. sc_SetBytes(sc_handle, offset, sizeof(BYTE), (BYTE *)&(g_pSVCDNav->m_iCurrVideoType));
  3141. return;
  3142. }
  3143. void SVCDNAV_NvmBmk_Play(NVM_GENERIC_BMK *pGenric_bmk)
  3144. {
  3145. gns.svcd.m_CurrPosition = pGenric_bmk->marker.svcd.m_CurrPosition;
  3146. g_pSVCDNav->m_bIsUsingPSD = pGenric_bmk->marker.svcd.m_bIsUsingPSD;
  3147. gns.svcd.m_CurrList = pGenric_bmk->marker.svcd.m_CurrList;
  3148. g_pSVCDNav->m_iCurrVideoType = (VideoSID)pGenric_bmk->marker.svcd.m_iCurrVideoType;
  3149. if ( g_pSVCDNav->m_bIsUsingPSD )
  3150. {
  3151. PM_SetPBC(TRUE);
  3152. g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
  3153. if ( ( g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES ) || ( g_pSVCDNav->m_iCurrVideoType == STILL_HIRES ) )
  3154. gns.svcd.m_CurrPosition.dwStartAddress = -1;
  3155. //g_pSVCDNav->m_dwPSD_CacheBase= 0xFFFF;
  3156. }
  3157. else
  3158. {
  3159. PM_SetPBC(FALSE);
  3160. PM_SetPlaybackMode((BYTE) PM_PLAYBACK_NORMAL);
  3161. g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
  3162. }
  3163. return;
  3164. }
  3165. #endif //HW_POWER_ON_RESUME
  3166. #endif //EXINO2