00001
00002 #include "stdio.h"
00003 #include "stdlib.h"
00004 #include "asx.h"
00005
00006 int CheckError(ASX_HANDLE hObj, int nLine);
00007
00008 ASX_HANDLE hSystem=0;
00009
00010 int main(int argc, char* argv[])
00011 {
00012
00013 ASX_ERROR asxError;
00014 int nAdapters=0;
00015 int i;
00016
00017
00018 ASX_System_Create(ASX_SYSTEM_TYPE_HPI,&hSystem);
00019 CheckError(hSystem, __LINE__);
00020
00021
00022 asxError = ASX_System_GetAdapterCount(hSystem,&nAdapters);
00023 CheckError(hSystem, __LINE__);
00024 printf("There are %d audio adapters in the system \n", nAdapters);
00025
00026
00027 for(i=0;i<nAdapters;i++)
00028 {
00029 char *pszAdapterName;
00030 ASX_HANDLE hAdapter;
00031 unsigned long lSerial;
00032 char *pszRevision;
00033 int nLen;
00034 int nDspUtilization;
00035 ASX_HANDLE hMixer;
00036
00037
00038 ASX_System_GetAdapter(hSystem,i,&hAdapter);
00039 CheckError(hSystem, __LINE__);
00040
00041 ASX_Adapter_GetName(hAdapter,0,0,&nLen);
00042 CheckError(hAdapter, __LINE__);
00043 pszAdapterName = (char *)malloc(nLen);
00044 ASX_Adapter_GetName(hAdapter,pszAdapterName,nLen,&nLen);
00045 CheckError(hAdapter, __LINE__);
00046 printf("Adapter [%d] is %s \n", i,pszAdapterName);
00047
00048 ASX_Adapter_GetSerialNumber(hAdapter,&lSerial);
00049 CheckError(hAdapter, __LINE__);
00050 printf("Serial is %ld \n", lSerial);
00051
00052 pszRevision = (char *)malloc(ASX_SHORT_STRING);
00053 ASX_Adapter_GetHardwareRevision(hAdapter,pszRevision);
00054 CheckError(hAdapter, __LINE__);
00055 printf("Revision is %s \n", pszRevision);
00056
00057 ASX_Adapter_GetDspUtilization(hAdapter,1,&nDspUtilization);
00058 CheckError(hAdapter, __LINE__);
00059 printf("Utilization is %d percent \n", nDspUtilization);
00060
00061 free(pszAdapterName);
00062 free(pszRevision);
00063 }
00064
00065 ASX_System_Delete(hSystem);
00066 printf("Press ENTER to exit\n");
00067 getchar();
00068 return 0;
00069 }
00070
00071 int CheckError(ASX_HANDLE hObj, int nLine)
00072 {
00073 int nError;
00074 int asxSubSystemErrorCode=0;
00075 char *pszAsxErrorString;
00076 char *pszAsxSubSystemErrorString;
00077 int nLen1,nLen2;
00078
00079 ASX_Error_GetLast( hObj, &nError, &asxSubSystemErrorCode);
00080 if(!nError)
00081 return 0;
00082 ASX_Error_GetLastString( hObj, 0,0,&nLen1,0,0,&nLen2);
00083 pszAsxErrorString = (char *)malloc(nLen1);
00084 pszAsxSubSystemErrorString = (char *)malloc(nLen2);
00085 ASX_Error_GetLastString( hObj, pszAsxErrorString,nLen1,&nLen1,pszAsxSubSystemErrorString,nLen2,&nLen2);
00086 printf("Error: #%d, %s - Subsystem Error: #%ld, %s \n",
00087 nError,
00088 pszAsxErrorString,
00089 asxSubSystemErrorCode,
00090 pszAsxSubSystemErrorString );
00091 printf("When called from source %s line %d\n",__FILE__,nLine);
00092
00093 printf("Press ENTER to exit\n");
00094 getchar();
00095 free(pszAsxErrorString);
00096 free(pszAsxSubSystemErrorString);
00097 ASX_System_Delete(hSystem);
00098 exit(1);
00099 return 1;
00100 }
00101