Chris@39: /** @file pa_test_jack_wasapi.c Chris@39: @ingroup test_src Chris@39: @brief Print out jack information for WASAPI endpoints Chris@39: @author Reid Bishop Chris@39: */ Chris@39: /* Chris@39: * $Id: pa_test_jack_wasapi.c 1368 2008-03-01 00:38:27Z rbishop $ Chris@39: * Chris@39: * This program uses the PortAudio Portable Audio Library. Chris@39: * For more information see: http://www.portaudio.com/ Chris@39: * Copyright (c) 1999-2010 Ross Bencina and Phil Burk Chris@39: * Chris@39: * Permission is hereby granted, free of charge, to any person obtaining Chris@39: * a copy of this software and associated documentation files Chris@39: * (the "Software"), to deal in the Software without restriction, Chris@39: * including without limitation the rights to use, copy, modify, merge, Chris@39: * publish, distribute, sublicense, and/or sell copies of the Software, Chris@39: * and to permit persons to whom the Software is furnished to do so, Chris@39: * subject to the following conditions: Chris@39: * Chris@39: * The above copyright notice and this permission notice shall be Chris@39: * included in all copies or substantial portions of the Software. Chris@39: * Chris@39: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@39: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@39: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. Chris@39: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR Chris@39: * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@39: * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@39: * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@39: */ Chris@39: Chris@39: /* Chris@39: * The text above constitutes the entire PortAudio license; however, Chris@39: * the PortAudio community also makes the following non-binding requests: Chris@39: * Chris@39: * Any person wishing to distribute modifications to the Software is Chris@39: * requested to send the modifications to the original developer so that Chris@39: * they can be incorporated into the canonical version. It is also Chris@39: * requested that these non-binding requests be included along with the Chris@39: * license above. Chris@39: */ Chris@39: #include Chris@39: #include "portaudio.h" Chris@39: #include "pa_win_wasapi.h" Chris@39: Chris@39: Chris@39: /* Chris@39: * Helper function to determine if a given enum is present in mask variable Chris@39: * Chris@39: */ Chris@39: static int IsInMask(int val, int val2) Chris@39: { Chris@39: return ((val & val2) == val2); Chris@39: } Chris@39: Chris@39: /* Chris@39: * This routine enumerates through the ChannelMapping for the IJackDescription Chris@39: */ Chris@39: Chris@39: static void EnumIJackChannels(int channelMapping) Chris@39: { Chris@39: printf("Channel Mapping: "); Chris@39: if(channelMapping == PAWIN_SPEAKER_DIRECTOUT) Chris@39: { Chris@39: printf("DIRECTOUT\n"); Chris@39: return; Chris@39: } Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT)) Chris@39: printf("FRONT_LEFT, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT)) Chris@39: printf("FRONT_RIGHT, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_CENTER)) Chris@39: printf("FRONT_CENTER, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_LOW_FREQUENCY)) Chris@39: printf("LOW_FREQUENCY, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_LEFT)) Chris@39: printf("BACK_LEFT, "); Chris@39: if(IsInMask(channelMapping,PAWIN_SPEAKER_BACK_RIGHT)) Chris@39: printf("BACK_RIGHT, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER)) Chris@39: printf("FRONT_LEFT_OF_CENTER, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER)) Chris@39: printf("FRONT_RIGHT_OF_CENTER, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_CENTER)) Chris@39: printf("BACK_CENTER, "); Chris@39: if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_LEFT)) Chris@39: printf("SIDE_LEFT, "); Chris@39: if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_RIGHT)) Chris@39: printf("SIDE_RIGHT, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_CENTER)) Chris@39: printf("TOP_CENTER, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_LEFT)) Chris@39: printf("TOP_FRONT_LEFT, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_CENTER)) Chris@39: printf("TOP_FRONT_CENTER, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_RIGHT)) Chris@39: printf("TOP_FRONT_RIGHT, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_LEFT)) Chris@39: printf("TOP_BACK_LEFT, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_CENTER)) Chris@39: printf("TOP_BACK_CENTER, "); Chris@39: if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_RIGHT)) Chris@39: printf("TOP_BACK_RIGHT, "); Chris@39: Chris@39: printf("\n"); Chris@39: } Chris@39: Chris@39: /* Chris@39: * This routine enumerates through the Jack Connection Types enums for IJackDescription Chris@39: */ Chris@39: static void EnumIJackConnectionType(int cType) Chris@39: { Chris@39: printf("Connection Type: "); Chris@39: switch(cType) Chris@39: { Chris@39: case eJackConnTypeUnknown: Chris@39: printf("eJackConnTypeUnknown"); Chris@39: break; Chris@39: case eJackConnType3Point5mm: Chris@39: printf("eJackConnType3Point5mm"); Chris@39: break; Chris@39: case eJackConnTypeQuarter: Chris@39: printf("eJackConnTypeQuarter"); Chris@39: break; Chris@39: case eJackConnTypeAtapiInternal: Chris@39: printf("eJackConnTypeAtapiInternal"); Chris@39: break; Chris@39: case eJackConnTypeRCA: Chris@39: printf("eJackConnTypeRCA"); Chris@39: break; Chris@39: case eJackConnTypeOptical: Chris@39: printf("eJackConnTypeOptical"); Chris@39: break; Chris@39: case eJackConnTypeOtherDigital: Chris@39: printf("eJackConnTypeOtherDigital"); Chris@39: break; Chris@39: case eJackConnTypeOtherAnalog: Chris@39: printf("eJackConnTypeOtherAnalog"); Chris@39: break; Chris@39: case eJackConnTypeMultichannelAnalogDIN: Chris@39: printf("eJackConnTypeMultichannelAnalogDIN"); Chris@39: break; Chris@39: case eJackConnTypeXlrProfessional: Chris@39: printf("eJackConnTypeXlrProfessional"); Chris@39: break; Chris@39: case eJackConnTypeRJ11Modem: Chris@39: printf("eJackConnTypeRJ11Modem"); Chris@39: break; Chris@39: case eJackConnTypeCombination: Chris@39: printf("eJackConnTypeCombination"); Chris@39: break; Chris@39: } Chris@39: printf("\n"); Chris@39: } Chris@39: Chris@39: /* Chris@39: * This routine enumerates through the GeoLocation enums for the IJackDescription Chris@39: */ Chris@39: static void EnumIJackGeoLocation(int iVal) Chris@39: { Chris@39: printf("Geometric Location: "); Chris@39: switch(iVal) Chris@39: { Chris@39: case eJackGeoLocRear: Chris@39: printf("eJackGeoLocRear"); Chris@39: break; Chris@39: case eJackGeoLocFront: Chris@39: printf("eJackGeoLocFront"); Chris@39: break; Chris@39: case eJackGeoLocLeft: Chris@39: printf("eJackGeoLocLeft"); Chris@39: break; Chris@39: case eJackGeoLocRight: Chris@39: printf("eJackGeoLocRight"); Chris@39: break; Chris@39: case eJackGeoLocTop: Chris@39: printf("eJackGeoLocTop"); Chris@39: break; Chris@39: case eJackGeoLocBottom: Chris@39: printf("eJackGeoLocBottom"); Chris@39: break; Chris@39: case eJackGeoLocRearPanel: Chris@39: printf("eJackGeoLocRearPanel"); Chris@39: break; Chris@39: case eJackGeoLocRiser: Chris@39: printf("eJackGeoLocRiser"); Chris@39: break; Chris@39: case eJackGeoLocInsideMobileLid: Chris@39: printf("eJackGeoLocInsideMobileLid"); Chris@39: break; Chris@39: case eJackGeoLocDrivebay: Chris@39: printf("eJackGeoLocDrivebay"); Chris@39: break; Chris@39: case eJackGeoLocHDMI: Chris@39: printf("eJackGeoLocHDMI"); Chris@39: break; Chris@39: case eJackGeoLocOutsideMobileLid: Chris@39: printf("eJackGeoLocOutsideMobileLid"); Chris@39: break; Chris@39: case eJackGeoLocATAPI: Chris@39: printf("eJackGeoLocATAPI"); Chris@39: break; Chris@39: } Chris@39: printf("\n"); Chris@39: } Chris@39: Chris@39: /* Chris@39: * This routine enumerates through the GenLocation enums for the IJackDescription Chris@39: */ Chris@39: static void EnumIJackGenLocation(int iVal) Chris@39: { Chris@39: printf("General Location: "); Chris@39: switch(iVal) Chris@39: { Chris@39: case eJackGenLocPrimaryBox: Chris@39: printf("eJackGenLocPrimaryBox"); Chris@39: break; Chris@39: case eJackGenLocInternal: Chris@39: printf("eJackGenLocInternal"); Chris@39: break; Chris@39: case eJackGenLocSeparate: Chris@39: printf("eJackGenLocSeparate"); Chris@39: break; Chris@39: case eJackGenLocOther: Chris@39: printf("eJackGenLocOther"); Chris@39: break; Chris@39: } Chris@39: printf("\n"); Chris@39: } Chris@39: Chris@39: /* Chris@39: * This routine enumerates through the PortConnection enums for the IJackDescription Chris@39: */ Chris@39: static void EnumIJackPortConnection(int iVal) Chris@39: { Chris@39: printf("Port Type: "); Chris@39: switch(iVal) Chris@39: { Chris@39: case eJackPortConnJack: Chris@39: printf("eJackPortConnJack"); Chris@39: break; Chris@39: case eJackPortConnIntegratedDevice: Chris@39: printf("eJackPortConnIntegratedDevice"); Chris@39: break; Chris@39: case eJackPortConnBothIntegratedAndJack: Chris@39: printf("eJackPortConnBothIntegratedAndJack"); Chris@39: break; Chris@39: case eJackPortConnUnknown: Chris@39: printf("eJackPortConnUnknown"); Chris@39: break; Chris@39: } Chris@39: printf("\n"); Chris@39: } Chris@39: Chris@39: /* Chris@39: * This routine retrieves and parses the KSJACK_DESCRIPTION structure for Chris@39: * the provided device ID. Chris@39: */ Chris@39: static PaError GetJackInformation(int deviceId) Chris@39: { Chris@39: PaError err; Chris@39: int i; Chris@39: int jackCount = 0; Chris@39: PaWasapiJackDescription jackDesc; Chris@39: Chris@39: err = PaWasapi_GetJackCount(deviceId, &jackCount); Chris@39: if( err != paNoError ) return err; Chris@39: Chris@39: fprintf( stderr,"Number of Jacks: %d \n", jackCount ); Chris@39: Chris@39: for( i = 0; ihostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI) ) Chris@39: { Chris@39: if( device->maxOutputChannels == 0 ) Chris@39: { Chris@39: isInput = 1; Chris@39: } Chris@39: printf("------------------------------------------\n"); Chris@39: printf("Device: %s",device->name); Chris@39: if(isInput) Chris@39: printf(" (Input) %d Channels\n",device->maxInputChannels); Chris@39: else Chris@39: printf(" (Output) %d Channels\n",device->maxOutputChannels); Chris@39: // Try to see if this WASAPI device can provide Jack information Chris@39: err = GetJackInformation(i); Chris@39: if( err != paNoError ) goto error; Chris@39: } Chris@39: } Chris@39: Pa_Terminate(); Chris@39: printf("Test finished.\n"); Chris@39: return err; Chris@39: Chris@39: error: Chris@39: Pa_Terminate(); Chris@39: fprintf( stderr, "An error occured while using the portaudio stream\n" ); Chris@39: fprintf( stderr, "Error number: %d\n", err ); Chris@39: fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); Chris@39: return err; Chris@39: }