|
ASX Version4.10.11
|
This is an example of how to use the ASX Adapter functions.
/* $Header: /home/eliot/asi/repo/cvsrepo/Repository/apps/asx/examples/adapter/main.c,v 1.6 2010/01/11 21:50:31 as-age Exp $ */ #include "stdio.h" #include "stdlib.h" #include "asx.h" int CheckError(ASX_HANDLE hObj, int nLine); ASX_HANDLE hSystem=0; int main(int argc, char* argv[]) { ASX_ERROR asxError; int nAdapters=0; int i; // create the system ASX_System_Create(ASX_SYSTEM_TYPE_HPI,&hSystem); CheckError(hSystem, __LINE__); // find out how many adapters there are asxError = ASX_System_GetAdapterCount(hSystem,&nAdapters); CheckError(hSystem, __LINE__); printf("There are %d audio adapters in the system \n", nAdapters); // loop over the adapters for(i=0;i<nAdapters;i++) { char *pszAdapterName; ASX_HANDLE hAdapter; unsigned long lSerial; char *pszRevision; int nLen; int nIndex; int nDspUtilization; ASX_HANDLE hMixer; ASX_System_GetAdapter(hSystem,i,&hAdapter); CheckError(hSystem, __LINE__); ASX_Adapter_GetName(hAdapter,0,0,&nLen); CheckError(hAdapter, __LINE__); pszAdapterName = (char *)malloc(nLen); ASX_Adapter_GetName(hAdapter,pszAdapterName,nLen,&nLen); CheckError(hAdapter, __LINE__); printf("Adapter [%d] is %s \n", i,pszAdapterName); /* the adapter index is not the same as the loop index */ ASX_Adapter_GetIndex(hAdapter, &nIndex); CheckError(hAdapter, __LINE__); printf("Index is %ld \n", nIndex); ASX_Adapter_GetSerialNumber(hAdapter,&lSerial); CheckError(hAdapter, __LINE__); printf("Serial is %ld \n", lSerial); pszRevision = (char *)malloc(ASX_SHORT_STRING); ASX_Adapter_GetHardwareRevision(hAdapter,pszRevision); CheckError(hAdapter, __LINE__); printf("Revision is %s \n", pszRevision); ASX_Adapter_GetDspUtilization(hAdapter,1,&nDspUtilization); CheckError(hAdapter, __LINE__); printf("Utilization is %d percent \n", nDspUtilization); free(pszAdapterName); free(pszRevision); } ASX_System_Delete(hSystem); printf("Press ENTER to exit\n"); getchar(); return 0; } int CheckError(ASX_HANDLE hObj, int nLine) { int nError; int asxSubSystemErrorCode=0; char *pszAsxErrorString; char *pszAsxSubSystemErrorString; int nLen1,nLen2; ASX_Error_GetLast( hObj, &nError, &asxSubSystemErrorCode); if(!nError) return 0; ASX_Error_GetLastString( hObj, 0,0,&nLen1,0,0,&nLen2); pszAsxErrorString = (char *)malloc(nLen1); pszAsxSubSystemErrorString = (char *)malloc(nLen2); ASX_Error_GetLastString( hObj, pszAsxErrorString,nLen1,&nLen1,pszAsxSubSystemErrorString,nLen2,&nLen2); printf("Error: #%d, %s - Subsystem Error: #%ld, %s \n", nError, pszAsxErrorString, asxSubSystemErrorCode, pszAsxSubSystemErrorString ); printf("When called from source %s line %d\n",__FILE__,nLine); printf("Press ENTER to exit\n"); getchar(); free(pszAsxErrorString); free(pszAsxSubSystemErrorString); ASX_System_Delete(hSystem); exit(1); return 1; }
1.7.3