]> git.pld-linux.org Git - packages/audacity.git/blob - portaudio_asihpi_406.patch
9c2d8b5da94a4c65807f9d7f12bef04f0a7cbd98
[packages/audacity.git] / portaudio_asihpi_406.patch
1 Index: 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,25 +737,24 @@
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           * interface and paNoError */
284          PA_DEBUG(( "Could not open HPI interface\n" ));
285          result = paNoError;
286 -        *hostApi = NULL;
287 +        hpiHostApi = NULL;
288          goto error;
289      }
290      else
291      {
292 -        HW32 hpiVersion;
293 -        PA_ASIHPI_UNLESS_( HPI_SubSysGetVersion( hpiHostApi->subSys, &hpiVersion ), paUnanticipatedHostError );
294 -        PA_DEBUG(( "HPI interface v%d.%02d\n",
295 -                   hpiVersion >> 8, 10*((hpiVersion & 0xF0) >> 4) + (hpiVersion & 0x0F) ));
296 +        uint32_t hpiVersion;
297 +        PA_ASIHPI_UNLESS_( HPI_SubSysGetVersionEx( NULL, &hpiVersion ), paUnanticipatedHostError );
298 +        PA_DEBUG(( "HPI interface v%d.%02d.%02d\n",
299 +                   hpiVersion >> 16,  (hpiVersion >> 8) & 0x0F, (hpiVersion & 0x0F) ));
300      }
301  
302      *hostApi = &hpiHostApi->baseHostApiRep;
303 @@ -820,25 +810,22 @@
304      if( hpiHostApi )
305      {
306          /* Get rid of HPI-specific structures */
307 -        if( hpiHostApi->subSys )
308 +        uint16_t lastAdapterIndex = HPI_MAX_ADAPTERS;
309 +        /* Iterate through device list and close adapters */
310 +        for( i=0; i < hostApi->info.deviceCount; ++i )
311          {
312 -            HW16 lastAdapterIndex = HPI_MAX_ADAPTERS;
313 -            /* Iterate through device list and close adapters */
314 -            for( i=0; i < hostApi->info.deviceCount; ++i )
315 +            PaAsiHpiDeviceInfo *hpiDevice = (PaAsiHpiDeviceInfo *) hostApi->deviceInfos[ i ];
316 +            /* Close adapter only if it differs from previous one */
317 +            if( hpiDevice->adapterIndex != lastAdapterIndex )
318              {
319 -                PaAsiHpiDeviceInfo *hpiDevice = (PaAsiHpiDeviceInfo *) hostApi->deviceInfos[ i ];
320 -                /* Close adapter only if it differs from previous one */
321 -                if( hpiDevice->adapterIndex != lastAdapterIndex )
322 -                {
323 -                    /* Ignore errors (report only during debugging) */
324 -                    PA_ASIHPI_UNLESS_( HPI_AdapterClose( hpiHostApi->subSys,
325 -                                                         hpiDevice->adapterIndex ), paNoError );
326 -                    lastAdapterIndex = hpiDevice->adapterIndex;
327 -                }
328 +                /* Ignore errors (report only during debugging) */
329 +                PA_ASIHPI_UNLESS_( HPI_AdapterClose( NULL,
330 +                                                     hpiDevice->adapterIndex ), paNoError );
331 +                lastAdapterIndex = hpiDevice->adapterIndex;
332              }
333 -            /* Finally dismantle HPI subsystem */
334 -            HPI_SubSysFree( hpiHostApi->subSys );
335          }
336 +        /* Finally dismantle HPI subsystem */
337 +        HPI_SubSysFree( NULL );
338  
339          if( hpiHostApi->allocations )
340          {
341 @@ -859,7 +846,7 @@
342  
343   @return HPI sample format
344   */
345 -static HW16 PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat )
346 +static uint16_t PaAsiHpi_PaToHpiFormat( PaSampleFormat paFormat )
347  {
348      /* Ignore interleaving flag */
349      switch( paFormat & ~paNonInterleaved )
350 @@ -893,7 +880,7 @@
351  
352   @return PortAudio sample format
353   */
354 -static PaSampleFormat PaAsiHpi_HpiToPaFormat( HW16 hpiFormat )
355 +static PaSampleFormat PaAsiHpi_HpiToPaFormat( uint16_t hpiFormat )
356  {
357      switch( hpiFormat )
358      {
359 @@ -938,11 +925,11 @@
360   */
361  static PaError PaAsiHpi_CreateFormat( struct PaUtilHostApiRepresentation *hostApi,
362                                        const PaStreamParameters *parameters, double sampleRate,
363 -                                      PaAsiHpiDeviceInfo **hpiDevice, HPI_FORMAT *hpiFormat )
364 +                                      PaAsiHpiDeviceInfo **hpiDevice, struct hpi_format *hpiFormat )
365  {
366      int maxChannelCount = 0;
367      PaSampleFormat hostSampleFormat = 0;
368 -    HW16 hpiError = 0;
369 +    hpi_err_t hpiError = 0;
370  
371      /* Unless alternate device specification is supported, reject the use of
372         paUseHostApiSpecificDeviceSpecification */
373 @@ -979,9 +966,9 @@
374      hostSampleFormat = PaUtil_SelectClosestAvailableFormat(PA_ASIHPI_AVAILABLE_FORMATS_,
375                         parameters->sampleFormat );
376      /* Setup format + info objects */
377 -    hpiError = HPI_FormatCreate( hpiFormat, (HW16)parameters->channelCount,
378 +    hpiError = HPI_FormatCreate( hpiFormat, (uint16_t)parameters->channelCount,
379                                   PaAsiHpi_PaToHpiFormat( hostSampleFormat ),
380 -                                 (HW32)sampleRate, 0, 0 );
381 +                                 (uint32_t)sampleRate, 0, 0 );
382      if( hpiError )
383      {
384          PA_ASIHPI_REPORT_ERROR_( hpiError );
385 @@ -1016,25 +1003,25 @@
386   @return PortAudio error code (typically indicating a problem with stream format or device)
387  */
388  static PaError PaAsiHpi_OpenInput( struct PaUtilHostApiRepresentation *hostApi,
389 -                                   const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,
390 -                                   HPI_HISTREAM *hpiStream )
391 +                                   const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,
392 +                                   hpi_handle_t *hpiStream )
393  {
394      PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;
395      PaError result = paNoError;
396 -    HW16 hpiError = 0;
397 +    hpi_err_t hpiError = 0;
398  
399      /* Catch misplaced output devices, as they typically have 0 input channels */
400      PA_UNLESS_( !hpiDevice->streamIsOutput, paInvalidChannelCount );
401      /* Try to open input stream */
402 -    PA_ASIHPI_UNLESS_( HPI_InStreamOpen( hpiHostApi->subSys, hpiDevice->adapterIndex,
403 +    PA_ASIHPI_UNLESS_( HPI_InStreamOpen( NULL, hpiDevice->adapterIndex,
404                                           hpiDevice->streamIndex, hpiStream ), paDeviceUnavailable );
405      /* Set input format (checking it in the process) */
406      /* Could also use HPI_InStreamQueryFormat, but this economizes the process */
407 -    hpiError = HPI_InStreamSetFormat( hpiHostApi->subSys, *hpiStream, (HPI_FORMAT*)hpiFormat );
408 +    hpiError = HPI_InStreamSetFormat( NULL, *hpiStream, (struct hpi_format*)hpiFormat );
409      if( hpiError )
410      {
411          PA_ASIHPI_REPORT_ERROR_( hpiError );
412 -        PA_ASIHPI_UNLESS_( HPI_InStreamClose( hpiHostApi->subSys, *hpiStream ), paNoError );
413 +        PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL, *hpiStream ), paNoError );
414          switch( hpiError )
415          {
416          case HPI_ERROR_INVALID_FORMAT:
417 @@ -1071,25 +1058,25 @@
418   @return PortAudio error code (typically indicating a problem with stream format or device)
419  */
420  static PaError PaAsiHpi_OpenOutput( struct PaUtilHostApiRepresentation *hostApi,
421 -                                    const PaAsiHpiDeviceInfo *hpiDevice, const HPI_FORMAT *hpiFormat,
422 -                                    HPI_HOSTREAM *hpiStream )
423 +                                    const PaAsiHpiDeviceInfo *hpiDevice, const struct hpi_format *hpiFormat,
424 +                                    hpi_handle_t *hpiStream )
425  {
426      PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;
427      PaError result = paNoError;
428 -    HW16 hpiError = 0;
429 +    hpi_err_t hpiError = 0;
430  
431      /* Catch misplaced input devices, as they typically have 0 output channels */
432      PA_UNLESS_( hpiDevice->streamIsOutput, paInvalidChannelCount );
433      /* Try to open output stream */
434 -    PA_ASIHPI_UNLESS_( HPI_OutStreamOpen( hpiHostApi->subSys, hpiDevice->adapterIndex,
435 +    PA_ASIHPI_UNLESS_( HPI_OutStreamOpen( NULL, hpiDevice->adapterIndex,
436                                            hpiDevice->streamIndex, hpiStream ), paDeviceUnavailable );
437  
438      /* Check output format (format is set on first write to output stream) */
439 -    hpiError = HPI_OutStreamQueryFormat( hpiHostApi->subSys, *hpiStream, (HPI_FORMAT*)hpiFormat );
440 +    hpiError = HPI_OutStreamQueryFormat( NULL, *hpiStream, (struct hpi_format*)hpiFormat );
441      if( hpiError )
442      {
443          PA_ASIHPI_REPORT_ERROR_( hpiError );
444 -        PA_ASIHPI_UNLESS_( HPI_OutStreamClose( hpiHostApi->subSys, *hpiStream ), paNoError );
445 +        PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL, *hpiStream ), paNoError );
446          switch( hpiError )
447          {
448          case HPI_ERROR_INVALID_FORMAT:
449 @@ -1135,12 +1122,12 @@
450      PaError result = paFormatIsSupported;
451      PaAsiHpiHostApiRepresentation *hpiHostApi = (PaAsiHpiHostApiRepresentation*)hostApi;
452      PaAsiHpiDeviceInfo *hpiDevice = NULL;
453 -    HPI_FORMAT hpiFormat;
454 +    struct hpi_format hpiFormat;
455  
456      /* Input stream */
457      if( inputParameters )
458      {
459 -        HPI_HISTREAM hpiStream;
460 +        hpi_handle_t hpiStream;
461          PA_DEBUG(( "%s: Checking input params: dev=%d, sr=%d, chans=%d, fmt=%d\n",
462                     __FUNCTION__, inputParameters->device, (int)sampleRate,
463                     inputParameters->channelCount, inputParameters->sampleFormat ));
464 @@ -1150,13 +1137,13 @@
465          /* Open stream to further check format */
466          PA_ENSURE_( PaAsiHpi_OpenInput( hostApi, hpiDevice, &hpiFormat, &hpiStream ) );
467          /* Close stream again */
468 -        PA_ASIHPI_UNLESS_( HPI_InStreamClose( hpiHostApi->subSys, hpiStream ), paNoError );
469 +        PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL, hpiStream ), paNoError );
470      }
471  
472      /* Output stream */
473      if( outputParameters )
474      {
475 -        HPI_HOSTREAM hpiStream;
476 +        hpi_handle_t hpiStream;
477          PA_DEBUG(( "%s: Checking output params: dev=%d, sr=%d, chans=%d, fmt=%d\n",
478                     __FUNCTION__, outputParameters->device, (int)sampleRate,
479                     outputParameters->channelCount, outputParameters->sampleFormat ));
480 @@ -1166,7 +1153,7 @@
481          /* Open stream to further check format */
482          PA_ENSURE_( PaAsiHpi_OpenOutput( hostApi, hpiDevice, &hpiFormat, &hpiStream ) );
483          /* Close stream again */
484 -        PA_ASIHPI_UNLESS_( HPI_OutStreamClose( hpiHostApi->subSys, hpiStream ), paNoError );
485 +        PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL, hpiStream ), paNoError );
486      }
487  
488  error:
489 @@ -1188,9 +1175,9 @@
490  static PaError PaAsiHpi_GetStreamInfo( PaAsiHpiStreamComponent *streamComp, PaAsiHpiStreamInfo *info )
491  {
492      PaError result = paDeviceUnavailable;
493 -    HW16 state;
494 -    HW32 bufferSize, dataSize, frameCounter, auxDataSize, threshold;
495 -    HW32 hwBufferSize, hwDataSize;
496 +    uint16_t state;
497 +    uint32_t bufferSize, dataSize, frameCounter, auxDataSize, threshold;
498 +    uint32_t hwBufferSize, hwDataSize;
499  
500      assert( streamComp );
501      assert( info );
502 @@ -1212,14 +1199,14 @@
503          /* Obtain detailed stream info (either input or output) */
504          if( streamComp->hpiDevice->streamIsOutput )
505          {
506 -            PA_ASIHPI_UNLESS_( HPI_OutStreamGetInfoEx( streamComp->hpiDevice->subSys,
507 +            PA_ASIHPI_UNLESS_( HPI_OutStreamGetInfoEx( NULL,
508                                 streamComp->hpiStream,
509                                 &state, &bufferSize, &dataSize, &frameCounter,
510                                 &auxDataSize ), paUnanticipatedHostError );
511          }
512          else
513          {
514 -            PA_ASIHPI_UNLESS_( HPI_InStreamGetInfoEx( streamComp->hpiDevice->subSys,
515 +            PA_ASIHPI_UNLESS_( HPI_InStreamGetInfoEx( NULL,
516                                 streamComp->hpiStream,
517                                 &state, &bufferSize, &dataSize, &frameCounter,
518                                 &auxDataSize ), paUnanticipatedHostError );
519 @@ -1479,7 +1466,7 @@
520  
521   @return PortAudio error code (possibly paBufferTooBig or paInsufficientMemory)
522   */
523 -static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, HW32 pollingInterval,
524 +static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, uint32_t pollingInterval,
525                                        unsigned long framesPerPaHostBuffer, PaTime suggestedLatency )
526  {
527      PaError result = paNoError;
528 @@ -1499,8 +1486,8 @@
529      /* Check if BBM (background bus mastering) is to be enabled */
530      if( PA_ASIHPI_USE_BBM_ )
531      {
532 -        HW32 bbmBufferSize = 0, preLatencyBufferSize = 0;
533 -        HW16 hpiError = 0;
534 +        uint32_t bbmBufferSize = 0, preLatencyBufferSize = 0;
535 +        hpi_err_t hpiError = 0;
536          PaTime pollingOverhead;
537  
538          /* Check overhead of Pa_Sleep() call (minimum sleep duration in ms -> OS dependent) */
539 @@ -1510,7 +1497,7 @@
540          PA_DEBUG(( "polling overhead = %f ms (length of 0-second sleep)\n", pollingOverhead ));
541          /* Obtain minimum recommended size for host buffer (in bytes) */
542          PA_ASIHPI_UNLESS_( HPI_StreamEstimateBufferSize( &streamComp->hpiFormat,
543 -                           pollingInterval + (HW32)ceil( pollingOverhead ),
544 +                           pollingInterval + (uint32_t)ceil( pollingOverhead ),
545                             &bbmBufferSize ), paUnanticipatedHostError );
546          /* BBM places more stringent requirements on buffer size (see description */
547          /* of HPI_StreamEstimateBufferSize in HPI API document) */
548 @@ -1528,27 +1515,26 @@
549              {
550                  /* Save old buffer size, to be retried if new size proves too big */
551                  preLatencyBufferSize = bbmBufferSize;
552 -                bbmBufferSize = (HW32)ceil( suggestedLatency * streamComp->bytesPerFrame
553 +                bbmBufferSize = (uint32_t)ceil( suggestedLatency * streamComp->bytesPerFrame
554                                              * streamComp->hpiFormat.dwSampleRate );
555              }
556          }
557          /* Choose closest memory block boundary (HPI API document states that
558          "a buffer size of Nx4096 - 20 makes the best use of memory"
559          (under the entry for HPI_StreamEstimateBufferSize)) */
560 -        bbmBufferSize = ((HW32)ceil((bbmBufferSize + 20)/4096.0))*4096 - 20;
561 +        bbmBufferSize = ((uint32_t)ceil((bbmBufferSize + 20)/4096.0))*4096 - 20;
562          streamComp->hostBufferSize = bbmBufferSize;
563          /* Allocate BBM host buffer (this enables bus mastering transfers in background) */
564          if( streamComp->hpiDevice->streamIsOutput )
565 -            hpiError = HPI_OutStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
566 +            hpiError = HPI_OutStreamHostBufferAllocate( NULL,
567                         streamComp->hpiStream,
568                         bbmBufferSize );
569          else
570 -            hpiError = HPI_InStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
571 +            hpiError = HPI_InStreamHostBufferAllocate( NULL,
572                         streamComp->hpiStream,
573                         bbmBufferSize );
574          if( hpiError )
575          {
576 -            PA_ASIHPI_REPORT_ERROR_( hpiError );
577              /* Indicate that BBM is disabled */
578              streamComp->hostBufferSize = 0;
579              /* Retry with smaller buffer size (transfers will still work, but not via BBM) */
580 @@ -1561,11 +1547,11 @@
581                                 preLatencyBufferSize, bbmBufferSize ));
582                      bbmBufferSize = preLatencyBufferSize;
583                      if( streamComp->hpiDevice->streamIsOutput )
584 -                        hpiError = HPI_OutStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
585 +                        hpiError = HPI_OutStreamHostBufferAllocate( NULL,
586                                     streamComp->hpiStream,
587                                     bbmBufferSize );
588                      else
589 -                        hpiError = HPI_InStreamHostBufferAllocate( streamComp->hpiDevice->subSys,
590 +                        hpiError = HPI_InStreamHostBufferAllocate( NULL,
591                                     streamComp->hpiStream,
592                                     bbmBufferSize );
593                      /* Another round of error checking */
594 @@ -1598,8 +1584,10 @@
595              }
596              /* If BBM not supported, foreground transfers will be used, but not a show-stopper */
597              /* Anything else is an error */
598 -            else if( hpiError != HPI_ERROR_INVALID_OPERATION )
599 +            else if (( hpiError != HPI_ERROR_INVALID_OPERATION ) &&
600 +                    ( hpiError != HPI_ERROR_INVALID_FUNC ))
601              {
602 +                PA_ASIHPI_REPORT_ERROR_( hpiError );
603                  result = paUnanticipatedHostError;
604                  goto error;
605              }
606 @@ -1623,7 +1611,7 @@
607          PaTime latency = suggestedLatency > 0.0 ? suggestedLatency :
608                           streamComp->hpiDevice->baseDeviceInfo.defaultHighOutputLatency;
609          streamComp->outputBufferCap =
610 -            (HW32)ceil( latency * streamComp->bytesPerFrame * streamComp->hpiFormat.dwSampleRate );
611 +            (uint32_t)ceil( latency * streamComp->bytesPerFrame * streamComp->hpiFormat.dwSampleRate );
612          /* The cap should not be too small, to prevent underflow */
613          if( streamComp->outputBufferCap < 4*paHostBufferSize )
614              streamComp->outputBufferCap = 4*paHostBufferSize;
615 @@ -1635,7 +1623,7 @@
616      /* Temp buffer size should be multiple of PA host buffer size (or 1x, if using fixed blocks) */
617      streamComp->tempBufferSize = paHostBufferSize;
618      /* Allocate temp buffer */
619 -    PA_UNLESS_( streamComp->tempBuffer = (HW8 *)PaUtil_AllocateMemory( streamComp->tempBufferSize ),
620 +    PA_UNLESS_( streamComp->tempBuffer = (uint8_t *)PaUtil_AllocateMemory( streamComp->tempBufferSize ),
621                  paInsufficientMemory );
622  error:
623      return result;
624 @@ -1725,7 +1713,7 @@
625       By keeping the frames a multiple of 4, this is ensured even for 8-bit mono sound. */
626      framesPerHostBuffer = (framesPerHostBuffer / 4) * 4;
627      /* Polling is based on time length (in milliseconds) of user-requested block size */
628 -    stream->pollingInterval = (HW32)ceil( 1000.0*framesPerHostBuffer/sampleRate );
629 +    stream->pollingInterval = (uint32_t)ceil( 1000.0*framesPerHostBuffer/sampleRate );
630      assert( framesPerHostBuffer > 0 );
631  
632      /* Open underlying streams, check formats and allocate buffers */
633 @@ -1890,7 +1878,7 @@
634          /* Close HPI stream (freeing BBM host buffer in the process, if used) */
635          if( stream->input->hpiStream )
636          {
637 -            PA_ASIHPI_UNLESS_( HPI_InStreamClose( stream->input->hpiDevice->subSys,
638 +            PA_ASIHPI_UNLESS_( HPI_InStreamClose( NULL,
639                                                    stream->input->hpiStream ), paUnanticipatedHostError );
640          }
641          /* Free temp buffer and stream component */
642 @@ -1902,7 +1890,7 @@
643          /* Close HPI stream (freeing BBM host buffer in the process, if used) */
644          if( stream->output->hpiStream )
645          {
646 -            PA_ASIHPI_UNLESS_( HPI_OutStreamClose( stream->output->hpiDevice->subSys,
647 +            PA_ASIHPI_UNLESS_( HPI_OutStreamClose( NULL,
648                                                     stream->output->hpiStream ), paUnanticipatedHostError );
649          }
650          /* Free temp buffer and stream component */
651 @@ -1933,9 +1921,6 @@
652      PaAsiHpiStreamComponent *out;
653      PaUtilZeroer *zeroer;
654      PaSampleFormat outputFormat;
655 -#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
656 -    HPI_DATA data;
657 -#endif
658      assert( stream );
659      out = stream->output;
660      /* Only continue if stream has output channels */
661 @@ -1944,28 +1929,19 @@
662      assert( out->tempBuffer );
663  
664      /* Clear all existing data in hardware playback buffer */
665 -    PA_ASIHPI_UNLESS_( HPI_OutStreamReset( out->hpiDevice->subSys,
666 +    PA_ASIHPI_UNLESS_( HPI_OutStreamReset( NULL,
667                                             out->hpiStream ), paUnanticipatedHostError );
668      /* Fill temp buffer with silence */
669      outputFormat = PaAsiHpi_HpiToPaFormat( out->hpiFormat.wFormat );
670      zeroer = PaUtil_SelectZeroer( outputFormat );
671      zeroer(out->tempBuffer, 1, out->tempBufferSize / Pa_GetSampleSize(outputFormat) );
672      /* Write temp buffer to hardware fifo twice, to get started */
673 -#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
674 -    PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( out->hpiDevice->subSys, out->hpiStream, 
675 +    PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL, out->hpiStream,
676                                                out->tempBuffer, out->tempBufferSize, &out->hpiFormat),
677                                                paUnanticipatedHostError );
678 -    PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( out->hpiDevice->subSys, out->hpiStream, 
679 +    PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL, out->hpiStream,
680                                                out->tempBuffer, out->tempBufferSize, &out->hpiFormat),
681                                                paUnanticipatedHostError );
682 -#else
683 -    PA_ASIHPI_UNLESS_( HPI_DataCreate( &data, &out->hpiFormat, out->tempBuffer, out->tempBufferSize ),
684 -                       paUnanticipatedHostError );
685 -    PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( out->hpiDevice->subSys,
686 -                                           out->hpiStream, &data ), paUnanticipatedHostError );
687 -    PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( out->hpiDevice->subSys,
688 -                                           out->hpiStream, &data ), paUnanticipatedHostError );
689 -#endif
690  error:
691      return result;
692  }
693 @@ -1989,7 +1965,7 @@
694  
695      if( stream->input )
696      {
697 -        PA_ASIHPI_UNLESS_( HPI_InStreamStart( stream->input->hpiDevice->subSys,
698 +        PA_ASIHPI_UNLESS_( HPI_InStreamStart( NULL,
699                                                stream->input->hpiStream ), paUnanticipatedHostError );
700      }
701      if( stream->output )
702 @@ -1999,7 +1975,7 @@
703              /* Buffer isn't primed, so load stream with silence */
704              PA_ENSURE_( PaAsiHpi_PrimeOutputWithSilence( stream ) );
705          }
706 -        PA_ASIHPI_UNLESS_( HPI_OutStreamStart( stream->output->hpiDevice->subSys,
707 +        PA_ASIHPI_UNLESS_( HPI_OutStreamStart( NULL,
708                                                 stream->output->hpiStream ), paUnanticipatedHostError );
709      }
710      stream->state = paAsiHpiActiveState;
711 @@ -2071,7 +2047,7 @@
712      /* Input channels */
713      if( stream->input )
714      {
715 -        PA_ASIHPI_UNLESS_( HPI_InStreamReset( stream->input->hpiDevice->subSys,
716 +        PA_ASIHPI_UNLESS_( HPI_InStreamReset( NULL,
717                                                stream->input->hpiStream ), paUnanticipatedHostError );
718      }
719      /* Output channels */
720 @@ -2097,7 +2073,7 @@
721                  Pa_Sleep( (long)ceil( timeLeft ) );
722              }
723          }
724 -        PA_ASIHPI_UNLESS_( HPI_OutStreamReset( stream->output->hpiDevice->subSys,
725 +        PA_ASIHPI_UNLESS_( HPI_OutStreamReset( NULL,
726                                                 stream->output->hpiStream ), paUnanticipatedHostError );
727      }
728  
729 @@ -2315,7 +2291,7 @@
730      PaError result = paNoError;
731      double sampleRate;
732      unsigned long framesTarget;
733 -    HW32 outputData = 0, outputSpace = 0, inputData = 0, framesLeft = 0;
734 +    uint32_t outputData = 0, outputSpace = 0, inputData = 0, framesLeft = 0;
735  
736      assert( stream );
737      assert( stream->input || stream->output );
738 @@ -2484,12 +2460,9 @@
739      if( stream->input )
740      {
741          PaAsiHpiStreamInfo info;
742 -       
743 -#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
744 -        HPI_DATA data;
745 -#endif
746 -        HW32 framesToGet = *numFrames;
747  
748 +        uint32_t framesToGet = *numFrames;
749 +
750          /* Check for overflows and underflows yet again */
751          PA_ENSURE_( PaAsiHpi_GetStreamInfo( stream->input, &info ) );
752          if( info.overflow )
753 @@ -2513,22 +2486,12 @@
754                     stream->input->tempBufferSize / Pa_GetSampleSize(inputFormat) );
755          }
756  
757 -#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
758          /* Read block of data into temp buffer */
759 -        PA_ASIHPI_UNLESS_( HPI_InStreamReadBuf( stream->input->hpiDevice->subSys,
760 -                                             stream->input->hpiStream, 
761 +        PA_ASIHPI_UNLESS_( HPI_InStreamReadBuf( NULL,
762 +                                             stream->input->hpiStream,
763                                               stream->input->tempBuffer,
764                                               framesToGet * stream->input->bytesPerFrame),
765                             paUnanticipatedHostError );
766 -#else
767 -        /* Setup HPI data structure around temp buffer */
768 -        HPI_DataCreate( &data, &stream->input->hpiFormat, stream->input->tempBuffer,
769 -                        framesToGet * stream->input->bytesPerFrame );
770 -        /* Read block of data into temp buffer */
771 -        PA_ASIHPI_UNLESS_( HPI_InStreamRead( stream->input->hpiDevice->subSys,
772 -                                             stream->input->hpiStream, &data ),
773 -                           paUnanticipatedHostError );
774 -#endif
775          /* Register temp buffer with buffer processor (always FULL buffer) */
776          PaUtil_SetInputFrameCount( &stream->bufferProcessor, *numFrames );
777          /* HPI interface only allows interleaved channels */
778 @@ -2572,9 +2535,6 @@
779      if( stream->output )
780      {
781          PaAsiHpiStreamInfo info;
782 -#if (HPI_VER < HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
783 -        HPI_DATA data;
784 -#endif
785          /* Check for underflows after the (potentially time-consuming) callback */
786          PA_ENSURE_( PaAsiHpi_GetStreamInfo( stream->output, &info ) );
787          if( info.underflow )
788 @@ -2582,23 +2542,13 @@
789              *cbFlags |= paOutputUnderflow;
790          }
791  
792 -#if (HPI_VER >= HPI_VERSION_CONSTRUCTOR( 3, 5, 5 ))
793          /* Write temp buffer to HPI stream */
794 -        PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( stream->output->hpiDevice->subSys,
795 -                                           stream->output->hpiStream, 
796 +        PA_ASIHPI_UNLESS_( HPI_OutStreamWriteBuf( NULL,
797 +                                           stream->output->hpiStream,
798                                             stream->output->tempBuffer,
799 -                                           numFrames * stream->output->bytesPerFrame, 
800 +                                           numFrames * stream->output->bytesPerFrame,
801                                             &stream->output->hpiFormat),
802                             paUnanticipatedHostError );
803 -#else
804 -        /* Setup HPI data structure around temp buffer */
805 -        HPI_DataCreate( &data, &stream->output->hpiFormat, stream->output->tempBuffer,
806 -                        numFrames * stream->output->bytesPerFrame );
807 -        /* Write temp buffer to HPI stream */
808 -        PA_ASIHPI_UNLESS_( HPI_OutStreamWrite( stream->output->hpiDevice->subSys,
809 -                                               stream->output->hpiStream, &data ),
810 -                           paUnanticipatedHostError );
811 -#endif
812      }
813  
814  error:
This page took 0.221387 seconds and 2 git commands to generate.