/** Check return value of HPI function, and map it to PaError */\r
#define PA_ASIHPI_UNLESS_(expr, paError) \\r
do { \\r
- HW16 hpiError = (expr); \\r
+ hpi_err_t hpiError = (expr); \\r
/* If HPI error occurred */ \\r
if( UNLIKELY( hpiError ) ) \\r
{ \\r
/* implementation specific data goes here */\r
\r
PaHostApiIndex hostApiIndex;\r
- /** HPI subsystem pointer */\r
- HPI_HSUBSYS *subSys;\r
}\r
PaAsiHpiHostApiRepresentation;\r
\r
\r
/* implementation specific data goes here */\r
\r
- /** HPI subsystem (required for most HPI calls) */\r
- HPI_HSUBSYS *subSys;\r
/** Adapter index */\r
- HW16 adapterIndex;\r
+ uint16_t adapterIndex;\r
/** Adapter model number (hex) */\r
- HW16 adapterType;\r
+ uint16_t adapterType;\r
/** Adapter HW/SW version */\r
- HW16 adapterVersion;\r
+ uint16_t adapterVersion;\r
/** Adapter serial number */\r
- HW32 adapterSerialNumber;\r
+ uint32_t adapterSerialNumber;\r
/** Stream number */\r
- HW16 streamIndex;\r
+ uint16_t streamIndex;\r
/** 0=Input, 1=Output (HPI streams are either input or output but not both) */\r
- HW16 streamIsOutput;\r
+ uint16_t streamIsOutput;\r
}\r
PaAsiHpiDeviceInfo;\r
\r
{\r
/** Device information (HPI handles, etc) */\r
PaAsiHpiDeviceInfo *hpiDevice;\r
- /** Stream handle, as passed to HPI interface.\r
- HACK: we assume types HPI_HISTREAM and HPI_HOSTREAM are the same...\r
- (both are HW32 up to version 3.00 of ASIHPI, and hopefully they stay that way) */\r
- HPI_HISTREAM hpiStream;\r
+ /** Stream handle, as passed to HPI interface. */\r
+ hpi_handle_t hpiStream;\r
/** Stream format, as passed to HPI interface */\r
- HPI_FORMAT hpiFormat;\r
+ struct hpi_format hpiFormat;\r
/** Number of bytes per frame, derived from hpiFormat and saved for convenience */\r
- HW32 bytesPerFrame;\r
+ uint32_t bytesPerFrame;\r
/** Size of hardware (on-card) buffer of stream in bytes */\r
- HW32 hardwareBufferSize;\r
+ uint32_t hardwareBufferSize;\r
/** Size of host (BBM) buffer of stream in bytes (if used) */\r
- HW32 hostBufferSize;\r
+ uint32_t hostBufferSize;\r
/** Upper limit on the utilization of output stream buffer (both hardware and host).\r
This prevents large latencies in an output-only stream with a potentially huge buffer\r
and a fast data generator, which would otherwise keep the hardware buffer filled to\r
capacity. See also the "Hardware Buffering=off" option in the AudioScience WAV driver. */\r
- HW32 outputBufferCap;\r
+ uint32_t outputBufferCap;\r
/** Sample buffer (halfway station between HPI and buffer processor) */\r
- HW8 *tempBuffer;\r
+ uint8_t *tempBuffer;\r
/** Sample buffer size, in bytes */\r
- HW32 tempBufferSize;\r
+ uint32_t tempBufferSize;\r
}\r
PaAsiHpiStreamComponent;\r
\r
PaAsiHpiStreamComponent *input, *output;\r
\r
/** Polling interval (in milliseconds) */\r
- HW32 pollingInterval;\r
+ uint32_t pollingInterval;\r
/** Are we running in callback mode? */\r
int callbackMode;\r
/** Number of frames to transfer at a time to/from HPI */\r
typedef struct PaAsiHpiStreamInfo\r
{\r
/** HPI stream state (HPI_STATE_STOPPED, HPI_STATE_PLAYING, etc.) */\r
- HW16 state;\r
+ uint16_t state;\r
/** Size (in bytes) of recording/playback data buffer in HPI driver */\r
- HW32 bufferSize;\r
+ uint32_t bufferSize;\r
/** Amount of data (in bytes) available in the buffer */\r
- HW32 dataSize;\r
+ uint32_t dataSize;\r
/** Number of frames played/recorded since last stream reset */\r
- HW32 frameCounter;\r
+ uint32_t frameCounter;\r
/** Amount of data (in bytes) in hardware (on-card) buffer.\r
This differs from dataSize if bus mastering (BBM) is used, which introduces another\r
driver-level buffer to which dataSize/bufferSize then refers. */\r
- HW32 auxDataSize;\r
+ uint32_t auxDataSize;\r
/** Total number of data frames currently buffered by HPI driver (host + hw buffers) */\r
- HW32 totalBufferedData;\r
+ uint32_t totalBufferedData;\r
/** Size of immediately available data (for input) or space (for output) in frames.\r
This only checks the first-level buffer (typically host buffer). This amount can be\r
transferred immediately. */\r
- HW32 availableFrames;\r
+ uint32_t availableFrames;\r
/** Indicates that hardware buffer is getting too full */\r
int overflow;\r
/** Indicates that hardware buffer is getting too empty */\r
\r
/* Functions specific to this API */\r
static PaError PaAsiHpi_BuildDeviceList( PaAsiHpiHostApiRepresentation *hpiHostApi );\r
-static HW16 PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat );\r
-static PaSampleFormat PaAsiHpi_HpiToPaFormat( HW16 hpiFormat );\r
+static uint16_t PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat );\r
+static PaSampleFormat PaAsiHpi_HpiToPaFormat( uint16_t hpiFormat );\r
static PaError PaAsiHpi_CreateFormat( struct PaUtilHostApiRepresentation *hostApi,\r
const PaStreamParameters *parameters, double sampleRate,\r
- PaAsiHpiDeviceInfo **hpiDevice, HPI_FORMAT *hpiFormat );\r
+ PaAsiHpiDeviceInfo **hpiDevice, struct hpi_format *hpiFormat );\r
static PaError PaAsiHpi_OpenInput( struct PaUtilHostApiRepresentation *hostApi,\r
- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,\r
- HPI_HISTREAM *hpiStream );\r
+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,\r
+ hpi_handle_t *hpiStream );\r
static PaError PaAsiHpi_OpenOutput( struct PaUtilHostApiRepresentation *hostApi,\r
- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,\r
- HPI_HOSTREAM *hpiStream );\r
+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,\r
+ hpi_handle_t *hpiStream );\r
static PaError PaAsiHpi_GetStreamInfo( PaAsiHpiStreamComponent *streamComp, PaAsiHpiStreamInfo *info );\r
static void PaAsiHpi_StreamComponentDump( PaAsiHpiStreamComponent *streamComp, PaAsiHpiStream *stream );\r
static void PaAsiHpi_StreamDump( PaAsiHpiStream *stream );\r
-static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, HW32 pollingInterval,\r
+static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, uint32_t pollingInterval,\r
unsigned long framesPerPaHostBuffer, PaTime suggestedLatency );\r
static PaError PaAsiHpi_PrimeOutputWithSilence( PaAsiHpiStream *stream );\r
static PaError PaAsiHpi_StartStream( PaAsiHpiStream *stream, int outputPrimed );\r
PaUtilHostApiRepresentation *hostApi = &hpiHostApi->baseHostApiRep;\r
PaHostApiInfo *baseApiInfo = &hostApi->info;\r
PaAsiHpiDeviceInfo *hpiDeviceList;\r
- HW16 adapterList[ HPI_MAX_ADAPTERS ];\r
- HW16 numAdapters;\r
- HW16 hpiError = 0;\r
+ int numAdapters;\r
+ hpi_err_t hpiError = 0;\r
int i, j, deviceCount = 0, deviceIndex = 0;\r
\r
assert( hpiHostApi );\r
- assert( hpiHostApi->subSys );\r
\r
- /* Look for adapters (not strictly necessary, as AdapterOpen can do the same, but this */\r
- /* way we have less errors since we do not try to open adapters we know aren't there) */\r
/* Errors not considered critical here (subsystem may report 0 devices), but report them */\r
/* in debug mode. */\r
- PA_ASIHPI_UNLESS_( HPI_SubSysFindAdapters( hpiHostApi->subSys, &numAdapters,\r
- adapterList, HPI_MAX_ADAPTERS ), paNoError );\r
+ PA_ASIHPI_UNLESS_( HPI_SubSysGetNumAdapters( NULL, &numAdapters), paNoError );\r
\r
- /* First open and count the number of devices (= number of streams), to ease memory allocation */\r
- for( i=0; i < HPI_MAX_ADAPTERS; ++i )\r
+ for( i=0; i < numAdapters; ++i )\r
{\r
- HW16 inStreams, outStreams;\r
- HW16 version;\r
- HW32 serial;\r
- HW16 type;\r
+ uint16_t inStreams, outStreams;\r
+ uint16_t version;\r
+ uint32_t serial;\r
+ uint16_t type;\r
+ uint32_t idx;\r
\r
- /* If no adapter found at this index, skip it */\r
- if( adapterList[i] == 0 )\r
+ hpiError = HPI_SubSysGetAdapter(NULL, i, &idx, &type);\r
+ if (hpiError)\r
continue;\r
\r
/* Try to open adapter */\r
- hpiError = HPI_AdapterOpen( hpiHostApi->subSys, i );\r
+ hpiError = HPI_AdapterOpen( NULL, idx );\r
/* Report error and skip to next device on failure */\r
if( hpiError )\r
{\r
PA_ASIHPI_REPORT_ERROR_( hpiError );\r
continue;\r
}\r
- hpiError = HPI_AdapterGetInfo( hpiHostApi->subSys, i,\r
- &outStreams, &inStreams, &version, &serial, &type );\r
+ hpiError = HPI_AdapterGetInfo( NULL, idx, &outStreams, &inStreams,
+ &version, &serial, &type );\r
/* Skip to next device on failure */\r
if( hpiError )\r
{\r
paInsufficientMemory );\r
\r
/* Now query devices again for information */\r
- for( i=0; i < HPI_MAX_ADAPTERS; ++i )\r
+ for( i=0; i < numAdapters; ++i )\r
{\r
- HW16 inStreams, outStreams;\r
- HW16 version;\r
- HW32 serial;\r
- HW16 type;\r
-\r
- /* If no adapter found at this index, skip it */\r
- if( adapterList[i] == 0 )\r
+ uint16_t inStreams, outStreams;\r
+ uint16_t version;\r
+ uint32_t serial;\r
+ uint16_t type;\r
+ uint32_t idx;\r
+\r
+ hpiError = HPI_SubSysGetAdapter( NULL, i, &idx, &type );\r
+ if (hpiError)\r
continue;\r
\r
/* Assume adapter is still open from previous round */\r
- hpiError = HPI_AdapterGetInfo( hpiHostApi->subSys, i,\r
+ hpiError = HPI_AdapterGetInfo( NULL, idx,\r
&outStreams, &inStreams, &version, &serial, &type );\r
/* Report error and skip to next device on failure */\r
if( hpiError )\r
else\r
{\r
PA_DEBUG(( "Found HPI Adapter ID=%4X Idx=%d #In=%d #Out=%d S/N=%d HWver=%c%d DSPver=%03d\n",\r
- type, i, inStreams, outStreams, serial,\r
+ type, idx, inStreams, outStreams, serial,\r
((version>>3)&0xf)+'A', /* Hw version major */\r
version&0x7, /* Hw version minor */\r
((version>>13)*100)+((version>>7)&0x3f) /* DSP code version */\r
\r
memset( hpiDevice, 0, sizeof(PaAsiHpiDeviceInfo) );\r
/* Set implementation-specific device details */\r
- hpiDevice->subSys = hpiHostApi->subSys;\r
- hpiDevice->adapterIndex = i;\r
+ hpiDevice->adapterIndex = idx;\r
hpiDevice->adapterType = type;\r
hpiDevice->adapterVersion = version;\r
hpiDevice->adapterSerialNumber = serial;\r
\r
memset( hpiDevice, 0, sizeof(PaAsiHpiDeviceInfo) );\r
/* Set implementation-specific device details */\r
- hpiDevice->subSys = hpiHostApi->subSys;\r
- hpiDevice->adapterIndex = i;\r
+ hpiDevice->adapterIndex = idx;\r
hpiDevice->adapterType = type;\r
hpiDevice->adapterVersion = version;\r
hpiDevice->adapterSerialNumber = serial;\r
PaAsiHpiHostApiRepresentation *hpiHostApi = NULL;\r
PaHostApiInfo *baseApiInfo;\r
\r
- /* Allocate host API structure */\r
- PA_UNLESS_( hpiHostApi = (PaAsiHpiHostApiRepresentation*) PaUtil_AllocateMemory(\r
- sizeof(PaAsiHpiHostApiRepresentation) ), paInsufficientMemory );\r
- PA_UNLESS_( hpiHostApi->allocations = PaUtil_CreateAllocationGroup(), paInsufficientMemory );\r
-\r
- hpiHostApi->hostApiIndex = hostApiIndex;\r
- hpiHostApi->subSys = NULL;\r
-\r
/* Try to initialize HPI subsystem */\r
- if( ( hpiHostApi->subSys = HPI_SubSysCreate() ) == NULL)\r
+ if (!HPI_SubSysCreate())\r
{\r
/* the V19 development docs say that if an implementation\r
* detects that it cannot be used, it should return a NULL\r
* interface and paNoError */\r
PA_DEBUG(( "Could not open HPI interface\n" ));\r
- result = paNoError;\r
- *hostApi = NULL;\r
- goto error;\r
+\r
+ *hostApi = NULL;\r
+ return paNoError;\r
}\r
else\r
{\r
- HW32 hpiVersion;\r
- PA_ASIHPI_UNLESS_( HPI_SubSysGetVersion( hpiHostApi->subSys, &hpiVersion ), paUnanticipatedHostError );\r
- PA_DEBUG(( "HPI interface v%d.%02d\n",\r
- hpiVersion >> 8, 10*((hpiVersion & 0xF0) >> 4) + (hpiVersion & 0x0F) ));\r
+ uint32_t hpiVersion;\r
+ PA_ASIHPI_UNLESS_( HPI_SubSysGetVersionEx( NULL, &hpiVersion ), paUnanticipatedHostError );\r
+ PA_DEBUG(( "HPI interface v%d.%02d.%02d\n",\r
+ hpiVersion >> 16, (hpiVersion >> 8) & 0x0F, (hpiVersion & 0x0F) ));\r
}\r
\r
+ /* Allocate host API structure */\r
+ PA_UNLESS_( hpiHostApi = (PaAsiHpiHostApiRepresentation*) PaUtil_AllocateMemory(\r
+ sizeof(PaAsiHpiHostApiRepresentation) ), paInsufficientMemory );\r
+ PA_UNLESS_( hpiHostApi->allocations = PaUtil_CreateAllocationGroup(), paInsufficientMemory );\r
+\r
+ hpiHostApi->hostApiIndex = hostApiIndex;\r
+\r
*hostApi = &hpiHostApi->baseHostApiRep;\r
baseApiInfo = &((*hostApi)->info);\r
/* Fill in common API details */\r
\r
return result;\r
error:\r
- /* Clean up memory */\r
- Terminate( (PaUtilHostApiRepresentation *)hpiHostApi );\r
+ if (hpiHostApi)\r
+ PaUtil_FreeMemory( hpiHostApi );\r
return result;\r
}\r
\r
if( hpiHostApi )\r
{\r
/* Get rid of HPI-specific structures */\r
- if( hpiHostApi->subSys )\r
+ uint16_t lastAdapterIndex = HPI_MAX_ADAPTERS;\r
+ /* Iterate through device list and close adapters */\r
+ for( i=0; i < hostApi->info.deviceCount; ++i )\r
{\r
- HW16 lastAdapterIndex = HPI_MAX_ADAPTERS;\r
- /* Iterate through device list and close adapters */\r
- for( i=0; i < hostApi->info.deviceCount; ++i )\r
+ PaAsiHpiDeviceInfo *hpiDevice = (PaAsiHpiDeviceInfo *) hostApi->deviceInfos[ i ];\r
+ /* Close adapter only if it differs from previous one */\r
+ if( hpiDevice->adapterIndex != lastAdapterIndex )\r
{\r
- PaAsiHpiDeviceInfo *hpiDevice = (PaAsiHpiDeviceInfo *) hostApi->deviceInfos[ i ];\r
- /* Close adapter only if it differs from previous one */\r
- if( hpiDevice->adapterIndex != lastAdapterIndex )\r
- {\r
- /* Ignore errors (report only during debugging) */\r
- PA_ASIHPI_UNLESS_( HPI_AdapterClose( hpiHostApi->subSys,\r
- hpiDevice->adapterIndex ), paNoError );\r
- lastAdapterIndex = hpiDevice->adapterIndex;\r
- }\r
+ /* Ignore errors (report only during debugging) */\r
+ PA_ASIHPI_UNLESS_( HPI_AdapterClose( NULL,\r
+ hpiDevice->adapterIndex ), paNoError );\r
+ lastAdapterIndex = hpiDevice->adapterIndex;\r
}\r
- /* Finally dismantle HPI subsystem */\r
- HPI_SubSysFree( hpiHostApi->subSys );\r
}\r
+ /* Finally dismantle HPI subsystem */\r
+ HPI_SubSysFree( NULL );\r
\r
if( hpiHostApi->allocations )\r
{\r
\r
@return HPI sample format\r
*/\r
-static HW16 PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat )\r
+static uint16_t PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat )\r
{\r
/* Ignore interleaving flag */\r
switch( paFormat & ~paNonInterleaved )\r
\r
@return PortAudio sample format\r
*/\r
-static PaSampleFormat PaAsiHpi_HpiToPaFormat( HW16 hpiFormat )\r
+static PaSampleFormat PaAsiHpi_HpiToPaFormat( uint16_t hpiFormat )\r
{\r
switch( hpiFormat )\r
{\r
*/\r
static PaError PaAsiHpi_CreateFormat( struct PaUtilHostApiRepresentation *hostApi,\r
const PaStreamParameters *parameters, double sampleRate,\r
- PaAsiHpiDeviceInfo **hpiDevice, HPI_FORMAT *hpiFormat )\r
+ PaAsiHpiDeviceInfo **hpiDevice, struct hpi_format *hpiFormat )\r
{\r
int maxChannelCount = 0;\r
PaSampleFormat hostSampleFormat = 0;\r
- HW16 hpiError = 0;\r
+ hpi_err_t hpiError = 0;\r
\r
/* Unless alternate device specification is supported, reject the use of\r
paUseHostApiSpecificDeviceSpecification */\r
hostSampleFormat = PaUtil_SelectClosestAvailableFormat(PA_ASIHPI_AVAILABLE_FORMATS_,\r
parameters->sampleFormat );\r
/* Setup format + info objects */\r
- hpiError = HPI_FormatCreate( hpiFormat, (HW16)parameters->channelCount,\r
+ hpiError = HPI_FormatCreate( hpiFormat, (uint16_t)parameters->channelCount,\r
PaAsiHpi_PaToHpiFormat( hostSampleFormat ),\r
- (HW32)sampleRate, 0, 0 );\r
+ (uint32_t)sampleRate, 0, 0 );\r
if( hpiError )\r
{\r
PA_ASIHPI_REPORT_ERROR_( hpiError );\r
@return PortAudio error code (typically indicating a problem with stream format or device)\r
*/\r
static PaError PaAsiHpi_OpenInput( struct PaUtilHostApiRepresentation *hostApi,\r
- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,\r
- HPI_HISTREAM *hpiStream )\r
+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,\r
+ hpi_handle_t *hpiStream )\r
{\r
PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;\r
PaError result = paNoError;\r
- HW16 hpiError = 0;\r
+ hpi_err_t hpiError = 0;\r
\r
/* Catch misplaced output devices, as they typically have 0 input channels */\r
PA_UNLESS_( !hpiDevice->streamIsOutput, paInvalidChannelCount );\r
/* Try to open input stream */\r
- PA_ASIHPI_UNLESS_( HPI_InStreamOpen( hpiHostApi->subSys, hpiDevice->adapterIndex,\r
+ PA_ASIHPI_UNLESS_( HPI_InStreamOpen( NULL, hpiDevice->adapterIndex,\r
hpiDevice->streamIndex, hpiStream ), paDeviceUnavailable );\r
/* Set input format (checking it in the process) */\r
/* Could also use HPI_InStreamQueryFormat, but this economizes the process */\r
- hpiError = HPI_InStreamSetFormat( hpiHostApi->subSys, *hpiStream, (HPI_FORMAT*)hpiFormat );\r
+ hpiError = HPI_InStreamSetFormat( NULL, *hpiStream, (struct hpi_format*)hpiFormat );\r
if( hpiError )\r
{\r
PA_ASIHPI_REPORT_ERROR_( hpiError );\r
- PA_ASIHPI_UNLESS_( HPI_InStreamClose( hpiHostApi->subSys, *hpiStream ), paNoError );\r
+ PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL, *hpiStream ), paNoError );\r
switch( hpiError )\r
{\r
case HPI_ERROR_INVALID_FORMAT:\r
@return PortAudio error code (typically indicating a problem with stream format or device)\r
*/\r
static PaError PaAsiHpi_OpenOutput( struct PaUtilHostApiRepresentation *hostApi,\r
- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,\r
- HPI_HOSTREAM *hpiStream )\r
+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,\r
+ hpi_handle_t *hpiStream )\r
{\r
PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;\r
PaError result = paNoError;\r
- HW16 hpiError = 0;\r
+ hpi_err_t hpiError = 0;\r
\r
/* Catch misplaced input devices, as they typically have 0 output channels */\r
PA_UNLESS_( hpiDevice->streamIsOutput, paInvalidChannelCount );\r
/* Try to open output stream */\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamOpen( hpiHostApi->subSys, hpiDevice->adapterIndex,\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamOpen( NULL, hpiDevice->adapterIndex,\r
hpiDevice->streamIndex, hpiStream ), paDeviceUnavailable );\r
\r
/* Check output format (format is set on first write to output stream) */\r
- hpiError = HPI_OutStreamQueryFormat( hpiHostApi->subSys, *hpiStream, (HPI_FORMAT*)hpiFormat );\r
+ hpiError = HPI_OutStreamQueryFormat( NULL, *hpiStream, (struct hpi_format*)hpiFormat );\r
if( hpiError )\r
{\r
PA_ASIHPI_REPORT_ERROR_( hpiError );\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamClose( hpiHostApi->subSys, *hpiStream ), paNoError );\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL, *hpiStream ), paNoError );\r
switch( hpiError )\r
{\r
case HPI_ERROR_INVALID_FORMAT:\r
PaError result = paFormatIsSupported;\r
PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;\r
PaAsiHpiDeviceInfo *hpiDevice = NULL;\r
- HPI_FORMAT hpiFormat;\r
+ struct hpi_format hpiFormat;\r
\r
/* Input stream */\r
if( inputParameters )\r
{\r
- HPI_HISTREAM hpiStream;\r
+ hpi_handle_t hpiStream;\r
PA_DEBUG(( "%s: Checking input params: dev=%d, sr=%d, chans=%d, fmt=%d\n",\r
__FUNCTION__, inputParameters->device, (int)sampleRate,\r
inputParameters->channelCount, inputParameters->sampleFormat ));\r
/* Open stream to further check format */\r
PA_ENSURE_( PaAsiHpi_OpenInput( hostApi, hpiDevice, &hpiFormat, &hpiStream ) );\r
/* Close stream again */\r
- PA_ASIHPI_UNLESS_( HPI_InStreamClose( hpiHostApi->subSys, hpiStream ), paNoError );\r
+ PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL, hpiStream ), paNoError );\r
}\r
\r
/* Output stream */\r
if( outputParameters )\r
{\r
- HPI_HOSTREAM hpiStream;\r
+ hpi_handle_t hpiStream;\r
PA_DEBUG(( "%s: Checking output params: dev=%d, sr=%d, chans=%d, fmt=%d\n",\r
__FUNCTION__, outputParameters->device, (int)sampleRate,\r
outputParameters->channelCount, outputParameters->sampleFormat ));\r
/* Open stream to further check format */\r
PA_ENSURE_( PaAsiHpi_OpenOutput( hostApi, hpiDevice, &hpiFormat, &hpiStream ) );\r
/* Close stream again */\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamClose( hpiHostApi->subSys, hpiStream ), paNoError );\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL, hpiStream ), paNoError );\r
}\r
\r
error:\r
static PaError PaAsiHpi_GetStreamInfo( PaAsiHpiStreamComponent *streamComp, PaAsiHpiStreamInfo *info )\r
{\r
PaError result = paDeviceUnavailable;\r
- HW16 state;\r
- HW32 bufferSize, dataSize, frameCounter, auxDataSize, threshold;\r
- HW32 hwBufferSize, hwDataSize;\r
+ uint16_t state;\r
+ uint32_t bufferSize, dataSize, frameCounter, auxDataSize, threshold;\r
+ uint32_t hwBufferSize, hwDataSize;\r
\r
assert( streamComp );\r
assert( info );\r
/* Obtain detailed stream info (either input or output) */\r
if( streamComp->hpiDevice->streamIsOutput )\r
{\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamGetInfoEx( streamComp->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamGetInfoEx( NULL,\r
streamComp->hpiStream,\r
&state, &bufferSize, &dataSize, &frameCounter,\r
&auxDataSize ), paUnanticipatedHostError );\r
}\r
else\r
{\r
- PA_ASIHPI_UNLESS_( HPI_InStreamGetInfoEx( streamComp->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_InStreamGetInfoEx( NULL,\r
streamComp->hpiStream,\r
&state, &bufferSize, &dataSize, &frameCounter,\r
&auxDataSize ), paUnanticipatedHostError );\r
\r
@return PortAudio error code (possibly paBufferTooBig or paInsufficientMemory)\r
*/\r
-static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, HW32 pollingInterval,\r
+static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, uint32_t pollingInterval,\r
unsigned long framesPerPaHostBuffer, PaTime suggestedLatency )\r
{\r
PaError result = paNoError;\r
/* Check if BBM (background bus mastering) is to be enabled */\r
if( PA_ASIHPI_USE_BBM_ )\r
{\r
- HW32 bbmBufferSize = 0, preLatencyBufferSize = 0;\r
- HW16 hpiError = 0;\r
+ uint32_t bbmBufferSize = 0, preLatencyBufferSize = 0;\r
+ hpi_err_t hpiError = 0;\r
PaTime pollingOverhead;\r
\r
/* Check overhead of Pa_Sleep() call (minimum sleep duration in ms -> OS dependent) */\r
PA_DEBUG(( "polling overhead = %f ms (length of 0-second sleep)\n", pollingOverhead ));\r
/* Obtain minimum recommended size for host buffer (in bytes) */\r
PA_ASIHPI_UNLESS_( HPI_StreamEstimateBufferSize( &streamComp->hpiFormat,\r
- pollingInterval + (HW32)ceil( pollingOverhead ),\r
+ pollingInterval + (uint32_t)ceil( pollingOverhead ),\r
&bbmBufferSize ), paUnanticipatedHostError );\r
/* BBM places more stringent requirements on buffer size (see description */\r
/* of HPI_StreamEstimateBufferSize in HPI API document) */\r
{\r
/* Save old buffer size, to be retried if new size proves too big */\r
preLatencyBufferSize = bbmBufferSize;\r
- bbmBufferSize = (HW32)ceil( suggestedLatency * streamComp->bytesPerFrame\r
+ bbmBufferSize = (uint32_t)ceil( suggestedLatency * streamComp->bytesPerFrame\r
* streamComp->hpiFormat.dwSampleRate );\r
}\r
}\r
/* Choose closest memory block boundary (HPI API document states that\r
"a buffer size of Nx4096 - 20 makes the best use of memory"\r
(under the entry for HPI_StreamEstimateBufferSize)) */\r
- bbmBufferSize = ((HW32)ceil((bbmBufferSize + 20)/4096.0))*4096 - 20;\r
+ bbmBufferSize = ((uint32_t)ceil((bbmBufferSize + 20)/4096.0))*4096 - 20;\r
streamComp->hostBufferSize = bbmBufferSize;\r
/* Allocate BBM host buffer (this enables bus mastering transfers in background) */\r
if( streamComp->hpiDevice->streamIsOutput )\r
- hpiError = HPI_OutStreamHostBufferAllocate( streamComp->hpiDevice->subSys,\r
+ hpiError = HPI_OutStreamHostBufferAllocate( NULL,\r
streamComp->hpiStream,\r
bbmBufferSize );\r
else\r
- hpiError = HPI_InStreamHostBufferAllocate( streamComp->hpiDevice->subSys,\r
+ hpiError = HPI_InStreamHostBufferAllocate( NULL,\r
streamComp->hpiStream,\r
bbmBufferSize );\r
if( hpiError )\r
{\r
- PA_ASIHPI_REPORT_ERROR_( hpiError );\r
/* Indicate that BBM is disabled */\r
streamComp->hostBufferSize = 0;\r
/* Retry with smaller buffer size (transfers will still work, but not via BBM) */\r
preLatencyBufferSize, bbmBufferSize ));\r
bbmBufferSize = preLatencyBufferSize;\r
if( streamComp->hpiDevice->streamIsOutput )\r
- hpiError = HPI_OutStreamHostBufferAllocate( streamComp->hpiDevice->subSys,\r
+ hpiError = HPI_OutStreamHostBufferAllocate( NULL,\r
streamComp->hpiStream,\r
bbmBufferSize );\r
else\r
- hpiError = HPI_InStreamHostBufferAllocate( streamComp->hpiDevice->subSys,\r
+ hpiError = HPI_InStreamHostBufferAllocate( NULL,\r
streamComp->hpiStream,\r
bbmBufferSize );\r
/* Another round of error checking */\r
}\r
/* If BBM not supported, foreground transfers will be used, but not a show-stopper */\r
/* Anything else is an error */\r
- else if( hpiError != HPI_ERROR_INVALID_OPERATION )\r
+ else if (( hpiError != HPI_ERROR_INVALID_OPERATION ) &&\r
+ ( hpiError != HPI_ERROR_INVALID_FUNC ))\r
{\r
+ PA_ASIHPI_REPORT_ERROR_( hpiError );\r
result = paUnanticipatedHostError;\r
goto error;\r
}\r
PaTime latency = suggestedLatency > 0.0 ? suggestedLatency :\r
streamComp->hpiDevice->baseDeviceInfo.defaultHighOutputLatency;\r
streamComp->outputBufferCap =\r
- (HW32)ceil( latency * streamComp->bytesPerFrame * streamComp->hpiFormat.dwSampleRate );\r
+ (uint32_t)ceil( latency * streamComp->bytesPerFrame * streamComp->hpiFormat.dwSampleRate );\r
/* The cap should not be too small, to prevent underflow */\r
if( streamComp->outputBufferCap < 4*paHostBufferSize )\r
streamComp->outputBufferCap = 4*paHostBufferSize;\r
/* Temp buffer size should be multiple of PA host buffer size (or 1x, if using fixed blocks) */\r
streamComp->tempBufferSize = paHostBufferSize;\r
/* Allocate temp buffer */\r
- PA_UNLESS_( streamComp->tempBuffer = (HW8 *)PaUtil_AllocateMemory( streamComp->tempBufferSize ),\r
+ PA_UNLESS_( streamComp->tempBuffer = (uint8_t *)PaUtil_AllocateMemory( streamComp->tempBufferSize ),\r
paInsufficientMemory );\r
error:\r
return result;\r
By keeping the frames a multiple of 4, this is ensured even for 8-bit mono sound. */\r
framesPerHostBuffer = (framesPerHostBuffer / 4) * 4;\r
/* Polling is based on time length (in milliseconds) of user-requested block size */\r
- stream->pollingInterval = (HW32)ceil( 1000.0*framesPerHostBuffer/sampleRate );\r
+ stream->pollingInterval = (uint32_t)ceil( 1000.0*framesPerHostBuffer/sampleRate );\r
assert( framesPerHostBuffer > 0 );\r
\r
/* Open underlying streams, check formats and allocate buffers */\r
/* Close HPI stream (freeing BBM host buffer in the process, if used) */\r
if( stream->input->hpiStream )\r
{\r
- PA_ASIHPI_UNLESS_( HPI_InStreamClose( stream->input->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL,\r
stream->input->hpiStream ), paUnanticipatedHostError );\r
}\r
/* Free temp buffer and stream component */\r
/* Close HPI stream (freeing BBM host buffer in the process, if used) */\r
if( stream->output->hpiStream )\r
{\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamClose( stream->output->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL,\r
stream->output->hpiStream ), paUnanticipatedHostError );\r
}\r
/* Free temp buffer and stream component */\r
PaAsiHpiStreamComponent *out;\r
PaUtilZeroer *zeroer;\r
PaSampleFormat outputFormat;\r
-#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))\r
- HPI_DATA data;\r
-#endif\r
assert( stream );\r
out = stream->output;\r
/* Only continue if stream has output channels */\r
assert( out->tempBuffer );\r
\r
/* Clear all existing data in hardware playback buffer */\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamReset( out->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamReset( NULL,\r
out->hpiStream ), paUnanticipatedHostError );\r
/* Fill temp buffer with silence */\r
outputFormat = PaAsiHpi_HpiToPaFormat( out->hpiFormat.wFormat );\r
zeroer = PaUtil_SelectZeroer( outputFormat );\r
zeroer(out->tempBuffer, 1, out->tempBufferSize / Pa_GetSampleSize(outputFormat) );\r
/* Write temp buffer to hardware fifo twice, to get started */\r
-#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( out->hpiDevice->subSys, out->hpiStream, \r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL, out->hpiStream,\r
out->tempBuffer, out->tempBufferSize, &out->hpiFormat),\r
paUnanticipatedHostError );\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( out->hpiDevice->subSys, out->hpiStream, \r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL, out->hpiStream,\r
out->tempBuffer, out->tempBufferSize, &out->hpiFormat),\r
paUnanticipatedHostError );\r
-#else\r
- PA_ASIHPI_UNLESS_( HPI_DataCreate( &data, &out->hpiFormat, out->tempBuffer, out->tempBufferSize ),\r
- paUnanticipatedHostError );\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( out->hpiDevice->subSys,\r
- out->hpiStream, &data ), paUnanticipatedHostError );\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( out->hpiDevice->subSys,\r
- out->hpiStream, &data ), paUnanticipatedHostError );\r
-#endif\r
error:\r
return result;\r
}\r
\r
if( stream->input )\r
{\r
- PA_ASIHPI_UNLESS_( HPI_InStreamStart( stream->input->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_InStreamStart( NULL,\r
stream->input->hpiStream ), paUnanticipatedHostError );\r
}\r
if( stream->output )\r
/* Buffer isn't primed, so load stream with silence */\r
PA_ENSURE_( PaAsiHpi_PrimeOutputWithSilence( stream ) );\r
}\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamStart( stream->output->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamStart( NULL,\r
stream->output->hpiStream ), paUnanticipatedHostError );\r
}\r
stream->state = paAsiHpiActiveState;\r
/* Input channels */\r
if( stream->input )\r
{\r
- PA_ASIHPI_UNLESS_( HPI_InStreamReset( stream->input->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_InStreamReset( NULL,\r
stream->input->hpiStream ), paUnanticipatedHostError );\r
}\r
/* Output channels */\r
Pa_Sleep( (long)ceil( timeLeft ) );\r
}\r
}\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamReset( stream->output->hpiDevice->subSys,\r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamReset( NULL,\r
stream->output->hpiStream ), paUnanticipatedHostError );\r
}\r
\r
PaError result = paNoError;\r
double sampleRate;\r
unsigned long framesTarget;\r
- HW32 outputData = 0, outputSpace = 0, inputData = 0, framesLeft = 0;\r
+ uint32_t outputData = 0, outputSpace = 0, inputData = 0, framesLeft = 0;\r
\r
assert( stream );\r
assert( stream->input || stream->output );\r
if( stream->input )\r
{\r
PaAsiHpiStreamInfo info;\r
- \r
-#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))\r
- HPI_DATA data;\r
-#endif\r
- HW32 framesToGet = *numFrames;\r
+\r
+ uint32_t framesToGet = *numFrames;\r
\r
/* Check for overflows and underflows yet again */\r
PA_ENSURE_( PaAsiHpi_GetStreamInfo( stream->input, &info ) );\r
stream->input->tempBufferSize / Pa_GetSampleSize(inputFormat) );\r
}\r
\r
-#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))\r
/* Read block of data into temp buffer */\r
- PA_ASIHPI_UNLESS_( HPI_InStreamReadBuf( stream->input->hpiDevice->subSys,\r
- stream->input->hpiStream, \r
+ PA_ASIHPI_UNLESS_( HPI_InStreamReadBuf( NULL,\r
+ stream->input->hpiStream,\r
stream->input->tempBuffer,\r
framesToGet * stream->input->bytesPerFrame),\r
paUnanticipatedHostError );\r
-#else\r
- /* Setup HPI data structure around temp buffer */\r
- HPI_DataCreate( &data, &stream->input->hpiFormat, stream->input->tempBuffer,\r
- framesToGet * stream->input->bytesPerFrame );\r
- /* Read block of data into temp buffer */\r
- PA_ASIHPI_UNLESS_( HPI_InStreamRead( stream->input->hpiDevice->subSys,\r
- stream->input->hpiStream, &data ),\r
- paUnanticipatedHostError );\r
-#endif\r
/* Register temp buffer with buffer processor (always FULL buffer) */\r
PaUtil_SetInputFrameCount( &stream->bufferProcessor, *numFrames );\r
/* HPI interface only allows interleaved channels */\r
if( stream->output )\r
{\r
PaAsiHpiStreamInfo info;\r
-#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))\r
- HPI_DATA data;\r
-#endif\r
/* Check for underflows after the (potentially time-consuming) callback */\r
PA_ENSURE_( PaAsiHpi_GetStreamInfo( stream->output, &info ) );\r
if( info.underflow )\r
*cbFlags |= paOutputUnderflow;\r
}\r
\r
-#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))\r
/* Write temp buffer to HPI stream */\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( stream->output->hpiDevice->subSys,\r
- stream->output->hpiStream, \r
+ PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL,\r
+ stream->output->hpiStream,\r
stream->output->tempBuffer,\r
- numFrames * stream->output->bytesPerFrame, \r
+ numFrames * stream->output->bytesPerFrame,\r
&stream->output->hpiFormat),\r
paUnanticipatedHostError );\r
-#else\r
- /* Setup HPI data structure around temp buffer */\r
- HPI_DataCreate( &data, &stream->output->hpiFormat, stream->output->tempBuffer,\r
- numFrames * stream->output->bytesPerFrame );\r
- /* Write temp buffer to HPI stream */\r
- PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( stream->output->hpiDevice->subSys,\r
- stream->output->hpiStream, &data ),\r
- paUnanticipatedHostError );\r
-#endif\r
}\r
\r
error:\r