Pa_ASIO_QueryDeviceInfo bug correction, memory allocation checking, better error handling
This commit is contained in:
parent
fb351c801a
commit
09a767d44c
1 changed files with 23 additions and 14 deletions
|
|
@ -56,6 +56,7 @@
|
||||||
09-04-02 Correct error code management in PaHost_Term, removes various compiler warning : Stephane Letz
|
09-04-02 Correct error code management in PaHost_Term, removes various compiler warning : Stephane Letz
|
||||||
12-04-02 Add Mac includes for <Devices.h> and <Timer.h> : Phil Burk
|
12-04-02 Add Mac includes for <Devices.h> and <Timer.h> : Phil Burk
|
||||||
13-04-02 Removes another compiler warning : Stephane Letz
|
13-04-02 Removes another compiler warning : Stephane Letz
|
||||||
|
30-04-02 Pa_ASIO_QueryDeviceInfo bug correction, memory allocation checking, better error handling : D Viens, P Burk, S Letz
|
||||||
|
|
||||||
TO DO :
|
TO DO :
|
||||||
|
|
||||||
|
|
@ -432,9 +433,13 @@ static PaError Pa_ASIO_QueryDeviceInfo( internalPortAudioDevice * ipad )
|
||||||
int i;
|
int i;
|
||||||
int numDrivers;
|
int numDrivers;
|
||||||
ASIOError asioError;
|
ASIOError asioError;
|
||||||
|
|
||||||
/* Allocate names */
|
/* Allocate names */
|
||||||
for (i = 0 ; i < PA_MAX_DEVICE_INFO ; i++) names[i] = (char*)PaHost_AllocateFastMemory(32);
|
for (i = 0 ; i < PA_MAX_DEVICE_INFO ; i++) {
|
||||||
|
names[i] = (char*)PaHost_AllocateFastMemory(32);
|
||||||
|
/* check memory */
|
||||||
|
if(!names[i]) return paInsufficientMemory;
|
||||||
|
}
|
||||||
|
|
||||||
/* MUST BE CHECKED : to force fragments loading on Mac */
|
/* MUST BE CHECKED : to force fragments loading on Mac */
|
||||||
Pa_ASIO_loadAsioDriver("dummy");
|
Pa_ASIO_loadAsioDriver("dummy");
|
||||||
|
|
@ -473,9 +478,8 @@ static PaError Pa_ASIO_QueryDeviceInfo( internalPortAudioDevice * ipad )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Gets the name */
|
||||||
/* Gets the name */
|
dev = &(ipad[sNumDevices].pad_Info);
|
||||||
dev = &(ipad[driver].pad_Info);
|
|
||||||
dev->name = names[driver];
|
dev->name = names[driver];
|
||||||
names[driver] = 0;
|
names[driver] = 0;
|
||||||
|
|
||||||
|
|
@ -487,7 +491,12 @@ static PaError Pa_ASIO_QueryDeviceInfo( internalPortAudioDevice * ipad )
|
||||||
DBUG(("PaASIO_QueryDeviceInfo: OutputChannels = %d\n", OutputChannels ));
|
DBUG(("PaASIO_QueryDeviceInfo: OutputChannels = %d\n", OutputChannels ));
|
||||||
|
|
||||||
/* Make room in case device supports all rates. */
|
/* Make room in case device supports all rates. */
|
||||||
sampleRates = (double*)PaHost_AllocateFastMemory( MAX_NUMSAMPLINGRATES * sizeof(double));
|
sampleRates = (double*)PaHost_AllocateFastMemory(MAX_NUMSAMPLINGRATES * sizeof(double));
|
||||||
|
/* check memory */
|
||||||
|
if (!sampleRates) {
|
||||||
|
ASIOExit();
|
||||||
|
return paInsufficientMemory;
|
||||||
|
}
|
||||||
dev->sampleRates = sampleRates;
|
dev->sampleRates = sampleRates;
|
||||||
dev->numSampleRates = 0;
|
dev->numSampleRates = 0;
|
||||||
|
|
||||||
|
|
@ -495,7 +504,7 @@ static PaError Pa_ASIO_QueryDeviceInfo( internalPortAudioDevice * ipad )
|
||||||
for (int index = 0; index < MAX_NUMSAMPLINGRATES; index++) {
|
for (int index = 0; index < MAX_NUMSAMPLINGRATES; index++) {
|
||||||
if (ASIOCanSampleRate(possibleSampleRates[index]) != ASE_NoClock) {
|
if (ASIOCanSampleRate(possibleSampleRates[index]) != ASE_NoClock) {
|
||||||
DBUG(("PortAudio : possible sample rate = %d\n", (long)possibleSampleRates[index]));
|
DBUG(("PortAudio : possible sample rate = %d\n", (long)possibleSampleRates[index]));
|
||||||
dev->numSampleRates+=1;
|
dev->numSampleRates += 1;
|
||||||
*sampleRates = possibleSampleRates[index];
|
*sampleRates = possibleSampleRates[index];
|
||||||
sampleRates++;
|
sampleRates++;
|
||||||
}
|
}
|
||||||
|
|
@ -509,9 +518,7 @@ static PaError Pa_ASIO_QueryDeviceInfo( internalPortAudioDevice * ipad )
|
||||||
dev->nativeSampleFormats = Pa_ASIO_Convert_SampleFormat(channelInfos.type);
|
dev->nativeSampleFormats = Pa_ASIO_Convert_SampleFormat(channelInfos.type);
|
||||||
|
|
||||||
/* unload the driver */
|
/* unload the driver */
|
||||||
ASIODisposeBuffers();
|
|
||||||
ASIOExit();
|
ASIOExit();
|
||||||
|
|
||||||
sNumDevices++;
|
sNumDevices++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2560,8 +2567,9 @@ error:
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PaError PaHost_Init( void )
|
PaError PaHost_Init( void )
|
||||||
{
|
{
|
||||||
/* Have we already initialized the device info? */
|
/* Have we already initialized the device info? */
|
||||||
return (Pa_CountDevices() < 0 ) ? paHostError : paNoError;
|
PaError err = (PaError) Pa_CountDevices();
|
||||||
|
return ( err < 0 ) ? err : paNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
@ -2578,10 +2586,11 @@ PaError PaHost_Term( void )
|
||||||
for( i=0; i<sNumDevices; i++ ){
|
for( i=0; i<sNumDevices; i++ ){
|
||||||
dev = &sDevices[i].pad_Info;
|
dev = &sDevices[i].pad_Info;
|
||||||
rates = (double *) dev->sampleRates;
|
rates = (double *) dev->sampleRates;
|
||||||
if((rates != NULL)) PaHost_FreeFastMemory(rates, MAX_NUMSAMPLINGRATES * sizeof(double));
|
if ((rates != NULL)) PaHost_FreeFastMemory(rates, MAX_NUMSAMPLINGRATES * sizeof(double));
|
||||||
dev->sampleRates = NULL;
|
dev->sampleRates = NULL;
|
||||||
if(dev->name != NULL) PaHost_FreeFastMemory((void *) dev->name, 32);
|
if(dev->name != NULL) PaHost_FreeFastMemory((void *) dev->name, 32);
|
||||||
dev->name = NULL;
|
dev->name = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sNumDevices = 0;
|
sNumDevices = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue