thg_sdi.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:36k
- /*******************************************************************************
- * 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_sdi.c %
- * %version: 33 %
- * %date_modified: Thu Nov 28 10:59:56 2002 %
- * %derived_by: potm %
- * Creation date: Thu Jun 14 16:22:32 2001
- * First author: klerxm
- *
- * Advanced Systems and Applications Lab - Eindhoven
- *
- * Continuus %full_filespec: thg_sdi.c~33:csrc:1 %
- *
- * Description: Test harness of SACD Disc Information
- *
- * Change history:
- *
- * Rev Date Who Comments
- * ---- ---------- -------- -----------------------------------------------------
- * 1 2001-06-06 klerxm Dummy version
- * 2 2001-06-14 klerxm Template update
- * 3 2001-08-24 potm First real version
- * 4 2001-09-04 klerxm Changes required for new global header files
- * 5 2001-09-13 klerxm
- * 6 2001-10-12 coenen
- * 7 2001-10-18 potm - Added parameter for language to text functions
- * - Area info now returned by SDI EventActivated
- * 8 2001-10-30 potm - Removed (Un)RegisterClient
- * - Fixed wrong types in TH_GetParam
- * - Added SetAvailableCharSets
- * 9 2001-11-07 potm Replaced SDI_AreaInfoDef with SAMP_AreaInfoDef
- * 10 2001-11-13 potm Increased size of UInt8Array
- * 11 2001-11-20 potm - Added pHybrid parameter to SDI_Activate
- * - Extended DumpToc test harness function to
- * print the address and the length of the TOC
- * simplifying dumping the TOC to a file from
- * the debugger
- * 12 2001-11-22 kasterej Add subscribe/unsubscribe functions
- * (subscription removed in Init function)
- * 13 2001-11-29 potm Extended DumpToc to be able to retrieve the master
- * TOC (0=master, 1=stereo, 2=multichannel)
- * 14 2001-12-20 klerxm Include all local stuff only if THGSDI defined
- * 15 2002-01-04 kokh Fixed bug in SetAvailableCharSets and
- * SetLanguagePreference
- * 16 2002-01-10 sribnyid GetAudioMode added
- * 17 2002-01-16 potm - Added comments
- * - Fixed bug in GetSubRangeStart
- * 18 2002-01-22 potm Added SDI_RecogniseDisc (CR218)
- * 19 2002-01-30 potm Adapted to new prototype of SDI_Activate (CR284)
- * 20 2002-02-18 potm Adapted to new prototype of
- * SDI_SetLanguagePreference (CR340)
- * 21 2002-02-22 potm Replaced SDI_InputChannels with
- * SACD_ChannelsConfigDef (CR260)
- * 22 2002-02-27 kokh TH_Send -> SAMP(TH_Send)
- * 23 2002-03-04 potm Fixed several bugs in PrepareTextItem
- * 24 2002-04-19 klerxm Fixed compiler warning if THGSDI not defined
- * 25 2002-05-13 potm Added proper string termination for SDI_GetAlbumText
- * 26 2002-06-07 klerxm Moved tocBuffer and textBuffer outside groupswitch to
- * prevent stack overflow
- * 27 2002-09-23 klerxm Use only UInt32 type parameters with TH_GetParam
- * 28 2002-10-14 potm Fixed some warnings
- * 29 2002-10-16 potm Added functions testAreaInfoTrackStart and
- * testAreaInfoTrackLength to be able to test area info
- * returned after activation (PR417)
- * 30 2002-11-08 potm Added parameter to EVENT_NOT_ACTIVATED (PR423)
- * 31 2002-11-13 klerxm Increased size of textBuffer (PR448)
- * 32 2002-11-28 potm Added asynchronous version of RecogniseDisc function
- * (test harness only) to be able to test SDI more
- * thoroughly (PR440)
- * 33 2003-02-14 potm Added SDI_GetSpecVersion and SDI_GetDTCP_Info (CR405)
- *
- *******************************************************************************/
- #define COMP_PREFIX "SDI"
- /*******************************************************************************
- * Include Files
- *******************************************************************************/
- #include "config.h"
- #ifdef TEST_HARNASS
- #include <samp_gen.h>
- #include <samp_sdi.h>
- #include <samp_sdi_exp.h>
- #include <glue_osa.h>
- #if 0
- #include <sbm.h>
- #include <sdi.h>
- #include <sdm.h>
- #endif
- #include "samp_osa_exp.h"
- #include <stdio.h>
- #include <testharn.h>
- #include <fatal.h>
- #include <glue_test.h>
- #ifdef THGSDI
- /*******************************************************************************
- * Macro Definitions
- *******************************************************************************/
- /*
- * The following lines are copied from sdi_tocoffsets.h
- */
- #define SDI_MASTER_TOC_0 0
- #define SDI_DISC_INFO (SDI_MASTER_TOC_0 + 64)
- #define SDI_2CH_TOC_LENGTH (SDI_DISC_INFO + 20)
- #define SDI_MC_TOC_LENGTH (SDI_DISC_INFO + 22)
- /*******************************************************************************
- * Data Definitions
- *******************************************************************************/
- static SAMP(Bool) sacd;
- static SAMP(SAMP_AreaInfoDef) stAreaInfo;
- static SAMP(SAMP_AreaInfoDef) mcAreaInfo;
- static SAMP(Bool) hybrid;
- static SAMP(Byte) textBuffer[400];
- #ifdef DUMPTOC
- static SAMP(Byte) tocBuffer[79*2048];
- /*******************************************************************************
- * External functions
- *******************************************************************************/
- extern SAMP(SBM_ID) SAMP(sdiAreaToBufferId)(SAMP(SACD_Area) area);
- #endif
- extern SAMP(UInt32) SAMP(sdiMasterTocId);
- /*******************************************************************************
- * Local functions
- *******************************************************************************/
- static void SdiCallback(SAMP(BitSet32) Event, void * EventData)
- {
- switch( Event )
- {
- #if 0
- case SDI_EVENT_ACTIVATED:
- SAMP(TH_Send)( "SDI" , "EventActivated", "%d%d%u%u%u%d%d%u%u%u%s",
- stAreaInfo.NumberOfTracks,
- stAreaInfo.TrackOffset,
- stAreaInfo.TotalAreaTime.min,
- stAreaInfo.TotalAreaTime.sec,
- stAreaInfo.TotalAreaTime.fr,
- mcAreaInfo.NumberOfTracks,
- mcAreaInfo.TrackOffset,
- mcAreaInfo.TotalAreaTime.min,
- mcAreaInfo.TotalAreaTime.sec,
- mcAreaInfo.TotalAreaTime.fr,
- hybrid ? "TRUE" : "FALSE");
- break;
- case SDI_EVENT_NOT_ACTIVATED:
- SAMP(TH_Send)( "SDI" , "EventNotActivated", "%u", (SAMP(UInt32))EventData );
- break;
- #endif
-
- default:
- SAMP(TH_Send)( "TESTH" , "***ERROR***", "Unknown event received" );
- break;
- }
- }
- static void PrepareTextItem(SAMP(Byte) *str, int maxLength, int bytesPerChar)
- {
- int i = 0, j, len = 0;
- SAMP(Byte) *ptr;
- SAMP(Bool) truncated = FALSE;
-
- if(bytesPerChar == 1)
- {
- len = strlen((char *)str);
- }
- else
- {
- ptr = str;
- while(ptr[0] && ptr[1])
- {
- len += 2;
- ptr += 2;
- }
- }
- if(len + 1 > maxLength)
- {
- truncated = TRUE;
- }
- while (i < len)
- {
- if ( (str[i] < 32) ||
- (str[i] >= 127) ||
- (str[i] == ',') ||
- (str[i] == '[') ||
- (str[i] == ']') ||
- (str[i] == 'n') ||
- (str[i] == 'r') )
- {
- j = len;
- if(j + 4 > maxLength)
- {
- truncated = TRUE;
- j = maxLength - 4;
- }
- else
- {
- len += 3;
- }
- while(j >= i)
- {
- str[j + 3] = str[j];
- j--;
- }
- if((i + 4) < maxLength)
- {
- str[i+1] = 'x';
- str[i+2] = (str[i] >> 4) + '0';
- if(str[i+2] > '9') str[i+2] = str[i+2] - '9' - 1 + 'A';
- str[i+3] = (str[i] & 0x0F) + '0';
- if(str[i+3] > '9') str[i+3] = str[i+3] - '9' - 1 + 'A';
- str[i] = '\';
- }
- i += 3;
- }
- i++;
- }
- if(truncated)
- {
- if(maxLength > 0)
- {
- str[maxLength - 1] = '';
- if( (bytesPerChar == 2) &&
- (maxLength & 1) &&
- (maxLength > 1) )
- {
- str[maxLength - 2] = '';
- }
- }
- }
- }
- static void PrepareBinaryData(SAMP(Byte) *pData, int inputLength, int maxOutputLength)
- {
- int i = 0, j;
- SAMP(Bool) truncated = FALSE;
-
- if(inputLength + 1 > maxOutputLength)
- {
- truncated = TRUE;
- }
- while (i < inputLength)
- {
- if ( (pData[i] < 32) ||
- (pData[i] >= 127) ||
- (pData[i] == ',') ||
- (pData[i] == '[') ||
- (pData[i] == ']') ||
- (pData[i] == 'n') ||
- (pData[i] == 'r') )
- {
- j = inputLength;
- if(j + 4 > maxOutputLength)
- {
- truncated = TRUE;
- j = maxOutputLength - 4;
- }
- else
- {
- inputLength += 3;
- }
- while(j >= i)
- {
- pData[j + 3] = pData[j];
- j--;
- }
- if((i + 4) < maxOutputLength)
- {
- pData[i+1] = 'x';
- pData[i+2] = (pData[i] >> 4) + '0';
- if(pData[i+2] > '9') pData[i+2] = pData[i+2] - '9' - 1 + 'A';
- pData[i+3] = (pData[i] & 0x0F) + '0';
- if(pData[i+3] > '9') pData[i+3] = pData[i+3] - '9' - 1 + 'A';
- pData[i] = '\';
- }
- i += 3;
- }
- i++;
- }
- if(truncated)
- {
- if(maxOutputLength > 0)
- {
- pData[maxOutputLength - 1] = '';
- }
- }
- }
- #if 0
- void callRecogniseDisc(void)
- {
- SAMP(UInt32) semId;
- SAMP(ErrCode) lErr;
- if(SAMP(OS_SemCreate)(0, &semId) == SAMP(ERR_OK))
- {
- if(SAMP(OS_SemP)(semId, 10) == SAMP(ERR_FAILED))
- {
- if(SAMP(OS_SemDelete)(semId) == SAMP(ERR_OK))
- {
- lErr = SAMP(SDI_RecogniseDisc)(&sacd, &hybrid);
- SAMP(TH_Send)("SDI", "RecogniseDiscAsync", "%u%s%s", lErr, sacd ? "TRUE" : "FALSE", hybrid ? "TRUE" : "FALSE");
- }
- }
- else
- {
- SAMP(Fatal)();
- }
- }
- else
- {
- SAMP(Fatal)();
- }
- }
- #endif
- #endif
- DECLARE_GROUPFUNC(THG_SDI)
- /*******************************************************************************
- * Global test-harness function
- *******************************************************************************/
- DEFINE_GROUPFUNC(THG_SDI)
- #ifdef THGSDI
- SAMP(ErrCode) lErr = SAMP(ERR_OK);
- SAMP(UInt32) index;
- SAMP(UInt8) UInt8Array[10];
- SAMP(UInt16) UInt16Array[12];
- SAMP(UInt32) UInt32Array[12];
- SAMP(SACD_TimeCode) timeCodeArray[3];
- SAMP(SACD_ChannelsConfigDef) inputChannels;
- SAMP(SDI_Album_Info) albumInfo;
- SAMP(SDI_Disc_Info) discInfo;
- SAMP(SDI_Track_Info) trackInfo;
- SAMP(Byte) language[3];
- #if 0
- SAMP(SDI_FrameFormat) frameFormat;
- #endif
- #endif
- GROUP_SWITCH
- #ifdef THGSDI
- /*********************************************
- *
- * Functions exported from SAMP (See [API])
- *
- *********************************************/
- /*
- * Parameters:
- * number of character sets
- * 1st character set
- * 2nd character set
- * ...
- * 10th character set
- */
- CASE_CMD( "SetAvailableCharSets" )
- TH_GetParam (OPTIONS, "%u%u%u%u%u%u%u%u%u%u%u", &UInt32Array[0],
- &UInt32Array[1], &UInt32Array[2],
- &UInt32Array[3], &UInt32Array[4],
- &UInt32Array[5], &UInt32Array[6],
- &UInt32Array[7], &UInt32Array[8],
- &UInt32Array[9], &UInt32Array[10]);
- if(UInt32Array[0] > 10)
- {
- SAMP(TH_Trace)("Too many parameters provided. Change test harness if necessary.");
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- else
- {
- for(index = 0; index < 10; index++)
- {
- UInt8Array[index] = (SAMP(UInt8))UInt32Array[1+index];
- }
- lErr = SAMP_EXP(SDI_SetAvailableCharSets)((SAMP(UInt8))UInt32Array[0], UInt8Array);
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- /*
- * Parameters:
- * number of languages
- * 1st language
- * 2nd language
- * ...
- * 10th language
- */
- CASE_CMD( "SetLanguagePreference" )
- SAMP(SDI_LanguageCodeDef) languages[10];
- char languageStrings[10][100];
- TH_GetParam (OPTIONS, "%u%s%s%s%s%s%s%s%s%s%s", &UInt32Array[0],
- languageStrings[0], languageStrings[1],
- languageStrings[2], languageStrings[3],
- languageStrings[4], languageStrings[5],
- languageStrings[6], languageStrings[7],
- languageStrings[8], languageStrings[9]);
- if(UInt32Array[0] > 10)
- {
- SAMP(TH_Trace)("Too many parameters provided. Change test harness if necessary.");
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- else
- {
- for(index = 0; index < 10; index++)
- {
- languages[index][0] = languageStrings[index][0];
- languages[index][1] = languageStrings[index][1];
- }
- lErr = SAMP_EXP(SDI_SetLanguagePreference)((SAMP(UInt8))UInt32Array[0], languages);
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- #ifdef DUMPTOC
- /*
- * Parameters:
- * TOC (0 = master, 1 = stereo, 2 = multichannel)
- */
- CASE_CMD( "DumpToc" )
- TH_GetParam (OPTIONS, "%u", &UInt32Array[0]);
- if(UInt32Array[0] < 3)
- {
- if(UInt32Array[0] == 0)
- {
- /* Master TOC */
- UInt32Array[1] = 10 * 2048;
- lErr = SAMP(SBM_Read)(SAMP(sdiMasterTocId), 0, UInt32Array[1], tocBuffer);
- if(lErr == SAMP(ERR_OK))
- {
- sprintf((char *)textBuffer, "%s TOC @ 0x%08X (size = %lu)", "MASTER",
- (int) tocBuffer,
- UInt32Array[1]);
- SAMP(TH_Send)(COMP_PREFIX, (char *)textBuffer, "%u", SAMP(ERR_OK));
- }
- }
- else
- {
- /* Convert input to something that can be used as an SACD_Area */
- UInt32Array[0]--;
- /* Read area TOC size from master TOC */
- if(SAMP(SBM_Read)(SAMP(sdiMasterTocId), (UInt32Array[0] == SAMP(SACD_AREA_STEREO)) ? SDI_2CH_TOC_LENGTH : SDI_MC_TOC_LENGTH,
- sizeof(SAMP(UInt16)),
- &UInt16Array[0]) == SAMP(ERR_OK))
- {
- UInt16Array[0] = (UInt16Array[0] >> 8) | (UInt16Array[0] << 8);
- UInt32Array[1] = (SAMP(UInt32))UInt16Array[0] * 2048;
- }
- else
- {
- UInt32Array[1] = 79 * 2048;
- }
- /* Read area TOC */
- lErr = SAMP(SBM_Read)(SAMP(sdiAreaToBufferId)(UInt32Array[0]), 0, UInt32Array[1], tocBuffer);
- if(lErr == SAMP(ERR_OK))
- {
- sprintf((char *)textBuffer, "%s TOC @ 0x%08X (size = %lu)",
- (UInt32Array[0] == 0) ? "STEREO" : "MULTICHANNEL",
- (int) tocBuffer,
- UInt32Array[1]);
- SAMP(TH_Send)(COMP_PREFIX, (char *)textBuffer, "%u", SAMP(ERR_OK));
- }
- }
- }
- else
- {
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- /*
- * Parameters:
- * none
- */
- #endif
- CASE_CMD( "GetAlbumInfo" )
- lErr = SAMP_EXP(SDI_GetAlbumInfo)(&albumInfo);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%s%u%u%u%u%u%u%u%u", lErr, albumInfo.Album_Set_Size,
- albumInfo.Album_Sequence_Number,
- albumInfo.Album_Catalog_Number,
- albumInfo.Album_Genre[0].Genre_Table,
- albumInfo.Album_Genre[0].Genre_Index,
- albumInfo.Album_Genre[1].Genre_Table,
- albumInfo.Album_Genre[1].Genre_Index,
- albumInfo.Album_Genre[2].Genre_Table,
- albumInfo.Album_Genre[2].Genre_Index,
- albumInfo.Album_Genre[3].Genre_Table,
- albumInfo.Album_Genre[3].Genre_Index);
- END_CASE
- /*
- * Parameters:
- * album text field
- * album text type (0 = normal, 1 = phonetic)
- * text buffer size
- */
- CASE_CMD( "GetAlbumText" )
- TH_GetParam (OPTIONS, "%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2]);
- textBuffer[0] = '';
- if(UInt32Array[2] >= sizeof(textBuffer))
- {
- SAMP(TH_Trace)("The specified buffer size is too large. Change test harness if necessary.");
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- else
- {
- lErr = SAMP_EXP(SDI_GetAlbumText)(UInt32Array[0], UInt32Array[1], UInt32Array[2], &textBuffer, &UInt8Array[0], (SAMP(SDI_LanguageCodeDef) *)&language);
- }
- textBuffer[UInt32Array[2]] = 0;
- PrepareTextItem(textBuffer, sizeof(textBuffer), ((UInt8Array[0] >= 3) && (UInt8Array[0] <= 6)) ? 2 : 1 );
- language[2] = '';
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s%u%s", lErr, textBuffer, UInt8Array[0], &language[0]);
- END_CASE
- /*
- * Parameters:
- * none
- */
- CASE_CMD( "GetDiscInfo" )
- lErr = SAMP_EXP(SDI_GetDiscInfo)(&discInfo);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s%u%u%u%u%u%u%u%u%u%u%u", lErr, discInfo.Disc_Catalog_Number,
- discInfo.Disc_Genre[0].Genre_Table,
- discInfo.Disc_Genre[0].Genre_Index,
- discInfo.Disc_Genre[1].Genre_Table,
- discInfo.Disc_Genre[1].Genre_Index,
- discInfo.Disc_Genre[2].Genre_Table,
- discInfo.Disc_Genre[2].Genre_Index,
- discInfo.Disc_Genre[3].Genre_Table,
- discInfo.Disc_Genre[3].Genre_Index,
- discInfo.Disc_Date.Year,
- discInfo.Disc_Date.Month,
- discInfo.Disc_Date.Day);
- END_CASE
- /*
- * Parameters:
- * disc text field
- * disc text type (0 = normal, 1 = phonetic)
- * text buffer size
- */
- CASE_CMD( "GetDiscText" )
- TH_GetParam (OPTIONS, "%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2]);
- textBuffer[0] = '';
- if(UInt32Array[2] >= sizeof(textBuffer))
- {
- SAMP(TH_Trace)("The specified buffer size is too large. Change test harness if necessary.");
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- else
- {
- lErr = SAMP_EXP(SDI_GetDiscText)(UInt32Array[0], UInt32Array[1], UInt32Array[2], &textBuffer, &UInt8Array[0], (SAMP(SDI_LanguageCodeDef) *)&language);
- }
- textBuffer[UInt32Array[2]] = 0;
- language[2] = '';
- PrepareTextItem(textBuffer, sizeof(textBuffer), ((UInt8Array[0] >= 3) && (UInt8Array[0] <= 6)) ? 2 : 1 );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s%u%s", lErr, textBuffer, UInt8Array[0], &language[0]);
- END_CASE
- /*
- * Parameters:
- * area
- * area text field
- * area text type (0 = normal, 1 = phonetic)
- * text buffer size
- */
- CASE_CMD( "GetAreaText" )
- textBuffer[0] = '';
- TH_GetParam (OPTIONS, "%u%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2], &UInt32Array[3]);
- if(UInt32Array[3] >= sizeof(textBuffer))
- {
- SAMP(TH_Trace)("The specified buffer size is too large. Change test harness if necessary.");
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- else
- {
- lErr = SAMP_EXP(SDI_GetAreaText)(UInt32Array[0], UInt32Array[1], UInt32Array[2], UInt32Array[3], &textBuffer, &UInt8Array[0], (SAMP(SDI_LanguageCodeDef) *)&language);
- }
- textBuffer[UInt32Array[3]] = 0;
- PrepareTextItem(textBuffer, sizeof(textBuffer), ((UInt8Array[0] >= 3) && (UInt8Array[0] <= 6)) ? 2 : 1 );
- language[2] = '';
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s%u%s", lErr, textBuffer, UInt8Array[0], &language[0]);
- END_CASE
- /*
- * Parameters:
- * area
- * track
- */
- CASE_CMD( "GetTrackInfo" )
- TH_GetParam (OPTIONS, "%u%u", &UInt32Array[0], &UInt32Array[1]);
- lErr = SAMP_EXP(SDI_GetTrackInfo)(UInt32Array[0], (SAMP(UInt8))UInt32Array[1], &trackInfo);
- memcpy(&textBuffer[0], trackInfo.ISRC.Country_Code, 2);
- textBuffer[2] = 0;
- memcpy(&textBuffer[3], trackInfo.ISRC.Owner_Code, 3);
- textBuffer[6] = 0;
- memcpy(&textBuffer[7], trackInfo.ISRC.Recording_Year, 2);
- textBuffer[9] = 0;
- memcpy(&textBuffer[10], trackInfo.ISRC.Designation_Code, 5);
- textBuffer[15] = 0;
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%s%s%s%s", lErr, trackInfo.Genre.Genre_Table,
- trackInfo.Genre.Genre_Index,
- &textBuffer[0],
- &textBuffer[3],
- &textBuffer[7],
- &textBuffer[10]);
- END_CASE
- /*
- * Parameters:
- * area
- * track
- * track text field
- * track text type (0 = normal, 1 = phonetic)
- * text buffer size
- */
- CASE_CMD( "GetTrackText" )
- TH_GetParam (OPTIONS, "%u%u%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2], &UInt32Array[3], &UInt32Array[4]);
- textBuffer[0] = '';
- if(UInt32Array[4] >= sizeof(textBuffer))
- {
- SAMP(TH_Trace)("The specified buffer size is too large. Change test harness if necessary.");
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- else
- {
- lErr = SAMP_EXP(SDI_GetTrackText)(UInt32Array[0], (SAMP(UInt8))UInt32Array[1], UInt32Array[2], UInt32Array[3], UInt32Array[4], &textBuffer, &UInt8Array[0], (SAMP(SDI_LanguageCodeDef) *)&language);
- }
- textBuffer[UInt32Array[4]] = 0;
- language[2] = '';
- PrepareTextItem(textBuffer, sizeof(textBuffer), ((UInt8Array[0] >= 3) && (UInt8Array[0] <= 6)) ? 2 : 1 );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s%u%s", lErr, textBuffer, UInt8Array[0], &language[0]);
- END_CASE
- /*
- * Parameters:
- * offset
- * size
- */
- CASE_CMD( "GetDTCP_Info" )
- TH_GetParam (OPTIONS, "%u%u", &UInt32Array[0], &UInt32Array[1]);
- textBuffer[0] = '';
- if(UInt32Array[1] >= sizeof(textBuffer))
- {
- SAMP(TH_Trace)("The specified buffer size is too large. Change test harness if necessary.");
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- else
- {
- lErr = SAMP_EXP(SDI_GetDTCP_Info)(UInt32Array[0], UInt32Array[1], &textBuffer);
- }
- textBuffer[UInt32Array[1]] = 0;
- PrepareBinaryData(textBuffer, (int)UInt32Array[1], sizeof(textBuffer));
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s", lErr, textBuffer);
- END_CASE
- /*
- * Parameters:
- * none
- */
- CASE_CMD( "GetSpecVersion" )
- SAMP(SDI_Spec_Version) specVersion;
- lErr = SAMP_EXP(SDI_GetSpecVersion)(&specVersion);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u", lErr, specVersion.Major_Version, specVersion.Minor_Version);
- END_CASE
- #if 0
- CASE_CMD( "Subscribe" )
- lErr = SAMP_EXP(SDI_Subscribe)( SdiCallback,
- ( SDI_EVENT_ACTIVATED
- | SDI_EVENT_NOT_ACTIVATED ) );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- #endif
- CASE_CMD( "Unsubscribe" )
- lErr = SAMP_EXP(SDI_Subscribe)( SdiCallback, 0 );
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- /*********************************************
- *
- * Functions local to SAMP (See [SCS_SDI])
- *
- *********************************************/
- CASE_CMD( "Init" )
- lErr = SAMP(SDI_Init)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Term" )
- lErr = SAMP(SDI_Term)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- /* TODO: Check how to report events
- SAMP(ErrCode) SAMP(SDI_Subscribe)( SAMP(SDI_CallbackDef) Callback, SAMP(BitSet32) Events );*/
- CASE_CMD( "RecogniseDisc" )
- lErr = SAMP_EXP(SDI_RecogniseDisc)(&sacd, &hybrid);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%s%s", lErr, sacd ? "TRUE" : "FALSE", hybrid ? "TRUE" : "FALSE");
- END_CASE
- #if 0
- /* This function is only present in the test harness and can be used to test
- SDI_RecogniseDisc more thoroughly. */
- CASE_CMD( "RecogniseDiscAsync" )
- SAMP(UInt32) taskId;
- SAMP_EXP(OS_TaskCreate)(SDM_PRIORITY_NAV, SDM_STACKSIZE_NAV, callRecogniseDisc, &taskId);
- END_CASE
- #endif
- /*
- * Parameters:
- * disc recognised (0 = read master TOC, 1 = master TOC already read)
- */
- CASE_CMD( "Activate" )
- TH_GetParam (OPTIONS, "%u", &UInt32Array[0]);
- lErr = SAMP_EXP(SDI_Activate)((SAMP(Bool))((UInt32Array[0] == 0) ? FALSE : TRUE), &stAreaInfo, &mcAreaInfo, &hybrid);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "testAreaInfoTrackStart" )
- TH_GetParam (OPTIONS, "%u%u", &UInt32Array[0], &UInt32Array[1]);
- if(UInt32Array[1] >= 1 && UInt32Array[0] <= SACD_MAX_TRACK_NUMBER)
- {
- timeCodeArray[0] = (UInt32Array[0] == SAMP(SACD_AREA_STEREO)) ?
- stAreaInfo.TrackStart[UInt32Array[1] - 1] :
- mcAreaInfo.TrackStart[UInt32Array[1] - 1];
- }
- else
- {
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u", lErr, timeCodeArray[0].min,
- timeCodeArray[0].sec,
- timeCodeArray[0].fr);
- END_CASE
- CASE_CMD( "testAreaInfoTrackLength" )
- TH_GetParam (OPTIONS, "%u%u", &UInt32Array[0], &UInt32Array[1]);
- if(UInt32Array[1] >= 1 && UInt32Array[0] <= SACD_MAX_TRACK_NUMBER)
- {
- timeCodeArray[0] = (UInt32Array[0] == SAMP(SACD_AREA_STEREO)) ?
- stAreaInfo.TrackLength[UInt32Array[1] - 1] :
- mcAreaInfo.TrackLength[UInt32Array[1] - 1];
- }
- else
- {
- lErr = SAMP(ERR_INVALID_PARAM);
- }
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u", lErr, timeCodeArray[0].min,
- timeCodeArray[0].sec,
- timeCodeArray[0].fr);
- END_CASE
- CASE_CMD( "Deactivate" )
- lErr = SAMP_EXP(SDI_Deactivate)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- CASE_CMD( "Reactivate" )
- lErr = SAMP_EXP(SDI_Reactivate)();
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u", lErr);
- END_CASE
- #if 0
- CASE_CMD( "GetState" )
- lErr = SAMP(SDI_GetState)((SAMP(SDI_StateDef) *)&UInt16Array[0]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, UInt16Array[0]);
- END_CASE
- #endif
- /*
- * Parameters:
- * area
- * track
- */
- CASE_CMD( "GetTrackStartTimeCode" )
- TH_GetParam (OPTIONS, "%u%u", &UInt32Array[0], &UInt32Array[1]);
- lErr = SAMP_EXP(SDI_GetTrackStartTimeCode)(UInt32Array[0], (SAMP(UInt8))UInt32Array[1], &timeCodeArray[0]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u", lErr, timeCodeArray[0].min, timeCodeArray[0].sec, timeCodeArray[0].fr);
- END_CASE
- /*
- * Parameters:
- * area
- * track
- */
- CASE_CMD( "GetTrackEndTimeCode" )
- TH_GetParam (OPTIONS, "%u%u", &UInt32Array[0], &UInt32Array[1]);
- lErr = SAMP_EXP(SDI_GetTrackEndTimeCode)(UInt32Array[0], (SAMP(UInt8))UInt32Array[1], &timeCodeArray[0]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u", lErr, timeCodeArray[0].min, timeCodeArray[0].sec, timeCodeArray[0].fr);
- END_CASE
- /*
- * Parameters:
- * area
- * minutes
- * seconds
- * frames
- */
- CASE_CMD( "AreaTimeToTrack" )
- TH_GetParam (OPTIONS, "%u%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2], &UInt32Array[3]);
- timeCodeArray[0].min = (SAMP(UInt8))UInt32Array[1];
- timeCodeArray[0].sec = (SAMP(UInt8))UInt32Array[2];
- timeCodeArray[0].fr = (SAMP(UInt8))UInt32Array[3];
- lErr = SAMP_EXP(SDI_AreaTimeToTrack)(UInt32Array[0], timeCodeArray[0], &UInt8Array[0], &timeCodeArray[0], &UInt8Array[1], &UInt8Array[2]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u%u%u%u", lErr, UInt8Array[0],
- timeCodeArray[0].min,
- timeCodeArray[0].sec,
- timeCodeArray[0].fr,
- UInt8Array[1],
- UInt8Array[2]);
- END_CASE
- /*
- * Parameters:
- * area
- * minutes
- * seconds
- * frames
- */
- CASE_CMD( "AreaTimeToTrack2" )
- TH_GetParam (OPTIONS, "%u%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2], &UInt32Array[3]);
- timeCodeArray[0].min = (SAMP(UInt8))UInt32Array[1];
- timeCodeArray[0].sec = (SAMP(UInt8))UInt32Array[2];
- timeCodeArray[0].fr = (SAMP(UInt8))UInt32Array[3];
- lErr = SAMP_EXP(SDI_AreaTimeToTrack)(UInt32Array[0], timeCodeArray[0], &UInt8Array[0], &timeCodeArray[0], &UInt8Array[1], NULL);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u%u%u%u", lErr, UInt8Array[0],
- timeCodeArray[0].min,
- timeCodeArray[0].sec,
- timeCodeArray[0].fr,
- UInt8Array[1],
- 0);
- END_CASE
- /*
- * Parameters:
- * area
- * minutes
- * seconds
- * frames
- */
- CASE_CMD( "AreaTimeToLogSector" )
- TH_GetParam (OPTIONS, "%u%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2], &UInt32Array[3]);
- timeCodeArray[0].min = (SAMP(UInt8))UInt32Array[1];
- timeCodeArray[0].sec = (SAMP(UInt8))UInt32Array[2];
- timeCodeArray[0].fr = (SAMP(UInt8))UInt32Array[3];
- lErr = SAMP_EXP(SDI_AreaTimeToLogSector)(UInt32Array[0], timeCodeArray[0], &UInt32Array[0], &UInt32Array[1]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u", lErr, UInt32Array[0], UInt32Array[1]);
- END_CASE
- /*
- * Parameters:
- * area
- * track
- */
- CASE_CMD( "GetNumberOfIndices" )
- TH_GetParam (OPTIONS, "%u%u", &UInt32Array[0], &UInt32Array[1]);
- lErr = SAMP_EXP(SDI_GetNumberOfIndices)(UInt32Array[0], (SAMP(UInt8))UInt32Array[1], &UInt8Array[0]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, UInt8Array[0]);
- END_CASE
- /*
- * Parameters:
- * area
- */
- CASE_CMD( "GetNumberOfTracks" )
- TH_GetParam (OPTIONS, "%u", &UInt32Array[0]);
- lErr = SAMP_EXP(SDI_GetNumberOfTracks)((SAMP(UInt16))UInt32Array[0], &UInt8Array[0]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u", lErr, UInt8Array[0]);
- END_CASE
- /*
- * Parameters:
- * area
- * track
- * index
- */
- CASE_CMD( "GetIndexStartTimeCode" )
- TH_GetParam (OPTIONS, "%u%u%u", &UInt32Array[0], &UInt32Array[1], &UInt32Array[2]);
- lErr = SAMP_EXP(SDI_GetIndexStartTimeCode)(UInt32Array[0], (SAMP(UInt8))UInt32Array[1], (SAMP(UInt8))UInt32Array[2], &timeCodeArray[0]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u", lErr, timeCodeArray[0].min, timeCodeArray[0].sec, timeCodeArray[0].fr);
- END_CASE
- /*
- * Parameters:
- * area
- * begin.min
- * begin.sec
- * begin.fr
- * end.min
- * end.sec
- * end.fr
- * current.min
- * current.sec
- * current.fr
- */
- CASE_CMD( "GetSubRangeEnd" )
- TH_GetParam (OPTIONS, "%u%u%u%u%u%u%u%u%u%u", &UInt32Array[0],
- &UInt32Array[1], &UInt32Array[2], &UInt32Array[3],
- &UInt32Array[4], &UInt32Array[5], &UInt32Array[6],
- &UInt32Array[7], &UInt32Array[8], &UInt32Array[9]);
- timeCodeArray[0].min = (SAMP(UInt8))UInt32Array[1];
- timeCodeArray[0].sec = (SAMP(UInt8))UInt32Array[2];
- timeCodeArray[0].fr = (SAMP(UInt8))UInt32Array[3];
- timeCodeArray[1].min = (SAMP(UInt8))UInt32Array[4];
- timeCodeArray[1].sec = (SAMP(UInt8))UInt32Array[5];
- timeCodeArray[1].fr = (SAMP(UInt8))UInt32Array[6];
- timeCodeArray[2].min = (SAMP(UInt8))UInt32Array[7];
- timeCodeArray[2].sec = (SAMP(UInt8))UInt32Array[8];
- timeCodeArray[2].fr = (SAMP(UInt8))UInt32Array[9];
- lErr = SAMP_EXP(SDI_GetSubRangeEnd)(UInt32Array[0], timeCodeArray[0], timeCodeArray[1], timeCodeArray[2], &timeCodeArray[0], &inputChannels);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u%u", lErr, timeCodeArray[0].min, timeCodeArray[0].sec, timeCodeArray[0].fr, inputChannels);
- END_CASE
- /*
- * Parameters:
- * area
- * begin.min
- * begin.sec
- * begin.fr
- * end.min
- * end.sec
- * end.fr
- * current.min
- * current.sec
- * current.fr
- */
- CASE_CMD( "GetSubRangeStart" )
- TH_GetParam (OPTIONS, "%u%u%u%u%u%u%u%u%u%u", &UInt32Array[0],
- &UInt32Array[1], &UInt32Array[2], &UInt32Array[3],
- &UInt32Array[4], &UInt32Array[5], &UInt32Array[6],
- &UInt32Array[7], &UInt32Array[8], &UInt32Array[9]);
- timeCodeArray[0].min = (SAMP(UInt8))UInt32Array[1];
- timeCodeArray[0].sec = (SAMP(UInt8))UInt32Array[2];
- timeCodeArray[0].fr = (SAMP(UInt8))UInt32Array[3];
- timeCodeArray[1].min = (SAMP(UInt8))UInt32Array[4];
- timeCodeArray[1].sec = (SAMP(UInt8))UInt32Array[5];
- timeCodeArray[1].fr = (SAMP(UInt8))UInt32Array[6];
- timeCodeArray[2].min = (SAMP(UInt8))UInt32Array[7];
- timeCodeArray[2].sec = (SAMP(UInt8))UInt32Array[8];
- timeCodeArray[2].fr = (SAMP(UInt8))UInt32Array[9];
- lErr = SAMP_EXP(SDI_GetSubRangeStart)(UInt32Array[0], timeCodeArray[0], timeCodeArray[1], timeCodeArray[2], &timeCodeArray[0], &inputChannels);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u%u%u", lErr, timeCodeArray[0].min, timeCodeArray[0].sec, timeCodeArray[0].fr, inputChannels);
- END_CASE
- #if 0
- CASE_CMD( "GetAudioMode" )
- TH_GetParam (OPTIONS, "%u", &UInt32Array[0]);
- lErr = SAMP(SDI_GetAudioMode)(UInt32Array[0], &frameFormat, &UInt8Array[0]);
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%u%u%u", lErr, frameFormat, UInt8Array[0]);
- END_CASE
- #endif
- #endif
- DEFAULT
- SAMP(TH_Send)(COMP_PREFIX, cmd, "%s", "Unknown command");
- END_CASE
- END_GROUPFUNC
- /*******************************************************************************
- * End of File
- *******************************************************************************/
- #endif