]> git.pld-linux.org Git - packages/audacity.git/blame - portaudio_asihpi_406.patch
- updated to 1.3.13
[packages/audacity.git] / portaudio_asihpi_406.patch
CommitLineData
0b5e52e1
JB
1Index: src/hostapi/asihpi/pa_linux_asihpi.c
2===================================================================
3--- src/hostapi/asihpi/pa_linux_asihpi.c (revision 1645)
4+++ src/hostapi/asihpi/pa_linux_asihpi.c (working copy)
5@@ -193,7 +193,7 @@
6 /** Check return value of HPI function, and map it to PaError */
7 #define PA_ASIHPI_UNLESS_(expr, paError) \
8 do { \
9- HW16 hpiError = (expr); \
10+ hpi_err_t hpiError = (expr); \
11 /* If HPI error occurred */ \
12 if( UNLIKELY( hpiError ) ) \
13 { \
14@@ -265,8 +265,6 @@
15 /* implementation specific data goes here */
16
17 PaHostApiIndex hostApiIndex;
18- /** HPI subsystem pointer */
19- HPI_HSUBSYS *subSys;
20 }
21 PaAsiHpiHostApiRepresentation;
22
23@@ -280,20 +278,18 @@
24
25 /* implementation specific data goes here */
26
27- /** HPI subsystem (required for most HPI calls) */
28- HPI_HSUBSYS *subSys;
29 /** Adapter index */
30- HW16 adapterIndex;
31+ uint16_t adapterIndex;
32 /** Adapter model number (hex) */
33- HW16 adapterType;
34+ uint16_t adapterType;
35 /** Adapter HW/SW version */
36- HW16 adapterVersion;
37+ uint16_t adapterVersion;
38 /** Adapter serial number */
39- HW32 adapterSerialNumber;
40+ uint32_t adapterSerialNumber;
41 /** Stream number */
42- HW16 streamIndex;
43+ uint16_t streamIndex;
44 /** 0=Input, 1=Output (HPI streams are either input or output but not both) */
45- HW16 streamIsOutput;
46+ uint16_t streamIsOutput;
47 }
48 PaAsiHpiDeviceInfo;
49
50@@ -328,27 +324,25 @@
51 {
52 /** Device information (HPI handles, etc) */
53 PaAsiHpiDeviceInfo *hpiDevice;
54- /** Stream handle, as passed to HPI interface.
55- HACK: we assume types HPI_HISTREAM and HPI_HOSTREAM are the same...
56- (both are HW32 up to version 3.00 of ASIHPI, and hopefully they stay that way) */
57- HPI_HISTREAM hpiStream;
58+ /** Stream handle, as passed to HPI interface. */
59+ hpi_handle_t hpiStream;
60 /** Stream format, as passed to HPI interface */
61- HPI_FORMAT hpiFormat;
62+ struct hpi_format hpiFormat;
63 /** Number of bytes per frame, derived from hpiFormat and saved for convenience */
64- HW32 bytesPerFrame;
65+ uint32_t bytesPerFrame;
66 /** Size of hardware (on-card) buffer of stream in bytes */
67- HW32 hardwareBufferSize;
68+ uint32_t hardwareBufferSize;
69 /** Size of host (BBM) buffer of stream in bytes (if used) */
70- HW32 hostBufferSize;
71+ uint32_t hostBufferSize;
72 /** Upper limit on the utilization of output stream buffer (both hardware and host).
73 This prevents large latencies in an output-only stream with a potentially huge buffer
74 and a fast data generator, which would otherwise keep the hardware buffer filled to
75 capacity. See also the "Hardware Buffering=off" option in the AudioScience WAV driver. */
76- HW32 outputBufferCap;
77+ uint32_t outputBufferCap;
78 /** Sample buffer (halfway station between HPI and buffer processor) */
79- HW8 *tempBuffer;
80+ uint8_t *tempBuffer;
81 /** Sample buffer size, in bytes */
82- HW32 tempBufferSize;
83+ uint32_t tempBufferSize;
84 }
85 PaAsiHpiStreamComponent;
86
87@@ -369,7 +363,7 @@
88 PaAsiHpiStreamComponent *input, *output;
89
90 /** Polling interval (in milliseconds) */
91- HW32 pollingInterval;
92+ uint32_t pollingInterval;
93 /** Are we running in callback mode? */
94 int callbackMode;
95 /** Number of frames to transfer at a time to/from HPI */
96@@ -401,23 +395,23 @@
97 typedef struct PaAsiHpiStreamInfo
98 {
99 /** HPI stream state (HPI_STATE_STOPPED, HPI_STATE_PLAYING, etc.) */
100- HW16 state;
101+ uint16_t state;
102 /** Size (in bytes) of recording/playback data buffer in HPI driver */
103- HW32 bufferSize;
104+ uint32_t bufferSize;
105 /** Amount of data (in bytes) available in the buffer */
106- HW32 dataSize;
107+ uint32_t dataSize;
108 /** Number of frames played/recorded since last stream reset */
109- HW32 frameCounter;
110+ uint32_t frameCounter;
111 /** Amount of data (in bytes) in hardware (on-card) buffer.
112 This differs from dataSize if bus mastering (BBM) is used, which introduces another
113 driver-level buffer to which dataSize/bufferSize then refers. */
114- HW32 auxDataSize;
115+ uint32_t auxDataSize;
116 /** Total number of data frames currently buffered by HPI driver (host + hw buffers) */
117- HW32 totalBufferedData;
118+ uint32_t totalBufferedData;
119 /** Size of immediately available data (for input) or space (for output) in frames.
120 This only checks the first-level buffer (typically host buffer). This amount can be
121 transferred immediately. */
122- HW32 availableFrames;
123+ uint32_t availableFrames;
124 /** Indicates that hardware buffer is getting too full */
125 int overflow;
126 /** Indicates that hardware buffer is getting too empty */
127@@ -479,21 +473,21 @@
128
129 /* Functions specific to this API */
130 static PaError PaAsiHpi_BuildDeviceList( PaAsiHpiHostApiRepresentation *hpiHostApi );
131-static HW16 PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat );
132-static PaSampleFormat PaAsiHpi_HpiToPaFormat( HW16 hpiFormat );
133+static uint16_t PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat );
134+static PaSampleFormat PaAsiHpi_HpiToPaFormat( uint16_t hpiFormat );
135 static PaError PaAsiHpi_CreateFormat( struct PaUtilHostApiRepresentation *hostApi,
136 const PaStreamParameters *parameters, double sampleRate,
137- PaAsiHpiDeviceInfo **hpiDevice, HPI_FORMAT *hpiFormat );
138+ PaAsiHpiDeviceInfo **hpiDevice, struct hpi_format *hpiFormat );
139 static PaError PaAsiHpi_OpenInput( struct PaUtilHostApiRepresentation *hostApi,
140- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,
141- HPI_HISTREAM *hpiStream );
142+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,
143+ hpi_handle_t *hpiStream );
144 static PaError PaAsiHpi_OpenOutput( struct PaUtilHostApiRepresentation *hostApi,
145- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,
146- HPI_HOSTREAM *hpiStream );
147+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,
148+ hpi_handle_t *hpiStream );
149 static PaError PaAsiHpi_GetStreamInfo( PaAsiHpiStreamComponent *streamComp, PaAsiHpiStreamInfo *info );
150 static void PaAsiHpi_StreamComponentDump( PaAsiHpiStreamComponent *streamComp, PaAsiHpiStream *stream );
151 static void PaAsiHpi_StreamDump( PaAsiHpiStream *stream );
152-static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, HW32 pollingInterval,
153+static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, uint32_t pollingInterval,
154 unsigned long framesPerPaHostBuffer, PaTime suggestedLatency );
155 static PaError PaAsiHpi_PrimeOutputWithSilence( PaAsiHpiStream *stream );
156 static PaError PaAsiHpi_StartStream( PaAsiHpiStream *stream, int outputPrimed );
157@@ -529,42 +523,40 @@
158 PaUtilHostApiRepresentation *hostApi = &hpiHostApi->baseHostApiRep;
159 PaHostApiInfo *baseApiInfo = &hostApi->info;
160 PaAsiHpiDeviceInfo *hpiDeviceList;
161- HW16 adapterList[ HPI_MAX_ADAPTERS ];
162- HW16 numAdapters;
163- HW16 hpiError = 0;
164+ int numAdapters;
165+ hpi_err_t hpiError = 0;
166 int i, j, deviceCount = 0, deviceIndex = 0;
167
168 assert( hpiHostApi );
169- assert( hpiHostApi->subSys );
170
171 /* Look for adapters (not strictly necessary, as AdapterOpen can do the same, but this */
172 /* way we have less errors since we do not try to open adapters we know aren't there) */
173 /* Errors not considered critical here (subsystem may report 0 devices), but report them */
174 /* in debug mode. */
175- PA_ASIHPI_UNLESS_( HPI_SubSysFindAdapters( hpiHostApi->subSys, &numAdapters,
176- adapterList, HPI_MAX_ADAPTERS ), paNoError );
177+ PA_ASIHPI_UNLESS_( HPI_SubSysGetNumAdapters( NULL, &numAdapters), paNoError );
178
179 /* First open and count the number of devices (= number of streams), to ease memory allocation */
180- for( i=0; i < HPI_MAX_ADAPTERS; ++i )
181+ for( i=0; i < numAdapters; ++i )
182 {
183- HW16 inStreams, outStreams;
184- HW16 version;
185- HW32 serial;
186- HW16 type;
187+ uint16_t inStreams, outStreams;
188+ uint16_t version;
189+ uint32_t serial;
190+ uint16_t type;
191+ uint32_t idx;
192
193- /* If no adapter found at this index, skip it */
194- if( adapterList[i] == 0 )
195+ hpiError = HPI_SubSysGetAdapter(NULL, i, &idx, &type);
196+ if (hpiError)
197 continue;
198
199 /* Try to open adapter */
200- hpiError = HPI_AdapterOpen( hpiHostApi->subSys, i );
201+ hpiError = HPI_AdapterOpen( NULL, idx );
202 /* Report error and skip to next device on failure */
203 if( hpiError )
204 {
205 PA_ASIHPI_REPORT_ERROR_( hpiError );
206 continue;
207 }
208- hpiError = HPI_AdapterGetInfo( hpiHostApi->subSys, i,
209+ hpiError = HPI_AdapterGetInfo( NULL, idx,
210 &outStreams, &inStreams, &version, &serial, &type );
211 /* Skip to next device on failure */
212 if( hpiError )
213@@ -597,19 +589,20 @@
214 paInsufficientMemory );
215
216 /* Now query devices again for information */
217- for( i=0; i < HPI_MAX_ADAPTERS; ++i )
218+ for( i=0; i < numAdapters; ++i )
219 {
220- HW16 inStreams, outStreams;
221- HW16 version;
222- HW32 serial;
223- HW16 type;
224+ uint16_t inStreams, outStreams;
225+ uint16_t version;
226+ uint32_t serial;
227+ uint16_t type;
228+ uint32_t idx;
229
230- /* If no adapter found at this index, skip it */
231- if( adapterList[i] == 0 )
232+ hpiError = HPI_SubSysGetAdapter(NULL, i, &idx, &type);
233+ if (hpiError)
234 continue;
235
236 /* Assume adapter is still open from previous round */
237- hpiError = HPI_AdapterGetInfo( hpiHostApi->subSys, i,
238+ hpiError = HPI_AdapterGetInfo( NULL, idx,
239 &outStreams, &inStreams, &version, &serial, &type );
240 /* Report error and skip to next device on failure */
241 if( hpiError )
242@@ -620,7 +613,7 @@
243 else
244 {
245 PA_DEBUG(( "Found HPI Adapter ID=%4X Idx=%d #In=%d #Out=%d S/N=%d HWver=%c%d DSPver=%03d\n",
246- type, i, inStreams, outStreams, serial,
247+ type, idx, inStreams, outStreams, serial,
248 ((version>>3)&0xf)+'A', /* Hw version major */
249 version&0x7, /* Hw version minor */
250 ((version>>13)*100)+((version>>7)&0x3f) /* DSP code version */
251@@ -637,8 +630,7 @@
252
253 memset( hpiDevice, 0, sizeof(PaAsiHpiDeviceInfo) );
254 /* Set implementation-specific device details */
255- hpiDevice->subSys = hpiHostApi->subSys;
256- hpiDevice->adapterIndex = i;
257+ hpiDevice->adapterIndex = idx;
258 hpiDevice->adapterType = type;
259 hpiDevice->adapterVersion = version;
260 hpiDevice->adapterSerialNumber = serial;
261@@ -680,8 +672,7 @@
262
263 memset( hpiDevice, 0, sizeof(PaAsiHpiDeviceInfo) );
264 /* Set implementation-specific device details */
265- hpiDevice->subSys = hpiHostApi->subSys;
266- hpiDevice->adapterIndex = i;
267+ hpiDevice->adapterIndex = idx;
268 hpiDevice->adapterType = type;
269 hpiDevice->adapterVersion = version;
270 hpiDevice->adapterSerialNumber = serial;
271@@ -746,10 +737,9 @@
272 PA_UNLESS_( hpiHostApi->allocations = PaUtil_CreateAllocationGroup(), paInsufficientMemory );
273
274 hpiHostApi->hostApiIndex = hostApiIndex;
275- hpiHostApi->subSys = NULL;
276
277 /* Try to initialize HPI subsystem */
278- if( ( hpiHostApi->subSys = HPI_SubSysCreate() ) == NULL)
279+ if(HPI_SubSysCreate() == NULL)
280 {
281 /* the V19 development docs say that if an implementation
282 * detects that it cannot be used, it should return a NULL
283@@ -761,10 +751,10 @@
284 }
285 else
286 {
287- HW32 hpiVersion;
288- PA_ASIHPI_UNLESS_( HPI_SubSysGetVersion( hpiHostApi->subSys, &hpiVersion ), paUnanticipatedHostError );
289- PA_DEBUG(( "HPI interface v%d.%02d\n",
290- hpiVersion >> 8, 10*((hpiVersion & 0xF0) >> 4) + (hpiVersion & 0x0F) ));
291+ uint32_t hpiVersion;
292+ PA_ASIHPI_UNLESS_( HPI_SubSysGetVersionEx( NULL, &hpiVersion ), paUnanticipatedHostError );
293+ PA_DEBUG(( "HPI interface v%d.%02d.%02d\n",
294+ hpiVersion >> 16, (hpiVersion >> 8) & 0x0F, (hpiVersion & 0x0F) ));
295 }
296
297 *hostApi = &hpiHostApi->baseHostApiRep;
298@@ -820,25 +810,22 @@
299 if( hpiHostApi )
300 {
301 /* Get rid of HPI-specific structures */
302- if( hpiHostApi->subSys )
303+ uint16_t lastAdapterIndex = HPI_MAX_ADAPTERS;
304+ /* Iterate through device list and close adapters */
305+ for( i=0; i < hostApi->info.deviceCount; ++i )
306 {
307- HW16 lastAdapterIndex = HPI_MAX_ADAPTERS;
308- /* Iterate through device list and close adapters */
309- for( i=0; i < hostApi->info.deviceCount; ++i )
310+ PaAsiHpiDeviceInfo *hpiDevice = (PaAsiHpiDeviceInfo *) hostApi->deviceInfos[ i ];
311+ /* Close adapter only if it differs from previous one */
312+ if( hpiDevice->adapterIndex != lastAdapterIndex )
313 {
314- PaAsiHpiDeviceInfo *hpiDevice = (PaAsiHpiDeviceInfo *) hostApi->deviceInfos[ i ];
315- /* Close adapter only if it differs from previous one */
316- if( hpiDevice->adapterIndex != lastAdapterIndex )
317- {
318- /* Ignore errors (report only during debugging) */
319- PA_ASIHPI_UNLESS_( HPI_AdapterClose( hpiHostApi->subSys,
320- hpiDevice->adapterIndex ), paNoError );
321- lastAdapterIndex = hpiDevice->adapterIndex;
322- }
323+ /* Ignore errors (report only during debugging) */
324+ PA_ASIHPI_UNLESS_( HPI_AdapterClose( NULL,
325+ hpiDevice->adapterIndex ), paNoError );
326+ lastAdapterIndex = hpiDevice->adapterIndex;
327 }
328- /* Finally dismantle HPI subsystem */
329- HPI_SubSysFree( hpiHostApi->subSys );
330 }
331+ /* Finally dismantle HPI subsystem */
332+ HPI_SubSysFree( NULL );
333
334 if( hpiHostApi->allocations )
335 {
336@@ -859,7 +846,7 @@
337
338 @return HPI sample format
339 */
340-static HW16 PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat )
341+static uint16_t PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat )
342 {
343 /* Ignore interleaving flag */
344 switch( paFormat & ~paNonInterleaved )
345@@ -893,7 +880,7 @@
346
347 @return PortAudio sample format
348 */
349-static PaSampleFormat PaAsiHpi_HpiToPaFormat( HW16 hpiFormat )
350+static PaSampleFormat PaAsiHpi_HpiToPaFormat( uint16_t hpiFormat )
351 {
352 switch( hpiFormat )
353 {
354@@ -938,11 +925,11 @@
355 */
356 static PaError PaAsiHpi_CreateFormat( struct PaUtilHostApiRepresentation *hostApi,
357 const PaStreamParameters *parameters, double sampleRate,
358- PaAsiHpiDeviceInfo **hpiDevice, HPI_FORMAT *hpiFormat )
359+ PaAsiHpiDeviceInfo **hpiDevice, struct hpi_format *hpiFormat )
360 {
361 int maxChannelCount = 0;
362 PaSampleFormat hostSampleFormat = 0;
363- HW16 hpiError = 0;
364+ hpi_err_t hpiError = 0;
365
366 /* Unless alternate device specification is supported, reject the use of
367 paUseHostApiSpecificDeviceSpecification */
368@@ -979,9 +966,9 @@
369 hostSampleFormat = PaUtil_SelectClosestAvailableFormat(PA_ASIHPI_AVAILABLE_FORMATS_,
370 parameters->sampleFormat );
371 /* Setup format + info objects */
372- hpiError = HPI_FormatCreate( hpiFormat, (HW16)parameters->channelCount,
373+ hpiError = HPI_FormatCreate( hpiFormat, (uint16_t)parameters->channelCount,
374 PaAsiHpi_PaToHpiFormat( hostSampleFormat ),
375- (HW32)sampleRate, 0, 0 );
376+ (uint32_t)sampleRate, 0, 0 );
377 if( hpiError )
378 {
379 PA_ASIHPI_REPORT_ERROR_( hpiError );
380@@ -1016,25 +1003,25 @@
381 @return PortAudio error code (typically indicating a problem with stream format or device)
382 */
383 static PaError PaAsiHpi_OpenInput( struct PaUtilHostApiRepresentation *hostApi,
384- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,
385- HPI_HISTREAM *hpiStream )
386+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,
387+ hpi_handle_t *hpiStream )
388 {
389 PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;
390 PaError result = paNoError;
391- HW16 hpiError = 0;
392+ hpi_err_t hpiError = 0;
393
394 /* Catch misplaced output devices, as they typically have 0 input channels */
395 PA_UNLESS_( !hpiDevice->streamIsOutput, paInvalidChannelCount );
396 /* Try to open input stream */
397- PA_ASIHPI_UNLESS_( HPI_InStreamOpen( hpiHostApi->subSys, hpiDevice->adapterIndex,
398+ PA_ASIHPI_UNLESS_( HPI_InStreamOpen( NULL, hpiDevice->adapterIndex,
399 hpiDevice->streamIndex, hpiStream ), paDeviceUnavailable );
400 /* Set input format (checking it in the process) */
401 /* Could also use HPI_InStreamQueryFormat, but this economizes the process */
402- hpiError = HPI_InStreamSetFormat( hpiHostApi->subSys, *hpiStream, (HPI_FORMAT*)hpiFormat );
403+ hpiError = HPI_InStreamSetFormat( NULL, *hpiStream, (struct hpi_format*)hpiFormat );
404 if( hpiError )
405 {
406 PA_ASIHPI_REPORT_ERROR_( hpiError );
407- PA_ASIHPI_UNLESS_( HPI_InStreamClose( hpiHostApi->subSys, *hpiStream ), paNoError );
408+ PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL, *hpiStream ), paNoError );
409 switch( hpiError )
410 {
411 case HPI_ERROR_INVALID_FORMAT:
412@@ -1071,25 +1058,25 @@
413 @return PortAudio error code (typically indicating a problem with stream format or device)
414 */
415 static PaError PaAsiHpi_OpenOutput( struct PaUtilHostApiRepresentation *hostApi,
416- const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,
417- HPI_HOSTREAM *hpiStream )
418+ const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,
419+ hpi_handle_t *hpiStream )
420 {
421 PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;
422 PaError result = paNoError;
423- HW16 hpiError = 0;
424+ hpi_err_t hpiError = 0;
425
426 /* Catch misplaced input devices, as they typically have 0 output channels */
427 PA_UNLESS_( hpiDevice->streamIsOutput, paInvalidChannelCount );
428 /* Try to open output stream */
429- PA_ASIHPI_UNLESS_( HPI_OutStreamOpen( hpiHostApi->subSys, hpiDevice->adapterIndex,
430+ PA_ASIHPI_UNLESS_( HPI_OutStreamOpen( NULL, hpiDevice->adapterIndex,
431 hpiDevice->streamIndex, hpiStream ), paDeviceUnavailable );
432
433 /* Check output format (format is set on first write to output stream) */
434- hpiError = HPI_OutStreamQueryFormat( hpiHostApi->subSys, *hpiStream, (HPI_FORMAT*)hpiFormat );
435+ hpiError = HPI_OutStreamQueryFormat( NULL, *hpiStream, (struct hpi_format*)hpiFormat );
436 if( hpiError )
437 {
438 PA_ASIHPI_REPORT_ERROR_( hpiError );
439- PA_ASIHPI_UNLESS_( HPI_OutStreamClose( hpiHostApi->subSys, *hpiStream ), paNoError );
440+ PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL, *hpiStream ), paNoError );
441 switch( hpiError )
442 {
443 case HPI_ERROR_INVALID_FORMAT:
444@@ -1135,12 +1122,12 @@
445 PaError result = paFormatIsSupported;
446 PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;
447 PaAsiHpiDeviceInfo *hpiDevice = NULL;
448- HPI_FORMAT hpiFormat;
449+ struct hpi_format hpiFormat;
450
451 /* Input stream */
452 if( inputParameters )
453 {
454- HPI_HISTREAM hpiStream;
455+ hpi_handle_t hpiStream;
456 PA_DEBUG(( "%s: Checking input params: dev=%d, sr=%d, chans=%d, fmt=%d\n",
457 __FUNCTION__, inputParameters->device, (int)sampleRate,
458 inputParameters->channelCount, inputParameters->sampleFormat ));
459@@ -1150,13 +1137,13 @@
460 /* Open stream to further check format */
461 PA_ENSURE_( PaAsiHpi_OpenInput( hostApi, hpiDevice, &hpiFormat, &hpiStream ) );
462 /* Close stream again */
463- PA_ASIHPI_UNLESS_( HPI_InStreamClose( hpiHostApi->subSys, hpiStream ), paNoError );
464+ PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL, hpiStream ), paNoError );
465 }
466
467 /* Output stream */
468 if( outputParameters )
469 {
470- HPI_HOSTREAM hpiStream;
471+ hpi_handle_t hpiStream;
472 PA_DEBUG(( "%s: Checking output params: dev=%d, sr=%d, chans=%d, fmt=%d\n",
473 __FUNCTION__, outputParameters->device, (int)sampleRate,
474 outputParameters->channelCount, outputParameters->sampleFormat ));
475@@ -1166,7 +1153,7 @@
476 /* Open stream to further check format */
477 PA_ENSURE_( PaAsiHpi_OpenOutput( hostApi, hpiDevice, &hpiFormat, &hpiStream ) );
478 /* Close stream again */
479- PA_ASIHPI_UNLESS_( HPI_OutStreamClose( hpiHostApi->subSys, hpiStream ), paNoError );
480+ PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL, hpiStream ), paNoError );
481 }
482
483 error:
484@@ -1188,9 +1175,9 @@
485 static PaError PaAsiHpi_GetStreamInfo( PaAsiHpiStreamComponent *streamComp, PaAsiHpiStreamInfo *info )
486 {
487 PaError result = paDeviceUnavailable;
488- HW16 state;
489- HW32 bufferSize, dataSize, frameCounter, auxDataSize, threshold;
490- HW32 hwBufferSize, hwDataSize;
491+ uint16_t state;
492+ uint32_t bufferSize, dataSize, frameCounter, auxDataSize, threshold;
493+ uint32_t hwBufferSize, hwDataSize;
494
495 assert( streamComp );
496 assert( info );
497@@ -1212,14 +1199,14 @@
498 /* Obtain detailed stream info (either input or output) */
499 if( streamComp->hpiDevice->streamIsOutput )
500 {
501- PA_ASIHPI_UNLESS_( HPI_OutStreamGetInfoEx( streamComp->hpiDevice->subSys,
502+ PA_ASIHPI_UNLESS_( HPI_OutStreamGetInfoEx( NULL,
503 streamComp->hpiStream,
504 &state, &bufferSize, &dataSize, &frameCounter,
505 &auxDataSize ), paUnanticipatedHostError );
506 }
507 else
508 {
509- PA_ASIHPI_UNLESS_( HPI_InStreamGetInfoEx( streamComp->hpiDevice->subSys,
510+ PA_ASIHPI_UNLESS_( HPI_InStreamGetInfoEx( NULL,
511 streamComp->hpiStream,
512 &state, &bufferSize, &dataSize, &frameCounter,
513 &auxDataSize ), paUnanticipatedHostError );
514@@ -1479,7 +1466,7 @@
515
516 @return PortAudio error code (possibly paBufferTooBig or paInsufficientMemory)
517 */
518-static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, HW32 pollingInterval,
519+static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, uint32_t pollingInterval,
520 unsigned long framesPerPaHostBuffer, PaTime suggestedLatency )
521 {
522 PaError result = paNoError;
523@@ -1499,8 +1486,8 @@
524 /* Check if BBM (background bus mastering) is to be enabled */
525 if( PA_ASIHPI_USE_BBM_ )
526 {
527- HW32 bbmBufferSize = 0, preLatencyBufferSize = 0;
528- HW16 hpiError = 0;
529+ uint32_t bbmBufferSize = 0, preLatencyBufferSize = 0;
530+ hpi_err_t hpiError = 0;
531 PaTime pollingOverhead;
532
533 /* Check overhead of Pa_Sleep() call (minimum sleep duration in ms -> OS dependent) */
534@@ -1510,7 +1497,7 @@
535 PA_DEBUG(( "polling overhead = %f ms (length of 0-second sleep)\n", pollingOverhead ));
536 /* Obtain minimum recommended size for host buffer (in bytes) */
537 PA_ASIHPI_UNLESS_( HPI_StreamEstimateBufferSize( &streamComp->hpiFormat,
538- pollingInterval + (HW32)ceil( pollingOverhead ),
539+ pollingInterval + (uint32_t)ceil( pollingOverhead ),
540 &bbmBufferSize ), paUnanticipatedHostError );
541 /* BBM places more stringent requirements on buffer size (see description */
542 /* of HPI_StreamEstimateBufferSize in HPI API document) */
543@@ -1528,27 +1515,26 @@
544 {
545 /* Save old buffer size, to be retried if new size proves too big */
546 preLatencyBufferSize = bbmBufferSize;
547- bbmBufferSize = (HW32)ceil( suggestedLatency * streamComp->bytesPerFrame
548+ bbmBufferSize = (uint32_t)ceil( suggestedLatency * streamComp->bytesPerFrame
549 * streamComp->hpiFormat.dwSampleRate );
550 }
551 }
552 /* Choose closest memory block boundary (HPI API document states that
553 "a buffer size of Nx4096 - 20 makes the best use of memory"
554 (under the entry for HPI_StreamEstimateBufferSize)) */
555- bbmBufferSize = ((HW32)ceil((bbmBufferSize + 20)/4096.0))*4096 - 20;
556+ bbmBufferSize = ((uint32_t)ceil((bbmBufferSize + 20)/4096.0))*4096 - 20;
557 streamComp->hostBufferSize = bbmBufferSize;
558 /* Allocate BBM host buffer (this enables bus mastering transfers in background) */
559 if( streamComp->hpiDevice->streamIsOutput )
560- hpiError = HPI_OutStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
561+ hpiError = HPI_OutStreamHostBufferAllocate( NULL,
562 streamComp->hpiStream,
563 bbmBufferSize );
564 else
565- hpiError = HPI_InStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
566+ hpiError = HPI_InStreamHostBufferAllocate( NULL,
567 streamComp->hpiStream,
568 bbmBufferSize );
569 if( hpiError )
570 {
571- PA_ASIHPI_REPORT_ERROR_( hpiError );
572 /* Indicate that BBM is disabled */
573 streamComp->hostBufferSize = 0;
574 /* Retry with smaller buffer size (transfers will still work, but not via BBM) */
575@@ -1561,11 +1547,11 @@
576 preLatencyBufferSize, bbmBufferSize ));
577 bbmBufferSize = preLatencyBufferSize;
578 if( streamComp->hpiDevice->streamIsOutput )
579- hpiError = HPI_OutStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
580+ hpiError = HPI_OutStreamHostBufferAllocate( NULL,
581 streamComp->hpiStream,
582 bbmBufferSize );
583 else
584- hpiError = HPI_InStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
585+ hpiError = HPI_InStreamHostBufferAllocate( NULL,
586 streamComp->hpiStream,
587 bbmBufferSize );
588 /* Another round of error checking */
589@@ -1598,8 +1584,10 @@
590 }
591 /* If BBM not supported, foreground transfers will be used, but not a show-stopper */
592 /* Anything else is an error */
593- else if( hpiError != HPI_ERROR_INVALID_OPERATION )
594+ else if (( hpiError != HPI_ERROR_INVALID_OPERATION ) &&
595+ ( hpiError != HPI_ERROR_INVALID_FUNC ))
596 {
597+ PA_ASIHPI_REPORT_ERROR_( hpiError );
598 result = paUnanticipatedHostError;
599 goto error;
600 }
601@@ -1623,7 +1611,7 @@
602 PaTime latency = suggestedLatency > 0.0 ? suggestedLatency :
603 streamComp->hpiDevice->baseDeviceInfo.defaultHighOutputLatency;
604 streamComp->outputBufferCap =
605- (HW32)ceil( latency * streamComp->bytesPerFrame * streamComp->hpiFormat.dwSampleRate );
606+ (uint32_t)ceil( latency * streamComp->bytesPerFrame * streamComp->hpiFormat.dwSampleRate );
607 /* The cap should not be too small, to prevent underflow */
608 if( streamComp->outputBufferCap < 4*paHostBufferSize )
609 streamComp->outputBufferCap = 4*paHostBufferSize;
610@@ -1635,7 +1623,7 @@
611 /* Temp buffer size should be multiple of PA host buffer size (or 1x, if using fixed blocks) */
612 streamComp->tempBufferSize = paHostBufferSize;
613 /* Allocate temp buffer */
614- PA_UNLESS_( streamComp->tempBuffer = (HW8 *)PaUtil_AllocateMemory( streamComp->tempBufferSize ),
615+ PA_UNLESS_( streamComp->tempBuffer = (uint8_t *)PaUtil_AllocateMemory( streamComp->tempBufferSize ),
616 paInsufficientMemory );
617 error:
618 return result;
619@@ -1725,7 +1713,7 @@
620 By keeping the frames a multiple of 4, this is ensured even for 8-bit mono sound. */
621 framesPerHostBuffer = (framesPerHostBuffer / 4) * 4;
622 /* Polling is based on time length (in milliseconds) of user-requested block size */
623- stream->pollingInterval = (HW32)ceil( 1000.0*framesPerHostBuffer/sampleRate );
624+ stream->pollingInterval = (uint32_t)ceil( 1000.0*framesPerHostBuffer/sampleRate );
625 assert( framesPerHostBuffer > 0 );
626
627 /* Open underlying streams, check formats and allocate buffers */
628@@ -1890,7 +1878,7 @@
629 /* Close HPI stream (freeing BBM host buffer in the process, if used) */
630 if( stream->input->hpiStream )
631 {
632- PA_ASIHPI_UNLESS_( HPI_InStreamClose( stream->input->hpiDevice->subSys,
633+ PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL,
634 stream->input->hpiStream ), paUnanticipatedHostError );
635 }
636 /* Free temp buffer and stream component */
637@@ -1902,7 +1890,7 @@
638 /* Close HPI stream (freeing BBM host buffer in the process, if used) */
639 if( stream->output->hpiStream )
640 {
641- PA_ASIHPI_UNLESS_( HPI_OutStreamClose( stream->output->hpiDevice->subSys,
642+ PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL,
643 stream->output->hpiStream ), paUnanticipatedHostError );
644 }
645 /* Free temp buffer and stream component */
646@@ -1933,9 +1921,6 @@
647 PaAsiHpiStreamComponent *out;
648 PaUtilZeroer *zeroer;
649 PaSampleFormat outputFormat;
650-#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
651- HPI_DATA data;
652-#endif
653 assert( stream );
654 out = stream->output;
655 /* Only continue if stream has output channels */
656@@ -1944,28 +1929,19 @@
657 assert( out->tempBuffer );
658
659 /* Clear all existing data in hardware playback buffer */
660- PA_ASIHPI_UNLESS_( HPI_OutStreamReset( out->hpiDevice->subSys,
661+ PA_ASIHPI_UNLESS_( HPI_OutStreamReset( NULL,
662 out->hpiStream ), paUnanticipatedHostError );
663 /* Fill temp buffer with silence */
664 outputFormat = PaAsiHpi_HpiToPaFormat( out->hpiFormat.wFormat );
665 zeroer = PaUtil_SelectZeroer( outputFormat );
666 zeroer(out->tempBuffer, 1, out->tempBufferSize / Pa_GetSampleSize(outputFormat) );
667 /* Write temp buffer to hardware fifo twice, to get started */
668-#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
669- PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( out->hpiDevice->subSys, out->hpiStream,
670+ PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL, out->hpiStream,
671 out->tempBuffer, out->tempBufferSize, &out->hpiFormat),
672 paUnanticipatedHostError );
673- PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( out->hpiDevice->subSys, out->hpiStream,
674+ PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL, out->hpiStream,
675 out->tempBuffer, out->tempBufferSize, &out->hpiFormat),
676 paUnanticipatedHostError );
677-#else
678- PA_ASIHPI_UNLESS_( HPI_DataCreate( &data, &out->hpiFormat, out->tempBuffer, out->tempBufferSize ),
679- paUnanticipatedHostError );
680- PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( out->hpiDevice->subSys,
681- out->hpiStream, &data ), paUnanticipatedHostError );
682- PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( out->hpiDevice->subSys,
683- out->hpiStream, &data ), paUnanticipatedHostError );
684-#endif
685 error:
686 return result;
687 }
688@@ -1989,7 +1965,7 @@
689
690 if( stream->input )
691 {
692- PA_ASIHPI_UNLESS_( HPI_InStreamStart( stream->input->hpiDevice->subSys,
693+ PA_ASIHPI_UNLESS_( HPI_InStreamStart( NULL,
694 stream->input->hpiStream ), paUnanticipatedHostError );
695 }
696 if( stream->output )
697@@ -1999,7 +1975,7 @@
698 /* Buffer isn't primed, so load stream with silence */
699 PA_ENSURE_( PaAsiHpi_PrimeOutputWithSilence( stream ) );
700 }
701- PA_ASIHPI_UNLESS_( HPI_OutStreamStart( stream->output->hpiDevice->subSys,
702+ PA_ASIHPI_UNLESS_( HPI_OutStreamStart( NULL,
703 stream->output->hpiStream ), paUnanticipatedHostError );
704 }
705 stream->state = paAsiHpiActiveState;
706@@ -2071,7 +2047,7 @@
707 /* Input channels */
708 if( stream->input )
709 {
710- PA_ASIHPI_UNLESS_( HPI_InStreamReset( stream->input->hpiDevice->subSys,
711+ PA_ASIHPI_UNLESS_( HPI_InStreamReset( NULL,
712 stream->input->hpiStream ), paUnanticipatedHostError );
713 }
714 /* Output channels */
715@@ -2097,7 +2073,7 @@
716 Pa_Sleep( (long)ceil( timeLeft ) );
717 }
718 }
719- PA_ASIHPI_UNLESS_( HPI_OutStreamReset( stream->output->hpiDevice->subSys,
720+ PA_ASIHPI_UNLESS_( HPI_OutStreamReset( NULL,
721 stream->output->hpiStream ), paUnanticipatedHostError );
722 }
723
724@@ -2315,7 +2291,7 @@
725 PaError result = paNoError;
726 double sampleRate;
727 unsigned long framesTarget;
728- HW32 outputData = 0, outputSpace = 0, inputData = 0, framesLeft = 0;
729+ uint32_t outputData = 0, outputSpace = 0, inputData = 0, framesLeft = 0;
730
731 assert( stream );
732 assert( stream->input || stream->output );
733@@ -2484,12 +2460,9 @@
734 if( stream->input )
735 {
736 PaAsiHpiStreamInfo info;
737-
738-#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
739- HPI_DATA data;
740-#endif
741- HW32 framesToGet = *numFrames;
742
743+ uint32_t framesToGet = *numFrames;
744+
745 /* Check for overflows and underflows yet again */
746 PA_ENSURE_( PaAsiHpi_GetStreamInfo( stream->input, &info ) );
747 if( info.overflow )
748@@ -2513,22 +2486,12 @@
749 stream->input->tempBufferSize / Pa_GetSampleSize(inputFormat) );
750 }
751
752-#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
753 /* Read block of data into temp buffer */
754- PA_ASIHPI_UNLESS_( HPI_InStreamReadBuf( stream->input->hpiDevice->subSys,
755- stream->input->hpiStream,
756+ PA_ASIHPI_UNLESS_( HPI_InStreamReadBuf( NULL,
757+ stream->input->hpiStream,
758 stream->input->tempBuffer,
759 framesToGet * stream->input->bytesPerFrame),
760 paUnanticipatedHostError );
761-#else
762- /* Setup HPI data structure around temp buffer */
763- HPI_DataCreate( &data, &stream->input->hpiFormat, stream->input->tempBuffer,
764- framesToGet * stream->input->bytesPerFrame );
765- /* Read block of data into temp buffer */
766- PA_ASIHPI_UNLESS_( HPI_InStreamRead( stream->input->hpiDevice->subSys,
767- stream->input->hpiStream, &data ),
768- paUnanticipatedHostError );
769-#endif
770 /* Register temp buffer with buffer processor (always FULL buffer) */
771 PaUtil_SetInputFrameCount( &stream->bufferProcessor, *numFrames );
772 /* HPI interface only allows interleaved channels */
773@@ -2572,9 +2535,6 @@
774 if( stream->output )
775 {
776 PaAsiHpiStreamInfo info;
777-#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
778- HPI_DATA data;
779-#endif
780 /* Check for underflows after the (potentially time-consuming) callback */
781 PA_ENSURE_( PaAsiHpi_GetStreamInfo( stream->output, &info ) );
782 if( info.underflow )
783@@ -2582,23 +2542,13 @@
784 *cbFlags |= paOutputUnderflow;
785 }
786
787-#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
788 /* Write temp buffer to HPI stream */
789- PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( stream->output->hpiDevice->subSys,
790- stream->output->hpiStream,
791+ PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL,
792+ stream->output->hpiStream,
793 stream->output->tempBuffer,
794- numFrames * stream->output->bytesPerFrame,
795+ numFrames * stream->output->bytesPerFrame,
796 &stream->output->hpiFormat),
797 paUnanticipatedHostError );
798-#else
799- /* Setup HPI data structure around temp buffer */
800- HPI_DataCreate( &data, &stream->output->hpiFormat, stream->output->tempBuffer,
801- numFrames * stream->output->bytesPerFrame );
802- /* Write temp buffer to HPI stream */
803- PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( stream->output->hpiDevice->subSys,
804- stream->output->hpiStream, &data ),
805- paUnanticipatedHostError );
806-#endif
807 }
808
809 error:
This page took 0.185343 seconds and 4 git commands to generate.