thg_nav.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:18k
- /*******************************************************************************
- * Copyright(c) Philips Consumer Electronics B.V. 2001
- * The attached material and the information contained therein is proprietary
- * to Philips and is issued only under strict confidentiality arrangements.
- * It shall not be used, reproduced, copied in whole or in part, adapted,
- * modified, or disseminated without a written license of Philips.
- * It must be returned to Philips upon its first request.
- *
- * Project: SA-MP ( Super Audio Media Player )
- * File %name: thg_nav.c %
- * %version: 23 %
- * %date_modified: Wed Nov 20 17:28:08 2002 %
- * %derived_by: hooydona %
- * Creation date: Thu Jun 14 16:09:03 2001
- * First author: klerxm
- *
- * Advanced Systems and Applications Lab - Eindhoven
- *
- * Continuus %full_filespec: thg_nav.c~23:csrc:1 %
- *
- * Description: Test harness of the Navigator
- *
- * Change history:
- *
- * Rev Date Who Comments
- * ---- ---------- -------- -----------------------------------------------------
- * 1 2001-06-06 klerxm Dummy version
- * 2 2001-06-14 klerxm Template update
- * 3 2001-09-04 klerxm Changes required for new global header files
- * 7 2001-12-04 kasterej Retrieve event data in NavCallback
- * 8 2001-12-07 kasterej Remove unsubscribe in Term()
- * 9 2001-12-11 kasterej Change NAV_NOF_CHANNELS to NAV_CHANNELS_CONFIG
- * 10 2001-12-14 kasterej Change debug output EventNofChannnels to
- * EventChannelsConfig
- * 11 2001-12-19 kasterej Add GetState function
- * 12 2002-01-11 novosadt pointer in NAV_SetProgramList (PR277)
- * 13 2002-01-11 kasterej Change EventData of NAV_EVENT_STARTED (Int8 to Int16)
- * 14 2002-01-15 kasterej Make programList global variable
- * 15 2002-01-30 kasterej Add GetPlayList function and NAV_CHANGE_MODE event
- * 16 2002-02-13 kasterej Add performance feedback to PlayTrack/PlayAtTimecode
- * 17 2002-02-22 potm Replaced SACD_ChannelsDef with
- * SACD_ChannelsConfigDef (CR260)
- * 18 2002-02-26 kasterej Add NAV_EVENT_WARNING and (more) performance feedback
- * 19 2002-02-27 kokh TH_Send -> SAMP(TH_Send)
- * 20 2002-09-23 klerxm Use only UInt32 type parameters with TH_GetParam
- * 21 2002-11-20 novosadt Added PLAY_SEQ_TRACK
- * 22 2003-07-01 potm Added 1394 subscription functions
- *
- *******************************************************************************/
- #define COMP_PREFIX "NAV"
- /*******************************************************************************
- * Include Files
- *******************************************************************************/
- #include "config.h"
- #ifdef TEST_HARNASS
- #include <samp_gen.h>
- #include <samp_nav.h>
- #include <samp_nav_exp.h>
- #if 0
- #include <nav.h>
- #endif
- #include <testharn.h>
- #include <glue_osa.h>
- #include "samp_osa_exp.h"
- #include "samp_apm.h"
- #include "samp_sdm.h"
- /*******************************************************************************
- * Macro Definitions
- *******************************************************************************/
- #ifdef THGNAV
- /*******************************************************************************
- * Data Definitions
- *******************************************************************************/
- SAMP(NAV_ProgramListDef) SAMP(programList);
- SAMP(UInt32) semId1394;
- /*******************************************************************************
- * Function prototype
- *******************************************************************************/
- static SAMP(SACD_TimeCode) totc( SAMP(UInt32) min, SAMP(UInt32) sec, SAMP(UInt32) fr)
- {
- SAMP(SACD_TimeCode) t;
- t.min = (unsigned char) ( min );
- t.sec = (unsigned char) ( sec );
- t.fr = (unsigned char) ( fr );
- return t;
- }
- static void NavCallback(SAMP(BitSet32) Event, void * EventData)
- {
- switch( Event )
- {
- case NAV_ACTIVATED:
- DAC_Initialize_For_SACD(); //todo: check later.
- DAC_Set_DSD_Mode(1); //back to pcm mode.
- SAMP(APM_SetOutputMode)(SAMP(APM_OUT_DSD), SAMP(APM_OUT_DSD));
- SAMP(SDM_SetDacPinning)(0, 0,
- 0, 0,
- 0, 0,
- 0, 0,
- 0, 0,
- 0, 0,
- SAMP(SDM_DSD_CLOCK), 0, 0);
- SAMP(TH_Send)( "NAV" , "EventActivated", "" );
- break;
- case NAV_NOT_ACTIVATED:
- SAMP(TH_Send)( "NAV" , "EventNotActivated", "" );
- break;
- case NAV_STARTED:
- {
- SAMP(Int32) speed = *((SAMP(Int16) *) EventData);
- SAMP(TH_Send)( "NAV" , "EventStarted", "%d", speed );
- }
- break;
- case NAV_PAUSED:
- SAMP(TH_Send)( "NAV" , "EventPaused", "" );
- break;
- case NAV_STOPPED:
- SAMP(TH_Send)( "NAV" , "EventStopped", "" );
- break;
- case NAV_FINISHED:
- SAMP(TH_Send)( "NAV" , "EventFinished", "" );
- break;
- case NAV_PROGRESS_INFO:
- {
- SAMP(NAV_ProgressInfoDef) *info = (SAMP(NAV_ProgressInfoDef) *) EventData;
- SAMP(TH_Send)("NAV" , "ProgressInfo", "%u%u%u%u%u%u%u%u%u", (SAMP(UInt32))info->track, (SAMP(UInt32))info->index,
- (SAMP(UInt32))info->abs_time.min, (SAMP(UInt32))info->abs_time.sec,
- (SAMP(UInt32))info->abs_time.fr, (SAMP(UInt32))info->rel_time.min,
- (SAMP(UInt32))info->rel_time.sec, (SAMP(UInt32))info->rel_time.fr,
- (SAMP(UInt32))info->pause);
- }
- break;
- case NAV_MODE_CHANGE:
- {
- SAMP(NAV_ModeChangeDef) mode = *(SAMP(NAV_ModeChangeDef) *) EventData;
- SAMP(TH_Send)("NAV" , "EventModeChange", "%u%u", mode.reshuffled, mode.repeat_ab_canceled);
- }
- break;
- case NAV_WARNING:
- {
- SAMP(NAV_WarningCodeDef) warningCode = *(SAMP(NAV_WarningCodeDef) *) EventData;
- SAMP(TH_Send)( "NAV" , "EventWarning", "%u", warningCode );
- }
- break;
- case NAV_ERROR:
- {
- SAMP(NAV_ErrorCodeDef) errorCode = *(SAMP(NAV_ErrorCodeDef) *) EventData;
- SAMP(TH_Send)( "NAV" , "EventError", "%u", errorCode );
- }
- break;
- case NAV_CHANNELS_CONFIG:
- {
- SAMP(SACD_ChannelsConfigDef) channels = *((SAMP(SACD_ChannelsConfigDef) *)EventData);
- SAMP(TH_Send)( "NAV" , "EventChannelsConfig", "%u", (SAMP(UInt32))channels );
- }
- break;
- break;
- default:
- SAMP(TH_Send)( "TESTH" , "***ERROR***", "Unknown event received" );
- break;
- }
- }
- static void NavCallback1394(SAMP(BitSet32) Event, void * EventData)
- {
- switch( Event )
- {
- case NAV_1394_CHANNELS_CONFIG:
- {
- SAMP(SACD_ChannelsConfigDef) channels = *((SAMP(SACD_ChannelsConfigDef) *)EventData);
- SAMP(TH_Send)( "NAV" , "Event1394ChannelsConfig", "%u", channels );
- SAMP(OS_SemP)( semId1394, OS_FOREVER );
- }
- break;
- break;
- default:
- SAMP(TH_Send)( "TESTH" , "***ERROR***", "Unknown event received" );
- break;
- }
- }
- #endif
- DECLARE_GROUPFUNC(THG_NAV)
- /*******************************************************************************
- * Global test-harness function
- *******************************************************************************/
- DEFINE_GROUPFUNC(THG_NAV)
- #ifdef THGNAV
- GROUP_SWITCH
- #if 0
- CASE_CMD( "Init" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Init)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Term" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Term)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Activate" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Activate)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Reactivate" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Reactivate)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Deactivate" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Deactivate)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- #endif
- CASE_CMD( "AreaSwitch" )
- SAMP(UInt32) lArea;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
-
- TH_GetParam (OPTIONS, "%u", &lArea);
- lErr = SAMP_EXP(NAV_AreaSwitch)(lArea);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "PlayAtTimecode" )
- SAMP(UInt32) lStartMin;
- SAMP(UInt32) lStartSec;
- SAMP(UInt32) lStartFrame;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
-
- TH_GetParam (OPTIONS, "%u%u%u", &lStartMin, &lStartSec, &lStartFrame);
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_PlayAtTimecode)( totc(lStartMin, lStartSec, lStartFrame) );
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "PlayTrack" )
- SAMP(UInt32) lTrack;
- SAMP(UInt32) lIndex;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
-
- TH_GetParam (OPTIONS, "%u%u", &lTrack, &lIndex);
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_PlayTrack)((SAMP(UInt16))lTrack, (SAMP(UInt16))lIndex);
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", (SAMP(UInt32))lErr, (SAMP(UInt32))(endTime-startTime));
- END_CASE
- CASE_CMD( "Stop" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_Stop)();
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "Pause" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_Pause)();
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "ResumePlay" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_ResumePlay)();
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "NextTrack" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_NextTrack)();
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "PreviousTrack" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_PreviousTrack)();
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "ForwardScan" )
- SAMP(UInt32) lSpeed;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
- TH_GetParam (OPTIONS, "%u", &lSpeed);
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_ForwardScan)((SAMP(UInt8))lSpeed);
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "BackwardScan" )
- SAMP(UInt32) lSpeed;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) startTime, endTime;
- TH_GetParam (OPTIONS, "%u", &lSpeed);
- SAMP(OS_GetTime)(&startTime);
- lErr = SAMP_EXP(NAV_BackwardScan)((SAMP(UInt8))lSpeed);
- SAMP(OS_GetTime)(&endTime);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, endTime-startTime);
- END_CASE
- CASE_CMD( "Repeat" )
- SAMP(UInt32) lRepeatMode;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u", &lRepeatMode);
- switch ( lRepeatMode )
- {
- case 0 :
- lErr = SAMP_EXP(NAV_Repeat)(SAMP(NAV_REPEAT_OFF));
- break;
- case 1 :
- lErr = SAMP_EXP(NAV_Repeat)(SAMP(NAV_REPEAT_TRACK));
- break;
- case 2 :
- lErr = SAMP_EXP(NAV_Repeat)(SAMP(NAV_REPEAT_ALL));
- break;
- default :
- break;
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "RepeatAB" )
- SAMP(UInt32) lRepeatABMode;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u", &lRepeatABMode);
- switch ( lRepeatABMode )
- {
- case 0 :
- lErr = SAMP_EXP(NAV_RepeatAB)(SAMP(NAV_REPEAT_AB_OFF));
- break;
- case 1 :
- lErr = SAMP_EXP(NAV_RepeatAB)(SAMP(NAV_REPEAT_AB_A));
- break;
- case 2 :
- lErr = SAMP_EXP(NAV_RepeatAB)(SAMP(NAV_REPEAT_AB_AB));
- break;
- default :
- break;
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Shuffle" )
- SAMP(UInt32) lShuffleMode;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u", &lShuffleMode);
- switch ( lShuffleMode )
- {
- case 0 :
- lErr = SAMP_EXP(NAV_Shuffle)(FALSE);
- break;
- case 1 :
- lErr = SAMP_EXP(NAV_Shuffle)(TRUE);
- break;
- default :
- break;
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "IntroScan" )
- SAMP(UInt32) lDuration;
- SAMP(UInt32) lIntroScanMode;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u%u", &lIntroScanMode, &lDuration);
- switch ( lIntroScanMode )
- {
- case 0 :
- lErr = SAMP_EXP(NAV_IntroScan)(FALSE, (SAMP(UInt8)) lDuration);
- break;
- case 1 :
- lErr = SAMP_EXP(NAV_IntroScan)(TRUE, (SAMP(UInt8)) lDuration);
- break;
- default :
- break;
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "SetPlaySequence" )
- SAMP(UInt32) lPlaySequence;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u", &lPlaySequence);
- switch ( lPlaySequence )
- {
- case 0 :
- lErr = SAMP_EXP(NAV_SetPlaySequence)(SAMP(NAV_PLAY_SEQ_ALL));
- break;
- case 1 :
- lErr = SAMP_EXP(NAV_SetPlaySequence)(SAMP(NAV_PLAY_SEQ_PROGRAM));
- break;
- case 2 :
- lErr = SAMP_EXP(NAV_SetPlaySequence)(SAMP(NAV_PLAY_SEQ_TRACK));
- break;
- default :
- break;
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD( "SetProgramList" )
-
- /* This can be called only after tracks have been set by 'SetProgramListTrack' */
- SAMP(UInt32) number;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u", &number);
- SAMP(programList.NumberOfTracks) = (SAMP(UInt8))number;
- lErr = SAMP_EXP(NAV_SetProgramList)(&SAMP(programList));
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "SetProgramListTrack" )
- SAMP(UInt32) index, value;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u%u", &index, &value);
- SAMP(programList.tracks[index]) = (SAMP(UInt8))value;
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "GetState" )
- SAMP(NAV_StateDef) stateDef;
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_GetState)(&stateDef);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u%u%u%u%d", lErr, stateDef.PlayState,
- stateDef.PlaySequence, stateDef.RepeatMode, stateDef.RepeatABMode,
- (SAMP(UInt32))stateDef.IntroOn, (SAMP(UInt32))stateDef.ShuffleOn,
- (SAMP(Int32))stateDef.PlaySpeed);
- END_CASE
- CASE_CMD( "GetPlayList" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt8) i;
- SAMP(NAV_ProgramListDef) playList;
-
- lErr = SAMP_EXP(NAV_GetPlayList)(&playList);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, playList.NumberOfTracks);
- for(i=0; i < playList.NumberOfTracks; i++)
- {
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", playList.tracks[i]);
- }
- END_CASE
- CASE_CMD( "Subscribe" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Subscribe)( NavCallback
- , ( NAV_ACTIVATED
- | NAV_NOT_ACTIVATED
- | NAV_STARTED
- | NAV_PAUSED
- | NAV_STOPPED
- | NAV_FINISHED
- | NAV_PROGRESS_INFO
- | NAV_MODE_CHANGE
- | NAV_WARNING
- | NAV_ERROR
- | NAV_CHANNELS_CONFIG) );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD( "Unsubscribe" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Subscribe)( NavCallback, 0);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Subscribe1394" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(OS_SemCreate)(0, &semId1394);
- lErr |= SAMP_EXP(NAV_Subscribe_1394)( NavCallback1394, NAV_1394_CHANNELS_CONFIG );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Unsubscribe1394" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(NAV_Subscribe_1394)( NavCallback1394, 0);
- lErr |= SAMP_EXP(OS_SemDelete)(semId1394);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Continue1394" )
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(OS_SemV)(semId1394);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- DEFAULT
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%s", "Unknown command");
- END_CASE
- #endif
- END_GROUPFUNC
- /*******************************************************************************
- * End of File
- *******************************************************************************/
- #endif