thg_samp.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:11k
- /*******************************************************************************
- * 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_samp.c %
- * %version: 15 %
- * %date_modified: Thu Nov 21 10:59:44 2002 %
- * %derived_by: hooydona %
- * Creation date: Wed Nov 07 16:34:46 2001
- * First author: coenen
- *
- * Advanced Systems and Applications Lab - Eindhoven
- *
- * Continuus %full_filespec: thg_samp.c~15:csrc:1 %
- *
- * Description: Test harness of SAMP
- *
- * Change history:
- *
- * Rev Date Who Comments
- * ---- ---------- ---------- -----------------------------------------------------
- * 1 2001-08-10 coenen Initial version
- * 2 2001-11-22 novosadt Adopted for new SAMP_Activate (PR70)
- * 3 2001-11-22 kasterej Add subscribe/unsubscribe functions
- * (subscription removed in Init function)
- * 4-6 2001-12-18 kokh Various changes
- * 7 2001-12-20 klerxm Include all local stuff only if THGSAMP defined
- * 8 2002-01-22 potm Added SAMP_SACDDiscRec function
- * 9 2002-01-29 kokh Fixed small bug in THG_GetTrackTiming
- * 10 2002-01-30 potm Adapted to new prototype of SAMP_Activate (CR284)
- * 11 2002-02-19 klerxm See CRPR154: Removed unused include files <bsp.h>
- * and <dxx.h>
- * 12 2002-02-27 kokh TH_Send -> SAMP(TH_Send)
- * 13 2002-11-08 potm Added parameter to event NOT_ACTIVATED (PR423)
- * 14 2002-11-21 potm Added SAMP_GetSignature (PR406)
- *
- *******************************************************************************/
- #define COMP_PREFIX "SAMP"
- /*******************************************************************************
- * Include Files
- *******************************************************************************/
- #include "config.h"
- #ifdef TEST_HARNASS
- #include <samp_gen.h>
- #include "samp_samp_exp.h"
- #include <samp_sdm.h>
- #include <samp_sdi.h>
- #include <samp_nav.h>
- #include <glue_test.h>
- #include <glue_osa.h>
- #include "PlaycoreSAMPschedulerSAMPScheduler.h"
- #include "Playcorescpadscmgr.h"
- #if 0
- #include <fur.h>
- #include <psp.h>
- #include <sp.h>
- #include <buf.h>
- #include <dmx.h>
- #include <lld.h>
- #include <app.h>
- #include <bp.h>
- #include <sbm.h>
- #include <ad.h>
- #include <apm.h>
- #include <pbc.h>
- #include <sdm.h>
- #include <sdi.h>
- #include <nav.h>
- #endif
- #include <fatal.h>
- #include <testharn.h>
- #include <stdlib.h>
- #include <stdio.h>
- /*******************************************************************************
- * Macro Definitions
- *******************************************************************************/
- /*******************************************************************************
- * Data Definitions
- *******************************************************************************/
- #ifdef THGSAMP
- /*static SAMP(SAMP_AreaInfoDef) stereo;
- static SAMP(SAMP_AreaInfoDef) multi;*/
- static SAMP(Bool) sacd;
- static SAMP(Bool) hybrid;
- extern const char *pSignature;
- #endif
- /*******************************************************************************
- * Local Functions
- *******************************************************************************/
- #ifdef THGSAMP
- static void SampCallback(SAMP(BitSet32) Event, void * EventData)
- {
- char bufferStereo[5];
- char bufferMulti[5];
- switch( Event )
- {
- case SAMP_ACTIVATED :
- sc_GetBytes32(SDRAM_2CH_AREA_INFO_BASE, 0, 5, bufferStereo);
- sc_GetBytes32(SDRAM_MULTICH_AREA_INFO_BASE, 0, 5, bufferMulti);
- /*SAMP(TH_Send)( "SAMP"
- , "EventActivated"
- , "%d%d%u%u%u%d%d%u%u%u%u"
- , (SAMP(UInt32))stereo.NumberOfTracks
- , (SAMP(UInt32))stereo.TrackOffset
- , (SAMP(UInt32))stereo.TotalAreaTime.min
- , (SAMP(UInt32))stereo.TotalAreaTime.sec
- , (SAMP(UInt32))stereo.TotalAreaTime.fr
- , (SAMP(UInt32))multi.NumberOfTracks
- , (SAMP(UInt32))multi.TrackOffset
- , (SAMP(UInt32))multi.TotalAreaTime.min
- , (SAMP(UInt32))multi.TotalAreaTime.sec
- , (SAMP(UInt32))multi.TotalAreaTime.fr
- , (SAMP(UInt32))hybrid );*/
- SAMP(TH_Send)( "SAMP"
- , "EventActivated"
- , "%d%d%u%u%u%d%d%u%u%u%u"
- , (SAMP(UInt32))bufferStereo[0]
- , (SAMP(UInt32))bufferStereo[1]
- , (SAMP(UInt32))bufferStereo[2]
- , (SAMP(UInt32))bufferStereo[3]
- , (SAMP(UInt32))bufferStereo[4]
- , (SAMP(UInt32))bufferMulti[0]
- , (SAMP(UInt32))bufferMulti[1]
- , (SAMP(UInt32))bufferMulti[2]
- , (SAMP(UInt32))bufferMulti[3]
- , (SAMP(UInt32))bufferMulti[4]
- , (SAMP(UInt32))hybrid );
- break;
- case SAMP_NOT_ACTIVATED:
- SAMP(TH_Send)( "SAMP" , "EventNotActivated", "%u", (SAMP(UInt32))EventData );
- break;
- default:
- SAMP(TH_Send)( "TESTH" , "***ERROR***", "Unknown event received" );
- break;
- }
- }
- #endif
- DECLARE_GROUPFUNC(THG_SAMP)
- /*******************************************************************************
- * Global test-harness function
- *******************************************************************************/
- DEFINE_GROUPFUNC(THG_SAMP)
- int i;
- GROUP_SWITCH
- #ifdef THGSAMP
- CASE_CMD("Init")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(SAMP_Init)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("Term")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(SAMP_Term)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("SACDDiscRec")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(SAMP_SACDDiscRec)(&sacd, &hybrid);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s%s", (SAMP(UInt32))lErr, sacd ? "TRUE" : "FALSE",
- hybrid ? "TRUE" : "FALSE");
- END_CASE
- CASE_CMD("Activate")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) lDiscRecognised;
- TH_GetParam (OPTIONS, "%u", &lDiscRecognised);
- lErr = SAMP_EXP(SAMP_Activate)(lDiscRecognised ? TRUE : FALSE, NULL, NULL, &hybrid);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("Deactivate")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(SAMP_Deactivate)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("Reactivate")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(SAMP_Reactivate)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("GetSignature")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(Byte) pPartialSignature[128];
- char pCharBuffer[3];
- SAMP(Byte) curChar;
- SAMP(UInt32) signatureIndex;
- pPartialSignature[0] = 0;
- /* Make sure there are no characters that confuse the test generator */
- /* Output it to the serial port */
- signatureIndex = 0;
- while((curChar = pSignature[signatureIndex]) != 0)
- {
- ASSERT(curChar >= 32 && curChar < 127);
- switch(curChar)
- {
- case '\':
- sprintf(pCharBuffer, "\\");
- break;
- case ',':
- sprintf(pCharBuffer, "\c");
- break;
- case '[':
- sprintf(pCharBuffer, "\(");
- break;
- case ']':
- sprintf(pCharBuffer, "\)");
- break;
- default:
- sprintf(pCharBuffer, "%c", curChar);
- break;
- }
- strcat((char *)pPartialSignature, (const char *)pCharBuffer);
- if(strlen((char *)pPartialSignature) > 100)
- {
- SAMP(TH_Send)(COMP_PREFIX, "SignaturePart", "%s", pPartialSignature);
- pPartialSignature[0] = 0;
- }
- signatureIndex++;
- }
- if(strlen((char *)pPartialSignature))
- {
- SAMP(TH_Send)(COMP_PREFIX, "SignaturePart", "%s", pPartialSignature);
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("Subscribe")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(SAMP_Subscribe)( SampCallback
- , ( SAMP_ACTIVATED
- | SAMP_NOT_ACTIVATED ) );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("Unsubscribe")
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- lErr = SAMP_EXP(SAMP_Subscribe)( SampCallback, 0 );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", (SAMP(UInt32))lErr);
- END_CASE
- CASE_CMD("THG_GetTrackTiming")
- SAMP(UInt32) lArea;
- SAMP(UInt32) lTrack;
- char NumberOfTracks;
- char start[3];
- char length[3];
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- TH_GetParam (OPTIONS, "%u%u", &lArea, &lTrack);
- lTrack--;
- if (lArea == SAMP(SACD_AREA_MULTICHANNEL))
- {
- sc_GetBytes32(SDRAM_MULTICH_AREA_INFO_BASE, 0, 1, &NumberOfTracks);
- if (lTrack>=NumberOfTracks)
- {
- lErr = SAMP(ERR_INVALID_PARAM);
- } else
- {
- sc_GetBytes32(SDRAM_MULTICH_AREA_INFO_BASE, 5 + lTrack * 3, 3, start);
- sc_GetBytes32(SDRAM_MULTICH_AREA_INFO_BASE, 5 + NumberOfTracks * 3 + lTrack * 3, 3, length);
- }
- } else if (lArea == SAMP(SACD_AREA_STEREO))
- {
- sc_GetBytes32(SDRAM_2CH_AREA_INFO_BASE, 0, 1, &NumberOfTracks);
- if (lTrack>=NumberOfTracks)
- {
- lErr = SAMP(ERR_INVALID_PARAM);
- } else
- {
- sc_GetBytes32(SDRAM_2CH_AREA_INFO_BASE, 5 + lTrack * 3, 3, start);
- sc_GetBytes32(SDRAM_2CH_AREA_INFO_BASE, 5 + NumberOfTracks * 3 + lTrack * 3, 3, length);
- }
- } else
- {
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u%u%u%u", (SAMP(UInt32))lErr, (SAMP(UInt32))start[0], (SAMP(UInt32))start[1], (SAMP(UInt32))start[2], (SAMP(UInt32))length[0], (SAMP(UInt32))length[1], (SAMP(UInt32))length[2]);
- END_CASE
- #endif
- DEFAULT
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%s", "Unknown command");
- END_CASE
- END_GROUPFUNC
- /*******************************************************************************
- * End of File
- *******************************************************************************/
- #endif