nav_svcd.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:253k
- if (! (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS) {
- // Measure the Elapsed-Time based on the Current MSF
- #ifdef SVCD_USE_ABSOLUTE_TIME
- if (SHARED_INFO.bIsElapsedTimeValid)
- {
- // Update with Global Elapsed Time
- //gns.svcd.wTotalElpasedTime = (WORD)(dwCurrentLocation/g_pSVCDNav->m_aCurrTrack[2] );
- gns.svcd.wTotalElpasedTime = ((dwCurrentLocation - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
-
- if (!g_pSVCDNav->m_bIsUsingPSD)
- {
- if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track) {
- // For AV Tracks, use the Track's beginning as a reference-point; assume a relation
- // of 75-Sectors per Second (Fixed-Bitrate).
- iElapsedTime= ((dwCurrentLocation - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
- }
- else {
- // For CDDA Tracks, use the Decoder's MSF
- int iSign;
- UINT8 uMinute, uSecond, uFrame;
- //The relative measurment is more accurate, so we use it instead of the
- //absolute one cause otherwise the check for position B encounter fails.
- if (PE_CD_GetDecoderCurrentLocationMSF(eRelativeLocation,
- &uMinute, &uSecond, &uFrame, &iSign))
- {
- iElapsedTime= (60 * uMinute) + uSecond;
- iElapsedTime+= ((g_pSVCDNav->m_aCurrTrack[0] - g_pSVCDNav->m_dwSecondTrackAddress)
- / SVCD_BLOCKS_PER_SECOND);
- }
- }
- }
- else
- {
- //On PSD mode the time is calculated as a relative time
- if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track) {
- // For AV Tracks, use the Track's beginning as a reference-point; assume a relation
- // of 75-Sectors per Second (Fixed-Bitrate).
- iElapsedTime= (int)((dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
- }
- else {
- // For CDDA Tracks, use the Decoder's MSF
- int iSign;
- UINT8 uMinute, uSecond, uFrame;
- if (PE_CD_GetDecoderCurrentLocationMSF(eRelativeLocation,
- &uMinute, &uSecond, &uFrame, &iSign))
- {
- iElapsedTime= (int)(iSign * ((60 * uMinute) + uSecond));
-
- if (iSign < 0)
- iElapsedTime--;
- }
- }
- }
- }
- else
- iElapsedTime = 0;
- #else //SVCD_USE_ABSOLUTE_TIME
- if (SHARED_INFO.bIsElapsedTimeValid)
- {
- #ifdef PARSE_ENTRY_INFO
- if ( ( NULL != g_hEntriesTable ) && ( 0 != g_pSVCDNav->m_wEntriesUsedCnt )
- && ( PST_STOP != gcs.pstate ) && ( SHARED_INFO.uCurrentTrackNumber > 1 ) )
- {
-
- WORD i;
- BYTE aucBuffer[4];
- DWORD dwEntriesStartAddress;
- if ( 1 == g_pSVCDNav->m_wEntriesUsedCnt )
- {
- gns.svcd.wCurrentEntryNumber = 1;
- // tr_printf(("Current Entry Number is %04xn", gns.svcd.wCurrentEntryNumber));
- }
- else
- {
- for ( i = 0; i < g_pSVCDNav->m_wEntriesUsedCnt; i++)
- {
- Array_getAt(g_hEntriesTable, (UINT16)i, aucBuffer);
- dwEntriesStartAddress= drv_msf2lbn(drv_bcd2bin(aucBuffer[1]), drv_bcd2bin(aucBuffer[2]), drv_bcd2bin(aucBuffer[3]));
-
- if ( dwCurrentLocation < dwEntriesStartAddress )
- {
-
- for(j=0;j<=g_pSVCDNav->m_wEntriesUsedCnt;j++)
- {
- Array_getAt(g_hEntriesTable, (UINT16)j, aucBuffer);
- dwEntriesStartAddress = drv_msf2lbn(drv_bcd2bin(aucBuffer[1]), drv_bcd2bin(aucBuffer[2]), drv_bcd2bin(aucBuffer[3]));
- if(dwEntriesStartAddress>=g_pSVCDNav->m_aCurrTrack[0])
- break;
- }
- i=i-j;
- gns.svcd.wCurrentEntryNumber = i;
- // tr_printf(("Current Entry Number is %04xn", gns.svcd.wCurrentEntryNumber));
- break;
- }
- }
- }
- }
- else
- gns.svcd.wCurrentEntryNumber = 0xFFFF;
- #endif
-
- // Update with Global Elapsed Time
- //gns.svcd.wTotalElpasedTime = (WORD)(dwCurrentLocation/g_pSVCDNav->m_aCurrTrack[2] );
- gns.svcd.wTotalElpasedTime = ((dwCurrentLocation - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
- if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track) {
- // For AV Tracks, use the Track's beginning as a reference-point; assume a relation
- // of 75-Sectors per Second (Fixed-Bitrate).
-
- //<<<LX091202
- if (SHARED_INFO.m_iScanSpeed > 0){
- //<<<LX090602: Check if in the range
- if( ( dwCurrentLocation >= g_pSVCDNav->m_aCurrTrack[0] ) && ( dwCurrentLocation <= g_pSVCDNav->m_aCurrTrack[1] ))
- iElapsedTime= (int)((dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
- else
- //LX090602>>>
- iElapsedTime = 0;
- }
- else
- //LX091202>>>
- iElapsedTime = (int)((dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
- }
- else {
- // For CDDA Tracks, use the Decoder's MSF
- int iSign;
- UINT8 uMinute, uSecond, uFrame;
- if (PE_CD_GetDecoderCurrentLocationMSF(eRelativeLocation,
- &uMinute, &uSecond, &uFrame, &iSign))
- {
- iElapsedTime= (int)(iSign * ((60 * uMinute) + uSecond));
-
- if (iSign < 0)
- iElapsedTime--;
- }
- }
- }
- #endif //SVCD_USE_ABSOLUTE_TIME
- }
- //Updating the remaining time
- #ifdef SVCD_USE_ABSOLUTE_TIME
- if (SHARED_INFO.bIsElapsedTimeValid)
- {
- if (!g_pSVCDNav->m_bIsUsingPSD)
- SHARED_INFO.wRemainingPlaybackTime = SHARED_INFO.wTotalPlaybackTime - iElapsedTime;
- else
- {
- WORD wTotalTime = (g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2];
- SHARED_INFO.wRemainingPlaybackTime = (WORD)(wTotalTime - iElapsedTime);
- }
- }
- else
- SHARED_INFO.wRemainingPlaybackTime = 0;
- #else
- if (SHARED_INFO.bIsElapsedTimeValid)
- {
- WORD wTotalTime = (WORD)((g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
- if ( SHARED_INFO.uCurrentTrackNumber == 1 )
- wTotalTime = (WORD)((g_pSVCDNav->m_aCurrSegment[1] - g_pSVCDNav->m_aCurrSegment[0])/g_pSVCDNav->m_aCurrTrack[2]);
- iElapsedTime = (iElapsedTime > wTotalTime)? wTotalTime: iElapsedTime;
- SHARED_INFO.wRemainingPlaybackTime = (WORD)(wTotalTime - iElapsedTime);
- }
- else
- SHARED_INFO.wRemainingPlaybackTime = 0;
- #endif //SVCD_USE_ABSOLUTE_TIME
- // Actually update the Elapsed-Time only if we are not in stop mode
- if (PST_STOP != gcs.pstate
- #ifdef D_ENABLE_ELAPSEDTIME_FOR_SLIDESHOW
- && !((g_pSVCDNav->m_iCurrVideoType == STILL_HIRES)||(g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES))
- #endif
- )
- SHARED_INFO.iCurrentTime = iElapsedTime;
- // Calculate the Current-Location based on the Current-Time, if possible
- if (SHARED_INFO.bIsElapsedTimeValid) {
- #ifdef SVCD_USE_ABSOLUTE_TIME
- dwCurrentLocation= (g_pSVCDNav->m_dwSecondTrackAddress + (iElapsedTime * g_pSVCDNav->m_aCurrTrack[2]));
- #else
- dwCurrentLocation= (g_pSVCDNav->m_aCurrTrack[0] + (iElapsedTime * g_pSVCDNav->m_aCurrTrack[2]));
- #endif //SVCD_USE_ABSOLUTE_TIME
- }
- else {
- dwCurrentLocation= PE_CD_GetCurrentLocation();
- }
- //ZKR JK0210 #6 : FLT time display for VCD PBC on johnkim
- #ifdef S1_GUI
- SHARED_INFO.dwCurrentLocation= dwCurrentLocation;
- #endif
- //updating the operation mask in case digest mode is on
- #ifdef SVCD_DIGEST_SUPPORT
- if (g_pSVCDNav->m_bDigestMode) {
- enDIGEST_VALID_OP eValidOpOnDigest = Digest_getValidOp();
-
- if (eValidOpOnDigest & eDIGEST_OP_NEXT)
- SET_COP_MASK(COP_NEXT_CHAPTER);
- else
- CLEAR_COP_MASK(COP_NEXT_CHAPTER);
- if (eValidOpOnDigest & eDIGEST_OP_PREV)
- SET_COP_MASK(COP_PREVIOUS_CHAPTER);
- else
- CLEAR_COP_MASK(COP_PREVIOUS_CHAPTER);
- }
- #endif //SVCD_DIGEST_SUPPORT
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- // Update the COP_MASK with regard to the Next-Chapter operation
- SET_COP_MASK(COP_NEXT_CHAPTER);
- // Update the COP_MASK with regard to the Pre-Chapter operation
- SET_COP_MASK(COP_PREVIOUS_CHAPTER);
- #ifndef SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
- if (! PM_IsRepeatAll() &&
- ((SHARED_INFO.m_CurrPosition).uListItem == (PM_GetProgramSize() - 1)))
- {
- // If the Current-Item is the last one on the Program-List, then Next is not allowed
- CLEAR_COP_MASK(COP_NEXT_CHAPTER);
- }
- #ifndef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
- if (! PM_IsRepeatAll() &&
- ((SHARED_INFO.m_CurrPosition).uListItem == 1))
- {
- // If the Current-Item is the first one on the Program-List, then Pre is not allowed
- CLEAR_COP_MASK(COP_PREVIOUS_CHAPTER);
- }
- #endif
- #endif //SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
- }
- // Update various information
- if (CDDA_SID == g_pSVCDNav->m_uCurrAudioSID) {
- BYTE ucCtrlField, ucTrackNumber;
- // For CDDA Tracks, update the Track-Info
- if (PE_CD_GetDecoderCurrentTrackInfo(&ucCtrlField, &ucTrackNumber)) {
- SHARED_INFO.ucCurrentTrackInfo= ucCtrlField;
- }
- }
-
- // Update S/PDIF information
- PE_CD_UpdateAudioSPDIF();
- // Check for Finished condition: This check is only relevant for the following play-
- // states: PLAY, SLOW and PAUSE (assuming usage of the Step function).
- // In addition, this condition should be checked for SCAN of a CDDA track (NOT relevant
- // for AV).
- if ( ((PST_PLAY == gcs.pstate) || (PST_SLOW == gcs.pstate) || (PST_PAUSE == gcs.pstate) ||
- ((PST_SCAN == gcs.pstate) && (CDDA_SID == g_pSVCDNav->m_uCurrAudioSID))) &&
- PE_CD_IsPlaybackFinished() )
- {
- //<<<LX091202
- if ( ( g_pSVCDNav->m_iCurrVideoType == STILL_HIRES ) || ( g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES ) ){
- g_pSVCDNav->ucStillPicturePlaybackFinishedGapCounter--;
-
- if ( !g_pSVCDNav->ucStillPicturePlaybackFinishedGapCounter )
- ie_send(IE_CORE_CDNAV_FINISHED);
- }
- else
- //LX091202>>>
- ie_send(IE_CORE_CDNAV_FINISHED);
- }
- if (SHARED_INFO.m_iScanSpeed > 0)
- {
- if (( SHARED_INFO.wRemainingPlaybackTime < abs(SHARED_INFO.m_iScanSpeed)) && (0 == SVCDMessageGap.ScanFinishGap))
- {
- ie_send(IE_CORE_CDNAV_FINISHED);
- SVCDMessageGap.ScanFinishGap = SCAN_FINISH_GAP;
- }
-
- if (SVCDMessageGap.ScanFinishGap > 0)
- SVCDMessageGap.ScanFinishGap--;
- }
- // Check whether a Location-Change is in progress
- if (g_pSVCDNav->m_bLocationChanging) {
- // Check whether the Change has completed
- if ((dwCurrentLocation >= g_pSVCDNav->m_dwTargetLocation) &&
- (dwCurrentLocation < (g_pSVCDNav->m_dwTargetLocation + SVCD_LOCATION_TOLERANCE))) {
- g_pSVCDNav->m_bLocationChanging= FALSE;
- }
- }
- // Check for a Position-Rendezvous condition, provided that there is no Location-Change in progress
- if (! g_pSVCDNav->m_bLocationChanging) {
- // Take care of A-B Repeat
- if (PM_GetRepeatAB() & PM_REPEAT_AB_B) {
- if ((PST_SCAN == gcs.pstate) && (SHARED_INFO.m_iScanSpeed < 0)) {
- // Handle a Backwards-scan (in this case, look for Position-A, rather than Position-B):
- // If not scanning, make sure that there is a perfect match between the PositionB Marker and
- // the current location.
- if ( (dwCurrentLocation <= (g_pSVCDNav->m_PositionA).dwStartAddress) &&
- ((g_pSVCDNav->m_PositionA).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
- ((g_pSVCDNav->m_PositionA).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
- ((g_pSVCDNav->m_PositionA).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
- {
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)ePositionA);
- }
- }
- else if ((g_pSVCDNav->m_PositionB).dwStartAddress < dwCurrentLocation) {
- // For Forward-scan, or Normal speed playback, look for Position-B:
- // Make sure that there is a perfect match between the PositionB Marker and
- // the current location.
- if ( ((g_pSVCDNav->m_PositionB).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
- ((g_pSVCDNav->m_PositionB).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
- ((g_pSVCDNav->m_PositionB).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
- {
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)ePositionB);
- }
- }
- }
- else if (PM_GetRepeatAB() & PM_REPEAT_AB_A) {
- // Only Position-A is set:
- // If the Current position precedes Position-A (e.g. during Backwards-scan),
- // then cancel the setting.
- if ((dwCurrentLocation < (g_pSVCDNav->m_PositionA).dwStartAddress) &&
- ((SHARED_INFO.m_CurrPosition).uListItem == (g_pSVCDNav->m_PositionA).uListItem))
- {
- CancelRepeatModes(PM_REPEAT_AB_MASK);
- }
- }
- }
- if (g_pSVCDNav->m_dwWaitTime > 0) {
- if (0 == --(g_pSVCDNav->m_dwWaitTime))
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)eWaitTimeExpired);
- }
- if (g_pSVCDNav->m_dwPausePeriod > 0) {
- if (0 == --(g_pSVCDNav->m_dwPausePeriod))
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)ePausePeriodExpired);
- }
- if (g_pSVCDNav->m_dwTimeout > 0) {
- if (0 == --(g_pSVCDNav->m_dwTimeout))
- ie_send_ex(IE_CORE_CDNAV_RENDEZVOUS, (void *)eTimeout);
- }
- if ( ( SHARED_INFO.bIsIntroPlayMode ) && ( SHARED_INFO.iCurrentTime == 10 )
- && ( PE_CD_GetCurrentLocation() > (g_pSVCDNav->m_aCurrTrack[0] + 10*SVCD_BLOCKS_PER_SECOND) ) ) {
- dbg_printf(("Intro Playaback Finished for current Trackn"));
- ie_send(IE_CORE_CDNAV_FINISHED);
- }
- #ifndef WATCHDOG_TRIGGERED_BY_FE
- // Call for Error-Recovery
- PerformErrorRecovery();
- #endif
- #if defined(MPP_SUPPORT) && defined(VCD_MPP_ENABLE)
- DEC_SetMPP( gcst.mMPP_Enable );
- #endif
- return;
- }
- #ifdef D_ENABLE_ELAPSEDTIME_FOR_SLIDESHOW
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnTickOneSec() -
- // Handels an IE_CORE_TICK_ONE_SEC Event.
- //
- // Input:
- // None
- //
- // Output:
- // Display still pictures elapsed time.
- //
- static void OnTickOneSec(void)
- {
- if(gcs.pstate == PST_PLAY)
- {
- //jeanz_0302_2005 Update time just for still pictures.
- if (( PlayList == (SHARED_INFO.m_CurrPosition).ListType) && ((g_pSVCDNav->m_iCurrVideoType == STILL_HIRES)||(g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES)))
- {
- int iElapsedTime= SHARED_INFO.iCurrentTime;
- WORD wTotalTime = (WORD)((g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
- if ( SHARED_INFO.uCurrentTrackNumber == 1 )
- wTotalTime = (WORD)((g_pSVCDNav->m_aCurrSegment[1] - g_pSVCDNav->m_aCurrSegment[0])/g_pSVCDNav->m_aCurrTrack[2]);
- iElapsedTime ++;
- iElapsedTime = (iElapsedTime > wTotalTime)? wTotalTime: iElapsedTime;
- SHARED_INFO.iCurrentTime = iElapsedTime;
- SHARED_INFO.wRemainingPlaybackTime = (WORD)(wTotalTime - iElapsedTime);
- }
-
- }
- return;
- }
- #endif
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnPlay() -
- // Handels an IE_CORE_PLAY Event.
- //
- // Input:
- // None
- //
- // Output:
- // Playback is resumed.
- //
- static void OnPlay(void)
- {
- dbg_printf(("OnPlay()n"));
- if(/*(gcs.pstate == PST_STOP )&&*/(! IS_COP_ENABLE( COP_SETUP )))
- SET_COP_MASK( COP_SETUP);
- // Check if a Paused playback is being resumed
- if (PST_PAUSE == gcs.pstate) {
- OnPausePeriodExpired();
- return;
- }
- //in case we were on digest mode we terminate the digest operation
- #ifdef SVCD_DIGEST_SUPPORT
- if (g_pSVCDNav->m_bDigestMode)
- _terminateDigestMode();
- #endif //SVCD_DIGEST_SUPPORT
- // If Scanning or Slow-Motion is in progress, eliminate it
- if ((PST_SCAN == gcs.pstate) || (PST_SLOW == gcs.pstate)) {
- BOOL bScan = FALSE;//jeanz_0306_2005 Set a value to the variable to prohibit it is given a invalid value.
-
- if ((PST_SCAN == gcs.pstate) || (SHARED_INFO.m_iSlowSpeed < 0))
- bScan = TRUE;
- if (SHARED_INFO.m_iSlowSpeed < 0)
- #ifdef USE_PTS_TO_MEASURE_TIME
- (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= TRUE; // By default, measuer using PTS's
- #else
- (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE; // Measuer not using PTS's
- #endif
- gcs.pstate= PST_PLAY;
- if (bScan)
- OnScan(0);
- else
- OnSlow(0);
- // For AV Tracks only, adjust the Time-measurement
- if (CDDA_SID != g_pSVCDNav->m_uCurrAudioSID) {
- //updating the time offset value
- #ifdef SVCD_USE_ABSOLUTE_TIME
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track)
- //calculating the absolute time offset from the beginning of track #2
- (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)((g_pSVCDNav->m_aCurrSegment[0] - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
- else
- (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)(g_pSVCDNav->m_aCurrSegment[0] / g_pSVCDNav->m_aCurrTrack[2]);
- }
- else
- (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)((g_pSVCDNav->m_aCurrSegment[0] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
- #else
- // (g_pSVCDNav->m_TimeMeasurementInfo).iTimeOffset = (int)((g_pSVCDNav->m_aCurrSegment[0] - g_pSVCDNav->m_aCurrTrack[0]) / g_pSVCDNav->m_aCurrTrack[2]);
- #endif //SVCD_USE_ABSOLUTE_TIME
- // Resume Time-Measurement according to PTS's; continue to use the last-acquired
- // PTS as a base. The last acquired PTS is the last PTS seen before transition to
- // the Scan mode.
- #ifdef USE_PTS_TO_MEASURE_TIME
- (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= TRUE; // By default, measuer using PTS's
- #else
- (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE; // Measuer not using PTS's
- #endif
- (g_pSVCDNav->m_TimeMeasurementInfo).bAcquireStartPTS= FALSE;
- }
- return;
- }
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- if (PST_PLAY == gcs.pstate) {
- dbg_printf(("Already playing. Ignored.n"));
- return;
- }
- // Check if the playback needs to be resumed from a previously recorded position
- if (-1 != (g_pSVCDNav->m_ResumePlayback).dwStartAddress) {
- dbg_printf(("Resuming playback.n"));
- memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_ResumePlayback),
- sizeof(SVCD_Marker));
- ClearMarker(eResumePlayback, 0); // Mark that this Marker has been used
- }
- // Now actually invoke playback of the List
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current Track.n"));
- gcs.pstate= PST_STOP;
- }
-
- return;
- }
- // Check if the playback needs to be resumed from a previously recorded position
- if (-1 != (g_pSVCDNav->m_ResumePlayback).dwPSD_Offset) {
- dbg_printf(("Resuming playback.n"));
- memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_ResumePlayback), sizeof(SVCD_Marker));
- ClearMarker(eResumePlayback, 0); // Mark that this Marker has been used
- // Check the current value of the Repeat-Counter. If it is Zero or negative, then force a
- // single iteration of the Selection-List Play-Item when resuming playback.
- if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) &&
- (((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt <= 0)) {
- ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
- }
- }
- // Check the type of the current List
- if ( (PlayList == (SHARED_INFO.m_CurrPosition).ListType) && (PST_PLAY == gcs.pstate) ) {
- // This is a Play-List: if there is already playback in progress, ignore.
- dbg_printf(("Already playing a PlayList Item. Ignored.n"));
- return;
- }
- else if ( (SelectionList == (SHARED_INFO.m_CurrPosition).ListType) &&
- ((PST_PLAY == gcs.pstate) || (PST_STILL == gcs.pstate)) )
- {
- // This is a Selection-List: if the Play-Item is already displaying, then this is a Default
- // selection.
- DWORD dwCurrLocation;
- WORD uDefaultOffset;
- // First, verify that the Default-Selection is allowed at this time, or should be postponed
- if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
- g_pSVCDNav->m_bPendingEvent= TRUE;
- g_pSVCDNav->m_PendingEvent= IE_CORE_PLAY;
- g_pSVCDNav->m_uPendingEventParam= NULL;
- return;
- }
- dwCurrLocation= PE_CD_GetCurrentLocation();
- //<<<LX090202: Check if the selection counter is zero in case get "divided by zero" error
- if (gns.svcd.m_CurrList.SelectionList.uSelectionsCnt == 0 )
- if ( (0xFFFD == gns.svcd.m_CurrList.SelectionList.uDefaultOffset) || (0xFFFE == gns.svcd.m_CurrList.SelectionList.uDefaultOffset) ||
- (0xFFFF == gns.svcd.m_CurrList.SelectionList.uDefaultOffset) )
- return;
- //LX090202>>>
-
- dbg_printf(("Activating the Default selection.n"));
- if (PST_PLAY == gcs.pstate)
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
- if ((0xFFFD == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset) ||
- (0xFFFE == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset))
- {
- dbg_printf(("Multi-Default Mode engaged.n"));
- uDefaultOffset= FindDefaultSelectionOffset(dwCurrLocation);
- if ((WORD)-1 == uDefaultOffset) {
- gcs.pstate= PST_STILL;
- return;
- }
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)uDefaultOffset;
- }
- else if (0xFFFF == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset) {
- dbg_printf(("No Default-List was defined.n"));
- uDefaultOffset= FindDefaultSelectionOffset(-1);
- if ((WORD)-1 == uDefaultOffset) {
- gcs.pstate= PST_STILL;
- return;
- }
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)uDefaultOffset;
- }
- else {
- dbg_printf(("The Default-List is at offset: %04xn", ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset));
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset;
- }
- }
- // Now actually invoke playback of the List
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current List.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnRendezvousPoint(enSVCD_RendezvousType eType) -
- // Handels an IE_CORE_CDNAV_RENDEZVOUS Event.
- //
- // Input:
- // eType - Specifies the type of Rendezvous point encountered.
- //
- // Output:
- // According to the type of Rendezvous detected, playback flow is changed.
- //
- // Remarks:
- // The handler examines the type of Rendezvous encountered;
- // for timer-expiration events, the handler calls the approriate sub-handlers.
- // For a PositionB encounter, the handler aborts the current playback and resumes it
- // from PositionA.
- static void OnRendezvousPoint(enSVCD_RendezvousType eType)
- {
-
- switch (eType)
- {
- case eTimeout:
- OnTimeout();
- break;
- case eWaitTimeExpired:
- OnWaitTimeExpired();
- break;
- case ePausePeriodExpired:
- OnPausePeriodExpired();
- break;
- case ePositionA: // Fall-Through!
- case ePositionB:
- dbg_printf(("Position%c Encountered.n", (ePositionA == eType) ? 'A' : 'B'));
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_PositionA), sizeof(SVCD_Marker));
- // Eliminate any on-going Scanning
- if (PST_SCAN == gcs.pstate) {
- OnScan(0);
- gcs.pstate= PST_PLAY;
- ie_send(IE_UI_STATE_CHANGE);
- }
- // Do some book-keeping for Selection-Lists in PBC mode
- if (g_pSVCDNav->m_bIsUsingPSD) {
- // Check the current value of the Repeat-Counter. If it is Zero or negative, then
- // force a single iteration of the Selection-List Play-Item when resuming playback.
- if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) &&
- (0 >= ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt)) {
- ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
- }
- }
- // Resume playback
- // <<< SEC shKang051304 : for Supporting the Slow Repeat A-B
- #ifdef EXINO2
- if( !( SHARED_INFO.m_iSlowSpeed != 0 && gcs.pstate == PST_SLOW ) )
- #endif
- // SEC shKang080703 >>>
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current List.n"));
- gcs.pstate= PST_STOP;
- }
- break;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnPlaybackFinished() -
- // Handels an IE_CORE_CDNAV_FINISHED Event.
- //
- // Input:
- // None
- //
- // Output:
- // Taking into account the current Playback-Mode and the current position, playback is
- // either repeated, continued or halted.
- static void OnPlaybackFinished(void)
- {
- WORD wListTimeField;
- DWORD dwTimePeriod;
- BOOL bListBoundariesReached = FALSE;
- dbg_printf(("OnPlaybackFinished()n"));
- // Cancel Error-Recovery Mechanism(s)
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
- (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= 0;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
- #ifdef WATCHDOG_TRIGGERED_BY_FE
- PE_CD_CancelNotification( StuckTrigger );
- #endif
- #ifdef SVCD_DIGEST_SUPPORT
- //no need to proccess this event on digest mode
- if (g_pSVCDNav->m_bDigestMode)
- return;
- #endif //SVCD_DIGEST_SUPPORT
- if ((PM_REPEAT_AB_A == PM_GetRepeatAB()) && PM_IsPBC(PM_GetPlaybackMode()))
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_REPEAT_AB_PROHIBIT );
- // When not using a PSD, advance to the next Program-List Item, provided that the end
- // of the Program-List has not been reached and the the Playback-Mode is not "Repeat Single".
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- dbg_printf(("PSD is not being used.n"));
- if (PM_IsRepeatSingle()) {
- dbg_printf(("Repeating the current Program-List Item.n"));
- // Resume Normal playback, if scanning
- if (PST_SCAN == gcs.pstate) {
- OnScan(0);
- gcs.pstate= PST_PLAY;
- ie_send(IE_UI_STATE_CHANGE);
- }
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current Item.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- //NOTE: Usually OnPlaybackFinished is called when a forward scan has reached its item
- //boundary. But, when scanning BACKWARDS from a CDDA track to a VCD track, the
- //Playback finished event occurrs as well. So we need to update the list item
- //accordingly, meaning reduce its number, and not only increase it.
- if (SHARED_INFO.m_iScanSpeed < 0)
- {
- #ifndef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- //moving to previous item
- (SHARED_INFO.m_CurrPosition).uListItem--;
- if ((SHARED_INFO.m_CurrPosition).uListItem <= 0) {
- (SHARED_INFO.m_CurrPosition).uListItem= PM_GetProgramSize();
- bListBoundariesReached = TRUE;
- }
- #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- }
- else
- {
- //moving to next item on the play list
- (SHARED_INFO.m_CurrPosition).uListItem++;
- if ((SHARED_INFO.m_CurrPosition).uListItem > (PM_GetProgramSize() - 1)) {
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- bListBoundariesReached = TRUE;
- }
- }
-
- // Check if the end of the Program-List has been reached. If so, rewind the Program-List.
- // If the Playback-Mode is "Repeat All", then also re-invoke the playback.
- if (bListBoundariesReached) {
- // Cancel A-B Repeat, in case only Position-A was set
- CancelRepeatModes(PM_REPEAT_AB_MASK);
- // If the current playback-mode is not "Repeat All", then don't re-invoke the playback
- if (! PM_IsRepeatAll()
- #ifdef D_REPEAT_PROGRAM_MODE
- && (PM_GetPlaybackMode() != PM_PLAYBACK_PROGRAM)
- #endif
- ){
- OnStop(eFullStop);
- ie_send(IE_UI_STATE_CHANGE);
- return;
- }
- // Resume Normal playback, if Scanning
- if (PST_SCAN == gcs.pstate) {
- OnScan(0);
- gcs.pstate= PST_PLAY;
- ie_send(IE_UI_STATE_CHANGE);
- }
- }
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the next Item.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- // The PSD information is being used:
- // Check whether the current Playback-Mode is "Single-Repeat", in which case
- // there's need to repeat the current item provided that the current List is a Play-List.
- if ((PlayList == (SHARED_INFO.m_CurrPosition).ListType) && PM_IsRepeatSingle()) {
- dbg_printf(("Repeating the current Play-Item...n"));
- // Resume Normal playback, if scanning
- if (PST_SCAN == gcs.pstate) {
- OnScan(0);
- gcs.pstate= PST_PLAY;
- ie_send(IE_UI_STATE_CHANGE);
- }
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current List.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- // Check the type of the current List, and extract the appropriate field
- if (PlayList == (SHARED_INFO.m_CurrPosition).ListType)
- wListTimeField= ((SHARED_INFO.m_CurrList).PlayList).wWaitTime;
- else
- wListTimeField= ((SHARED_INFO.m_CurrList).SelectionList).wTimeoutWaitTime;
- // Calculate the equivalent amount of Ticks
- if (0xFF == wListTimeField)
- dwTimePeriod= SVCD_INFINITE; // Wait forever
- else if (0 == wListTimeField)
- dwTimePeriod= 1; // Engage immediately (i.e. on the next Tick)
- else if ((1 <= wListTimeField) && (60 >= wListTimeField))
- dwTimePeriod= (DWORD)wListTimeField * SVCD_TICKS_PER_SECOND;
- else
- dwTimePeriod= (60 + (((DWORD)wListTimeField - 60) * 10)) * SVCD_TICKS_PER_SECOND;
- // Check the type of the current List again.
- // If the current List is a PlayList, then engage the Waiting-Time counter;
- // Otherwise, the current List is a SelectionList -- engage the Timeout-Period counter,
- // provided that no more iterations are left
- if (PlayList == (SHARED_INFO.m_CurrPosition).ListType) {
- g_pSVCDNav->m_dwWaitTime= dwTimePeriod;
- #ifdef _DEBUG
- if (SVCD_INFINITE == dwTimePeriod)
- dbg_printf(("Infinite Wait-Time engaged for the current PlayList Item.n"));
- else
- dbg_printf(("Engaged a Wait-Time of %lu Seconds for the current PlayList Item.n", (dwTimePeriod/SVCD_TICKS_PER_SECOND)));
- #endif //_DEBUG
- }
- else {
- // Check if there's a Pending-Event. This would occur in the case of finishing the playback of
- // a SelectionList Play-Item, whose Jump-Timing is set to "After playback finish".
- // If there is a Pending-Event, reschedule that event first.
- if (g_pSVCDNav->m_bPendingEvent) {
- gcs.pstate= PST_STILL;
- dbg_printf(("Executing Pending-Event: %un", g_pSVCDNav->m_PendingEvent));
- g_pSVCDNav->m_bPendingEvent= FALSE;
- ie_send_ex(g_pSVCDNav->m_PendingEvent, (void *)g_pSVCDNav->m_uPendingEventParam);
- return;
- }
- // Check the Repeat-Counter: If it is Zero, start measuring the Timeout period.
- // Otherwise, invoke an additional playback of the same Item.
- if (0 != ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt) {
- if (! InvokePlayback()) {
- dbg_printf(("Failed to invoke repeated playback.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- else {
- g_pSVCDNav->m_dwTimeout= dwTimePeriod;
- #ifdef _DEBUG
- if (SVCD_INFINITE == dwTimePeriod)
- dbg_printf(("Infinite Timeout-Period engaged for the current SelectionList.n"));
- else
- dbg_printf(("Engaged a Timeout-Period of %lu Seconds for the current SelectionList.n", (dwTimePeriod/SVCD_TICKS_PER_SECOND)));
- #endif //_DEBUG
- }
- }
- // Cancel any current CDDA Scanning (unnecessary for AV streams, since I-Frame notification
- // has already been cancelled).
- // if ((PST_SCAN == gcs.pstate) && (CDDA_SID == g_pSVCDNav->m_uCurrAudioSID))
- if (PST_SCAN == gcs.pstate)
- OnScan(0);
- gcs.pstate= PST_STILL;
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnAutoPauseEngaged() -
- // Handels an Auto-Pause Event, issued by the OnRendezvous() handler.
- //
- // Input:
- // None
- //
- // Output:
- // According to the value of the Pause-Period as defined by the current List, the internal
- // Auto-Pause-Period Timer is set.
- static void OnAutoPauseEngaged(void)
- {
- BYTE uPausePeriod;
- dbg_printf(("OnAutoPauseEngaged()n"));
- // Ignore this event if PBC is not being used (meaningless)
- if (! g_pSVCDNav->m_bIsUsingPSD)
- return;
- // Check if there's still a point in starting an Auto-Pause
- if ((PST_PLAY != gcs.pstate) && (PST_SLOW != gcs.pstate))
- return;
- // The Auto-Pause can only be engaged inside a PlayList Item; therefore, the current List
- // must be a Play-List.
- // Examine the value of the Auto-Pause Period Field, and act accoringly.
- uPausePeriod= ((SHARED_INFO.m_CurrList).PlayList).wAutoPausePeriod;
- if (0 == uPausePeriod) {
- // No need to execute any Pause. Continue playback.
- dbg_printf(("Zero Pause-Period defined for the current PlayList. Ignored.n"));
- return;
- }
- // Pause the playback
- PE_CD_PausePlayback(TRUE, g_pSVCDNav->m_uCurrAudioSID);
- gcs.pstate= PST_PAUSE;
- // Enable Play, Next and Previous
- SET_COP_MASK(COP_PLAY | COP_PREVIOUS_CHAPTER | COP_NEXT_CHAPTER);
- // Start the Pause-Period Counter
- if (0xFF == uPausePeriod)
- g_pSVCDNav->m_dwPausePeriod= SVCD_INFINITE;
- else
- g_pSVCDNav->m_dwPausePeriod= SVCD_TICKS_PER_SECOND * (((WORD)uPausePeriod <= 60) ? uPausePeriod: (60 + (((WORD)uPausePeriod - 60) * 10)));
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnStop(enSVCD_StopType eStopType) -
- // Handels an IE_CORE_PAUSE and an IE_CORE_STOP Event.
- //
- // Input:
- // eStopType - The type of Stopping requested
- //
- // Output:
- // Playback is stopped or paused, depending on the type of event that was received.
- // For a STOP event, the current position is also recorded in order to allow playback
- // to resume from that point in the future.
- static void OnStop(enSVCD_StopType eStopType)
- {
- BOOL bResumeOnDigest = TRUE;
- dbg_printf(("OnStop()n"));
- // <<< ZKR GL050104 : Eliminate unnecessary sequence header reads.
- #if defined(ENHANCED_SEQ_HDR_READING) || defined(EXINO2)
- g_ucReadSeqHdr = FALSE;
- #endif
- // >>>
- #ifdef SVCD_DIGEST_SUPPORT
- //checking if we are on digest mode
- if (g_pSVCDNav->m_bDigestMode) {
- //The stop resume mechanism should only work when we were on Track-digest
- //because when we are on stop mode the address is -1
- if (eTrackView != Digest_getDigestMode())
- bResumeOnDigest = FALSE;
- _terminateDigestMode();
- }
- #endif //SVCD_DIGEST_SUPPORT
- // Cancel Error-Recovery Mechanism(s)
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
- (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= 0;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
- #ifdef WATCHDOG_TRIGGERED_BY_FE
- PE_CD_CancelNotification( StuckTrigger );
- #endif
-
- PE_CD_CancelNotification(TriggerBit);
-
- //DAC_SetMute(TRUE);
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(TRUE);
- #endif //DIGITAL_AMPLIFIER_ENABLE
- // If Scanning is in progress, eliminate it
- if (PST_SCAN == gcs.pstate)
- {
- OnScan(0);
- //<<<Hannah_0923_2004 To wait for the DVP decode one picture before Send pause command. //jeanz_1115_2004 Move the patch from I64
- {
- UINT8 uPictureCnt;
- UINT16 uStatus2;
- UINT16 utry = 5;
- // Extract the value of the Picture-Counter
- while (utry--)
- {
- uStatus2 = inport(I64_STATUS_2);
- uPictureCnt = (UINT8)((uStatus2 & (UINT16)DEC_LL_STATUS2_DEC_PIC_CNTR_MASK) >> DEC_LL_STATUS2_DEC_PIC_CNTR_SHIFT);
- printf("n****** Wait for the DVP to docoder the picture before pause.uPictureCnt = %d utry = %dn",uPictureCnt,utry);
- if(uPictureCnt<2)
- usleep(250000UL);
- else
- break;
- }
- if(!utry)
- printf("n Time out to wait for the DVP decoder one Picture!!! n");
- }
- }
- // If Slow-Motion is in progress, cancel it
- if (PST_SLOW == gcs.pstate)
- {
- OnSlow(0);
- //<<<Hannah_0923_2004 To wait for the DVP decode one picture before Send pause command. //jeanz_1115_2004 Move the patch from I64
- {
- UINT8 uPictureCnt;
- UINT16 uStatus2;
- UINT16 utry = 5;
- // Extract the value of the Picture-Counter
- while (utry--)
- {
- uStatus2 = inport(I64_STATUS_2);
- uPictureCnt = (UINT8)((uStatus2 & (UINT16)DEC_LL_STATUS2_DEC_PIC_CNTR_MASK) >> DEC_LL_STATUS2_DEC_PIC_CNTR_SHIFT);
- printf("n****** Wait for the DVP to docoder the picture before pause.uPictureCnt = %d utry = %dn",uPictureCnt,utry);
- if(uPictureCnt<2)
- usleep(250000UL);
- else
- break;
- }
- if(!utry)
- printf("n Time out to wait for the DVP decoder one Picture!!! n");
- }
- }
- switch (eStopType)
- {
- case ePause:
- // Make sure that there's need to pause
- if (PST_STILL == gcs.pstate) {
- dbg_printf(("Cannot Pause during a Still Image. Ignored.n"));
-
- if (PS_GET_ANALOG_AUDIO_SETTING() != NO_ANALOG_AUDIO)
- {
- //DAC_SetMute(FALSE);
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(FALSE);
- #endif //DIGITAL_AMPLIFIER_ENABLE
- }
- return;
- }
- dbg_printf(("Pausing current playback.n"));
- PE_CD_PausePlayback(TRUE, g_pSVCDNav->m_uCurrAudioSID);
- gcs.pstate= PST_PAUSE;
- break;
- case eStopResume:
- // <<< ZKR GL050104 : Eliminate unnecessary sequence header reads.
- #if defined(ENHANCED_SEQ_HDR_READING) || defined(EXINO2)
- g_ucReadSeqHdr = TRUE;
- #endif
- // >>>
- case eFullStop:
- // Record the current position
- dbg_printf(("Stopping playback. Current-position recorded.n"));
- // Cancel Intro Playmode
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- if ((eStopResume == eStopType) && bResumeOnDigest)
- SetMarker(eResumePlayback, 0);
- else {
- #ifndef K1_WL
- ClearMarker(eResumePlayback,0);
- #endif
- //add by wl033004 for set the play mode to normal after full stop
- #ifdef K1_WL
- if ( PM_IsPlaybackProgram(PM_GetPlaybackMode()) || PM_IsPlaybackIntro(PM_GetPlaybackMode())
- #ifdef D_ENABLE_SHUFFLE_MODE
- || PM_IsPlaybackShuffle(PM_GetPlaybackMode())
- #endif
- )
- {
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- mode_set_private_program_size(0);
- OnModeChange();
- }
- #endif
- //add by wl033004 for set the play mode to normal after full stop
- // Rewind the Current-Position to the Program-Beginning
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined; // The type of the first List is yet undetermined
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= 0; // The first List is at the beginning of the PSD
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // By default, begin with the first item in the List
- (SHARED_INFO.m_CurrPosition).dwStartAddress= -1; // The address is yet undefined
- }
- PE_CD_AbortPlayback((eStopResume == eStopType) ? TRUE : FALSE);
- if (PST_STOP != gcs.pstate) {
- gcs.pstate= PST_STOP;
- CLEAR_COP_MASK(COP_PAUSE | COP_SLOW | COP_SCAN | COP_SCAN_BACKWARD | COP_STEP);
- // Cancel any current Repeat-Modes
- if (eStopResume != eStopType) //BT0407: only full stop cancel repeat mode
- CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
- // Display Logo
- PE_CD_DisplayLogo();
- }
- break;
- }
- if (PS_GET_ANALOG_AUDIO_SETTING()!=NO_ANALOG_AUDIO)
- {
- //DAC_SetMute(FALSE);
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(FALSE);
- #endif //DIGITAL_AMPLIFIER_ENABLE
- }
- // Enable Play, Next and Previous
- SET_COP_MASK(COP_PLAY | COP_PREVIOUS_CHAPTER | COP_NEXT_CHAPTER);
- // Terminate any pending Rendezvous events
- g_pSVCDNav->m_dwTimeout= SVCD_INFINITE;
- g_pSVCDNav->m_dwWaitTime= SVCD_INFINITE;
- g_pSVCDNav->m_dwPausePeriod= SVCD_INFINITE;
-
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnStep() -
- // Handels an IE_CORE_STEP Event.
- //
- // Input:
- // None
- //
- // Output:
- // The appropriate PE method is called to step forward.
- static void OnStep(void)
- {
- dbg_printf(("OnStep()n"));
- if (PST_PAUSE != gcs.pstate) {
- dbg_printf(("Step is illegal when not Pausing. Ignored.n"));
- return;
- }
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- PE_CD_Step();
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnModeChange() -
- // Handels an IE_CORE_SEAMLESS_MODE_CHANGE Event.
- //
- // Input:
- // None
- //
- // Output:
- // The playback flow is changed according to the exact Mode that has changed.
- //
- // Remarks:
- // This handler first determines what kind of Mode change has occurred.
- // According to the change, different actions are taken:
- // - If PBC has been turned Off, a seamless transition is performed, and the current
- // item continues playback;
- // - If PBC has been turned On, the current playback is unconditionally stopped and restarted
- // from the first List.
- // - If Shuffle has been turned On, then: if the current state is Playing, the transition
- // is seamless by suffling everything except the current item, and placing the current item
- // at the beginning of the Program-List.
- // If the current state is not Playing, a complete shuffle is performed.
- // - If Program has been turned On, the current playback is unconditionally stopped and
- // restarted from the first Program-List item.
- // - If Normal has been turned On, the current Program-List is purged and replaced with
- // a sequential Track-list (PBC must be Off).
- // Playback is then continued from that point on seamlessly.
- static void OnModeChange(void)
- {
- BYTE GetCurrentPlaybackMode = PM_GetPlaybackMode();
-
- dbg_printf(("OnModeChange()n"));
- // Cancel Intro Playmode
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- // Detect a transition of type: PBC -> Non-PBC
- if (PM_IsPBC(g_pSVCDNav->m_uCurrPlaybackMode) && ! PM_IsPBC(GetCurrentPlaybackMode)) {
- WORD uEntry;
- BOOL bReinvokePlayback= FALSE;
- dbg_printf(("PBC -> No PBCn"));
- g_pSVCDNav->m_bIsUsingPSD= FALSE;
- PE_CD_CancelNotification(TriggerBit);
- // Rebuild the Normal Program-List (sequential playback of the Tracks)
- PM_InitializeProgramList();
- for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
- PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- // Reset the Resumption-point
- ClearMarker(eResumePlayback, 0);
- core_clear_bookmark_info( 0 ); // clear all bookmarks
- // If the current List is a Selection-List and there's an image displaying, then
- // re-invoke playback from the beginning.
- // if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && (PST_STILL == gcs.pstate)) {
- if ( SHARED_INFO.uCurrentTrackNumber == 1 ){
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- bReinvokePlayback= TRUE;
- }
- // If the current List is a Play-List, and the current Playback-Status is not Stopped,
- // then:
- // - If the current Play-Item is a Track or an Entry, and the Playing time is not set,
- // continue playback of the current Item, but set the Current-Position to the
- // corresponding Track.
- // - Otherwise, stop the current playback and re-invoke playback from the beginning.
- if ((PlayList == (SHARED_INFO.m_CurrPosition).ListType) && (PST_STOP != gcs.pstate)) {
- // If the Playing-Time is not "Play until finish", then the current playback must be
- // stopped and re-invoked from the beginning.
- if (0 != ((SHARED_INFO.m_CurrList).PlayList).uPlayingTime) {
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- bReinvokePlayback= TRUE;
- }
- else {
- // Since the current Play-Item will play until its end, it is safe to perform a truely
- // seamless transition (provided that the current Play-Item is either a Track or an Entry).
- BYTE aBuffer[2];
- WORD uPlayItemNumber;
- DWORD dwPSD_Offset= ((SHARED_INFO.m_CurrPosition).dwPSD_Offset + SVCD_PLAYLIST_HDR_SIZE
- + (2 * ((SHARED_INFO.m_CurrPosition).uListItem - 1)));
- // Find-out which Track is being played-back
- if (! _getPSDRecord(dwPSD_Offset, 2, aBuffer)) {
- dbg_printf(("Failed to retrieve PSD information.n"));
- return;
- }
-
- uPlayItemNumber= (((WORD)aBuffer[0] << 8) | aBuffer[1]);
-
- if ((uPlayItemNumber >= 2) && (uPlayItemNumber <= 99)) {
- // The current Play-Item is a Track
- (SHARED_INFO.m_CurrPosition).uListItem= (uPlayItemNumber - 1);
- }
- else if ((uPlayItemNumber >= 100) && (uPlayItemNumber <= 599)) {
- // The current Play-Item is an Entry
- BYTE aBuffer[4];
-
- //sc_Read(g_uEntriesTableOffset + (SVCD_ENTRY_SIZE * (uPlayItemNumber-100) / BYTE_PER_CONTAINER),
- // (SVCD_ENTRY_SIZE / BYTE_PER_CONTAINER), (Sc_cont*)aBuffer);
- Array_getAt(g_hEntriesTable, (uPlayItemNumber - 100), (BYTE *)aBuffer);
- (SHARED_INFO.m_CurrPosition).uListItem= ((WORD)drv_bcd2bin(aBuffer[0]) - 1);
- }
- else {
- // The current Play-Item is a Segment - the playback must be restarted
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- bReinvokePlayback= TRUE;
- }
- }
- }
- if ( ( SelectionList == ( SHARED_INFO.m_CurrPosition).ListType ) && ( PST_STOP != gcs.pstate ) ) {
- if ( ( gns.svcd.m_CurrList.SelectionList.uPlayItemNumber > 1 )
- && ( gns.svcd.m_CurrList.SelectionList.uPlayItemNumber <= 99 ) ){
- gns.svcd.m_CurrPosition.dwPSD_Offset = 0xFFFF;
- gns.svcd.m_CurrPosition.dwStartAddress = -1;
- gns.svcd.m_CurrPosition.uListItem = gns.svcd.m_CurrList.SelectionList.uPlayItemNumber - 1;
- }
- }
- if (bReinvokePlayback) {
- // Re-invoke playback, if necessary
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to re-invoke playback after PBC change.n"));
- gcs.pstate= PST_STOP;
- }
- }
- // Update the current Playback-Mode
- g_pSVCDNav->m_uCurrPlaybackMode= GetCurrentPlaybackMode;
- return;
- }
- // Continue checking for other Mode-Transitions only if the PSD information is not being
- // used.
- if (g_pSVCDNav->m_bIsUsingPSD) {
- dbg_printf(("Mode-Changes are disabled when PSD Information is being used. Ignored.n"));
- return;
- }
- ClearMarker(eResumePlayback, 0);
- core_clear_bookmark_info( 0 ); // clear all bookmarks
- // Find-out what kind of mode has changed: the Playback-Mode or the Repeat-Mode
- // If the change is not in Playback-Mode, then nothing to do.
- if (g_pSVCDNav->m_uCurrPlaybackMode == GetCurrentPlaybackMode) {
- //Dm061902 prevent using empty playlist
- if(PM_GetProgramSize() <= 0)
- {
- WORD uEntry;
- // Rebuild the Normal Program-List (sequential playback of the Tracks)
- PM_InitializeProgramList();
- for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
- PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
- }
- dbg_printf(("No Playback-Mode change detected.n"));
- return;
- }
- // Cancel any current Repeat-Modes
- CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
- // Detect a transition of type: Non-Shuffle -> Shuffle
- if (! PM_IsPlaybackShuffle(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPlaybackShuffle(GetCurrentPlaybackMode)) {
- dbg_printf(("Non-Shuffle -> Shufflen"));
- if(PM_GetProgramSize() <= 0)
- {
- WORD uEntry;
- // Rebuild the Normal Program-List (sequential playback of the Tracks)
- PM_InitializeProgramList();
- for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
- PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
- }
- // If the current Playback-Status is other than Stopped, shuffle the Program-List while
- // keeping the current item as the first item
- if (PST_STOP != gcs.pstate)
- PM_ShuffleProgramList(TRUE, (SHARED_INFO.m_CurrPosition).uListItem);
- else
- PM_ShuffleProgramList(FALSE, 0);
- // Now set the Current-Item to Item #1
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- }
- // Detect a transition of type: Non-Normal -> Normal
- if (! PM_IsPlaybackNormal(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPlaybackNormal(GetCurrentPlaybackMode)) {
- WORD uEntry;
- WORD uCurrTrack= (WORD) PM_GetProgramListEntry((SHARED_INFO.m_CurrPosition).uListItem);
- dbg_printf(("Non-Normal -> Normaln"));
- // Rebuild the Normal Program-List (sequential playback of the Tracks)
- PM_InitializeProgramList();
- for (uEntry=1; uEntry < (WORD) PE_CD_GetTracksCnt(); uEntry++)
- PM_SetProgramListEntry((WORD)uEntry, (WORD)(uEntry+1));
- // Now update the Current-Position to point at the Entry holding the current-Track,
- // if playback is currently in progress
- if (PST_STOP != gcs.pstate)
- (SHARED_INFO.m_CurrPosition).uListItem= (uCurrTrack - 1);
- else
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- }
- // Detect a transition of type: Non-Program -> Program
- if (! PM_IsPlaybackProgram(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPlaybackProgram(GetCurrentPlaybackMode)) {
- dbg_printf(("Non-Program -> Programn"));
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- if (PST_STOP != gcs.pstate) {
- // Abort current playback, if any
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to re-invoke playback after Playback-Mode change.n"));
- gcs.pstate= PST_STOP;
- }
- }
- }
- // Detect a transition of type: Non-PBC -> PBC
- if (! PM_IsPBC(g_pSVCDNav->m_uCurrPlaybackMode) && PM_IsPBC(GetCurrentPlaybackMode)) {
- dbg_printf(("Non PBC -> PBCn"));
- if (0 == (g_pSVCDNav->m_NavigationInfo).ulPSD_Size) {
- dbg_printf(("PBC Cannot be turned-on for this Disc. Ignored.n"));
- PM_SetPBC(FALSE);
- return;
- }
- g_pSVCDNav->m_bIsUsingPSD= TRUE;
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- PM_ReConstructProgramListEntry();/*Stivenz_0201_2005:need reconstruct progm list, in case play mode change from shuff mode and it will shuff the progm list*/
- // Reset the Current-Position
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined; // The type of the first List is yet undetermined
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= 0; // The first List is at the beginning of the PSD
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // By default, begin with the first item in the List
- (SHARED_INFO.m_CurrPosition).dwStartAddress= -1; // The address is yet undefined
- if (PST_STOP != gcs.pstate) {
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to re-invoke playback after PBC change.n"));
- gcs.pstate= PST_STOP;
- }
- }
- }
- // Update the current Playback-Mode
- g_pSVCDNav->m_uCurrPlaybackMode= GetCurrentPlaybackMode;
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSetMarkerA() -
- // Sets the PositionA marker.
- //
- // Input:
- // None
- //
- // Output:
- // None. PositionA marker is set.
- static void OnSetMarkerA(void)
- {
- dbg_printf(("OnSetMarkerA()n"));
- // Allow setting of Marker-A only for Non-PBC playback; or for PBC playback, provided that:
- // the current List is a Play-List, or the current list is a Selection-List and the Elapsed
- // Time is Valid (i.e. the current PIN is not a Segment).
- if (! g_pSVCDNav->m_bIsUsingPSD || (PlayList == (SHARED_INFO.m_CurrPosition).ListType) ||
- ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) && SHARED_INFO.bIsElapsedTimeValid))
- {
- if(SHARED_INFO.iCurrentTime !=0 )
- {
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
-
- SetMarker(eMarkerA, 0);
- PM_SetRepeatAB(PM_REPEAT_AB_A);
- ie_send(IE_UI_STATE_CHANGE);
- }
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSetMarkerB() -
- // Sets the PositionB marker.
- //
- // Input:
- // None
- //
- // Output:
- // None. PositionB marker is set, and then playback is stopped and resumed from the
- // PositionA marker.
- static void OnSetMarkerB(void)
- {
- dbg_printf(("OnSetMarkerB()n"));
- SetMarker(eMarkerB, 0);
- // Prohibit an A-B Segment of less than 2 Second
- if (((g_pSVCDNav->m_PositionB).dwStartAddress - (g_pSVCDNav->m_PositionA).dwStartAddress) < 2*SVCD_BLOCKS_PER_SECOND)
- {
- // Force a 2 Second gap between Point-A and Point-B
- (g_pSVCDNav->m_PositionB).dwStartAddress= (g_pSVCDNav->m_PositionA).dwStartAddress + 2*SVCD_BLOCKS_PER_SECOND;
- }
- //<<<ZCH MikeX_0905_2003_A: make the mark B point not at the last 2 second of current track
- if( g_pSVCDNav->m_aCurrTrack[1] - (g_pSVCDNav->m_PositionB).dwStartAddress < 2*SVCD_BLOCKS_PER_SECOND)
- {//forbit mark B point at the last 2 second of current track
- (g_pSVCDNav->m_PositionB).dwStartAddress = g_pSVCDNav->m_aCurrTrack[1] - 2*SVCD_BLOCKS_PER_SECOND;
- if (((g_pSVCDNav->m_PositionB).dwStartAddress - (g_pSVCDNav->m_PositionA).dwStartAddress) < 2*SVCD_BLOCKS_PER_SECOND)
- //Force a 2 Second gap between Point-A and Point-B
- (g_pSVCDNav->m_PositionA).dwStartAddress= (g_pSVCDNav->m_PositionB).dwStartAddress - 2*SVCD_BLOCKS_PER_SECOND;
- }
- //ZCH MikeX_0905_2003_A>>>
- // Stop Playback
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- // Move the Current-Position to Point-A
- memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_PositionA), sizeof(SVCD_Marker));
- if (g_pSVCDNav->m_bIsUsingPSD) {
- // Check the current value of the Repeat-Counter. If it is Zero or negative, then force a
- // single iteration of the Selection-List Play-Item when resuming playback.
- if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) &&
- (0 >= ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt)) {
- ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
- }
- }
- // Invoke A-B Repeat mode, and start Playback
- PM_SetRepeatAB(PM_REPEAT_AB_B);
- // <<< SEC shKang051304 : for Supporting the Slow Repeat A-B
- #ifdef EXINO2
- if( !( SHARED_INFO.m_iSlowSpeed != 0 && gcs.pstate == PST_SLOW ) )
- #endif
- // SEC shKang051304 >>>
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current List.n"));
- gcs.pstate= PST_STOP;
- }
- ie_send(IE_UI_STATE_CHANGE);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnCancelABRepeat(void) -
- // Clears the current REPEAT_AB mode.
- //
- // Input:
- // None
- //
- // Output:
- // Both PositionA and PositionB are cleared, and the REPEAT_AB mode is explicitly turned Off.
- static void OnCancelABRepeat(void)
- {
- dbg_printf(("OnCancelABRepeat()n"));
- ClearMarker(eMarkerA, 0);
- ClearMarker(eMarkerB, 0);
- PM_SetRepeatAB(0);
- ie_send(IE_UI_STATE_CHANGE);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnGoToBookmark(WORD uBookmarkNumber) -
- // Handles an IE_CORE_GOTO_BOOKMARK Event.
- //
- // Input:
- // uBookmarkNumber - The number of Bookmark to go to.
- //
- // Output:
- // None. Playback is restarted from the desired Bookmark.
- //
- // Remarks:
- // The handler checks validity of the selected Bookmark. If the Bookmark number is legal
- // and the requested Bookmark is valid, then the current playback is unconditionally
- // stopped and resumed from the position recorded by the requested Bookmark.
- static void OnGoToBookmark(WORD uBookmarkNumber)
- {
- dbg_printf(("OnGoToBookmark(%d)n", uBookmarkNumber));
- // Make sure that the requested Bookmark is still valid
- if ((uBookmarkNumber >= SVCD_MAX_BOOKMARKS) ||
- (-1 == (g_pSVCDNav->m_Bookmarks[uBookmarkNumber]).dwPSD_Offset)) {
- dbg_printf(("Bookmark #%d is invalid. Ignored.n", uBookmarkNumber));
- return;
- }
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- // Stop any ongoing playback
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- // Cancel any current Repeat-Modes
- CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
- // Set the Current-Position to hold the selected Bookmark
- memcpy(&(SHARED_INFO.m_CurrPosition), &(g_pSVCDNav->m_Bookmarks[uBookmarkNumber]), sizeof(SVCD_Marker));
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined; // Force re-parsing of the current List
- if (g_pSVCDNav->m_bIsUsingPSD) {
- // Check the current value of the Repeat-Counter. If it is Zero or negative, then force a
- // single iteration of the Selection-List Play-Item when resuming playback.
- if ((SelectionList == (SHARED_INFO.m_CurrPosition).ListType) &&
- (0 >= ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt)) {
- ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt= 1;
- }
- }
- if (PST_SCAN == gcs.pstate) {
- // Cancel the on-going Scan
- OnScan(0);
- }
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current List.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnScan(int iSpeed) -
- // Handles an IE_CORE_SCAN Event.
- //
- // Input:
- // iSpeed - Holds the speed to scan at.
- //
- // Output:
- // None. Scanning is started, if possible.
- //
- // Remarks:
- // The handler verifies that there is some Play-Item currently in playback, and
- // then switches the Playback-state to SCAN, sets the scanning-speed and requests
- // notification of the next I-Frame.
- static void OnScan(int iSpeed)
- {
- DWORD dwCurrLocationForCDDA;
- dbg_printf(("OnScan(%d)n", iSpeed));
- if ((PST_STOP == gcs.pstate) || (PST_STILL == gcs.pstate)) {
- dbg_printf(("Cannot scan during a Stop. Ignored.n"));
- return;
- }
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- dwCurrLocationForCDDA= PE_CD_GetDecoderCurrentLocationLBN();
- //setting the operation mask to enable/disable play while scanning
- if (0 != iSpeed)
- SET_COP_MASK(COP_PLAY);
- else if (!g_pSVCDNav->m_bIsUsingPSD)
- CLEAR_COP_MASK(COP_PLAY);
- // If currently Pausing, first resume playback
- if (PST_PAUSE == gcs.pstate)
- PE_CD_PausePlayback(FALSE, g_pSVCDNav->m_uCurrAudioSID);
- 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
- {
- //If only change scan speed
- SHARED_INFO.m_iScanSpeed= ((iSpeed >= 0) ? iSpeed : (iSpeed - 1));
- return;
- }
- // Switch to Time-Measurement based on the MSF
- (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE;
- // Record the current Scanning-speed, and issue a request for I-Frame notification
- // Note: if the speed is Negative, then increase it by one, to prevent getting stuck at the
- // same position.
- SHARED_INFO.m_iScanSpeed= ((iSpeed >= 0) ? iSpeed : (iSpeed - 1));
- if (0 != iSpeed)
- {
- CLEAR_COP_MASK(COP_ABREPEAT);
- // Start Scanning
- PE_CD_SetScan(TRUE, g_pSVCDNav->m_uCurrAudioSID, SHARED_INFO.m_iScanSpeed);
- gcs.pstate= PST_SCAN;
- if (CDDA_SID != g_pSVCDNav->m_uCurrAudioSID) {
- // For AV Tracks only, request I-Frame notification
- PE_CD_RequestNotification(IFrame);
- //cancel Trigger Bit notification
- PE_CD_CancelNotification(TriggerBit);
- // Engage the Error-Recovery mehcanism for I-Frame Display Miss
- (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_IFRAME_MISS_TIMEOUT;
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eIFrameDisplayMiss;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302: Not acutual needed here
- #ifdef WATCHDOG_TRIGGERED_BY_FE
- PE_CD_RequestNotification( StuckTrigger );
- #endif
- }
- else {
- DWORD dwScanStart;
- ULONG ulBlocksCnt;
- // For CDDA Tracks, first stop the playback, and then renew from the same
- // position. This is required for correct Scanning of CDDA.
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
-
- if (iSpeed > 0) {
- dwScanStart= dwCurrLocationForCDDA;
- ulBlocksCnt= (g_pSVCDNav->m_aCurrTrack[1] - dwCurrLocationForCDDA);
- }
- else {
- dwScanStart= g_pSVCDNav->m_aCurrTrack[0];
- ulBlocksCnt= (dwCurrLocationForCDDA - g_pSVCDNav->m_aCurrTrack[0]);
- }
-
- // Initiate the Error-Recovery Mechanism for Playback-Hangup
- (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_PB_HANGUP_TIMEOUT;
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= ePlaybackHangup;
- (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= dwScanStart;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
- #ifdef CDDA_MUTE_ON_SCAN
- PE_CD_SetMute(TRUE);
- #endif //CDDA_MUTE_ON_SCAN
- if (! PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID,
- dwScanStart, ulBlocksCnt, eSearch, iSpeed))
- {
- dbg_printf(("Failed to re-invoke Playback.n"));
- return;
- }
- PE_CD_SetCurrentLocationLBN_Bakcup(dwScanStart);
- }
- dbg_printf(("Scanning-Speed: %d.n", SHARED_INFO.m_iScanSpeed));
- }
- else
- {
- SET_COP_MASK(COP_ABREPEAT);
- // Stop Scanning
- PE_CD_SetScan(FALSE, g_pSVCDNav->m_uCurrAudioSID, SHARED_INFO.m_iScanSpeed);
- #ifdef K1_WL
- gcs.pstate= PST_PLAY; //add by wl032404
- #endif
- // Initiate the Error-Recovery Mechanism for Playback-Hangup
- (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_PB_HANGUP_TIMEOUT;
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= ePlaybackHangup;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302
- if (CDDA_SID != g_pSVCDNav->m_uCurrAudioSID) {
- (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= PE_CD_GetCurrentLocation();
- if (g_pSVCDNav->m_bIsUsingPSD)
- PE_CD_RequestNotification(TriggerBit);
- #ifdef WATCHDOG_TRIGGERED_BY_FE
- PE_CD_RequestNotification( StuckTrigger );
- #endif
- }
- else {
- // For CDDA Tracks, first stop the playback, and then renew from the same
- // position. This is required for correct Scanning of CDDA.
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- // Adjust the Error-Recovery Mechanism for Playback-Hangup
- (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= dwCurrLocationForCDDA;
- #ifdef CDDA_MUTE_ON_SCAN)
- PE_CD_SetMute(FALSE);
- #endif //CDDA_MUTE_ON_SCAN
- if (! PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID,
- dwCurrLocationForCDDA,
- (g_pSVCDNav->m_aCurrTrack[1] - dwCurrLocationForCDDA),
- eNormalSpeed, iSpeed))
- {
- dbg_printf(("Failed to re-invoke Playback.n"));
- return;
- }
- PE_CD_SetCurrentLocationLBN_Bakcup(dwCurrLocationForCDDA);
- }
- dbg_printf(("Scanning stopped.n"));
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnIFrameDisplayed() -
- // Handles an IE_CORE_I_FRAME Event.
- //
- // Input:
- // None
- //
- // Output:
- // None. The playback is skipped forward/backwards in order to seek and present the next
- // I-Frame.
- //
- // Remarks:
- // The handler checks the direction of the current Scan.
- // In case of a forward scan, the current playback is halted and restarted from a position
- // further down the stream.
- // In the case of a backwards scan, the current playback is halted and restarted from a
- // position preceding the current one.
- // In both cases, if the next position is outside the boundaries of the current Playing-Segment,
- // the appropriate action is performed; i.e.: the next item (in forward scan) or the previous
- // item (in backwards scan) is invoked.
- static void OnIFrameDisplayed(void)
- {
- BOOL bInsideSegmentBoundaries= TRUE;
- DWORD dwCurrLocation= -1;
- DWORD dwNextLocation;
- BOOL bLocationFromDriveValid = FALSE;
- dbg_printf(("OnIFrameDisplayed()n"));
- SET_COP_MASK(COP_SCAN);//LX090502
- //<<<LX051302: Clear retry coutner since we got one Iframe
- if ( 0 != (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter ){
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;
- // (g_pSVCDNav->m_ErrorRecoveryInfo).dw
- dbg_printf(("Clear error retry countern"));
- }
- //LX051302>>>
-
- // Make sure that Scanning is still active
- if ( ((PST_SCAN != gcs.pstate) || (0 == SHARED_INFO.m_iScanSpeed))
- &&(PST_SLOW != gcs.pstate)
- ){
- dbg_printf(("Scanning cancelled. Ignored.n"));
- dwCurrLocation= -1; // Reset the Scan position
- return;
- }
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
- #ifdef WATCHDOG_TRIGGERED_BY_FE
- PE_CD_CancelNotification( StuckTrigger );
- #endif
- dwCurrLocation=PE_CD_GetCurrentLocation();
- (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= dwCurrLocation;
- // Abort the current Playback, without changing Decoder mode
- PE_CD_AbortPlayback(TRUE);//LX090502
- // Check if dwCurrentLocation valid
- bLocationFromDriveValid = ( ( g_pSVCDNav->m_aCurrTrack[0] <= dwCurrLocation ) &&
- ( g_pSVCDNav->m_aCurrTrack[1] >= dwCurrLocation ) ) ?
- TRUE : FALSE;
- // If this is the first I-Frame of the current Scan, use the Beginning/End address
- // of the Current Segment as the reference for scanning, depending on the Scanning direction.
- // if (-1 == dwCurrLocation) {
- if ( !bLocationFromDriveValid ){
- if (SHARED_INFO.bIsElapsedTimeValid) {
- #ifdef SVCD_USE_ABSOLUTE_TIME
- if (!g_pSVCDNav->m_bIsUsingPSD)
- dwCurrLocation = (g_pSVCDNav->m_dwSecondTrackAddress + (SHARED_INFO.iCurrentTime * g_pSVCDNav->m_aCurrTrack[2]));
- else
- dwCurrLocation = (g_pSVCDNav->m_aCurrTrack[0] + (SHARED_INFO.iCurrentTime * g_pSVCDNav->m_aCurrTrack[2]));
- #else
- dwCurrLocation = (g_pSVCDNav->m_aCurrTrack[0] + (SHARED_INFO.iCurrentTime * g_pSVCDNav->m_aCurrTrack[2]));
- #endif //SVCD_USE_ABSOLUTE_TIME
- }
- }
- // Calculate the Next target location; avoid slipping over the edge
- if (SHARED_INFO.m_iScanSpeed != 0)
- {
- dwNextLocation= (dwCurrLocation + (SHARED_INFO.m_iScanSpeed * g_pSVCDNav->m_aCurrTrack[2]));
- }
- else if (SHARED_INFO.m_iSlowSpeed != 0)
- {
- DWORD dwSlowBackGap;
- dwSlowBackGap = (abs(SLOW_SCAN_SPEED) * g_pSVCDNav->m_aCurrTrack[2])>>2;
- (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS = 0;
- dwNextLocation= g_pSVCDNav->dwSlowRCurrentPosition - dwSlowBackGap;
- g_pSVCDNav->dwSlowRCurrentPosition = dwNextLocation;
- }
-
- if ((INT32)dwNextLocation < 0)
- dwNextLocation= 0;
- // Check the Scanning-direction, and act accordingly
- if (SHARED_INFO.m_iScanSpeed > 0) {
- // Forward-scan: Check for a Rendezvous-condition during A-B Repeat
- if ((PM_GetRepeatAB() & PM_REPEAT_AB_B) &&
- ((g_pSVCDNav->m_PositionB).dwStartAddress < dwNextLocation))
- {
- // Make sure that there is a perfect match between the PositionB Marker and
- // the current location.
- if ( ((g_pSVCDNav->m_PositionB).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
- ((g_pSVCDNav->m_PositionB).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
- ((g_pSVCDNav->m_PositionB).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
- {
- OnRendezvousPoint(ePositionB);
- return;
- }
- }
- // Continue Scanning
- if (dwNextLocation < g_pSVCDNav->m_aCurrSegment[1]) {
- // The next sub-segment to skip to is within the boundaries of the current segment
- dwCurrLocation= dwNextLocation;
- }
- else {
- bInsideSegmentBoundaries= FALSE;
- dwCurrLocation= -1;
- // The next sub-segment to skip to is beyond the current segment -- jumpt to the next
- // item, via reporting a Playback-Finish event.
- #ifdef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- // Cancel the on-going Scanning
- OnScan(0);
- gcs.pstate= PST_PLAY;
- #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- OnPlaybackFinished();
- #ifndef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- OnScan(SHARED_INFO.m_iScanSpeed);
- #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- }
- }
- else if ( ( SHARED_INFO.m_iScanSpeed < 0 ) || ( SHARED_INFO.m_iSlowSpeed < 0 )){
- // Backwards-scan: Check for a Rendezvous-condition during A-B Repeat
- if ((PM_GetRepeatAB() & PM_REPEAT_AB_B) &&
- (dwNextLocation <= (g_pSVCDNav->m_PositionA).dwStartAddress))
- {
- // Make sure that there is a perfect match between the PositionA Marker and
- // the current location.
- if ( ((g_pSVCDNav->m_PositionA).ListType == (SHARED_INFO.m_CurrPosition).ListType) &&
- ((g_pSVCDNav->m_PositionA).dwPSD_Offset == (SHARED_INFO.m_CurrPosition).dwPSD_Offset) &&
- ((g_pSVCDNav->m_PositionA).uListItem == (SHARED_INFO.m_CurrPosition).uListItem) )
- {
- OnRendezvousPoint(ePositionA);
- return;
- }
- }
- // Continue Scanning
- if (dwNextLocation > g_pSVCDNav->m_aCurrSegment[0]) {
- // The previous sub-segment to skip to is within the boundaries of the current segment
- dwCurrLocation= dwNextLocation;
- }
- else {
- bInsideSegmentBoundaries= FALSE;
- dwCurrLocation= -1;
- #ifdef SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- // The previous sub-segment to skip to precedes the current segment -- restart playback
- // of the Current item
- OnScan(0);
- gcs.pstate= PST_PLAY;
- // If PBC is in use, force re-parsing of the Current List in order to accurately
- // play it from its beginning.
- if (g_pSVCDNav->m_bIsUsingPSD)
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to re-invoke Playback.n"));
- gcs.pstate= PST_STOP;
- }
- #else //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- // The previous sub-segment to skip to precedes the current segment -- jump to the previous item
- if ( ((! g_pSVCDNav->m_bIsUsingPSD) && (1 == (SHARED_INFO.m_CurrPosition).uListItem)) ||
- ((g_pSVCDNav->m_bIsUsingPSD && (PlayList == (SHARED_INFO.m_CurrPosition).ListType) &&
- (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset))) ||
- PM_IsRepeatSingle() )
- {
- // The beginning of the Program has been reached, or there is no Previous
- // item defined, or Single-Repeat is on: resume Normal Speed playback of the
- // First/Current item.
- OnScan(0);
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to re-invoke Playback.n"));
- gcs.pstate= PST_STOP;
- }
- ie_send(IE_UI_STATE_CHANGE);
- }
- else
- {
- // Move to the Previous item, while preserving the Scan mode
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- UINT16 uPrevTrackNum;
- TrackInfo prevTrack;
- DWORD dwPlaybackStartAddress;
- int iScanSlowSpeed;
- if ( PST_SLOW == gcs.pstate )
- iScanSlowSpeed = gns.svcd.m_iSlowSpeed;
- else
- iScanSlowSpeed = gns.svcd.m_iScanSpeed;
- // Move to the previous Item unconditionally, and re-invoke the Playback
- // while preserving the Scan mode.
- (SHARED_INFO.m_CurrPosition).uListItem--;
- uPrevTrackNum= PM_GetProgramListEntry((SHARED_INFO.m_CurrPosition).uListItem);
- if (! PE_CD_GetTrackInfo(uPrevTrackNum, &prevTrack)) {
- dbg_printf(("Failed to retrieve information for a Track.n"));
- return;
- }
- // Update the boundries of the Previous Track and Segment
- g_pSVCDNav->m_aCurrTrack[0] = prevTrack.dwStartAddress;
- g_pSVCDNav->m_aCurrTrack[1] = (g_pSVCDNav->m_aCurrTrack[0] + prevTrack.ulBlocksCnt);
- g_pSVCDNav->m_aCurrTrack[2] = _getBlocksPerSecond(uPrevTrackNum, prevTrack.ulBlocksCnt);
- g_pSVCDNav->m_aCurrSegment[0]= g_pSVCDNav->m_aCurrTrack[0];
- g_pSVCDNav->m_aCurrSegment[1]= g_pSVCDNav->m_aCurrTrack[1];
- tr_printf(("track range is between %lx an d%lxn", g_pSVCDNav->m_aCurrTrack[0], g_pSVCDNav->m_aCurrTrack[1]));
-
- // if ( PST_SLOW == gcs.pstate ){
- // dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[1] + (DWORD)(iScanSlowSpeed * (int)g_pSVCDNav->m_aCurrTrack[2]*64);
- // tr_printf(("slow dwstart addres is %lxn", dwPlaybackStartAddress ));
- // }
- // else{
- dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[1] + (DWORD)(iScanSlowSpeed * (int)g_pSVCDNav->m_aCurrTrack[2]*4);
- tr_printf(("scan dwstart addres is %lxn", dwPlaybackStartAddress ));
- // }
- if ( dwPlaybackStartAddress <= g_pSVCDNav->m_aCurrTrack[0] ){
- dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[0];
- tr_printf(("Set to track start addressn"));
- }
- g_pSVCDNav->dwSlowRCurrentPosition = dwPlaybackStartAddress;
-
- // if (!( ( 0 > gns.svcd.m_iScanSpeed ) && ( PST_SLOW == gcs.pstate ) && ( dwPlaybackStartAddress >= g_pSVCDNav->m_aCurrTrack[0] ) ))
- // dwPlaybackStartAddress = g_pSVCDNav->m_aCurrTrack[1] + SHARED_INFO.m_iScanSpeed * g_pSVCDNav->m_aCurrTrack[2];
-
- // Invoke the playback, while preserving the Scan mode
- PE_CD_RequestNotification(IFrame);
- if (! PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID,
- dwPlaybackStartAddress,
- (iScanSlowSpeed * g_pSVCDNav->m_aCurrTrack[2] * -1),
- eScan, SHARED_INFO.m_iScanSpeed))
- {
- dbg_printf(("Failed to play.n"));
- return;
- }
- PE_CD_SetCurrentLocationLBN_Bakcup(dwPlaybackStartAddress);
-
- // Update the Global Information
- SHARED_INFO.uCurrentTrackNumber= uPrevTrackNum;
- // Switch to Time-Measurement based on the MSF
- (g_pSVCDNav->m_TimeMeasurementInfo).bUsePTS= FALSE;
- // Engage the Error-Recovery mehcanism for I-Frame Display Miss
- (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_IFRAME_MISS_TIMEOUT;
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eIFrameDisplayMiss;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302: Not actual needed here
- }
- else {
- // For PBC mode, abort Scanning and move to the Previous item
- OnScan(0);
- gcs.pstate= PST_PLAY;
- OnPreviousItem();
- }
- }
- #endif //SVCD_PROHIBIT_SCAN_ACROSS_ITEM_BOUNDARIES
- }
- }
- if (bInsideSegmentBoundaries) {
- if (SHARED_INFO.m_iScanSpeed != 0)
- gcs.pstate= PST_SCAN;
- else
- if (SHARED_INFO.m_iSlowSpeed != 0)
- gcs.pstate= PST_SLOW;
- // Arrange for an additional I-Frame notification
- PE_CD_RequestNotification(IFrame);
- // Engage the Error-Recovery mehcanism for I-Frame Display Miss
- (g_pSVCDNav->m_ErrorRecoveryInfo).uTimeout= SVCD_IFRAME_MISS_TIMEOUT;
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eIFrameDisplayMiss;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302:Not actual needed here
- // Invoke playback of the next sub-segment within the current segment
- if (SHARED_INFO.m_iScanSpeed != 0)
- PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID,
- dwCurrLocation, (g_pSVCDNav->m_aCurrSegment[1] - dwCurrLocation),
- eScan, (ULONG)SHARED_INFO.m_iScanSpeed);
- else
- if (SHARED_INFO.m_iSlowSpeed != 0)
- PE_CD_PlaySegment(g_pSVCDNav->m_iCurrVideoType, g_pSVCDNav->m_uCurrAudioSID,
- dwCurrLocation, (g_pSVCDNav->m_aCurrSegment[1] - dwCurrLocation),
- eScan, 0/*(ULONG)SLOW_SCAN_SPEED*/);
- PE_CD_SetCurrentLocationLBN_Bakcup(dwCurrLocation);
-
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnNextItem() -
- // Handles an IE_CORE_NEXT_CHAPTER Event.
- //
- // Input: None
- //
- // Output:
- // The next appropriate Item is invoked.
- /////////////////////////////////////////////////////////////////////////////////////////////////
- static void OnNextItem(void)
- {
- dbg_printf(("OnNextItem()n"));
- OnCancelABRepeat();
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- // Check the current Playback-Status. If in Stop-mode, then resume playback.
- if (PST_STOP == gcs.pstate) {
- // Resume playback from the Item's beginning
- (g_pSVCDNav->m_ResumePlayback).dwStartAddress= -1;
- OnPlay();
- return;
- }
- // Actually move to the next Item
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- // Take care of A-B Repeat
- if (PM_GetRepeatAB() & PM_REPEAT_AB_B) {
- // If the Current Playlist Item contains Position-B, then cancel A-B Repeat (A-B Loop
- // scope has been exceeded).
- if ((SHARED_INFO.m_CurrPosition).uListItem == (g_pSVCDNav->m_PositionB).uListItem)
- CancelRepeatModes(PM_REPEAT_AB_MASK);
- }
- if ((SHARED_INFO.m_CurrPosition).uListItem == (PM_GetProgramSize() - 1)) {
- #ifdef SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
- // Set the Current Item to Zero, so that the first Item on the Play-List
- // will be used (i.e. a wrap-around is performed).
- (SHARED_INFO.m_CurrPosition).uListItem= 0;
- #else
- // Wrap-around if Repeat-All is on
- if (PM_IsRepeatAll()) {
- (SHARED_INFO.m_CurrPosition).uListItem= 0;
- }
- else
- if(PM_IsRepeatSingle())
- {
- ; //add this though we prohibit skipf at the last track upper already.
- }
- else {
- dbg_printf(("Already playing the last item on the Playlist. Ignored.n"));
- return;
- }
- #endif //SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
- }
- if(!PM_IsRepeatSingle()) // if repeat track, return to current track start
- (SHARED_INFO.m_CurrPosition).uListItem++;
- }
- else {
- // Cancel existing A-B Repeat, if any, unconditionally
- CancelRepeatModes(PM_REPEAT_AB_MASK);
- switch ((SHARED_INFO.m_CurrPosition).ListType)
- {
- case PlayList:
- if(!PM_IsRepeatSingle())
- if (((SHARED_INFO.m_CurrList).PlayList).uItemsCnt <= (SHARED_INFO.m_CurrPosition).uListItem++) {
- dbg_printf(("PlayList playback is done. Switching to the next list.n"));
- if (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uNextOffset) {
- dbg_printf(("Invalid Next List Offset for a Play-List. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );//jeanz_0318_2005 Add OSD prohibit logo.
- return;
- }
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)((SHARED_INFO.m_CurrList).PlayList).uNextOffset;
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
- }
- break;
- case SelectionList:
- //if(!PM_IsRepeatSingle())//mikex_0821_2003_b: add a judgement for the single repeat
- {
- if (0xFFFF == ((SHARED_INFO.m_CurrList).SelectionList).uNextOffset) {
- dbg_printf(("No Next-List defined. Ignored.n"));
- return;
- }
- if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
- g_pSVCDNav->m_bPendingEvent= TRUE;
- g_pSVCDNav->m_PendingEvent= IE_CORE_NEXT_CHAPTER;
- return;
- }
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)((SHARED_INFO.m_CurrList).SelectionList).uNextOffset;
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
- }
- break;
- }
- }
- //canceling the scanning mode when moving to another track
- if (PST_SCAN == gcs.pstate)
- OnScan(0);
- if (PST_SLOW == gcs.pstate)
- {
- //DAC_SetMute(TRUE);
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(TRUE);
- #endif //DIGITAL_AMPLIFIER_ENABLE
- OnSlow(0);
-
- if (PS_GET_ANALOG_AUDIO_SETTING()!=NO_ANALOG_AUDIO)
- {
- //DAC_SetMute(FALSE);
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(FALSE);
- #endif //DIGITAL_AMPLIFIER_ENABLE
- }
- }
- // Invoke playback of the next Item
- if (! InvokePlayback()) {
- dbg_printf(("Failed to invoke playback.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnPreviousItem() -
- // Handles an IE_CORE_PREVIOUS_CHAPTER Event.
- //
- // Input:
- // None
- //
- // Output:
- // The previous appropriate Item is invoked.
- static void OnPreviousItem(void)
- {
- int iTimeFromTrackStart = 0;
- OnCancelABRepeat();
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- dbg_printf(("OnPreviousItem()n"));
- // Check the current Playback-Status. If in Stop-mode, then resume playback.
- if (PST_STOP == gcs.pstate) {
- // Resume playback from the Item's beginning
- (g_pSVCDNav->m_ResumePlayback).dwStartAddress= -1;
- OnPlay();
- return;
- }
- //canceling the scanning mode when moving to another track
- if (PST_SCAN == gcs.pstate)
- OnScan(0);
- if (PST_SLOW == gcs.pstate)
- {
- DAC_SetMute(TRUE);
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(TRUE);
- #endif //DIGITAL_AMPLIFIER_ENABLE
- OnSlow(0);
-
- //if (PS_GET_ANALOG_AUDIO_SETTING(gcst.mAudioStream)!=NO_ANALOG_AUDIO)
- if (PS_GET_ANALOG_AUDIO_SETTING()!=NO_ANALOG_AUDIO)
- {
- DAC_SetMute(FALSE);
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(FALSE);
- #endif //DIGITAL_AMPLIFIER_ENABLE
- }
- }
- // Actually move to the previous Item
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- // Check the time elapsed from the beginning of the Current Item.
- // If it is less than or equals SKIP_BACK_THRESHOLD seconds, skip
- // to the previous Item. Otherwise, maintain Current position.
- #ifdef SVCD_USE_ABSOLUTE_TIME
- if (SHARED_INFO.uCurrentTrackNumber < g_pSVCDNav->m_uFirstCDDA_Track)
- iTimeFromTrackStart = SHARED_INFO.iCurrentTime - ((g_pSVCDNav->m_aCurrTrack[0] - g_pSVCDNav->m_dwSecondTrackAddress) / g_pSVCDNav->m_aCurrTrack[2]);
- else
- //in case this is a CDDA track, the current time is the absolute time on the disc
- iTimeFromTrackStart = SHARED_INFO.iCurrentTime - (g_pSVCDNav->m_aCurrTrack[0] / g_pSVCDNav->m_aCurrTrack[2]);
- #else
- iTimeFromTrackStart = SHARED_INFO.iCurrentTime;
- #endif //SVCD_USE_ABSOLUTE_TIME
-
- #ifdef D_USE_VARIABLE_FOR_LIB
- if (iTimeFromTrackStart <= svcd_skip_back_threshold)
- #else
- if (iTimeFromTrackStart <= SVCD_SKIP_BACK_THRESHOLD)
- #endif
- {
- if (1 == (SHARED_INFO.m_CurrPosition).uListItem) {
- // Cancel A-B Repeat (if any)
- CancelRepeatModes(PM_REPEAT_AB_MASK);
- #ifdef SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
- // Set the Current Item to one past the Last item on the Play-List (i.e.
- // wrap-around is performed).
- (SHARED_INFO.m_CurrPosition).uListItem= PM_GetProgramSize() - 1;
- #endif //SVCD_WRAP_AROUND_ON_PROGRAM_EDGES
- }
- else
- if(!PM_IsRepeatSingle()) // if repeat track, return to current track start
- (SHARED_INFO.m_CurrPosition).uListItem--;
- }
- // Take care of A-B Repeat
- if (PM_GetRepeatAB() & PM_REPEAT_AB_B) {
- // If the Previous Playlist Item contains Position-B, then cancel A-B Repeat (A-B Loop
- // scope has been exceeded).
- if ((SHARED_INFO.m_CurrPosition).uListItem == (g_pSVCDNav->m_PositionA).uListItem)
- CancelRepeatModes(PM_REPEAT_AB_MASK);
- }
- }
- else {
- // Cancel existing A-B Repeat, if any, unconditionally
- CancelRepeatModes(PM_REPEAT_AB_MASK);
- switch ((SHARED_INFO.m_CurrPosition).ListType)
- {
- case PlayList:
- #ifdef SVCD_FORCE_PERVIOUS_ITEM
- if ((0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset) &&
- (1 != (SHARED_INFO.m_CurrPosition).uListItem))
- {
- (SHARED_INFO.m_CurrPosition).uListItem--;
- break;
- }
- #endif //SVCD_FORCE_PERVIOUS_ITEM
- #ifndef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
- if (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset)
- {
- dbg_printf(("No Previous-List defined. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP ); //jeanz_0318_2005 Add OSD prohibit logo.
- return;
- }
- #endif
- if(!PM_IsRepeatSingle())
- if (0 == --(SHARED_INFO.m_CurrPosition).uListItem) {
- (SHARED_INFO.m_CurrPosition).uListItem= 1;
- #ifndef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
- if (0xFFFF == ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset)
- {
- dbg_printf(("No Previous-List defined, at First PlayList Item. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP ); //jeanz_0318_2005 Add OSD prohibit logo.
- return;
- }
- #endif
- dbg_printf(("Switching to the previous list.n"));
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- #ifdef SKIP_TO_THE_BEGINING//angieh_0324_2004:For Alco,support previous func when play the first track.
- if (0xFFFF != ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset)
- #endif
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)((SHARED_INFO.m_CurrList).PlayList).uPrevOffset;
-
- }
- break;
- case SelectionList:
- if (0xFFFF == ((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset) {
- dbg_printf(("No Previous-List defined. Ignored.n"));
- return;
- }
- if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
- g_pSVCDNav->m_bPendingEvent= TRUE;
- g_pSVCDNav->m_PendingEvent= IE_CORE_PREVIOUS_CHAPTER;
- return;
- }
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= (g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset;
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
- break;
- }
- }
- // Invoke playback of the previous Item
- if (! InvokePlayback()) {
- dbg_printf(("Failed to invoke playback.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnNumericSelection(WORD uSelection) -
- // Handles an IE_CORE_MENU_NUMERICAL_SELECTION or an IE_CORE_GOTO_ENTRY Event.
- //
- // Input:
- // uSelection - The serial number of the Selection.
- //
- // Output:
- // None. If the selected number is inside the valid appropriate range, the corresponsing
- // Play-Item is invoked.
- //
- // Remarks:
- // When PBC is Off, Numeric-Selection is interpreted as jumping to a specific Track.
- // For PBC On, Numeric-Selection is associated with the current Menu that is being displayed
- // (the current Selection-List).
- static void OnNumericSelection(WORD uSelection)
- {
- BYTE aBuffer[2];
- DWORD dwPSD_Offset;
- BOOL bNeedDisableScanOp = FALSE;//LX090502
-
- dbg_printf(("OnNumericSelection(%d)n", uSelection));
- #ifdef SVCD_DIGEST_SUPPORT
- dbg_printf(("Current Digest Mode is %02xn", Digest_getDigestMode()));
- //handling digest mode selection
- if (g_pSVCDNav->m_bDigestMode) {
- //first check if the selection is within the current displayed digest frames range
- if ((uSelection -1) > (WORD)Digest_getCurrentDisplayed()) {
- dbg_printf(("Digest: Given selection is outside digest range. Operation ignored.n"));
- return;
- }
- // Setting the start address and the play item number
- if (eTrackView == Digest_getDigestMode()) {
- Digest_Unit m_DigestUnit;
- Array_getAt(g_pSVCDNav->m_uiDigestUnits, (UINT16)(uSelection - 1), (BYTE *)&m_DigestUnit);
- (SHARED_INFO.m_CurrPosition).dwStartAddress = m_DigestUnit.dwAddress;
- }
- #ifdef DISC_TRACK_DIGEST_VIEW_ENABLE
- else if ( eTrackDiscView == Digest_getDigestMode() ){
- Digest_Unit m_DigestUnit;
- UINT16 uiCurrentItem = Digest_getCurrentDisplayed();
- WORD wCurrentTrackNum = (WORD)(uiCurrentItem/DIGEST_MAX_FRAMES_ON_SCREEN);
- Array_getAt(g_pSVCDNav->m_uiDigestUnits, (UINT16)(uSelection - 1), (BYTE *)&m_DigestUnit);
- (SHARED_INFO.m_CurrPosition).uListItem= wCurrentTrackNum + 1;
- (SHARED_INFO.m_CurrPosition).dwStartAddress= m_DigestUnit.dwAddress;
- dbg_printf(("Starting from Track %02x, address %08xn", (SHARED_INFO.m_CurrPosition).uListItem,
- (SHARED_INFO.m_CurrPosition).dwStartAddress));
- }
- #endif
- else {
- (SHARED_INFO.m_CurrPosition).uListItem= uSelection; // By default, begin with the first item in the List
- (SHARED_INFO.m_CurrPosition).dwStartAddress= -1; // The address is yet undefined
- }
- //terminating the on going digest mode
- _terminateDigestMode();
- if (! InvokePlayback()) {
- dbg_printf(("Failed to play-back the current Track.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- #endif //SVCD_DIGEST_SUPPORT
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- PE_CD_CancelNotification(IFrame);
- // If currently in STOP state, then turn PBC Off
- if (gcs.pstate == PST_STOP) {
- PM_SetPBC(FALSE);
- g_pSVCDNav->m_bIsUsingPSD= FALSE;
- // Update the current Playback-Mode
- g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- //canceling trigger bit notification
- PE_CD_CancelNotification(TriggerBit);
- }
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- //BOOL bRepeatModeChanged= FALSE;
- if (! PM_IsPlaybackNormal(PM_GetPlaybackMode())) {
- dbg_printf(("Numeric-Selection is not allowed for Program or Shuffle. Ignored.n"));
- return;
- }
- // Verify that the selected number is legal
- if ((0 == uSelection) || (uSelection > (PM_GetProgramSize() - 1))) {
- dbg_printf(("Illegal Selection Number. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- return;
- }
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- // If Scanning or Slow-Motion is in progress, eliminate it
- if (PST_SCAN == gcs.pstate)
- OnScan(0);
- else if (PST_SLOW == gcs.pstate)
- OnSlow(0);
- // Cancel any current Repeat-Modes
- CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
- (SHARED_INFO.m_CurrPosition).uListItem= uSelection;
-
- if (! InvokePlayback()) {
- dbg_printf(("Failed to invoke playback a SelectionList Item.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- // Verify that there is some menu displaying or an Item playing
- if ((PST_STILL != gcs.pstate) && (PST_PLAY != gcs.pstate)) {
- dbg_printf(("Numeric-Selection disabled at this point. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- return;
- }
- // The PSD information is being used:
- if (PlayList == (SHARED_INFO.m_CurrPosition).ListType) {
- dbg_printf(("Numeric-Selection is meaningless within a PlayList Item. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- return;
- }
- // This is a SelectionList: find-out if the selection is within the legal range for this List
- if ((uSelection < ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase) ||
- (uSelection >= ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase + ((SHARED_INFO.m_CurrList).SelectionList).uSelectionsCnt)) {
- dbg_printf(("Illegal Selection Number. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- return;
- }
- // Check if a Numeric-Selection is allowed at this time, or should be postponed.
- if ((PST_PLAY == gcs.pstate) && ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
- g_pSVCDNav->m_bPendingEvent= TRUE;
- g_pSVCDNav->m_PendingEvent= IE_CORE_NUM_SELECTION;
- g_pSVCDNav->m_uPendingEventParam= uSelection;
- return;
- }
- // Check if a Numeric-Selection is allowed, in case of Multi-Default Selections
- if (0xFFFD == ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset) {
- dbg_printf(("Numeric-Selection disabled for Multi-Default in this SelectionList. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- return;
- }
- // Abort any current playback before switching to another item
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
- // If Scanning or Slow-Motion is in progress, eliminate it
- if (PST_SCAN == gcs.pstate)
- OnScan(0);
- else if (PST_SLOW == gcs.pstate)
- OnSlow(0);
- // Extract the appropriate PSD-Offset for the selected item
- dwPSD_Offset= ((SHARED_INFO.m_CurrPosition).dwPSD_Offset + SVCD_SELECTIONLIST_HDR_SIZE
- + (2 * (uSelection - ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase)));
- if (! _getPSDRecord(dwPSD_Offset, 2, aBuffer)) {
- dbg_printf(("Failed to enumerate a SelectionList Selection Item.n"));
- return;
- }
- //<<<LX090502
- if ( gns.svcd.uCurrentTrackNumber == 1 ){
- bNeedDisableScanOp = TRUE;
- }
- //LX090502>>>
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= ((g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)((aBuffer[0] << 8) | aBuffer[1]));
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
-
- if (! InvokePlayback()) {
- dbg_printf(("Failed to invoke playback a SelectionList Item.n"));
- gcs.pstate= PST_STOP;
- }
- //<<<LX090502
- if ( bNeedDisableScanOp ){
- CLEAR_COP_MASK(COP_SCAN);
- PE_CD_RequestNotification(IFrame);
- }
- //LX090502>>>
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnReturn() -
- // Handles an IE_CORE_CDNAV_RETURN Event.
- //
- // Input:
- // None
- //
- // Output:
- // None. If a Return-Offset is defined for the current List, then the List pointed by
- // that offset is invoked.
- //
- // Remarks:
- // This event is only relevant for PBC On.
- static void OnReturn(void)
- {
- WORD dwPSD_Offset= 0;
- dbg_printf(("OnReturn()n"));
- if (! g_pSVCDNav->m_bIsUsingPSD) {
- dbg_printf(("Return is meaningless when PSD information is not being used!n"));
- return;
- }
- // First of all, extract the value of the ReturnOffset in the Current-List
- switch ((SHARED_INFO.m_CurrPosition).ListType)
- {
- case PlayList:
- dwPSD_Offset= ((SHARED_INFO.m_CurrList).PlayList).uReturnOffset;
- break;
- case SelectionList:
- dwPSD_Offset= ((SHARED_INFO.m_CurrList).SelectionList).uReturnOffset;
- break;
- }
- // Check if the Offset is valid. If not, ignore.
- if (0xFFFF == dwPSD_Offset) {
- dbg_printf(("No Return-List defined. Ignored.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- return;
- }
- // For a SelectionList, check if this is a good time for execution
- if ((PST_PLAY == gcs.pstate) && (SelectionList == (SHARED_INFO.m_CurrPosition).ListType) &&
- ((SHARED_INFO.m_CurrList).SelectionList).bPostponeEventsDuringPlay) {
- g_pSVCDNav->m_bPendingEvent= TRUE;
- g_pSVCDNav->m_PendingEvent= IE_CORE_RETURN;
- return;
- }
- (SHARED_INFO.m_CurrPosition).ListType= Undetermined;
- (SHARED_INFO.m_CurrPosition).dwPSD_Offset= ((g_pSVCDNav->m_NavigationInfo).uOffsetMultiplier *
- (UINT32)dwPSD_Offset);
- (SHARED_INFO.m_CurrPosition).uListItem= 1; // Start playback from the first Item
- // If Scanning or Slow-Motion is in progress, eliminate it
- if (PST_SCAN == gcs.pstate)
- OnScan(0);
- else if (PST_SLOW == gcs.pstate)
- OnSlow(0);
- // Cancel any current Repeat-Modes
- CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
- gcs.pstate= PST_PLAY;
- if (! InvokePlayback()) {
- dbg_printf(("Failed to invoke playback.n"));
- gcs.pstate= PST_STOP;
- }
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // OnAudioSelection(WORD uSelection) -
- // Handles an IE_CORE_AUDIO_STREAM_SELECTION Event.
- //
- // Input:
- // uSelection - The serial number of the Audio track to play.
- //
- // Output:
- // None. If possible, the requested Audio-SID is played.
- //
- // Remarks:
- // The handler will refuse switching the Audio-SID if the current Play-Item is a CDDA Track.
- static void OnAudioSelection(WORD uSelection)
- {
- dbg_printf(("OnAudioSelection(%x)n", uSelection));
- if (gns.svcd.uCurrentTrackNumber >= g_pSVCDNav->m_uFirstCDDA_Track) {
- dbg_printf(("Currently playing a CDDA Track - cannot switch Audio SID. Ignored.n"));
- return;
- }
- #ifdef ASSUME_SVCD_4_AUDIO_CHANNELS)
- g_pSVCDNav->m_uCurrAudioSID = MPEG_SID0 | ((uSelection-1) & 0x3);
- SHARED_INFO.uCurrentAudioSIDChannel = uSelection;
- #else
- g_pSVCDNav->m_uCurrAudioSID = (1 == uSelection) ? MPEG_SID0 : MPEG_SID1;
- SHARED_INFO.uCurrentAudioSIDChannel = (1 == uSelection) ? 1 : 2;
- #endif
- PE_CD_SelectAudioStream(g_pSVCDNav->m_uCurrAudioSID);
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // void OnSlow(int iSpeed) -
- // Handles an IE_CORE_SLOW Event.
- //
- // Input:
- // iSpeed - Holds the requested Slow-Motion speed.
- //
- // Output:
- // None. Slow forward is started, if possible.
- //
- // Remarks:
- // Requests a Slow-Motion from the PE.
- static void OnSlow(int iSpeed)
- {
- dbg_printf(("OnSlow(%d)n", iSpeed));
- if (PST_STOP == gcs.pstate) {
- dbg_printf(("Cannot slow forward during a stop. Ignored.n"));
- return;
- }
- // SET_COP_MASK(COP_PLAY);
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- // Eliminate current Scanning
- if ( (PST_SCAN == gcs.pstate) || ( ( PST_SLOW == gcs.pstate) && ( SHARED_INFO.m_iSlowSpeed < 0 ) ) )
- OnScan(0);
- SET_COP_MASK(COP_PLAY);
- // First of all, resume Normal-Playback, if in Stop or Pause (essential for Slow-Motion),
- // or if Scanning is being eliminated.
- if ((PST_STOP == gcs.pstate) || (PST_PAUSE == gcs.pstate) || (0 == iSpeed))
- PE_CD_SetSlowMotion(FALSE, 0);
- // Now actually invoke Slow-Motion, if necessary
- if (0 != iSpeed) {
- if (iSpeed > 0) {
- PE_CD_SetSlowMotion(TRUE, (UINT8)iSpeed);
- PE_CD_CancelNotification(IFrame);
- gcs.pstate= PST_SLOW;
- }
- else {
- iSpeed = ((int)(iSpeed) + 9)*(-1);
- g_pSVCDNav->dwSlowRCurrentPosition = PE_CD_GetCurrentLocation();
- //This routine is like OnScan, we separate it with OnScan is becasue we don't want the gcs.pstate to be confused
- PE_CD_RequestNotification(IFrame);
- //cancel Trigger Bit notification
- PE_CD_CancelNotification(TriggerBit);
- PE_CD_SetScan(TRUE, g_pSVCDNav->m_uCurrAudioSID, 2);
- gcs.pstate = PST_SLOW;
- }
- }
- SHARED_INFO.m_iSlowSpeed= iSpeed;
- return;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // OnGotoEntry(WORD uSelection) -
- // Handles an IE_CORE_GOTO_ENTRY Event.
- //
- // Input:
- // uSelection - The serial number of the Entry to play.
- //
- // Output:
- // None. The requested Entry starts playback.
- //
- // Remarks:
- // Jumpting to an Entry automatically turns PBC Off.
- static void OnGotoEntry(WORD uSelection)
- {
- dbg_printf(("OnGotoEntry(%d)n", uSelection));
- // Cancel Intro Playmode
- //SHARED_INFO.bIsIntroPlayMode = FALSE;
- if (PM_IsPBC(PM_GetPlaybackMode())) {
- PM_SetPBC(FALSE);
- g_pSVCDNav->m_bIsUsingPSD= FALSE;
- //NOTE: canceling the trigger bit notification is done inside onNumericSelection()
- g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- ie_send(IE_UI_STATE_CHANGE);
- }
- OnNumericSelection(uSelection);
- return;
- }
- #ifdef D_ENABLE_DISC_TIMESEARCH
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // static void OnGotoDiscTime(ULONG ulTime) -
- // Handles an IE_CORE_GOTO_DISC_TIME Event.
- //
- // Input:
- // ulTime - The absolute time, within the Whole Disc, to jump to.
- //
- // Output:
- // None. The playback is resumed from the requested time, if possible.
- //
- // Remarks:
- // None.
- static void OnGotoDiscTime(ULONG ulTime)
- {
- TrackInfo Track;
- DWORD dwStartAddress;
- WORD uCurrTrackNumber= 2, uLastTrack = PE_CD_GetTracksCnt();
- BOOL done = 0;
- dbg_printf(("OnGotoDiscTime(%ld)n", ulTime));
- if ( g_pSVCDNav->m_uDiscStandard == DEC_DISC_TYPE_SVCD )
- ulTime = ulTime << 1;
- // if (( g_pSVCDNav->m_bIsUsingPSD ) && ( gcs.pstate != PST_STOP) ){
- // dbg_printf(("Disc Time Search invalidn"));
- // core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- // return;
- // }
-
- if (! PE_CD_GetTrackInfo(uCurrTrackNumber, &Track)){
- dbg_printf(("Failed to access the TOC for Track %d.n", (int)uCurrTrackNumber));
- return;
- }
- dwStartAddress = ulTime*SVCD_BLOCKS_PER_SECOND + Track.dwStartAddress;
- if ( !PE_CD_GetTrackInfo(uLastTrack, &Track)){
- dbg_printf(("Failed to access the TOC for Track %d.n", (int)uLastTrack));
- return;
- }
- if ( dwStartAddress > ( Track.dwStartAddress + Track.ulBlocksCnt ) ){
- dbg_printf(("Search time is out of lead out area.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
- return;
- }
- // Cancel Intro Playmode
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- uCurrTrackNumber = 1;
- while( ( uCurrTrackNumber <= uLastTrack ) && ( !done ) ){
- uCurrTrackNumber ++;
- if(!PE_CD_GetTrackInfo(uCurrTrackNumber, &Track)){
- dbg_printf(("Failed to access the TOC for Track %d.n", (int)uCurrTrackNumber));
- return;
- }
-
- if ( ( dwStartAddress >= Track.dwStartAddress ) && ( dwStartAddress < ( Track.dwStartAddress + Track.ulBlocksCnt ) ) ){
- SHARED_INFO.m_CurrPosition.uListItem = uCurrTrackNumber - 1;
- SHARED_INFO.m_CurrPosition.dwStartAddress = dwStartAddress;
- SHARED_INFO.uCurrentTrackNumber = SHARED_INFO.m_CurrPosition.uListItem;
- SHARED_INFO.m_CurrPosition.dwPSD_Offset = 0;
- done = 1;
- }
- }
- //we must cancel all the playmode and scan, initilaize the playlist
- OnScan(0);
- CancelRepeatModes((PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK));
- PM_InitializeProgramList();
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- PM_SetPBC(FALSE);
- g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- for(uCurrTrackNumber = 1; uCurrTrackNumber < uLastTrack; uCurrTrackNumber++ ){
- PM_SetProgramListEntry((WORD)uCurrTrackNumber, (WORD)(uCurrTrackNumber + 1));
- }
- // Clear all Markers and Bookmarks
- ClearMarker(eResumePlayback, 0);
- ClearMarker(eMarkerA, 0);
- ClearMarker(eMarkerB, 0);
- if ( gcs.pstate != PST_STOP ){
- PE_CD_AbortPlayback(TRUE); // Maintain standby
- gcs.pstate = PST_STOP;
- }
- g_pSVCDNav->m_bIsUsingPSD = FALSE;
- if (!InvokePlayback()){
- dbg_printf(("Can't invoke playback for Disc Time Search.n"));
- }
- return;
- }
- #endif
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // static void OnGotoTime(ULONG ulTime) -
- // Handles an IE_CORE_GOTO_TIME Event.
- //
- // Input:
- // ulTime - The absolute time, within the Current Track, to jump to.
- //
- // Output:
- // None. The playback is resumed from the requested time, if possible.
- //
- // Remarks:
- // None.
- static void OnGotoTime(ULONG ulTime)
- {
- DWORD dwStartAddress;
- #ifdef SVCD_USE_ABSOLUTE_TIME
- UINT16 uTracksCount,uCurrTrackNumber;
- TrackInfo tiCurrTrack;
- #endif //SVCD_USE_ABSOLUTE_TIME
- dbg_printf(("OnGotoTime(%ld)n", ulTime));
- #ifdef SVCD_USE_ABSOLUTE_TIME
- //calculating the new play address
- dwStartAddress = g_pSVCDNav->m_dwSecondTrackAddress + (ulTime * g_pSVCDNav->m_aCurrTrack[2]);
- //checking the validity of the new address - not greater than the last track end address
- if (ulTime > SHARED_INFO.wTotalPlaybackTime)
- {
- dbg_printf(("Illegal Time requested.n"));
- core_report_error( IE_UI_REPORT_ERROR, (void *) CDNAV_ERR_PROHIBITED_UOP );
-
- return;
- }
- // Cancel Intro Playmode
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- // Rebuild the Normal Program-List (sequential playback of the Tracks)
- PM_InitializeProgramList();
- uTracksCount = (UINT16)PE_CD_GetTracksCnt();
- // Initialize the Program-List to sequencial playback
- for (uCurrTrackNumber = 1; uCurrTrackNumber < uTracksCount; uCurrTrackNumber++)
- PM_SetProgramListEntry((WORD)(uCurrTrackNumber), (WORD)(uCurrTrackNumber + 1));
-
- //setting the current play item according to the address
- uCurrTrackNumber = 2;
- while (uCurrTrackNumber <= uTracksCount)
- {
- //reading the track info from the disc
- PE_CD_GetTrackInfo(uCurrTrackNumber, &tiCurrTrack);
- // checking if the start address is within the current track bounderies
- if ((dwStartAddress >= tiCurrTrack.dwStartAddress) &&
- (dwStartAddress <= (tiCurrTrack.dwStartAddress + tiCurrTrack.ulBlocksCnt)))
- {
- (gns.svcd.m_CurrPosition).uListItem = uCurrTrackNumber - 1;
- break;
- }
-
- uCurrTrackNumber++;
- }
- //setting the PBC off in case it was on
- if (PM_IsPBC(g_pSVCDNav->m_uCurrPlaybackMode))
- {
- if (0 != (g_pSVCDNav->m_NavigationInfo).ulPSD_Size)
- {
- g_pSVCDNav->m_bIsUsingPSD= FALSE;
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
-
- if (PST_STOP != gcs.pstate)
- PE_CD_AbortPlayback(TRUE); // Maintain Standby mode
-
- gcs.pstate= PST_PLAY;
- PM_SetPBC(FALSE);
- // Update the current Playback-Mode
- g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- //cancel trigger bit notification
- PE_CD_CancelNotification(TriggerBit);
- }
- }
- #else //SVCD_USE_ABSOLUTE_TIME
- if (! SHARED_INFO.bIsElapsedTimeValid)
- {
- dbg_printf(("Cannot jump to Time. Current Time is undefined.n"));
- return;
- }
- //calculating the new play address
- dwStartAddress = (g_pSVCDNav->m_aCurrTrack[0] + (ulTime * g_pSVCDNav->m_aCurrTrack[2]));
- //checking the validity of the new address
- if (dwStartAddress > g_pSVCDNav->m_aCurrTrack[1])
- {
- dbg_printf(("Illegal Time requested.n"));
- return;
- }
- //The play item number stays as it was
- #endif //SVCD_USE_ABSOLUTE_TIME
- PE_CD_AbortPlayback(TRUE); // Maintain standby
- gcs.pstate= PST_STOP;
- // Cancel any Repeat mode
- CancelRepeatModes(PM_REPEAT_SINGLE | PM_REPEAT_ALL | PM_REPEAT_AB_MASK);
- // Record the Current Position
- SetMarker(eResumePlayback, 0);
- // Now manipulate the Start-Address and the play item number
- g_pSVCDNav->m_ResumePlayback.dwStartAddress = dwStartAddress;
- // Emulate Playback-invocation
- OnPlay();
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : OnIntro
- //
- // Input Parameters : void
- //
- // Return Value : void
- //
- // Description : Begin to start intro playback or stop it.
- //////////////////////////////////////////////////////////////////////////////////
- static void OnIntro(void)
- {
- if (TRUE != SHARED_INFO.bIsIntroPlayMode)
- {
- if ( PST_STOP == gcs.pstate ){
- dbg_printf(("Cancel Playmode/Repeat moden"));
- PM_SetPlaybackMode(0);
- PM_ClearRepeat();
- // SHARED_INFO.uCurrPlaylistItem = 1;
- OnGotoEntry(1);
- SHARED_INFO.bIsIntroPlayMode = TRUE;
- // OnPlay();
- }else
- dbg_printf(("Can't Activate Intro Mode in non-stop moden"));
- }else
- dbg_printf((" Already in intro mode, ignoren"));
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Digest related functions
- #ifdef SVCD_DIGEST_SUPPORT
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : _handleDigestUnit
- //
- // Purpose : Supplying a dedicated function for handling a digest item
- //
- // Input Parameters :
- // uUnitIndex - index of the item to be played
- // eQuery - a requested Query
- //
- // Return Value : static void
- //
- // Description : A callback functon that is supplied to the digest in order
- // to provide a specific play/stop operations.
- //////////////////////////////////////////////////////////////////////////////////
- static BOOL _handleDigestUnit(UINT16 uUnitIndex, enDigestQuery eQuery)
- {
- switch (eQuery)
- {
- case eDigestQuery_Start:
- {
- Digest_Unit m_DigestUnit;
- Array_getAt(g_pSVCDNav->m_uiDigestUnits, uUnitIndex, (BYTE *)&m_DigestUnit);
- PE_CD_StreamPortion( m_DigestUnit.dwAddress, m_DigestUnit.uSize);
- // PE_CD_StreamPortion(g_pSVCDNav->m_uiDigestUnits[uUnitIndex].dwAddress,
- // g_pSVCDNav->m_uiDigestUnits[uUnitIndex].uSize);
- return TRUE;
- }
- case eDigestQuery_Stop:
- PE_CD_AbortPlaybackEx();
- return TRUE;
- case eDigestQuery_IsFinished:
- return drv_is_play_done();
- }
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : OnDigest
- //
- // Purpose : Initiate digest mode.
- //
- // Input Parameters : UINT16 Param - holds the parameters values of the digest mode
- // and the intro frames count.
- //
- // Return Value : void
- //
- // Description : Initialize the digest items array, and start performing the
- // digest.
- //////////////////////////////////////////////////////////////////////////////////
- static void OnDigest(UINT16 Param)
- {
- UINT16 uDigestItemsCnt = 0, uIndex;
- UINT16 uTrackDigestUnitSize;
- enDigestMode eDigestMode = (enDigestMode)(Param & 0x00FF);
- UINT8 uIntroFramesCount = (Param >> 8);
- dbg_printf(("OnDigest()n"));
- //if already on digest mode ignoring the request
- if (g_pSVCDNav->m_bDigestMode) {
- dbg_printf(("Already on digest mode. Ignored.n"));
- return;
- }
- OnScan(0);
-
- // Cancel Intro Playmode
- SHARED_INFO.bIsIntroPlayMode = FALSE;
- PM_SetPBC(FALSE);
- OnModeChange();
- Logo_setBackgroundColor(0x65, 0xA4, 0x61);//LeonH_0827_2003_c:mode change will flush background color, so reset it
- //saving the current position in order to resume the playback in the future
- if (PST_STOP != gcs.pstate){
- SetMarker(eResumePlayback, 0);
- PE_CD_AbortPlayback(TRUE);
- }
- // Cancel Error-Recovery Mechanism(s)
- (g_pSVCDNav->m_ErrorRecoveryInfo).eRecoveryType= eNoError;
- (g_pSVCDNav->m_ErrorRecoveryInfo).dwParam= 0;
- (g_pSVCDNav->m_ErrorRecoveryInfo).ucRetryCounter = 0;//LX051302: Not actual needed here
- #ifdef WATCHDOG_TRIGGERED_BY_FE
- PE_CD_CancelNotification( StuckTrigger );
- #endif
- //If we are on play we initiate a Track-Digest: presenting 9 frames from the current track
- if (eTrackView == eDigestMode)
- {
- DWORD dwCurrTrackSize = g_pSVCDNav->m_aCurrTrack[1] - g_pSVCDNav->m_aCurrTrack[0];
- DWORD dwTrackAddress = g_pSVCDNav->m_aCurrTrack[0];
- Digest_Unit m_DigestUnit;
- uDigestItemsCnt = DIGEST_MAX_FRAMES_ON_SCREEN;
- g_pSVCDNav->m_uiDigestUnits = Array_construct(uDigestItemsCnt, sizeof(Digest_Unit), NULL);
- if (NULL == g_pSVCDNav->m_uiDigestUnits) {
- dbg_printf(("Failed to allocate digest items array!n"));
- return;
- }
- uTrackDigestUnitSize = (UINT16)(dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
-
- //initializing the array
- for (uIndex = 0; uIndex < uDigestItemsCnt; uIndex++)
- {
- m_DigestUnit.dwAddress = dwTrackAddress;
- dwTrackAddress += (dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
- m_DigestUnit.uSize = uTrackDigestUnitSize;
- //fixing the last unit size to be the remaining of the track
- if ( ( uDigestItemsCnt - 1) == uIndex )
- m_DigestUnit.uSize = dwCurrTrackSize -
- (uTrackDigestUnitSize * (DIGEST_MAX_FRAMES_ON_SCREEN - 1));
- Array_setAt(g_pSVCDNav->m_uiDigestUnits, uIndex, (CONST BYTE *)&m_DigestUnit);
- }
- }
- //Disc-digest: each frame is a track sample
- else if (eDiscView == eDigestMode)
- {
- Digest_Unit m_DigestUnit;
-
- //the digest items count is actually the number of tracks on the disc minues the info track
- //and minus the audio tracks
- if (PE_CD_GetTracksCnt() > g_pSVCDNav->m_uFirstCDDA_Track)
- uDigestItemsCnt = (UINT16)(g_pSVCDNav->m_uFirstCDDA_Track - 2);
- else
- uDigestItemsCnt = (UINT16)PE_CD_GetTracksCnt() - 1;
- g_pSVCDNav->m_uiDigestUnits = Array_construct(uDigestItemsCnt, sizeof(Digest_Unit), NULL);
- if (NULL == g_pSVCDNav->m_uiDigestUnits) {
- dbg_printf(("Failed to allocate digest items array!n"));
- return;
- }
- //initializing the array
- for (uIndex = 0; uIndex < uDigestItemsCnt; uIndex++) {
- TrackInfo tiTrackInfo;
- PE_CD_GetTrackInfo((uIndex + 2), &tiTrackInfo);
- m_DigestUnit.dwAddress = tiTrackInfo.dwStartAddress;
- m_DigestUnit.uSize = (UINT16)tiTrackInfo.ulBlocksCnt;
- Array_setAt(g_pSVCDNav->m_uiDigestUnits, uIndex, (CONST BYTE *)&m_DigestUnit);
- }
- }
- #ifdef DISC_TRACK_DIGEST_VIEW_ENABLE
- else if ( eTrackDiscView == eDigestMode ){
- DWORD dwCurrTrackSize;
- DWORD dwTrackAddress;
- BYTE ucNumOfTracks, ucTrackIndex;
- Digest_Unit m_DigestUnit;
- if (PE_CD_GetTracksCnt() > g_pSVCDNav->m_uFirstCDDA_Track)
- ucNumOfTracks = (BYTE)(g_pSVCDNav->m_uFirstCDDA_Track - 2);
- else
- ucNumOfTracks = (BYTE)PE_CD_GetTracksCnt() - 1;
- uDigestItemsCnt = DIGEST_MAX_FRAMES_ON_SCREEN * ucNumOfTracks;
- dbg_printf(("Num of Digets Items for Disc_Track_View %04xn", uDigestItemsCnt ));
- g_pSVCDNav->m_uiDigestUnits = Array_construct(uDigestItemsCnt, sizeof(Digest_Unit), NULL);
-
- if (NULL == g_pSVCDNav->m_uiDigestUnits) {
- dbg_printf(("Failed to allocate digest items array!n"));
- return;
- }
- for ( ucTrackIndex = 0; ucTrackIndex < ucNumOfTracks; ucTrackIndex++ ){
- TrackInfo m_TrackInfo;
-
- if ( PE_CD_GetTrackInfo((int)(ucTrackIndex + 2), &m_TrackInfo) ){
- dwTrackAddress = m_TrackInfo.dwStartAddress;
- dwCurrTrackSize = m_TrackInfo.ulBlocksCnt;
- }
- else{
- Array_destruct(g_pSVCDNav->m_uiDigestUnits);
- dbg_printf(("Error, can't get Toc infon"));
- return;
- }
- uTrackDigestUnitSize = (UINT16)(dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
-
- for ( uIndex = 0; uIndex < DIGEST_MAX_FRAMES_ON_SCREEN; uIndex ++ ){
- m_DigestUnit.dwAddress = dwTrackAddress;
- m_DigestUnit.uSize = uTrackDigestUnitSize;
- //fixing the last unit size to be the remaining of the track
- if ( uIndex == ( DIGEST_MAX_FRAMES_ON_SCREEN - 1) )
- m_DigestUnit.uSize = (UINT16)(dwCurrTrackSize -
- (uTrackDigestUnitSize * (DIGEST_MAX_FRAMES_ON_SCREEN - 1)));
- Array_setAt(g_pSVCDNav->m_uiDigestUnits, (UINT16)(uIndex + ucTrackIndex*DIGEST_MAX_FRAMES_ON_SCREEN),
- (const BYTE *)&m_DigestUnit);
- dwTrackAddress += (dwCurrTrackSize / DIGEST_MAX_FRAMES_ON_SCREEN);
- }
- }
- }
- #endif//DISC_TRACK_DIGEST_VIEW_ENABLE
- else
- {
- tr_printf(("Unsupported digest mode.n"));
- return;
- }
- //setting the play state to PST_STILL
- gcs.pstate = PST_STILL;
- SHARED_INFO.bIsElapsedTimeValid = FALSE;
- //initiating the digest operation
- if (Digest_init(_handleDigestUnit, uDigestItemsCnt, eDigestMode, uIntroFramesCount))
- {
- //Setting the Digest mode indication
- g_pSVCDNav->m_bDigestMode = TRUE;
- //saving the operation mask
- g_pSVCDNav->m_ulCOP_Mask = COP_MASK;
- //start the actual digest process
- Digest_start(0);
- //setting the new operation mask
- CLEAR_COP_MASK(COP_PLAY | COP_PAUSE | COP_STEP | COP_SLOW | COP_SCAN |
- COP_SCAN_BACKWARD| COP_NEXT_CHAPTER | COP_PREVIOUS_CHAPTER);
- SET_COP_MASK(COP_STOP | COP_NEXT_CHAPTER | COP_PREVIOUS_CHAPTER);
- }
- }
- #endif //SVCD_DIGEST_SUPPORT
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : IsSegmentPlay
- //
- // Purpose : Check if current disc is segment playback
- //
- // Input Parameters : none
- //
- // Return Value :
- //
- // Description :
- //////////////////////////////////////////////////////////////////////////////////
- BOOL IsSegmentPlay(void)
- {
- if(g_pSVCDNav->m_bIsSegment)
- return TRUE;
- else
- return FALSE;
- }
- // <<< ZCO SH021403:Added to check Zoom availability
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : IsSVCDUsingPSD
- //
- // Purpose : Check if current disc is using PSD
- //
- // Input Parameters : none
- //
- // Return Value : TRUE if current disc is using PSD, FALSE otherwise
- //
- // Description :
- //////////////////////////////////////////////////////////////////////////////////
- BOOL IsSVCDUsingPSD(void)
- {
- if(g_pSVCDNav->m_bIsUsingPSD)
- return TRUE;
- else
- return FALSE;
- }
- // ZCO SH021403 >>>
- // <<< ZCO SH021403:Added to check Zoom availability
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : GetCurrentSVCDRes
- //
- // Purpose : Return current Video SID use by navigator
- //
- // Input Parameters : none
- //
- // Return Value : current video sid
- //
- // Description :
- //////////////////////////////////////////////////////////////////////////////////
- int GetCurrentSVCDRes(void)
- {
- return g_pSVCDNav->m_iCurrVideoType;
- }
- // ZCO SH021403 >>>
- // <<< SEC BK.LIM070203
- #ifdef EXINO2
- // <<< SEC BK.LIM090203: Give location changing value to UI
- BOOL Is_VCD_Location_Changing(void)
- {
- return g_pSVCDNav->m_bLocationChanging;
- }
- // SEC BK.090203>>>
- //<<< SEC BK.LIM080703: Get current playback time
- DWORD Get_Curr_Playbacktime(void)
- {
- return (((SHARED_INFO.dwCurrentLocation - g_pSVCDNav->m_aCurrTrack[0]) / 75L) );
- }
- //>>>
- BOOL CheckValidTime(void)
- {
- //WORD wTrack = PM_IsPlaybackProgram(PM_GetPlaybackMode()) ? PM_GetProgramListEntry((gns.svcd.m_CurrPosition).uListItem) : (gns.svcd.m_CurrPosition).uListItem + 1;
-
- return ( ((SHARED_INFO.dwCurrentLocation > g_pSVCDNav->m_aCurrTrack[0]) && (SHARED_INFO.dwCurrentLocation< g_pSVCDNav->m_aCurrTrack[1])) );
- }
- BOOL SVCD_Nav_Check_UOP(EVENT Event, void *Param)
- {
- BOOL bIsNextOp = FALSE;
- WORD wtime = 0;
- if(PM_IsPBC(PM_GetPlaybackMode()) )
- wtime = SI_SVCD_ELAPSED_TIME_PBC_ON;
- else
- wtime = SI_SVCD_ELAPSED_TIME;
- switch(Event){
- case IE_CORE_NEXT_CHAPTER:
- bIsNextOp = TRUE;
- case IE_CORE_PREVIOUS_CHAPTER:
- if ( gcs.pstate == PST_STOP )
- return FALSE;
- if ( !g_pSVCDNav->m_bIsUsingPSD){
- if ((( gns.svcd.m_CurrPosition.uListItem == ( PM_GetProgramSize() - 1 )) && (bIsNextOp )) ||
- ((gns.svcd.m_CurrPosition.uListItem == 1) && (wtime < (SVCD_PREV_THRESHOLD/SVCD_BLOCKS_PER_SECOND+1)) && (!bIsNextOp)) )
- if ( !PM_IsPlaybackShuffle(PM_GetPlaybackMode())) //Added by Billt 081602
- return FALSE; //Added by Billt 081602
- return TRUE;
- }
- else{
- switch( (SHARED_INFO.m_CurrPosition).ListType){
- case EndList:
- return FALSE;
- case PlayList:
- if ((( ((SHARED_INFO.m_CurrList).PlayList).uNextOffset== 0xFFFF ) && (bIsNextOp)) ||
- ( (((SHARED_INFO.m_CurrList).PlayList).uPrevOffset == 0xFFFF ) && (!bIsNextOp)) )
- return FALSE;
- return TRUE;
- case SelectionList:
- if ( bIsNextOp){
- if ( ((SHARED_INFO.m_CurrList).SelectionList).uNextOffset == 0xFFFF )
- return FALSE;
- }
- else{
- if (((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset == 0xFFFF )
- return FALSE;
- }
- return TRUE;
- default:
- return FALSE;
- };
- }
- break;
- case IE_CORE_RETURN:
- if ( ( !g_pSVCDNav->m_bIsUsingPSD) || ( gcs.pstate == PST_STOP ))
- return FALSE;
- switch((SHARED_INFO.m_CurrPosition).ListType){
- case EndList:
- return FALSE;
- case PlayList:
- if (((SHARED_INFO.m_CurrList).PlayList).uReturnOffset== 0xFFFF )
- return FALSE;
- case SelectionList:
- if (((SHARED_INFO.m_CurrList).SelectionList).uReturnOffset == 0xFFFF )
- return FALSE;
- }
- return TRUE;
- case IE_CORE_SCAN:
- case IE_CORE_SLOW:
- if ( gcs.pstate == PST_STOP )
- return FALSE;
- if (( g_pSVCDNav->m_bIsUsingPSD ) && ( (SHARED_INFO.m_CurrPosition).ListType == SelectionList)
- && (g_pSVCDNav->m_aCurrTrack[1]== -1 ))
- return FALSE;
- return TRUE;
- default:
- return FALSE;
- };
- }
- #endif
- // SEC BK.LIM070203>>>
- #ifdef _DEBUG
- static void OnStatusReport(void)
- {
- dbg_printf(("Status Report for SVCD-Navigator:n"));
- dbg_printf(("tPlayback-Sequence-Descriptor %s;n", (g_pSVCDNav->m_bIsUsingPSD ? "Used" : "Not Used")));
- if (g_pSVCDNav->m_bIsUsingPSD) {
- if (g_pSVCDNav->m_bPendingEvent) {
- dbg_printf(("tPending Event: %lx, %u;n", g_pSVCDNav->m_PendingEvent, g_pSVCDNav->m_uPendingEventParam));
- }
- dbg_printf(("tRemaining Waiting-Time: %u Seconds;n", (g_pSVCDNav->m_dwWaitTime / SVCD_TICKS_PER_SECOND)));
- dbg_printf(("tRemaining time until Timeout: %u Seconds;n", (g_pSVCDNav->m_dwTimeout / SVCD_TICKS_PER_SECOND)));
- dbg_printf(("tRemaining Pause-Time: %u Seconds;n", (g_pSVCDNav->m_dwPausePeriod / SVCD_TICKS_PER_SECOND)));
- switch ((SHARED_INFO.m_CurrPosition).ListType) {
- case PlayList:
- dbg_printf(("tThe Current-List is a Play-List:n"));
- dbg_printf(("ttNumber of items on the list: %u;n", ((SHARED_INFO.m_CurrList).PlayList).uItemsCnt));
- dbg_printf(("ttCurrent Item: %u;n", ((SHARED_INFO.m_CurrPosition).uListItem)));
- dbg_printf(("ttPlaying-Time: %u;n", ((SHARED_INFO.m_CurrList).PlayList).uPlayingTime));
- dbg_printf(("ttWaiting-Time: %02x;n", ((SHARED_INFO.m_CurrList).PlayList).wWaitTime));
- dbg_printf(("ttAuto-Pause Period: %02x;n", ((SHARED_INFO.m_CurrList).PlayList).wAutoPausePeriod));
- dbg_printf(("ttPrevious: %04x;n", ((SHARED_INFO.m_CurrList).PlayList).uPrevOffset));
- dbg_printf(("ttNext: %04x;n", ((SHARED_INFO.m_CurrList).PlayList).uNextOffset));
- dbg_printf(("ttReturn: %04x.n", ((SHARED_INFO.m_CurrList).PlayList).uReturnOffset));
- break;
- case SelectionList:
- dbg_printf(("tThe Current-List is a Selection-List:n"));
- dbg_printf(("ttNumber of selection-items: %u;n", ((SHARED_INFO.m_CurrList).SelectionList).uSelectionsCnt));
- dbg_printf(("ttBase of selection: %u;n", ((SHARED_INFO.m_CurrList).SelectionList).uSelectionBase));
- dbg_printf(("ttIterations Left: %u;n", ((SHARED_INFO.m_CurrList).SelectionList).uRepeatCnt));
- dbg_printf(("ttTimeout-Period: %02x;n", ((SHARED_INFO.m_CurrList).SelectionList).wTimeoutWaitTime));
- dbg_printf(("ttPrevious: %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uPrevOffset));
- dbg_printf(("ttNext: %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uNextOffset));
- dbg_printf(("ttReturn: %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uReturnOffset));
- dbg_printf(("ttTimeout: %04x;n", ((SHARED_INFO.m_CurrList).SelectionList).uTimeoutOffset));
- dbg_printf(("ttDefault: %04x.n", ((SHARED_INFO.m_CurrList).SelectionList).uDefaultOffset));
- break;
- case EndList:
- dbg_printf(("tThe Current-List is an End-List.n"));
- break;
- case Undetermined:
- dbg_printf(("tThe Current-List has not been determined yet.n"));
- break;
- }
- }
- else {
- dbg_printf(("tTotal number of items on the Program-List is: %dn", (PM_GetProgramSize() - 1)));
- dbg_printf(("tCurrent Program-List item: %d.n", (SHARED_INFO.m_CurrPosition).uListItem));
- }
- return;
- }
- #endif //_DEBUG
- #ifdef EXINO2 //ZKR JK0331 : for power_on_resume in EEPROM
- #ifdef HW_POWER_ON_RESUME
- static WORD GetResumeLeadOutInfo(void)
- {
- WORD wLeadOut;
- if (eeprom_read(SVCD_LeadOut_Info_ADDR, (BYTE *)&wLeadOut, sizeof(WORD) ))
- return wLeadOut;
- else
- return 0;
- }
- static void GetCurretnLocationStructure(void)
- {
- if ( eeprom_read( SVCD_CurrentPosition_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrPosition), sizeof(SVCD_Marker) ) )
- return;
- }
- static void GetPSDAvaiableInfo(void)
- {
- if ( eeprom_read(SVCD_UsingPSD_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_bIsUsingPSD), sizeof(BOOL) ))
- return;
- }
- static void GetCurrentListInfo(void)
- {
- if ( eeprom_read(SVCD_CurrentList_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrList), sizeof(SVCD_PSDList) ) )
- return;
- else
- dbg_printf(("Error on reading SVCD Current List Info to EEPROMn"));
- }
- static void GetVideoTypeInfo(void)
- {
- if ( eeprom_read(SVCD_VideoType_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_iCurrVideoType), sizeof(g_pSVCDNav->m_iCurrVideoType)) )
- return;
- else
- dbg_printf(("Error on reading SVCD Current Video Type to EEPROMn"));
- }
- static void SetResumeLeadOutInfo(void)
- {
- if (eeprom_write (SVCD_LeadOut_Info_ADDR, (BYTE *)&((gns.svcd).wTotalPlaybackTime), sizeof(WORD) ))
- return;
- else
- dbg_printf(("Error on writing Lead Out info to EEPROMn"));
- }
- static void SetCurretnLocationStructure(void)
- {
- if(gcs.pstate == PST_STOP)
- gns.svcd.m_CurrPosition.dwStartAddress =g_pSVCDNav->m_ResumePlayback.dwStartAddress;
- else
- gns.svcd.m_CurrPosition.dwStartAddress = PE_CD_GetCurrentLocation();
- if ( eeprom_write(SVCD_CurrentPosition_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrPosition), sizeof(SVCD_Marker)))
- return;
- else
- dbg_printf(("Error on writing SVCD CurrentPosition info to EEPROMn"));
- }
- static void SetPSDAvaiableInfo(void)
- {
- if ( eeprom_write( SVCD_UsingPSD_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_bIsUsingPSD), sizeof(BOOL) ) )
- return;
- else
- dbg_printf(("Error on writing SVCD IsUsingPSD info to EEPROMn"));
- }
- static void SetCurrentListInfo(void)
- {
- if ( eeprom_write(SVCD_CurrentList_Info_ADDR, (BYTE *)&(gns.svcd.m_CurrList), sizeof(SVCD_PSDList) ) )
- return;
- else
- dbg_printf(("Error on writing SVCD Current List Info to EEPROMn"));
- }
- static void SetVideoTypeInfo(void)
- {
- if ( eeprom_write(SVCD_VideoType_Info_ADDR, (BYTE *)&(g_pSVCDNav->m_iCurrVideoType), sizeof(g_pSVCDNav->m_iCurrVideoType)) )
- return;
- else
- dbg_printf(("Error on writing SVCD Current Video Type to EEPROMn"));
- }
- static void ClearResumeLeadOutInfo(void)
- {
- WORD wLeadOut;
- wLeadOut = 0x0000;
-
- // <<< ZKR GL021302 : Use eeprom_write()
- //if (eeprom_read(SVCD_LeadOut_Info_ADDR, (BYTE *)&wLeadOut, sizeof(WORD) ))
- if (eeprom_write(SVCD_LeadOut_Info_ADDR, (BYTE *)&wLeadOut, sizeof(WORD) ))
- // ZKR GL021302 >>>
- return;
- else
- dbg_printf(("Error on cleanning SVCD Lead Out info from EEPROM when eject tray n"));
- }
- // <<< ZKR GL012702 : To notify power-on resume for UI before restarting
- BOOL IsPowerOnResumeAvailable(void)
- {
- if ( /*bPowerResume &&*/ ( GetResumeLeadOutInfo() == gns.svcd.wTotalPlaybackTime ) ) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- BOOL IsPowerOnResumeUsingPSD(void)
- {
- BOOL bIsUsingPSD;
- if ( !eeprom_read(SVCD_UsingPSD_Info_ADDR, (BYTE *)&bIsUsingPSD, sizeof(BOOL)) )
- printf("Error on reading SVCD IsUsingPSD info from EEPROMn");
- return bIsUsingPSD;
- }
- // ZKR GL012702 >>>
- #endif//HW_POWER_ON_RESUME
- #else //EXINO2
- #ifdef HW_POWER_ON_RESUME
- BOOL SVCDNAV_NvmBmk_Match(NVM_GENERIC_BMK* pGenric_bmk)
- {
- if (gns.svcd.wTotalPlaybackTime != pGenric_bmk->marker.svcd.wLeadOut)
- return FALSE;
- return TRUE;
- }
- void SVCDNAV_NvmBmk_Set( WORD sc_handle)
- {
- WORD wSCTmp;
- BYTE b_temp;
- int i, offset;
- NVM_GENERIC_BMK* pGenric_bmk;
- SVCD_Marker *pMarker= NULL;
- offset = (int)&pGenric_bmk->marker.svcd.m_bIsUsingPSD - (int)pGenric_bmk;
- sc_SetBytes(sc_handle, offset, sizeof(BYTE), (BYTE *)&(g_pSVCDNav->m_bIsUsingPSD));
- offset = (int)&pGenric_bmk->marker.svcd.wLeadOut - (int)pGenric_bmk;
- sc_SetBytes(sc_handle, offset, sizeof(WORD), (BYTE *)&((gns.svcd).wTotalPlaybackTime));
- memcpy(pMarker, &(gns.svcd.m_CurrPosition), sizeof(SVCD_Marker));
- if(gcs.pstate == PST_STOP)
- pMarker->dwStartAddress =g_pSVCDNav->m_ResumePlayback.dwStartAddress;
- else
- pMarker->dwStartAddress = PE_CD_GetCurrentLocation();
- offset = (int)&pGenric_bmk->marker.svcd.m_CurrPosition - (int)pGenric_bmk;
- sc_SetBytes(sc_handle, offset, sizeof(SVCD_Marker), (BYTE *)pMarker);
- offset = (int)&pGenric_bmk->marker.svcd.m_CurrList - (int)pGenric_bmk;
- sc_SetBytes(sc_handle, offset, sizeof(SVCD_PSDList), (BYTE *)&(gns.svcd.m_CurrList));
-
- offset = (int)&pGenric_bmk->marker.svcd.m_iCurrVideoType- (int)pGenric_bmk;
- sc_SetBytes(sc_handle, offset, sizeof(BYTE), (BYTE *)&(g_pSVCDNav->m_iCurrVideoType));
-
- return;
- }
- void SVCDNAV_NvmBmk_Play(NVM_GENERIC_BMK *pGenric_bmk)
- {
- gns.svcd.m_CurrPosition = pGenric_bmk->marker.svcd.m_CurrPosition;
- g_pSVCDNav->m_bIsUsingPSD = pGenric_bmk->marker.svcd.m_bIsUsingPSD;
- gns.svcd.m_CurrList = pGenric_bmk->marker.svcd.m_CurrList;
- g_pSVCDNav->m_iCurrVideoType = (VideoSID)pGenric_bmk->marker.svcd.m_iCurrVideoType;
- if ( g_pSVCDNav->m_bIsUsingPSD )
- {
- PM_SetPBC(TRUE);
- g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- if ( ( g_pSVCDNav->m_iCurrVideoType == STILL_LOWRES ) || ( g_pSVCDNav->m_iCurrVideoType == STILL_HIRES ) )
- gns.svcd.m_CurrPosition.dwStartAddress = -1;
- //g_pSVCDNav->m_dwPSD_CacheBase= 0xFFFF;
- }
- else
- {
- PM_SetPBC(FALSE);
- PM_SetPlaybackMode((BYTE) PM_PLAYBACK_NORMAL);
- g_pSVCDNav->m_uCurrPlaybackMode= PM_GetPlaybackMode();
- }
- return;
- }
- #endif //HW_POWER_ON_RESUME
- #endif //EXINO2