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