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

DVD

开发平台:

Others

  1. #include "Config.h" // Global Configuration - do not remove!
  2. #if D_SUPPORT_SACD // ZKR GLSACD
  3. #if 1 ////////////////////////////////////////////////////////////////////////////////////////
  4. #include "IncludeSysDefs.h"
  5. #include "PlaycoreCoremaincoremain.h"
  6. #include "KerneluITRONrtos.h"
  7. #include "KernelKer_API.h"
  8. #include "KernelEventDef.h"
  9. #include "PlaycoreSAMPschedulerSAMPScheduler.h"
  10. #include "PlaycoreSAMPschedulerSAMP_API.h"
  11. #define SAMP_READY
  12. #ifdef SAMP_READY
  13. #include "playcoresampsamp_apm.h"
  14. #include "playcoresampsamp_nav.h"
  15. #include "playcoresampsamp_sdi.h"
  16. #include "playcoresampsamp_sdm.h"
  17. #endif
  18. #ifdef dbg_printf
  19. #undef dbg_printf
  20. #define dbg_printf(sMsg) printf ## sMsg
  21. #endif
  22. // *****************************************************************************
  23. // * External referencies
  24. // *****************************************************************************
  25. extern int SchedulerID;
  26. // *****************************************************************************
  27. // * Global variable
  28. // *****************************************************************************
  29. //keeps error code for API function calls
  30. SAMP(ErrCode) errorCode;
  31. static BOOL gbSAMP_APICallFinished = 0;
  32. // *****************************************************************************
  33. // * Function prototypes
  34. // *****************************************************************************
  35. SAMP(ErrCode) SAMP_API_Start (void);
  36. // *****************************************************************************
  37. // * Purpose          : Send event to CORE dispatcher and wait for the answer
  38. // * Input Parameters : APIFunction - ID of called API function
  39. // *                    errPtr - error code return by called API function
  40. // * Return Value     : TRUE - API function call executed succesfuly
  41. // *    FALSE - API function call failed
  42. // * Description : The APICallSend will send event to CORE handler 
  43. // *                   dispatcher. The parameter is required ID of API function
  44. // *                   call. The functions wait for API execution finished
  45. // * Comments   : Need to figur out correct parameter passing
  46. // *****************************************************************************
  47. BOOL SAMP_APICallRequest (UINT32 APIFunction, SAMP(ErrCode) *errPtr)
  48. {
  49. // ER SAMP(ErrCode) = E_OK;
  50.    if (SchedulerID == -1)
  51.    {
  52. tr_printf (("SAMP Scheduler is not installedn"));
  53.     return FALSE;
  54.    }
  55.    gbSAMP_APICallFinished = 0;
  56.    
  57. //send request to call API function
  58. if (!ie_send_ex(IE_CORE_SAMP_API, (void *)(APIFunction)))
  59.    {
  60.     tr_printf (("SAMP_APICall failure - sent eventn"));
  61.       return FALSE;
  62.    }
  63.    //wait for the confirmation and error code
  64. //   SAMP(ErrCode) = wai_sem(SEM_SAMP);
  65.    while(gbSAMP_APICallFinished == 0) usleep(1000UL);
  66. #if 0
  67. if (SAMP(ErrCode) != E_OK)
  68.    {
  69.     tr_printf (("SAMP_APICall failure - wait for semaphoren"));
  70.       return FALSE;
  71.    }
  72. #endif   
  73.    *errPtr = errorCode;
  74. return TRUE;
  75. }
  76. // *****************************************************************************
  77. // * Purpose          : Acknowledge the API function call is finished
  78. // * Input Parameters : err - error code return by API function call
  79. // * Return Value     : TRUE - API function call executed succesfuly
  80. // *    FALSE - API function call failed
  81. // * Description :
  82. // *****************************************************************************
  83. BOOL SAMP_APICallAcknowledge (SAMP(ErrCode) err)
  84. {
  85. //confirm the comand is executed and return the ERROR code
  86. errorCode = err;
  87.    gbSAMP_APICallFinished = 1;
  88.    return 1;
  89. //   return (sig_sem(SEM_SAMP) == E_OK);
  90. }
  91. #ifdef SAMP_READY
  92. #ifdef TEST_HARNASS
  93. // *****************************************************************************
  94. // * Purpose          : handle the NAV API function call event
  95. // * Input Parameters : err - error code return by API function call
  96. // * Return Value     : TRUE - API function call executed succesfuly
  97. // *    FALSE - API function call failed
  98. // * Description :
  99. // *****************************************************************************
  100. static SAMP(ErrCode) SAMP_NAV_API_Handler(UINT32 param)
  101. {
  102. SAMP(ErrCode) err = SAMP(ERR_OK);
  103.      switch(param)
  104.      {
  105.       case NAV_AREASWITCH:
  106.       {
  107.         SAMP(SACD_Area) Area = (SAMP(SACD_Area))SAMP_API_PARAM[0];
  108.         err = SAMP(NAV_AreaSwitch)(Area);
  109.         break;
  110.       }
  111.       case NAV_PLAYATTIMECODE:
  112.       {
  113.         SAMP(SACD_TimeCode) Timecode;
  114.         Timecode.min = (BYTE)SAMP_API_PARAM[0];
  115.         Timecode.sec = (BYTE)SAMP_API_PARAM[1];
  116.         Timecode.fr = (BYTE)SAMP_API_PARAM[2];
  117.         err = SAMP(NAV_PlayAtTimecode)(Timecode);
  118.         break;
  119.       }
  120.       case NAV_PLAYTRACK:
  121.       {
  122.         SAMP(UInt16) track = (SAMP(UInt16))SAMP_API_PARAM[0];
  123.         SAMP(UInt16) index = (SAMP(UInt16))SAMP_API_PARAM[1];
  124.         err = SAMP(NAV_PlayTrack)(track, index);
  125.         break;
  126.       }
  127.       case NAV_STOP:
  128.       {
  129.         err = SAMP(NAV_Stop)();
  130.         break;
  131.       }
  132.       case NAV_PAUSE:
  133.         err = SAMP(NAV_Pause)();
  134.         break;
  135.       case NAV_RESUMEPLAY:
  136.         err = SAMP(NAV_ResumePlay)();
  137.         break;
  138.       case NAV_NEXTTRACK:
  139.         err = SAMP(NAV_NextTrack)();
  140.         break;
  141.       case NAV_PREVIOUSTRACK:
  142.         err = SAMP(NAV_PreviousTrack)();
  143.         break;
  144.       case NAV_FORWORDSCAN:
  145.       {
  146.         SAMP(UInt8) Speed = (SAMP(UInt8))SAMP_API_PARAM[0];
  147.         err = SAMP(NAV_ForwardScan)(Speed);
  148.         break;
  149.       }
  150.       case NAV_BACKWORDSCAN:
  151.       {
  152.         SAMP(UInt8) Speed = (SAMP(UInt8))SAMP_API_PARAM[0];
  153.         err = SAMP(NAV_BackwardScan)(Speed);
  154.         break;
  155.       }
  156.       case NAV_REPEAT:
  157.       {
  158.         SAMP(NAV_RepeatModeDef) RepeatMode = (SAMP(NAV_RepeatModeDef))SAMP_API_PARAM[0];
  159.         err = SAMP(NAV_Repeat)(RepeatMode);
  160.         break;
  161.       }
  162.       case NAV_REPEATAB:
  163.       {
  164.         SAMP(NAV_RepeatABModeDef) RepeatABMode = (SAMP(NAV_RepeatABModeDef))SAMP_API_PARAM[0];
  165.         err = SAMP(NAV_RepeatAB)(RepeatABMode);
  166.         break;
  167.       }
  168.       case NAV_SHUFFLE:
  169.       {
  170.         SAMP(Bool) ShuffleMode = (SAMP(Bool))SAMP_API_PARAM[0];
  171.         err = SAMP(NAV_Shuffle)(ShuffleMode);
  172.         break;
  173.       }
  174.       case NAV_INTROSCAN:
  175.       {
  176.         SAMP(Bool) IntroScanMode = (SAMP(Bool))SAMP_API_PARAM[0];
  177.         SAMP(UInt8) Duration = SAMP_API_PARAM[1];
  178.         err = SAMP(NAV_IntroScan)(IntroScanMode, Duration);
  179.         break;
  180.       }
  181.       case NAV_SETPLAYSEQUENCE:
  182.       {
  183.         SAMP(NAV_PlaySequenceDef) PlaySequence = (SAMP(NAV_PlaySequenceDef))SAMP_API_PARAM[0];
  184.         err = SAMP(NAV_SetPlaySequence)(PlaySequence);
  185.         break;
  186.       }
  187.       case NAV_PLAYSEQUENCEDEF:
  188.       {
  189.         SAMP(NAV_ProgramListDef) *ProgramList = (SAMP(NAV_ProgramListDef) *)SAMP_API_PARAM[0];
  190.         err = SAMP(NAV_SetProgramList)(ProgramList);
  191.         break;
  192.       }
  193.       case NAV_SUBSCRIBE:
  194.       {
  195.         SAMP(NAV_CallbackDef) Callback = (SAMP(NAV_CallbackDef))SAMP_API_PARAM[0];
  196.         SAMP(BitSet32) Events = SAMP_API_PARAM[1];
  197.         err = SAMP(NAV_Subscribe)(Callback, Events);
  198.         break;
  199.       }
  200.       case NAV_SUBSCRIBE_1394:
  201.       {
  202.         SAMP(NAV_CallbackDef) Callback = (SAMP(NAV_CallbackDef))SAMP_API_PARAM[0];
  203.         SAMP(BitSet32) Events = SAMP_API_PARAM[1];
  204.         err = SAMP(NAV_Subscribe_1394)(Callback, Events);
  205.         break;
  206.       }
  207.       case NAV_GETSTATE:
  208.       {
  209.         SAMP(NAV_StateDef) *PState = (SAMP(NAV_StateDef) *)SAMP_API_PARAM[0];
  210.         err = SAMP(NAV_GetState)(PState);
  211.         break;
  212.       }
  213.       case NAV_GETPLAYLIST:
  214.       {
  215.         SAMP(NAV_ProgramListDef) *ProgramList = (SAMP(NAV_ProgramListDef) *)SAMP_API_PARAM[0];
  216.         err = SAMP(NAV_GetPlayList)(ProgramList);
  217.         break;
  218.       }
  219.      }
  220.    return err;
  221. }
  222. // *****************************************************************************
  223. // * Purpose          : handle the SDM API function call event
  224. // * Input Parameters : err - error code return by API function call
  225. // * Return Value     : TRUE - API function call executed succesfuly
  226. // *    FALSE - API function call failed
  227. // * Description :
  228. // *****************************************************************************
  229. static SAMP(ErrCode) SAMP_SDM_API_Handler(UINT32 param)
  230. {
  231. SAMP(ErrCode) err = SAMP(ERR_OK);
  232.      switch(param)
  233.      {
  234.       case  SDM_GETHANDLER:
  235.       {
  236.         SAMP(SDM_PVoidFuncDef) *ph = SAMP_API_PARAM[0];
  237.         SAMP(SDM_GetHandler)(ph);
  238.         break;
  239.       }
  240.       case  SDM_SETENGINETYPE:
  241.       {
  242.         SAMP(SDM_EngineTypeDef) Engine = SAMP_API_PARAM[0];
  243.         err = SAMP(SDM_SetEngineType)(Engine);
  244.         break;
  245.       }
  246.       case  SDM_SETDACPINNING:
  247.       {
  248.          SAMP(SDM_DataLineDef) PcmLine0 = SAMP_API_PARAM[0] & 0xf;
  249.          SAMP(SDM_DataLineDef) PcmLine1 = (SAMP_API_PARAM[0]>>8) & 0xf;
  250.          SAMP(SDM_DataLineDef) PcmLine2 = (SAMP_API_PARAM[0]>>16) & 0xf;
  251.          SAMP(SDM_DataLineDef) PcmLine3 = (SAMP_API_PARAM[0]>>24) & 0xf;
  252.          SAMP(SDM_DataLineDef) PcmLine4 = SAMP_API_PARAM[1] & 0xf;
  253.          SAMP(SDM_DataLineDef) PcmLine5 = (SAMP_API_PARAM[1]>>8) & 0xf;
  254.          SAMP(SDM_DataLineDef) PcmLine6 = (SAMP_API_PARAM[1]>>16) & 0xf;
  255.          SAMP(SDM_DataLineDef) PcmLine7 = (SAMP_API_PARAM[1]>>24) & 0xf;
  256.          SAMP(SDM_DataLineDef) PcmLine8 = (SAMP_API_PARAM[2]) & 0xf;
  257.          SAMP(SDM_DataLineDef) PcmLine9 = (SAMP_API_PARAM[2]>>8) & 0xf;
  258.          SAMP(SDM_DataLineDef) PcmLine10 = (SAMP_API_PARAM[2]>>16) & 0xf;
  259.          SAMP(SDM_DataLineDef) PcmLine11 = (SAMP_API_PARAM[2]>>24) & 0xf;
  260.          SAMP(SDM_DataLineDef) DsdLine6 = (SAMP_API_PARAM[3]) & 0xf;
  261.          SAMP(SDM_DataLineDef) DsdLine7 = (SAMP_API_PARAM[3]>>8) & 0xf;
  262.          SAMP(SDM_DataLineDef) DsdLine9 = (SAMP_API_PARAM[3]>>16) & 0xf;
  263.         err = SAMP(SDM_SetDacPinning)
  264.          (  PcmLine0
  265.          ,  PcmLine1
  266.          ,  PcmLine2
  267.          ,  PcmLine3
  268.          ,  PcmLine4
  269.          ,  PcmLine5
  270.          ,  PcmLine6
  271.          ,  PcmLine7
  272.          ,  PcmLine8
  273.          ,  PcmLine9
  274.          ,  PcmLine10
  275.          ,  PcmLine11
  276.          ,  DsdLine6
  277.          ,  DsdLine7
  278.          ,  DsdLine9);
  279.         break;
  280.       }
  281.       case  SDM_SETDSDCLKPOLARITY:
  282.       {
  283.         SAMP(Bool) Positive = SAMP_API_PARAM[0];
  284.         err = SAMP(SDM_SetDsdClockPolarity)(Positive);
  285.         break;
  286.       }
  287.       case  SDM_SETAUDIOCLK:
  288.       {
  289.         SAMP(SACD_InputModeDef) InputMode = SAMP_API_PARAM[0];
  290.         SAMP(SDM_AudioClockDef) AudioClock = SAMP_API_PARAM[1];
  291.         err = SAMP(SDM_SetAudioClock)(InputMode,
  292.                                       AudioClock);
  293.         break;
  294.       }
  295.       case  SDM_SETSYSCLK:
  296.       {
  297.         SAMP(UInt32) SystemClock = SAMP_API_PARAM[0];
  298.         err = SAMP(SDM_SetSystemClock)(SystemClock);
  299.         break;
  300.       }
  301.       case  SDM_SETBURSTLEN:
  302.       {
  303.         SAMP(UInt16) BurstLength = SAMP_API_PARAM[0];
  304.         err = SAMP(SDM_SetBurstLength)(BurstLength);
  305.         break;
  306.       }
  307.       case  SDM_ENA_DTCP:
  308.       {
  309.         SAMP(Bool) enableDTCP = (SAMP(Bool))SAMP_API_PARAM[0];
  310.         err = SAMP(SDM_EnableDTCP)(enableDTCP);
  311.         break;
  312.       }
  313.      }
  314.    return err;
  315. }
  316. // *****************************************************************************
  317. // * Purpose          : handle the APM API function call event
  318. // * Input Parameters : err - error code return by API function call
  319. // * Return Value     : TRUE - API function call executed succesfuly
  320. // *    FALSE - API function call failed
  321. // * Description :
  322. // *****************************************************************************
  323. static SAMP(ErrCode) SAMP_APM_API_Handler(UINT32 param)
  324. {
  325.   SAMP(ErrCode) err = SAMP(ERR_OK);
  326.      switch(param)
  327.      {
  328.       case  APM_SET_INPUTMODE:
  329.       {
  330.         SAMP(SACD_InputModeDef) InputStream = SAMP_API_PARAM[0];
  331.         err = SAMP(APM_SetInputMode)(InputStream);
  332.         break;
  333.       }
  334.       case  APM_SET_OUTPUTMODE:
  335.       {
  336.         SAMP(APM_OutputModeDef) out_mode_6ch = SAMP_API_PARAM[0];
  337.         SAMP(APM_OutputModeDef) out_mode_2ch = SAMP_API_PARAM[1];
  338.         err = SAMP(APM_SetOutputMode)(out_mode_6ch, out_mode_2ch);
  339.         break;
  340.       }
  341.       case  APM_SET_6CHDOWNMIX:
  342.       {
  343.         SAMP(APM_6ch_MixDef) Downmix = SAMP_API_PARAM[0];
  344.         err = SAMP(APM_Set6chDownmix)(Downmix);
  345.         break;
  346.       }
  347.       case  APM_SET_2CHDOWNMIX:
  348.       {
  349.         SAMP(APM_2ch_MixDef) Downmix = SAMP_API_PARAM[0];
  350.         err = SAMP(APM_Set2chDownmix)(Downmix);
  351.         break;
  352.       }
  353.       case  APM_SET_SPEAKERS:
  354.       {
  355.         SAMP(APM_SpeakerDef) Speakers = SAMP_API_PARAM[0];
  356.         err = SAMP(APM_SetSpeakers)(Speakers);
  357.         break;
  358.       }
  359.       case  APM_SET_ATTENUATION:
  360.       {
  361.         SAMP(UInt16) Attenuation[8];
  362.         Attenuation[0] = SAMP_API_PARAM[0];
  363.         Attenuation[1] = SAMP_API_PARAM[1];
  364.         Attenuation[2] = SAMP_API_PARAM[2];
  365.         Attenuation[3] = SAMP_API_PARAM[3];
  366.         Attenuation[4] = SAMP_API_PARAM[4];
  367.         Attenuation[5] = SAMP_API_PARAM[5];
  368.         Attenuation[6] = SAMP_API_PARAM[6];
  369.         Attenuation[7] = SAMP_API_PARAM[7];
  370.         err = SAMP(APM_SetAttenuation)(Attenuation);
  371.         break;
  372.       }
  373.       case  APM_SET_DELAY:
  374.       {
  375.         SAMP(UInt32) Delay[6];
  376.         Delay[0] = SAMP_API_PARAM[0];
  377.         Delay[1] = SAMP_API_PARAM[1];
  378.         Delay[2] = SAMP_API_PARAM[2];
  379.         Delay[3] = SAMP_API_PARAM[3];
  380.         Delay[4] = SAMP_API_PARAM[4];
  381.         Delay[5] = SAMP_API_PARAM[5];
  382.         err = SAMP(APM_SetDelay)(Delay);
  383.         break;
  384.       }
  385.       case  APM_SET_FILTERMODE:
  386.       {
  387.         SAMP(APM_FilterModeDef) FilterMode = SAMP_API_PARAM[0];
  388.         err = SAMP(APM_SetFilterMode)(FilterMode);
  389.         break;
  390.       }
  391.       case  APM_SET_PCMUPSAMPLING:
  392.       {
  393.         SAMP(UInt8) Upsampling = SAMP_API_PARAM[0];
  394.         err = SAMP(APM_SetPcmUpsampling)(Upsampling);
  395.         break;
  396.       }
  397.       case  APM_SET_BASSFILTERS:
  398.       {
  399.         SAMP(APM_BassFrequencyDef) BassFrequency = SAMP_API_PARAM[0];
  400.         SAMP(APM_BassSlopeDef) BassSlope = SAMP_API_PARAM[1];
  401.         err = SAMP(APM_SetBassFilters)(BassFrequency, BassSlope);
  402.         break;
  403.       }
  404.       case  APM_SET_PIO:
  405.       {
  406.         SAMP(BitSet16) pio_bits = SAMP_API_PARAM[0];
  407.         err = SAMP(APM_SetPIO)(pio_bits);
  408.         break;
  409.       }
  410.      }
  411.      return err;
  412. }
  413. // *****************************************************************************
  414. // * Purpose          : handle the SAMP API function call event
  415. // * Input Parameters : err - error code return by API function call
  416. // * Return Value     : TRUE - API function call executed succesfuly
  417. // *    FALSE - API function call failed
  418. // * Description :
  419. // *****************************************************************************
  420. static SAMP(ErrCode) SAMP_SAMP_API_Handler(UINT32 param)
  421. {
  422.   SAMP(ErrCode) err = SAMP(ERR_OK);
  423.      switch(param)
  424.      {
  425.       case  SAMP_INIT:
  426.       {
  427.         err = SAMP(SAMP_Init)();
  428.         break;
  429.       }
  430.       case  SAMP_TERM:
  431.       {
  432.         err = SAMP(SAMP_Term)();
  433.         break;
  434.       }
  435.       case  SAMP_SACDDISCREC:
  436.       {
  437.         SAMP(Bool) *pSACD = SAMP_API_PARAM[0];
  438.         SAMP(Bool) *pHybrid = SAMP_API_PARAM[1];
  439.         err = SAMP(SAMP_SACDDiscRec)(pSACD, pHybrid);
  440.         break;
  441.       }
  442.       case  SAMP_ACTIVATE:
  443.       {
  444.         SAMP(Bool) discRecognised = SAMP_API_PARAM[0];
  445.         SAMP(SAMP_AreaInfoDef) *pST_Info = SAMP_API_PARAM[1];
  446.         SAMP(SAMP_AreaInfoDef) *pMC_Info = SAMP_API_PARAM[2];
  447.         SAMP(Bool) *pHybrid = SAMP_API_PARAM[3];
  448.         err = SAMP(SAMP_Activate)(discRecognised, pST_Info, pMC_Info, pHybrid);
  449.         break;
  450.       }
  451.       case  SAMP_DEACTIVATE:
  452.       {
  453.         err = SAMP(SAMP_Deactivate)();
  454.         break;
  455.       }
  456.       case  SAMP_REACTIVATE:
  457.       {
  458.         err = SAMP(SAMP_Reactivate)();
  459.         break;
  460.       }
  461.       case  SAMP_SUBSCRIBE:
  462.       {
  463.         SAMP(SAMP_CallbackDef) Callback = SAMP_API_PARAM[0];
  464.         SAMP(BitSet32) Events = SAMP_API_PARAM[1];
  465.         err = SAMP(SAMP_Subscribe)(Callback, Events);
  466.         break;
  467.       }
  468.      }
  469.      return err;
  470. }
  471. // *****************************************************************************
  472. // * Purpose          : handle the OSA API function call event
  473. // * Input Parameters : err - error code return by API function call
  474. // * Return Value     : TRUE - API function call executed succesfuly
  475. // *    FALSE - API function call failed
  476. // * Description :
  477. // *****************************************************************************
  478. static SAMP(ErrCode) SAMP_OSA_API_Handler(UINT32 param)
  479. {
  480.   SAMP(ErrCode) err = SAMP(ERR_OK);
  481.      switch(param)
  482.      {
  483.       case  OSA_TASK_CREATE:
  484.       {
  485.         PRIORITY Priority = (PRIORITY)SAMP_API_PARAM[0];
  486.         size_t Stacksize = (size_t)SAMP_API_PARAM[1];
  487.         FP Entry = SAMP_API_PARAM[2];
  488.         IDENT *Id = (IDENT *)SAMP_API_PARAM[3];
  489.         err = SAMP(OS_TaskCreate) (Priority, Stacksize, Entry, Id);
  490.         break;
  491.       }
  492.       case  OSA_TASK_DELETE:
  493.       {
  494.         IDENT Id = (IDENT)SAMP_API_PARAM[0];
  495.         err = SAMP(OS_TaskDelete) (Id);
  496.         break;
  497.       }
  498.       case  OSA_SEM_CREATE:
  499.       {
  500.         UNITS Units = (UNITS)SAMP_API_PARAM[0];
  501.         IDENT *Id = (IDENT *)SAMP_API_PARAM[1];
  502.         err = SAMP(OS_SemCreate) (Units, Id);
  503.         break;
  504.       }
  505.       case  OSA_SEM_DELETE:
  506.       {
  507.         IDENT Id = (IDENT)SAMP_API_PARAM[0];
  508.         err = SAMP(OS_SemDelete) (Id);
  509.         break;
  510.       }
  511.       case  OSA_SEM_V:
  512.       {
  513.         IDENT Id = (IDENT)SAMP_API_PARAM[0];
  514.         err = SAMP(OS_SemV) (Id);
  515.         break;
  516.       }
  517.      }
  518.      return err;
  519. }
  520. #endif
  521. #endif
  522. // *****************************************************************************
  523. // * Purpose          : handle the SDI API function call event
  524. // * Input Parameters : err - error code return by API function call
  525. // * Return Value     : TRUE - API function call executed succesfuly
  526. // *    FALSE - API function call failed
  527. // * Description :
  528. // *****************************************************************************
  529. static SAMP(ErrCode) SAMP_SDI_API_Handler(UINT32 param)
  530. {
  531. SAMP(ErrCode) err = SAMP(ERR_OK);
  532.      switch(param)
  533.      {
  534.       case SDI_SETAVAILABLECHARSETS:
  535.       {
  536.         SAMP(UInt8) nrOfCharSets = (SAMP(UInt8))SAMP_API_PARAM[0];
  537.         SAMP(UInt8) *pCharSetList = (SAMP(UInt8)*)SAMP_API_PARAM[1];
  538.         err = SAMP(SDI_SetAvailableCharSets)(nrOfCharSets, pCharSetList );
  539.         break;
  540.       }
  541.       case SDI_SETLANGPREF:
  542.       {
  543.         SAMP(UInt8) nrOfLanguages = (SAMP(UInt8))SAMP_API_PARAM[0];
  544.         SAMP(SDI_LanguageCodeDef) *pLanguageCodes = (SAMP(SDI_LanguageCodeDef) *)SAMP_API_PARAM[1];
  545.         err = SAMP(SDI_SetLanguagePreference)(nrOfLanguages, pLanguageCodes );
  546.         break;
  547.       }
  548.       case SDI_GETALBUMINFO:
  549.       {
  550.         SAMP(SDI_Album_Info) *pAlbumInfo = (SAMP(SDI_Album_Info) *)SAMP_API_PARAM[0];
  551.         err = SAMP(SDI_GetAlbumInfo)(pAlbumInfo );
  552.         break;
  553.       }
  554.       case SDI_GETALBUMTEXT:
  555.       {
  556.         SAMP(SDI_AlbumTextField) field = (SAMP(SDI_AlbumTextField))SAMP_API_PARAM[0];
  557.         SAMP(SDI_TextChannelType) type = (SAMP(SDI_TextChannelType))SAMP_API_PARAM[1];
  558.         SAMP(UInt32) bufferSize = (SAMP(UInt32))SAMP_API_PARAM[2];
  559.         void *pAlbumText = (void *)SAMP_API_PARAM[3];
  560.         SAMP(UInt8) *pCharSet = (SAMP(UInt8) *)SAMP_API_PARAM[4];
  561.         SAMP(SDI_LanguageCodeDef) *pLanguage = (SAMP(SDI_LanguageCodeDef) *)SAMP_API_PARAM[5];
  562.         err = SAMP(SDI_GetAlbumText)(field, type, bufferSize, pAlbumText, pCharSet, pLanguage );
  563.         break;
  564.       }
  565.       case SDI_GETDISCINFO:
  566.       {
  567.         SAMP(SDI_Disc_Info) *pDiscInfo = (SAMP(SDI_Disc_Info) *)SAMP_API_PARAM[0];
  568.         err = SAMP(SDI_GetDiscInfo)(pDiscInfo );
  569.         break;
  570.       }
  571.       case SDI_GETDISCTEXT:
  572.       {
  573.         SAMP(SDI_DiscTextField) field = (SAMP(SDI_DiscTextField))SAMP_API_PARAM[0];
  574.         SAMP(SDI_TextChannelType) type = SAMP_API_PARAM[1];
  575.         SAMP(UInt32) bufferSize = SAMP_API_PARAM[2];
  576.         void *pDiscText = (void *)SAMP_API_PARAM[3];
  577.         SAMP(UInt8) *pCharSet = (SAMP(UInt8) *)SAMP_API_PARAM[4];
  578.         SAMP(SDI_LanguageCodeDef) *pLanguage = (SAMP(SDI_LanguageCodeDef) *)SAMP_API_PARAM[5];
  579.         err = SAMP(SDI_GetDiscText)( field, type, bufferSize, pDiscText, pCharSet, pLanguage );
  580.         break;
  581.       }
  582.       case SDI_GETAREATEXT:
  583.       {
  584.         SAMP(SACD_Area) area = SAMP_API_PARAM[0];
  585.         SAMP(SDI_AreaTextField) field = SAMP_API_PARAM[1];
  586.         SAMP(SDI_TextChannelType) type = SAMP_API_PARAM[2];
  587.         SAMP(UInt32) bufferSize = SAMP_API_PARAM[3];
  588.         void *pAreaText = (void *)SAMP_API_PARAM[4];
  589.         SAMP(UInt8) *pCharSet = (SAMP(UInt8) *)SAMP_API_PARAM[5];
  590.         SAMP(SDI_LanguageCodeDef) *pLanguage = (SAMP(SDI_LanguageCodeDef) *)SAMP_API_PARAM[6];
  591.         err = SAMP(SDI_GetAreaText)( area, field, type, bufferSize, pAreaText, pCharSet, pLanguage );
  592.         break;
  593.       }
  594.       case SDI_GETTRACKINFO:
  595.       {
  596.         SAMP(SACD_Area) area = SAMP_API_PARAM[0];
  597.         SAMP(UInt8) trackNr = SAMP_API_PARAM[1];
  598.         SAMP(SDI_Track_Info) *pTrackInfo = (SAMP(SDI_Track_Info) *)SAMP_API_PARAM[2];
  599.         err = SAMP(SDI_GetTrackInfo)(area, trackNr, pTrackInfo );
  600.         break;
  601.       }
  602.       case SDI_GETTRACKTEXT:
  603.       {
  604.         SAMP(SACD_Area) area = SAMP_API_PARAM[0];
  605.         SAMP(UInt8) trackNr = SAMP_API_PARAM[1];
  606.         SAMP(SDI_TrackTextField) field = SAMP_API_PARAM[2];
  607.         SAMP(SDI_TextChannelType) type = SAMP_API_PARAM[3];
  608.         SAMP(UInt32) bufferSize = SAMP_API_PARAM[4];
  609.         void *pTrackText = (void *)SAMP_API_PARAM[5];
  610.         SAMP(UInt8) *pCharSet = (SAMP(UInt8) *)SAMP_API_PARAM[6];
  611.         SAMP(SDI_LanguageCodeDef) *pLanguage = (SAMP(SDI_LanguageCodeDef) *)SAMP_API_PARAM[7];
  612.         err = SAMP(SDI_GetTrackText)(area, trackNr, field, type, bufferSize, pTrackText, pCharSet, pLanguage );
  613.         break;
  614.       }
  615.       case SDI_GETNUMOFINDEX:
  616.       {
  617.         SAMP(SACD_Area) area = SAMP_API_PARAM[0];
  618.         SAMP(UInt8) track = SAMP_API_PARAM[1];
  619.         SAMP(UInt8) *pNrOfIndices = (SAMP(UInt8) *)SAMP_API_PARAM[2];
  620.         err = SAMP(SDI_GetNumberOfIndices)(area, track, pNrOfIndices );
  621.         break;
  622.       }
  623.       case SDI_GETDTCPINFO:
  624.       {
  625.         SAMP(UInt32) offset = SAMP_API_PARAM[0];
  626.         SAMP(UInt32) size = SAMP_API_PARAM[1];
  627.         void *pBuffer = (void *)SAMP_API_PARAM[2];
  628.         err = SAMP(SDI_GetDTCP_Info)(offset, size, pBuffer);
  629.         break;
  630.       }
  631.       case SDI_GETSPECVERSION:
  632.       {
  633.         SAMP(SDI_Spec_Version) *pSpecVersion = (SAMP(SDI_Spec_Version) *)SAMP_API_PARAM[0];
  634.         err = SAMP(SDI_GetSpecVersion)(pSpecVersion );
  635.         break;
  636.       }
  637.       case SDI_GETAREADATA:
  638.       {
  639.         SAMP(SACD_Area) area = SAMP_API_PARAM[0];
  640.         SAMP(SDI_Area_Data) *pAreaData = (SAMP(SDI_Area_Data) *)SAMP_API_PARAM[1];
  641.         err = SAMP(SDI_GetAreaData)(area, pAreaData );
  642.         break;
  643.       }
  644.      }
  645.    return err;
  646. }
  647. // *****************************************************************************
  648. // * Purpose          : API function call collector
  649. // * Input Parameters : param - IDE of the API function
  650. // * Return Value     : NA
  651. // * Description : Call API function according requeste parameter, after the
  652. // *                   API function call set error code in global variable and
  653. // *                  confirm the execution is finished to caller
  654. // *****************************************************************************
  655. void SAMP_API_Handler (UINT32 param)
  656. {
  657. SAMP(ErrCode) err = SAMP(ERR_OK);
  658.    char group = param >>8;
  659. #ifdef SAMP_READY
  660.    if(SDI_GROUP == group)
  661.    {
  662.      err = SAMP_SDI_API_Handler(param);
  663.    }
  664. #endif
  665. //for test only
  666. #ifdef TEST_HARNASS
  667. #ifdef SAMP_READY
  668.    else
  669.    if(NAV_GROUP == group)
  670.    {
  671.      err = SAMP_NAV_API_Handler(param);
  672.    }
  673.    else
  674.    if(SDM_GROUP == group)
  675.    {
  676.      err = SAMP_SDM_API_Handler(param);
  677.    }
  678.    else
  679.    if(APM_GROUP == group)
  680.    {
  681.      err = SAMP_APM_API_Handler(param);
  682.    }
  683.    else
  684.    if(SAMP_GROUP == group)
  685.    {
  686.      err = SAMP_SAMP_API_Handler(param);
  687.    }
  688.    else
  689.    if(OSA_GROUP == group)
  690.    {
  691.      err = SAMP_OSA_API_Handler(param);
  692.    }
  693. #endif
  694.    else
  695.    {
  696.      switch (param)
  697.      {
  698.    case SAMP_API_START:
  699.      err = SAMP_API_Start ();
  700.        break;
  701.       default:
  702.      dbg_printf (("The API command was not recognizedn"));
  703.        break;;
  704.      }
  705.    }
  706. #endif
  707.    SAMP_APICallAcknowledge (err);
  708. }
  709. #ifdef TEST_HARNASS
  710. // *****************************************************************************
  711. // * Purpose          : Start SAMP code by creating first task
  712. // * Input Parameters : NA
  713. // * Return Value     : error code of OS - schedular function
  714. // *****************************************************************************
  715. extern void task0 (void);
  716. extern IDENT tid0;
  717. SAMP(ErrCode) SAMP_API_Start (void)
  718. {
  719. return SAMP(OS_TaskCreate) (5,1500,task0,&tid0);
  720. }
  721. #endif
  722. #endif
  723. #endif // D_SUPPORT_SACD