00001
00002 #include "stdio.h"
00003 #include "stdlib.h"
00004 #include "asx.h"
00005 #include "asxstring.h"
00006
00007 ASX_HANDLE hSystem=0;
00008
00009 void PrintControlName(ASX_HANDLE hControl);
00010 int CheckError(ASX_HANDLE hObj, int nLine);
00011
00012 int main(int argc, char* argv[])
00013 {
00014 char *pszName;
00015 char *pszFormat;
00016 char *pDummy;
00017 ASX_HANDLE hAdapter;
00018 ASX_HANDLE hMixer;
00019 ASX_HANDLE hPlayer;
00020 ASX_ERROR asxError;
00021 int nAdapterToUse=0;
00022 int nLen;
00023
00024 if(argc<2)
00025 {
00026 printf("Filename to play is a required parameter.\n");
00027 return -1;
00028 }
00029
00030
00031 ASX_System_Create(ASX_SYSTEM_TYPE_HPI,&hSystem);
00032 CheckError(hSystem, __LINE__);
00033
00034
00035 ASX_System_GetAdapter(hSystem,nAdapterToUse,&hAdapter);
00036 CheckError(hAdapter, __LINE__);
00037
00038 ASX_Adapter_GetName(hAdapter,0,0,&nLen);
00039 CheckError(hAdapter, __LINE__);
00040 pszName = (char *)malloc(nLen);
00041 ASX_Adapter_GetName(hAdapter,pszName,nLen,&nLen);
00042 CheckError(hAdapter, __LINE__);
00043 printf("Adapter [%d] is %s \n", nAdapterToUse,pszName);
00044
00045
00046 ASX_Adapter_GetMixer( hAdapter, &hMixer );
00047 CheckError(hAdapter, __LINE__);
00048
00049
00050 asxError = ASX_Mixer_GetControlByNodeTypeAndIndex(
00051 hMixer,
00052 asxNODE_PLAYER,0,
00053 0,0,
00054 asxCONTROL_PLAYER,
00055 &hPlayer);
00056 CheckError(hMixer, __LINE__);
00057
00058
00059 PrintControlName(hPlayer);
00060
00061
00062 ASX_Player_Open( hPlayer, argv[1]);
00063 CheckError(hPlayer, __LINE__);
00064
00065 if(argc>2)
00066 {
00067 printf("Start at offset %s milliseconds\n",argv[2]);
00068 ASX_Player_PreLoad(hPlayer,asxTIMESCALE_MILLISECONDS,strtol(argv[2],&pDummy,10));
00069 }
00070
00071
00072 ASX_Player_Start( hPlayer );
00073 CheckError(hPlayer, __LINE__);
00074
00075 ASX_Player_Format_GetString(hPlayer, &pszFormat);
00076 printf("Playing %s Format %s on Device %s\n",argv[1],pszFormat,pszName);
00077 free(pszName);
00078
00079
00080 printf("Waiting for playback to complete\n");
00081 ASX_Player_Wait(hPlayer);
00082 CheckError(hPlayer, __LINE__);
00083
00084 printf("Playback complete.\n");
00085
00086
00087 ASX_Player_Close(hPlayer);
00088 CheckError(hPlayer, __LINE__);
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 printf("Press ENTER to exit\n");
00104 getchar();
00105 ASX_System_Delete(hSystem);
00106 return 0;
00107 }
00108
00109 void PrintControlName(ASX_HANDLE hControl)
00110 {
00111 char *pszName;
00112 int nLen;
00113 enum asxCONTROL eControl;
00114
00115 ASX_Control_GetType(hControl, &eControl);
00116 ASXSTRING_EnumToString(eControl,0,0,&nLen);
00117 pszName=(char *)malloc(nLen);
00118 ASXSTRING_EnumToString(eControl,pszName,nLen,&nLen);
00119 printf("Control : %s\n",pszName);
00120
00121 free(pszName);
00122 }
00123 int CheckError(ASX_HANDLE hObj, int nLine)
00124 {
00125 int nError;
00126 int asxSubSystemErrorCode=0;
00127 char *pszAsxErrorString;
00128 char *pszAsxSubSystemErrorString;
00129 int nLen1,nLen2;
00130
00131 ASX_Error_GetLast( hObj, (ASX_ERROR*)&nError, &asxSubSystemErrorCode);
00132 if(!nError)
00133 return 0;
00134 ASX_Error_GetLastString( hObj, 0,0,&nLen1,0,0,&nLen2);
00135 pszAsxErrorString = (char *)malloc(nLen1);
00136 pszAsxSubSystemErrorString = (char *)malloc(nLen2);
00137 ASX_Error_GetLastString( hObj, pszAsxErrorString,nLen1,&nLen1,pszAsxSubSystemErrorString,nLen2,&nLen2);
00138 printf("Error: #%d, %s - Subsystem Error: #%ld, %s \n",
00139 nError,
00140 pszAsxErrorString,
00141 asxSubSystemErrorCode,
00142 pszAsxSubSystemErrorString );
00143 printf("When called from source %s line %d\n",__FILE__,nLine);
00144
00145 printf("Press ENTER to exit\n");
00146 getchar();
00147 free(pszAsxErrorString);
00148 free(pszAsxSubSystemErrorString);
00149 ASX_System_Delete(hSystem);
00150 exit(1);
00151 return 1;
00152 }