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