mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-03 09:09:47 +02:00
------------------------------------------------------------------------ r1910 | gineera | 2013-09-07 05:14:52 -0500 (Sat, 07 Sep 2013) | 1 line paqa_devs: limit max number of channels tested (to 4); add a fixed decimal format to the timestamp printout. ------------------------------------------------------------------------ r1909 | rbencina | 2013-08-28 19:36:56 -0500 (Wed, 28 Aug 2013) | 1 line pa_mac_core.c line 664 fixed incorrect memset size (was using sizeof(ptr) not sizeof(struct type) ------------------------------------------------------------------------ r1908 | gineera | 2013-08-27 12:14:51 -0500 (Tue, 27 Aug 2013) | 1 line Alsa: Add function to prevent duplicate parts in the visible pa device name string, that occur when the pcm-device name starts with the card name (since they are both used). Achieved by trimming the pcm-device string beginning. ------------------------------------------------------------------------ r1907 | gineera | 2013-08-22 17:01:17 -0500 (Thu, 22 Aug 2013) | 1 line Alsa: Fix memory leak as nonMmapBuffers were not freed (since change to realloc). Clean out corresponding dead code chunk. ------------------------------------------------------------------------ r1906 | gineera | 2013-08-22 14:43:07 -0500 (Thu, 22 Aug 2013) | 1 line Alsa: Rename some variables in pa_linux_alsa where the meaning is mis-leading or wrong in the Alsa context. Also tweak one debug message and a few typos. ------------------------------------------------------------------------ r1897 | gineera | 2013-08-13 15:37:04 -0500 (Tue, 13 Aug 2013) | 1 line Alsa: Fix handling of poll descriptors in PaAlsaStream_WaitForFrames(). Otherwise if capture signals before playback a duplex stream could poll the wrong descriptor, causing a loop (reported by Alexander Kartashov). ------------------------------------------------------------------------ r1896 | rbencina | 2013-08-06 03:26:55 -0500 (Tue, 06 Aug 2013) | 1 line fixed bug that was causing memory corruption in PA/ALSA when host sample format was lager than user format. e.g. using 16 bit output with a sound card that used 24 bit buffers. the incorrect input zeroer was being used. Thanks to Anders Tornvig for identifying the problem ------------------------------------------------------------------------ r1895 | rbencina | 2013-07-24 10:37:15 -0500 (Wed, 24 Jul 2013) | 1 line fixed doxygen markup for a few line breaks in the tutorial ------------------------------------------------------------------------ r1894 | gineera | 2013-06-08 14:30:41 -0500 (Sat, 08 Jun 2013) | 1 line OSS: revise default latency reporting: previous fixed values could not actually be achieved with OSS power-of-2 sizes. Instead try a configuration and correctly report the default latency based on one less than the number of fragments; also fix the stream component 'bufSz' calculation. ------------------------------------------------------------------------ r1893 | gineera | 2013-06-08 14:12:25 -0500 (Sat, 08 Jun 2013) | 1 line Alsa: revise latency use and calculations, since the latency should be equivalent to one Alsa period less than the Alsa ringbuffer (was based on the whole). Also fixes failure if zero latency was specified. ------------------------------------------------------------------------ r1892 | gineera | 2013-05-30 06:30:28 -0500 (Thu, 30 May 2013) | 1 line qa-latency: fix printout typos; re-enable checks of default high vs low latency - but allow them to be equal; remove rogue tab. ------------------------------------------------------------------------ r1891 | rbencina | 2013-05-05 09:00:02 -0500 (Sun, 05 May 2013) | 1 line added code to print error result from Pa_Initialize() in pa_devs.c example ------------------------------------------------------------------------ r1890 | rbencina | 2013-05-01 20:06:01 -0500 (Wed, 01 May 2013) | 1 line factored out InitPaDeviceInfoFromAsioDriver function. skip device rather than failing entire init process if a single ASIO driver returns an error during init. This was happening with MOTU devices if the device wasn't present. See ticket #221 ------------------------------------------------------------------------ r1889 | rbencina | 2013-04-07 09:15:24 -0500 (Sun, 07 Apr 2013) | 1 line move static variables into x86 section so they don't generate warnings when trying to build on 64 bit ------------------------------------------------------------------------ r1888 | rbencina | 2013-04-07 05:20:18 -0500 (Sun, 07 Apr 2013) | 1 line configure.in fix from Leland '[Portaudio] Small patch to fix Mac build' march 4
254 lines
9.2 KiB
C
254 lines
9.2 KiB
C
/** @file pa_devs.c
|
|
@ingroup examples_src
|
|
@brief List available devices, including device information.
|
|
@author Phil Burk http://www.softsynth.com
|
|
|
|
@note Define PA_USE_ASIO=0 to compile this code on Windows without
|
|
ASIO support.
|
|
*/
|
|
/*
|
|
* $Id: pa_devs.c 1817 2012-02-22 12:44:10Z robiwan $
|
|
*
|
|
* This program uses the PortAudio Portable Audio Library.
|
|
* For more information see: http://www.portaudio.com
|
|
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
* a copy of this software and associated documentation files
|
|
* (the "Software"), to deal in the Software without restriction,
|
|
* including without limitation the rights to use, copy, modify, merge,
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
* and to permit persons to whom the Software is furnished to do so,
|
|
* subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
/*
|
|
* The text above constitutes the entire PortAudio license; however,
|
|
* the PortAudio community also makes the following non-binding requests:
|
|
*
|
|
* Any person wishing to distribute modifications to the Software is
|
|
* requested to send the modifications to the original developer so that
|
|
* they can be incorporated into the canonical version. It is also
|
|
* requested that these non-binding requests be included along with the
|
|
* license above.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <math.h>
|
|
#include "portaudio.h"
|
|
|
|
#ifdef WIN32
|
|
#include <windows.h>
|
|
|
|
#if PA_USE_ASIO
|
|
#include "pa_asio.h"
|
|
#endif
|
|
#endif
|
|
|
|
/*******************************************************************/
|
|
static void PrintSupportedStandardSampleRates(
|
|
const PaStreamParameters *inputParameters,
|
|
const PaStreamParameters *outputParameters )
|
|
{
|
|
static double standardSampleRates[] = {
|
|
8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
|
|
44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1 /* negative terminated list */
|
|
};
|
|
int i, printCount;
|
|
PaError err;
|
|
|
|
printCount = 0;
|
|
for( i=0; standardSampleRates[i] > 0; i++ )
|
|
{
|
|
err = Pa_IsFormatSupported( inputParameters, outputParameters, standardSampleRates[i] );
|
|
if( err == paFormatIsSupported )
|
|
{
|
|
if( printCount == 0 )
|
|
{
|
|
printf( "\t%8.2f", standardSampleRates[i] );
|
|
printCount = 1;
|
|
}
|
|
else if( printCount == 4 )
|
|
{
|
|
printf( ",\n\t%8.2f", standardSampleRates[i] );
|
|
printCount = 1;
|
|
}
|
|
else
|
|
{
|
|
printf( ", %8.2f", standardSampleRates[i] );
|
|
++printCount;
|
|
}
|
|
}
|
|
}
|
|
if( !printCount )
|
|
printf( "None\n" );
|
|
else
|
|
printf( "\n" );
|
|
}
|
|
|
|
/*******************************************************************/
|
|
int main(void);
|
|
int main(void)
|
|
{
|
|
int i, numDevices, defaultDisplayed;
|
|
const PaDeviceInfo *deviceInfo;
|
|
PaStreamParameters inputParameters, outputParameters;
|
|
PaError err;
|
|
|
|
|
|
err = Pa_Initialize();
|
|
if( err != paNoError )
|
|
{
|
|
printf( "ERROR: Pa_Initialize returned 0x%x\n", err );
|
|
goto error;
|
|
}
|
|
|
|
printf( "PortAudio version number = %d\nPortAudio version text = '%s'\n",
|
|
Pa_GetVersion(), Pa_GetVersionText() );
|
|
|
|
|
|
numDevices = Pa_GetDeviceCount();
|
|
if( numDevices < 0 )
|
|
{
|
|
printf( "ERROR: Pa_GetDeviceCount returned 0x%x\n", numDevices );
|
|
err = numDevices;
|
|
goto error;
|
|
}
|
|
|
|
printf( "Number of devices = %d\n", numDevices );
|
|
for( i=0; i<numDevices; i++ )
|
|
{
|
|
deviceInfo = Pa_GetDeviceInfo( i );
|
|
printf( "--------------------------------------- device #%d\n", i );
|
|
|
|
/* Mark global and API specific default devices */
|
|
defaultDisplayed = 0;
|
|
if( i == Pa_GetDefaultInputDevice() )
|
|
{
|
|
printf( "[ Default Input" );
|
|
defaultDisplayed = 1;
|
|
}
|
|
else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultInputDevice )
|
|
{
|
|
const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
|
|
printf( "[ Default %s Input", hostInfo->name );
|
|
defaultDisplayed = 1;
|
|
}
|
|
|
|
if( i == Pa_GetDefaultOutputDevice() )
|
|
{
|
|
printf( (defaultDisplayed ? "," : "[") );
|
|
printf( " Default Output" );
|
|
defaultDisplayed = 1;
|
|
}
|
|
else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultOutputDevice )
|
|
{
|
|
const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
|
|
printf( (defaultDisplayed ? "," : "[") );
|
|
printf( " Default %s Output", hostInfo->name );
|
|
defaultDisplayed = 1;
|
|
}
|
|
|
|
if( defaultDisplayed )
|
|
printf( " ]\n" );
|
|
|
|
/* print device info fields */
|
|
#ifdef WIN32
|
|
{ /* Use wide char on windows, so we can show UTF-8 encoded device names */
|
|
wchar_t wideName[MAX_PATH];
|
|
MultiByteToWideChar(CP_UTF8, 0, deviceInfo->name, -1, wideName, MAX_PATH-1);
|
|
wprintf( L"Name = %s\n", wideName );
|
|
}
|
|
#else
|
|
printf( "Name = %s\n", deviceInfo->name );
|
|
#endif
|
|
printf( "Host API = %s\n", Pa_GetHostApiInfo( deviceInfo->hostApi )->name );
|
|
printf( "Max inputs = %d", deviceInfo->maxInputChannels );
|
|
printf( ", Max outputs = %d\n", deviceInfo->maxOutputChannels );
|
|
|
|
printf( "Default low input latency = %8.4f\n", deviceInfo->defaultLowInputLatency );
|
|
printf( "Default low output latency = %8.4f\n", deviceInfo->defaultLowOutputLatency );
|
|
printf( "Default high input latency = %8.4f\n", deviceInfo->defaultHighInputLatency );
|
|
printf( "Default high output latency = %8.4f\n", deviceInfo->defaultHighOutputLatency );
|
|
|
|
#ifdef WIN32
|
|
#if PA_USE_ASIO
|
|
/* ASIO specific latency information */
|
|
if( Pa_GetHostApiInfo( deviceInfo->hostApi )->type == paASIO ){
|
|
long minLatency, maxLatency, preferredLatency, granularity;
|
|
|
|
err = PaAsio_GetAvailableLatencyValues( i,
|
|
&minLatency, &maxLatency, &preferredLatency, &granularity );
|
|
|
|
printf( "ASIO minimum buffer size = %ld\n", minLatency );
|
|
printf( "ASIO maximum buffer size = %ld\n", maxLatency );
|
|
printf( "ASIO preferred buffer size = %ld\n", preferredLatency );
|
|
|
|
if( granularity == -1 )
|
|
printf( "ASIO buffer granularity = power of 2\n" );
|
|
else
|
|
printf( "ASIO buffer granularity = %ld\n", granularity );
|
|
}
|
|
#endif /* PA_USE_ASIO */
|
|
#endif /* WIN32 */
|
|
|
|
printf( "Default sample rate = %8.2f\n", deviceInfo->defaultSampleRate );
|
|
|
|
/* poll for standard sample rates */
|
|
inputParameters.device = i;
|
|
inputParameters.channelCount = deviceInfo->maxInputChannels;
|
|
inputParameters.sampleFormat = paInt16;
|
|
inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
|
|
inputParameters.hostApiSpecificStreamInfo = NULL;
|
|
|
|
outputParameters.device = i;
|
|
outputParameters.channelCount = deviceInfo->maxOutputChannels;
|
|
outputParameters.sampleFormat = paInt16;
|
|
outputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
|
|
outputParameters.hostApiSpecificStreamInfo = NULL;
|
|
|
|
if( inputParameters.channelCount > 0 )
|
|
{
|
|
printf("Supported standard sample rates\n for half-duplex 16 bit %d channel input = \n",
|
|
inputParameters.channelCount );
|
|
PrintSupportedStandardSampleRates( &inputParameters, NULL );
|
|
}
|
|
|
|
if( outputParameters.channelCount > 0 )
|
|
{
|
|
printf("Supported standard sample rates\n for half-duplex 16 bit %d channel output = \n",
|
|
outputParameters.channelCount );
|
|
PrintSupportedStandardSampleRates( NULL, &outputParameters );
|
|
}
|
|
|
|
if( inputParameters.channelCount > 0 && outputParameters.channelCount > 0 )
|
|
{
|
|
printf("Supported standard sample rates\n for full-duplex 16 bit %d channel input, %d channel output = \n",
|
|
inputParameters.channelCount, outputParameters.channelCount );
|
|
PrintSupportedStandardSampleRates( &inputParameters, &outputParameters );
|
|
}
|
|
}
|
|
|
|
Pa_Terminate();
|
|
|
|
printf("----------------------------------------------\n");
|
|
return 0;
|
|
|
|
error:
|
|
Pa_Terminate();
|
|
fprintf( stderr, "Error number: %d\n", err );
|
|
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
|
|
return err;
|
|
}
|