} PaHostApiTypeId;
+/** Returns the number of compiled-in host APIs in this build of PortAudio.
+
+ The returned value is large enough that it can be used to dimension
+ arrays passed to Pa_GetAvailableHostApis and Pa_GetSelectedHostApis.
+
+ FIXME REVIEW The "Available" name should match whatever is chosen for
+ Pa_GetAvailableHostApis
+
+ @see Pa_GetAvailableHostApis, Pa_GetSelectedHostApis
+*/
+int Pa_GetAvailableHostApisCount( void );
+
+
+/** Returns the type ids of all compiled-in host APIs in initialization order.
+
+ Note that the compiled-in host APIs are not necessarily those that are
+ installed on the system. It is possible for compiled-in dynamically loaded
+ host APIs to be not installed on the system, and it is possible for
+ installed audio APIs to not be supported (compiled in to) PortAudio.
+
+ @param hostApiTypes (IN/OUT) An array that will be filled with
+ host API identifiers belonging to the PaHostApiTypeId enumeration.
+
+ @param count (OUT) The number of host APIs, returned even on error.
+
+ @param countAvailable The number of available elements in the hostApiTypes array.
+
+ FIXME REVIEW: Consider a different name for this function, both "available"
+ and "supported" are ambiguous between what is available/supported on the
+ target platform and what is compiled into PA. Keep in mind that
+ Pa_IsFormatSupported refers to formats supported by a device.
+ Proposals:
+ GetConfiguredHostApis, GetCompiledHostApis
+ NOTE: also fix name oPa_GetAvailableHostApisCount
+
+ @see Pa_SelectHostApis
+*/
+PaError Pa_GetAvailableHostApis( PaHostApiTypeId *hostApiTypes, int countAvailable, int *count );
+
+
/** Select host APIs and their initialization order.
This function may only be called prior to calling Pa_Initialize()
*/
PaError Pa_SelectHostApis( const PaHostApiTypeId *hostApiTypes, int count );
+
/** Returns the type ids of the selected host APIs in initialization order.
@param hostApiTypes (IN/OUT) An array that will be filled with
*/
PaError Pa_GetSelectedHostApis( PaHostApiTypeId *hostApiTypes, int countAvailable, int *count );
-/** Returns the type ids of all compiled-in host APIs in initialization order.
-
- Note that the compiled-in host APIs are not necessarily those that are
- installed on the target system.
-
- @param hostApiTypes (IN/OUT) An array that will be filled with
- host API identifiers belonging to the PaHostApiTypeId enumeration.
-
- @param count (OUT) The number of host APIs, returned even on error.
-
- @param countAvailable The number of available elements in the hostApiTypes array.
-
- FIXME REVIEW: Consider a different name for this function, both "available"
- and "supported" are ambiguous between what is available/supported on the
- target platform and what is compiled into PA. Keep in mind that
- Pa_IsFormatSupported refers to formats supported by a device.
- Proposals:
- GetConfiguredHostApis, GetCompiledHostApis
-
- @see Pa_SelectHostApis
-*/
-PaError Pa_GetAvailableHostApis( PaHostApiTypeId *hostApiTypes, int countAvailable, int *count );
-
/** A structure containing information about a particular host API. */
return result;
}
+
static const PaUtilHostApiInitializerEntry* FindHostApiInitializerEntry( PaHostApiTypeId hostApiType )
{
int i = 0;
return NULL;
}
+
+int Pa_GetAvailableHostApisCount( void )
+{
+ return CountHostApiInitializers();
+}
+
+
+PaError Pa_GetAvailableHostApis( PaHostApiTypeId *hostApiTypes, int countAvailable, int *count )
+{
+ int i;
+ int initializerCount = CountHostApiInitializers();
+
+ *count = initializerCount;
+ if( countAvailable >= initializerCount )
+ {
+ for( i=0; i < initializerCount; ++i )
+ hostApiTypes[i] = paHostApiInitializers[i].hostApiType;
+ }
+ else
+ {
+ return paInsufficientMemory;
+ }
+
+ return paNoError;
+}
+
+
static int CountSelectedHostApis()
{
if( selectedHostApiTypes_ == NULL )
return selectedHostApiCount_;
}
+
static const PaUtilHostApiInitializerEntry* GetSelectedHostApi( int index )
{
if( selectedHostApiTypes_ == NULL )
return FindHostApiInitializerEntry( selectedHostApiTypes_[index] );
}
+
PaError Pa_SelectHostApis( const PaHostApiTypeId *hostApiTypes, int count )
{
int i, j;
return paNoError;
}
+
PaError Pa_GetSelectedHostApis( PaHostApiTypeId *hostApiTypes, int countAvailable, int *count )
{
if( selectedHostApiTypes_ == NULL )
}
}
-PaError Pa_GetAvailableHostApis( PaHostApiTypeId *hostApiTypes, int countAvailable, int *count )
-{
- int i;
- int initializerCount = CountHostApiInitializers();
-
- *count = initializerCount;
- if( countAvailable >= initializerCount )
- {
- for( i=0; i < initializerCount; ++i )
- hostApiTypes[i] = paHostApiInitializers[i].hostApiType;
- }
- else
- {
- return paInsufficientMemory;
- }
-
- return paNoError;
-}
-
static void TerminateHostApis( void )
{
*/
#include <stdio.h>
#include <assert.h>
+#include <stdlib.h>
+
#include "portaudio.h"
/*******************************************************************/
{
int i, j, k;
int availableHostApiCount, scratchHostApiCount;
-#define MAX_HOST_API_COUNT 100
- PaHostApiTypeId availableHostApis[MAX_HOST_API_COUNT];
- PaHostApiTypeId scratchHostApis[MAX_HOST_API_COUNT];
+ int maxHostApiCount;
+ PaHostApiTypeId *availableHostApis;
+ PaHostApiTypeId *scratchHostApis;
PaError err;
+ maxHostApiCount = Pa_GetAvailableHostApisCount();
+ availableHostApis = (PaHostApiTypeId*)malloc( sizeof(PaHostApiTypeId) * maxHostApiCount );
+ assert( availableHostApis != NULL );
+ scratchHostApis = (PaHostApiTypeId*)malloc( sizeof(PaHostApiTypeId) * maxHostApiCount );
+ assert( scratchHostApis != NULL );
+
availableHostApiCount = 0;
- err = Pa_GetAvailableHostApis( availableHostApis, MAX_HOST_API_COUNT, &availableHostApiCount );
+ err = Pa_GetAvailableHostApis( availableHostApis, maxHostApiCount, &availableHostApiCount );
assert( err == paNoError );
assert( availableHostApiCount > 0 );
assert( err == paNoError );
/* read back and verify selected apis*/
- err = Pa_GetSelectedHostApis( scratchHostApis, MAX_HOST_API_COUNT, &scratchHostApiCount );
+ err = Pa_GetSelectedHostApis( scratchHostApis, maxHostApiCount, &scratchHostApiCount );
assert( err == paNoError );
assert( scratchHostApiCount == 1 );
assert( scratchHostApis[0] == hostApiType );
assert( err == paNoError );
/* read back and verify selected apis*/
- err = Pa_GetSelectedHostApis( scratchHostApis, MAX_HOST_API_COUNT, &scratchHostApiCount );
+ err = Pa_GetSelectedHostApis( scratchHostApis, maxHostApiCount, &scratchHostApiCount );
assert( err == paNoError );
assert( scratchHostApiCount == i );
for( j = 0; j < i; ++j )
Pa_Terminate();
}
+
+ free(availableHostApis);
+ free(scratchHostApis);
}