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