| 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * pa_devs.c |
|---|
| 4 | * List available devices. |
|---|
| 5 | * |
|---|
| 6 | * Author: Phil Burk http://www.softsynth.com |
|---|
| 7 | * |
|---|
| 8 | * This program uses the PortAudio Portable Audio Library. |
|---|
| 9 | * For more information see: http://www.portaudio.com |
|---|
| 10 | * Copyright (c) 1999-2000 Ross Bencina and Phil Burk |
|---|
| 11 | * |
|---|
| 12 | * Permission is hereby granted, free of charge, to any person obtaining |
|---|
| 13 | * a copy of this software and associated documentation files |
|---|
| 14 | * (the "Software"), to deal in the Software without restriction, |
|---|
| 15 | * including without limitation the rights to use, copy, modify, merge, |
|---|
| 16 | * publish, distribute, sublicense, and/or sell copies of the Software, |
|---|
| 17 | * and to permit persons to whom the Software is furnished to do so, |
|---|
| 18 | * subject to the following conditions: |
|---|
| 19 | * |
|---|
| 20 | * The above copyright notice and this permission notice shall be |
|---|
| 21 | * included in all copies or substantial portions of the Software. |
|---|
| 22 | * |
|---|
| 23 | * Any person wishing to distribute modifications to the Software is |
|---|
| 24 | * requested to send the modifications to the original developer so that |
|---|
| 25 | * they can be incorporated into the canonical version. |
|---|
| 26 | * |
|---|
| 27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|---|
| 28 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|---|
| 29 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|---|
| 30 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
|---|
| 31 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
|---|
| 32 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|---|
| 33 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|---|
| 34 | * |
|---|
| 35 | */ |
|---|
| 36 | #include <stdio.h> |
|---|
| 37 | #include <math.h> |
|---|
| 38 | #include "portaudio.h" |
|---|
| 39 | /*******************************************************************/ |
|---|
| 40 | int main(void); |
|---|
| 41 | int main(void) |
|---|
| 42 | { |
|---|
| 43 | int i,j; |
|---|
| 44 | int numDevices; |
|---|
| 45 | const PaDeviceInfo *pdi; |
|---|
| 46 | PaError err; |
|---|
| 47 | Pa_Initialize(); |
|---|
| 48 | numDevices = Pa_CountDevices(); |
|---|
| 49 | if( numDevices < 0 ) |
|---|
| 50 | { |
|---|
| 51 | printf("ERROR: Pa_CountDevices returned 0x%x\n", numDevices ); |
|---|
| 52 | err = numDevices; |
|---|
| 53 | goto error; |
|---|
| 54 | } |
|---|
| 55 | printf("Number of devices = %d\n", numDevices ); |
|---|
| 56 | for( i=0; i<numDevices; i++ ) |
|---|
| 57 | { |
|---|
| 58 | pdi = Pa_GetDeviceInfo( i ); |
|---|
| 59 | printf("---------------------------------------------- #%d", i ); |
|---|
| 60 | if( i == Pa_GetDefaultInputDeviceID() ) printf(" DefaultInput"); |
|---|
| 61 | if( i == Pa_GetDefaultOutputDeviceID() ) printf(" DefaultOutput"); |
|---|
| 62 | printf("\nName = %s\n", pdi->name ); |
|---|
| 63 | printf("Max Inputs = %d", pdi->maxInputChannels ); |
|---|
| 64 | printf(", Max Outputs = %d\n", pdi->maxOutputChannels ); |
|---|
| 65 | if( pdi->numSampleRates == -1 ) |
|---|
| 66 | { |
|---|
| 67 | printf("Sample Rate Range = %f to %f\n", pdi->sampleRates[0], pdi->sampleRates[1] ); |
|---|
| 68 | } |
|---|
| 69 | else |
|---|
| 70 | { |
|---|
| 71 | printf("Sample Rates ="); |
|---|
| 72 | for( j=0; j<pdi->numSampleRates; j++ ) |
|---|
| 73 | { |
|---|
| 74 | printf(" %8.2f,", pdi->sampleRates[j] ); |
|---|
| 75 | } |
|---|
| 76 | printf("\n"); |
|---|
| 77 | } |
|---|
| 78 | printf("Native Sample Formats = "); |
|---|
| 79 | if( pdi->nativeSampleFormats & paInt8 ) printf("paInt8, "); |
|---|
| 80 | if( pdi->nativeSampleFormats & paUInt8 ) printf("paUInt8, "); |
|---|
| 81 | if( pdi->nativeSampleFormats & paInt16 ) printf("paInt16, "); |
|---|
| 82 | if( pdi->nativeSampleFormats & paInt32 ) printf("paInt32, "); |
|---|
| 83 | if( pdi->nativeSampleFormats & paFloat32 ) printf("paFloat32, "); |
|---|
| 84 | if( pdi->nativeSampleFormats & paInt24 ) printf("paInt24, "); |
|---|
| 85 | if( pdi->nativeSampleFormats & paPackedInt24 ) printf("paPackedInt24, "); |
|---|
| 86 | printf("\n"); |
|---|
| 87 | } |
|---|
| 88 | Pa_Terminate(); |
|---|
| 89 | |
|---|
| 90 | printf("----------------------------------------------\n"); |
|---|
| 91 | return 0; |
|---|
| 92 | error: |
|---|
| 93 | Pa_Terminate(); |
|---|
| 94 | fprintf( stderr, "An error occured while using the portaudio stream\n" ); |
|---|
| 95 | fprintf( stderr, "Error number: %d\n", err ); |
|---|
| 96 | fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); |
|---|
| 97 | return err; |
|---|
| 98 | } |
|---|