From: <sb...@us...> - 2007-06-05 19:56:24
|
Revision: 1001 http://svn.sourceforge.net/iaxclient/?rev=1001&view=rev Author: sbalea Date: 2007-06-05 12:56:22 -0700 (Tue, 05 Jun 2007) Log Message: ----------- Fixed Microphone Boost on Lenovo desktops with "soundmax hd" audio hardware. It appears that Mic Boost controls are not always MIXERCONTROL_CONTROLTYPE_ONOFF In this case, the control was MIXERCONTROL_CONTROLTYPE_LOUDNESS. Anyway, the control is of the more general "BOOLEAN" type so we test for that. Combined with the existing test for "MIC" and "BOOST", we should get the correct mic boost control, if one is available. Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-06-05 19:12:24 UTC (rev 1000) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-06-05 19:56:22 UTC (rev 1001) @@ -36,6 +36,7 @@ */ #include <windows.h> +#include <stdio.h> #include "portaudio.h" #include "portmixer.h" @@ -683,7 +684,7 @@ for ( ; x < mixerLineControls.cControls ; ++x ) { // check control type - if ( mixerControl[x].dwControlType == MIXERCONTROL_CONTROLTYPE_ONOFF ) + if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) { // normalize control name char* name = _strupr( mixerControl[x].szName ) ; @@ -807,7 +808,7 @@ for ( ; x < mixerLineControls.cControls ; ++x ) { // check control type - if ( mixerControl[x].dwControlType == MIXERCONTROL_CONTROLTYPE_ONOFF ) + if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) { // normalize control name char* name = _strupr( mixerControl[x].szName ) ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-06-05 22:15:46
|
Revision: 1003 http://svn.sourceforge.net/iaxclient/?rev=1003&view=rev Author: jpgrayson Date: 2007-06-05 15:15:48 -0700 (Tue, 05 Jun 2007) Log Message: ----------- Remove unneeded include. Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-06-05 20:54:04 UTC (rev 1002) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-06-05 22:15:48 UTC (rev 1003) @@ -36,7 +36,6 @@ */ #include <windows.h> -#include <stdio.h> #include "portaudio.h" #include "portmixer.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sb...@us...> - 2007-10-30 18:32:03
|
Revision: 1243 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1243&view=rev Author: sbalea Date: 2007-10-30 11:32:07 -0700 (Tue, 30 Oct 2007) Log Message: ----------- Fix memory leaks in px_win_wmme.c. Patch provided by Teri Schoech. Thanks Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-10-30 18:18:45 UTC (rev 1242) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-10-30 18:32:07 UTC (rev 1243) @@ -671,7 +671,11 @@ ) ; if ( mmr != MMSYSERR_NOERROR ) + { + free(mixerControl); + return mmr ; + } // // find boost control @@ -701,7 +705,11 @@ } if ( boost_id == -1 ) + { + free(mixerControl); + return MMSYSERR_ERROR ; + } // // get control details @@ -724,7 +732,11 @@ ) ; if ( mmr != MMSYSERR_NOERROR ) + { + free(mixerControl); + return mmr ; + } // // update value @@ -742,6 +754,8 @@ MIXER_SETCONTROLDETAILSF_VALUE ) ; + free(mixerControl); + if ( mmr != MMSYSERR_NOERROR ) return mmr ; @@ -795,7 +809,11 @@ ) ; if ( mmr != MMSYSERR_NOERROR ) + { + free(mixerControl); + return -1 ; + } // // find boost control @@ -825,7 +843,11 @@ } if ( boost_id == -1 ) + { + free(mixerControl); + return -1 ; + } // // get control details @@ -847,6 +869,8 @@ MIXER_GETCONTROLDETAILSF_VALUE ) ; + free(mixerControl); + if ( mmr != MMSYSERR_NOERROR ) return -1 ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-03-18 13:48:02
|
Revision: 1372 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1372&view=rev Author: jpgrayson Date: 2008-03-18 06:48:08 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Consistent indenting. Other whitespace. Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 13:25:08 UTC (rev 1371) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 13:48:08 UTC (rev 1372) @@ -211,8 +211,8 @@ mixer->numInputs = 0; mixer->muxID = 0; - /* ??? win32 default for wave control seems to be 0 ??? */ - mixer->waveID = 0 ; + /* ??? win32 default for wave control seems to be 0 ??? */ + mixer->waveID = 0 ; /* * Find the input source selector (mux or mixer) and @@ -300,7 +300,7 @@ */ mixer->speakerID = 0; - + if (mixer->hOutputMixer) { line.cbStruct = sizeof(MIXERLINE); line.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; @@ -360,7 +360,7 @@ /* Px_CloseMixer() closes a mixer opened using Px_OpenMixer and frees any - memory associated with it. + memory associated with it. */ void Px_CloseMixer(PxMixer *mixer) @@ -399,56 +399,56 @@ PCM output volume */ -int Px_SupportsPCMOutputVolume( PxMixer* mixer ) +int Px_SupportsPCMOutputVolume( PxMixer* mixer ) { - PxInfo* info = ( PxInfo* )( mixer ) ; - return ( info->waveID == -1 ) ? 0 : 1 ; + PxInfo* info = ( PxInfo* )( mixer ) ; + return ( info->waveID == -1 ) ? 0 : 1 ; } PxVolume Px_GetPCMOutputVolume( PxMixer *mixer ) { - MMRESULT result; - DWORD vol = 0; - unsigned short mono_vol = 0; - PxInfo *info = (PxInfo *)mixer; + MMRESULT result; + DWORD vol = 0; + unsigned short mono_vol = 0; + PxInfo *info = (PxInfo *)mixer; - /* invalid waveID, return zero */ - if ( info->waveID == -1 ) - return 0.0 ; + /* invalid waveID, return zero */ + if ( info->waveID == -1 ) + return 0.0 ; - /* get the wave output volume */ - result = waveOutGetVolume( (HWAVEOUT)( info->waveID ), &vol); + /* get the wave output volume */ + result = waveOutGetVolume( (HWAVEOUT)( info->waveID ), &vol); - /* on failure, mark waveID as invalid and return zero */ - if ( result != MMSYSERR_NOERROR ) - { - info->waveID = -1 ; - return 0.0 ; - } + /* on failure, mark waveID as invalid and return zero */ + if ( result != MMSYSERR_NOERROR ) + { + info->waveID = -1 ; + return 0.0 ; + } - mono_vol = (unsigned short)vol; - return (PxVolume)mono_vol/65535.0F; + mono_vol = (unsigned short)vol; + return (PxVolume)mono_vol/65535.0F; } void Px_SetPCMOutputVolume( PxMixer *mixer, PxVolume volume ) { - MMRESULT result; - PxInfo *info = (PxInfo *)mixer; + MMRESULT result; + PxInfo *info = (PxInfo *)mixer; - /* invalid waveID */ - if ( info->waveID == -1 ) - return ; + /* invalid waveID */ + if ( info->waveID == -1 ) + return ; - /* set the wave output volume */ - result = waveOutSetVolume( (HWAVEOUT)( info->waveID ), MAKELONG(volume*0xFFFF, volume*0xFFFF)); + /* set the wave output volume */ + result = waveOutSetVolume( (HWAVEOUT)( info->waveID ), MAKELONG(volume*0xFFFF, volume*0xFFFF)); - /* on failure, mark waveID as invalid */ - if ( result != MMSYSERR_NOERROR ) - { - info->waveID = -1 ; - } + /* on failure, mark waveID as invalid */ + if ( result != MMSYSERR_NOERROR ) + { + info->waveID = -1 ; + } - return ; + return ; } /* @@ -465,7 +465,7 @@ const char *Px_GetOutputVolumeName( PxMixer *mixer, int i ) { PxInfo *info = (PxInfo *)mixer; - + if (i==1) return "Wave Out"; else @@ -499,14 +499,14 @@ int Px_GetNumInputSources( PxMixer *mixer ) { PxInfo *info = (PxInfo *)mixer; - + return info->numInputs; } const char *Px_GetInputSourceName( PxMixer *mixer, int i) { PxInfo *info = (PxInfo *)mixer; - + return info->src[i].name; } @@ -521,7 +521,7 @@ details.cbStruct = sizeof(MIXERCONTROLDETAILS); details.dwControlID = info->muxID; details.cMultipleItems = info->numInputs; - details.cChannels = 1; + details.cChannels = 1; details.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN); details.paDetails = (LPMIXERCONTROLDETAILS_BOOLEAN)&flags[0]; @@ -549,7 +549,7 @@ details.cbStruct = sizeof(MIXERCONTROLDETAILS); details.dwControlID = info->muxID; details.cMultipleItems = info->numInputs; - details.cChannels = 1; + details.cChannels = 1; details.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN); details.paDetails = (LPMIXERCONTROLDETAILS_BOOLEAN)&flags[0]; @@ -620,296 +620,292 @@ { } +int Px_SetMicrophoneBoost( PxMixer* mixer, int enable ) +{ + MIXERLINE mixerLine ; + LPMIXERCONTROL mixerControl ; + MIXERLINECONTROLS mixerLineControls ; + MIXERCONTROLDETAILS mixerControlDetails ; + MIXERCONTROLDETAILS_BOOLEAN value ; + MMRESULT mmr = MMSYSERR_ERROR ; + DWORD boost_id = -1 ; + DWORD x ; + // cast void pointer + PxInfo* info = ( PxInfo* )( mixer ) ; + if ( info == NULL ) + return MMSYSERR_ERROR ; + // + // get line info + // -int Px_SetMicrophoneBoost( PxMixer* mixer, int enable ) -{ - MIXERLINE mixerLine ; - LPMIXERCONTROL mixerControl ; - MIXERLINECONTROLS mixerLineControls ; - MIXERCONTROLDETAILS mixerControlDetails ; - MIXERCONTROLDETAILS_BOOLEAN value ; - MMRESULT mmr = MMSYSERR_ERROR ; - DWORD boost_id = -1 ; - DWORD x ; - - // cast void pointer - PxInfo* info = ( PxInfo* )( mixer ) ; + mixerLine.cbStruct = sizeof( MIXERLINE ) ; + mixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ; - if ( info == NULL ) - return MMSYSERR_ERROR ; - - // - // get line info - // - - mixerLine.cbStruct = sizeof( MIXERLINE ) ; - mixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ; - - mmr = mixerGetLineInfo( - ( HMIXEROBJ )( info->hInputMixer ), - &mixerLine, - MIXER_GETLINEINFOF_COMPONENTTYPE - ) ; + mmr = mixerGetLineInfo( + ( HMIXEROBJ )( info->hInputMixer ), + &mixerLine, + MIXER_GETLINEINFOF_COMPONENTTYPE + ) ; - if ( mmr != MMSYSERR_NOERROR ) - return mmr ; + if ( mmr != MMSYSERR_NOERROR ) + return mmr ; - // - // get all controls - // + // + // get all controls + // - mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; - - mixerLineControls.cbStruct = sizeof( MIXERLINECONTROLS ) ; - mixerLineControls.dwLineID = mixerLine.dwLineID ; - mixerLineControls.cControls = mixerLine.cControls ; - mixerLineControls.cbmxctrl = sizeof( MIXERCONTROL ) ; - mixerLineControls.pamxctrl = ( LPMIXERCONTROL )( mixerControl ) ; - - mmr = mixerGetLineControls( - ( HMIXEROBJ )( info->hInputMixer ), - &mixerLineControls, - MIXER_GETLINECONTROLSF_ALL - ) ; - - if ( mmr != MMSYSERR_NOERROR ) - { - free(mixerControl); + mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; - return mmr ; - } + mixerLineControls.cbStruct = sizeof( MIXERLINECONTROLS ) ; + mixerLineControls.dwLineID = mixerLine.dwLineID ; + mixerLineControls.cControls = mixerLine.cControls ; + mixerLineControls.cbmxctrl = sizeof( MIXERCONTROL ) ; + mixerLineControls.pamxctrl = ( LPMIXERCONTROL )( mixerControl ) ; - // - // find boost control - // + mmr = mixerGetLineControls( + ( HMIXEROBJ )( info->hInputMixer ), + &mixerLineControls, + MIXER_GETLINECONTROLSF_ALL + ) ; - for ( x = 0 ; x < mixerLineControls.cControls ; ++x ) - { - // check control type - if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) - { - // normalize control name - char* name = _strupr( mixerControl[x].szName ) ; + if ( mmr != MMSYSERR_NOERROR ) + { + free(mixerControl); - // check for 'mic' and 'boost' - if ( - ( strstr( name, "MIC" ) != NULL ) - && ( strstr( name, "BOOST" ) != NULL ) - ) - { - boost_id = mixerControl[x].dwControlID ; - break ; - } - } - } + return mmr ; + } - if ( boost_id == -1 ) - { - free(mixerControl); + // + // find boost control + // - return MMSYSERR_ERROR ; - } + for ( x = 0 ; x < mixerLineControls.cControls ; ++x ) + { + // check control type + if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) + { + // normalize control name + char* name = _strupr( mixerControl[x].szName ) ; - // - // get control details - // - - mixerControlDetails.cbStruct = sizeof( MIXERCONTROLDETAILS ) ; - mixerControlDetails.dwControlID = boost_id ; - mixerControlDetails.cChannels = 1 ; - mixerControlDetails.cMultipleItems = 0 ; - mixerControlDetails.cbDetails = sizeof( MIXERCONTROLDETAILS_BOOLEAN ) ; - mixerControlDetails.paDetails = &value ; + // check for 'mic' and 'boost' + if ( + ( strstr( name, "MIC" ) != NULL ) + && ( strstr( name, "BOOST" ) != NULL ) + ) + { + boost_id = mixerControl[x].dwControlID ; + break ; + } + } + } - mmr = mixerGetControlDetails( - ( HMIXEROBJ )( info->hInputMixer ), - &mixerControlDetails, - MIXER_GETCONTROLDETAILSF_VALUE - ) ; + if ( boost_id == -1 ) + { + free(mixerControl); - if ( mmr != MMSYSERR_NOERROR ) - { - free(mixerControl); + return MMSYSERR_ERROR ; + } - return mmr ; - } + // + // get control details + // - // - // update value - // + mixerControlDetails.cbStruct = sizeof( MIXERCONTROLDETAILS ) ; + mixerControlDetails.dwControlID = boost_id ; + mixerControlDetails.cChannels = 1 ; + mixerControlDetails.cMultipleItems = 0 ; + mixerControlDetails.cbDetails = sizeof( MIXERCONTROLDETAILS_BOOLEAN ) ; + mixerControlDetails.paDetails = &value ; - value.fValue = ( enable == 0 ) ? 0L : 1L ; + mmr = mixerGetControlDetails( + ( HMIXEROBJ )( info->hInputMixer ), + &mixerControlDetails, + MIXER_GETCONTROLDETAILSF_VALUE + ) ; - // - // set control details - // - - mmr = mixerSetControlDetails( - ( HMIXEROBJ )( info->hInputMixer ), - &mixerControlDetails, - MIXER_SETCONTROLDETAILSF_VALUE - ) ; + if ( mmr != MMSYSERR_NOERROR ) + { + free(mixerControl); - free(mixerControl); + return mmr ; + } - if ( mmr != MMSYSERR_NOERROR ) - return mmr ; - - return mmr ; + // + // update value + // + + value.fValue = ( enable == 0 ) ? 0L : 1L ; + + // + // set control details + // + + mmr = mixerSetControlDetails( + ( HMIXEROBJ )( info->hInputMixer ), + &mixerControlDetails, + MIXER_SETCONTROLDETAILSF_VALUE + ) ; + + free(mixerControl); + + if ( mmr != MMSYSERR_NOERROR ) + return mmr ; + + return mmr ; } int Px_GetMicrophoneBoost( PxMixer* mixer ) { - MIXERLINE mixerLine ; - LPMIXERCONTROL mixerControl ; - MIXERLINECONTROLS mixerLineControls ; - MIXERCONTROLDETAILS mixerControlDetails ; - MIXERCONTROLDETAILS_BOOLEAN value ; - MMRESULT mmr = MMSYSERR_ERROR ; - DWORD boost_id = -1 ; - DWORD x ; - - // cast void pointer - PxInfo* info = ( PxInfo* )( mixer ) ; + MIXERLINE mixerLine ; + LPMIXERCONTROL mixerControl ; + MIXERLINECONTROLS mixerLineControls ; + MIXERCONTROLDETAILS mixerControlDetails ; + MIXERCONTROLDETAILS_BOOLEAN value ; + MMRESULT mmr = MMSYSERR_ERROR ; + DWORD boost_id = -1 ; + DWORD x ; - if ( info == NULL ) - return -1 ; - - // - // get line info - // - - mixerLine.cbStruct = sizeof( MIXERLINE ) ; - mixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ; - - mmr = mixerGetLineInfo( - ( HMIXEROBJ )( info->hInputMixer ), - &mixerLine, - MIXER_GETLINEINFOF_COMPONENTTYPE - ) ; + // cast void pointer + PxInfo* info = ( PxInfo* )( mixer ) ; - if ( mmr != MMSYSERR_NOERROR ) - return -1 ; + if ( info == NULL ) + return -1 ; - // - // get all controls - // + // + // get line info + // - mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; - - mixerLineControls.cbStruct = sizeof( MIXERLINECONTROLS ) ; - mixerLineControls.dwLineID = mixerLine.dwLineID ; - mixerLineControls.cControls = mixerLine.cControls ; - mixerLineControls.cbmxctrl = sizeof( MIXERCONTROL ) ; - mixerLineControls.pamxctrl = ( LPMIXERCONTROL )( mixerControl ) ; - - mmr = mixerGetLineControls( - ( HMIXEROBJ )( info->hInputMixer ), - &mixerLineControls, - MIXER_GETLINECONTROLSF_ALL - ) ; - - if ( mmr != MMSYSERR_NOERROR ) - { - free(mixerControl); + mixerLine.cbStruct = sizeof( MIXERLINE ) ; + mixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ; - return -1 ; - } + mmr = mixerGetLineInfo( + ( HMIXEROBJ )( info->hInputMixer ), + &mixerLine, + MIXER_GETLINEINFOF_COMPONENTTYPE + ) ; - // - // find boost control - // + if ( mmr != MMSYSERR_NOERROR ) + return -1 ; - for ( x = 0 ; x < mixerLineControls.cControls ; ++x ) - { - // check control type - if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) - { - // normalize control name - char* name = _strupr( mixerControl[x].szName ) ; + // + // get all controls + // - // check for 'mic' and 'boost' - if ( - ( strstr( name, "MIC" ) != NULL ) - && ( strstr( name, "BOOST" ) != NULL ) - ) - { - boost_id = mixerControl[x].dwControlID ; - break ; - } - } - } + mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; - if ( boost_id == -1 ) - { - free(mixerControl); + mixerLineControls.cbStruct = sizeof( MIXERLINECONTROLS ) ; + mixerLineControls.dwLineID = mixerLine.dwLineID ; + mixerLineControls.cControls = mixerLine.cControls ; + mixerLineControls.cbmxctrl = sizeof( MIXERCONTROL ) ; + mixerLineControls.pamxctrl = ( LPMIXERCONTROL )( mixerControl ) ; - return -1 ; - } + mmr = mixerGetLineControls( + ( HMIXEROBJ )( info->hInputMixer ), + &mixerLineControls, + MIXER_GETLINECONTROLSF_ALL + ) ; - // - // get control details - // - - mixerControlDetails.cbStruct = sizeof( MIXERCONTROLDETAILS ) ; - mixerControlDetails.dwControlID = boost_id ; - mixerControlDetails.cChannels = 1 ; - mixerControlDetails.cMultipleItems = 0 ; - mixerControlDetails.cbDetails = sizeof( MIXERCONTROLDETAILS_BOOLEAN ) ; - mixerControlDetails.paDetails = &value ; + if ( mmr != MMSYSERR_NOERROR ) + { + free(mixerControl); - mmr = mixerGetControlDetails( - ( HMIXEROBJ )( info->hInputMixer ), - &mixerControlDetails, - MIXER_GETCONTROLDETAILSF_VALUE - ) ; + return -1 ; + } - free(mixerControl); + // + // find boost control + // - if ( mmr != MMSYSERR_NOERROR ) - return -1 ; - - return ( int )( value.fValue ) ; + for ( x = 0 ; x < mixerLineControls.cControls ; ++x ) + { + // check control type + if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) + { + // normalize control name + char* name = _strupr( mixerControl[x].szName ) ; + + // check for 'mic' and 'boost' + if ( + ( strstr( name, "MIC" ) != NULL ) + && ( strstr( name, "BOOST" ) != NULL ) + ) + { + boost_id = mixerControl[x].dwControlID ; + break ; + } + } + } + + if ( boost_id == -1 ) + { + free(mixerControl); + + return -1 ; + } + + // + // get control details + // + + mixerControlDetails.cbStruct = sizeof( MIXERCONTROLDETAILS ) ; + mixerControlDetails.dwControlID = boost_id ; + mixerControlDetails.cChannels = 1 ; + mixerControlDetails.cMultipleItems = 0 ; + mixerControlDetails.cbDetails = sizeof( MIXERCONTROLDETAILS_BOOLEAN ) ; + mixerControlDetails.paDetails = &value ; + + mmr = mixerGetControlDetails( + ( HMIXEROBJ )( info->hInputMixer ), + &mixerControlDetails, + MIXER_GETCONTROLDETAILSF_VALUE + ) ; + + free(mixerControl); + + if ( mmr != MMSYSERR_NOERROR ) + return -1 ; + + return ( int )( value.fValue ) ; } -int Px_SetCurrentInputSourceByName( PxMixer* mixer, const char* name ) +int Px_SetCurrentInputSourceByName( PxMixer* mixer, const char* name ) { - int x ; + int x ; - // cast void pointer - PxInfo* info = ( PxInfo* )( mixer ) ; + // cast void pointer + PxInfo* info = ( PxInfo* )( mixer ) ; - // make sure we have a mixer - if ( info == NULL ) - return MMSYSERR_ERROR ; + // make sure we have a mixer + if ( info == NULL ) + return MMSYSERR_ERROR ; - // make sure we have a search name - if ( name == NULL ) - return MMSYSERR_ERROR ; + // make sure we have a search name + if ( name == NULL ) + return MMSYSERR_ERROR ; - // - // set input source - // + // + // set input source + // - for ( x = 0 ; x < info->numInputs ; ++x ) - { - // compare passed name with control name - if ( strncasecmp( info->src[x].name, name, strlen( name ) ) == 0 ) - { - // set input source - Px_SetCurrentInputSource( mixer, x ) ; - - // make sure set'ing worked - if ( Px_GetCurrentInputSource( mixer ) == x ) - return MMSYSERR_NOERROR ; - else - return MMSYSERR_ERROR ; - } - } + for ( x = 0 ; x < info->numInputs ; ++x ) + { + // compare passed name with control name + if ( strncasecmp( info->src[x].name, name, strlen( name ) ) == 0 ) + { + // set input source + Px_SetCurrentInputSource( mixer, x ) ; - return MMSYSERR_ERROR ; + // make sure set'ing worked + if ( Px_GetCurrentInputSource( mixer ) == x ) + return MMSYSERR_NOERROR ; + else + return MMSYSERR_ERROR ; + } + } + + return MMSYSERR_ERROR ; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-03-18 13:51:39
|
Revision: 1373 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1373&view=rev Author: jpgrayson Date: 2008-03-18 06:51:45 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Remove portaudio V18 support, now only support portaudio V19. This had already been done for the rest of portmixer. Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 13:48:08 UTC (rev 1372) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 13:51:45 UTC (rev 1373) @@ -40,29 +40,6 @@ #include "portaudio.h" #include "portmixer.h" -#if defined(PaStream) -#define PA_V18 -#else -#define PA_V19 -#endif - -#if defined(PA_V18) -#include "pa_host.h" - -typedef struct PaWMMEStreamData -{ - /* Input -------------- */ - HWAVEIN hWaveIn; - WAVEHDR *inputBuffers; - int currentInputBuffer; - int bytesPerHostInputBuffer; - int bytesPerUserInputBuffer; /* native buffer size in bytes */ - /* Output -------------- */ - HWAVEOUT hWaveOut; -} PaWMMEStreamData; -#endif - -#if defined(PA_V19) #include "pa_cpuload.h" #include "pa_process.h" #include "pa_stream.h" @@ -111,7 +88,6 @@ DWORD allBuffersDurationMs; /* used to calculate timeouts */ }; -#endif typedef struct PxSrcInfo { @@ -143,14 +119,7 @@ PxMixer *Px_OpenMixer( void *pa_stream, int index ) { -#if defined(PA_V18) - internalPortAudioStream *past; - PaWMMEStreamData *wmmeStreamData; -#endif - -#if defined(PA_V19) struct PaWinMmeStream *past; -#endif HWAVEIN hWaveIn; HWAVEOUT hWaveOut; @@ -170,15 +139,6 @@ mixer->hInputMixer = NULL; mixer->hOutputMixer = NULL; -#if defined(PA_V18) - past = (internalPortAudioStream *) pa_stream; - wmmeStreamData = (PaWMMEStreamData *) past->past_DeviceData; - - hWaveIn = wmmeStreamData->hWaveIn; - hWaveOut = wmmeStreamData->hWaveOut; -#endif - -#if defined(PA_V19) past = (struct PaWinMmeStream *) pa_stream; hWaveIn = 0; @@ -190,7 +150,6 @@ if (past->output.waveHandles) { hWaveOut = ((HWAVEOUT *)past->output.waveHandles)[0]; } -#endif if (hWaveIn) { result = mixerOpen((HMIXER *)&mixer->hInputMixer, (UINT)hWaveIn, 0, 0, MIXER_OBJECTF_HWAVEIN); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-03-18 14:00:22
|
Revision: 1374 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1374&view=rev Author: jpgrayson Date: 2008-03-18 07:00:28 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Move declarations to scope where they are used. Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 13:51:45 UTC (rev 1373) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 14:00:28 UTC (rev 1374) @@ -119,19 +119,12 @@ PxMixer *Px_OpenMixer( void *pa_stream, int index ) { - struct PaWinMmeStream *past; + struct PaWinMmeStream *past; + HWAVEIN hWaveIn; + HWAVEOUT hWaveOut; + PxInfo *mixer; + MMRESULT result; - HWAVEIN hWaveIn; - HWAVEOUT hWaveOut; - PxInfo *mixer; - MMRESULT result; - MIXERLINE line; - MIXERLINECONTROLS controls; - MIXERCONTROL control; - MIXERCONTROLDETAILS details; - MIXERCONTROLDETAILS_LISTTEXT mixList[32]; - int j; - if (!pa_stream) return NULL; @@ -179,12 +172,16 @@ */ if (mixer->hInputMixer) { + MIXERLINE line; line.cbStruct = sizeof(MIXERLINE); line.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN; result = mixerGetLineInfo(mixer->hInputMixer, &line, MIXER_GETLINEINFOF_COMPONENTTYPE); if (result == MMSYSERR_NOERROR) { + int j; + MIXERLINECONTROLS controls; + MIXERCONTROL control; controls.cbStruct = sizeof(MIXERLINECONTROLS); controls.dwLineID = line.dwLineID; @@ -206,6 +203,9 @@ } if (result == MMSYSERR_NOERROR) { + MIXERCONTROLDETAILS details; + MIXERCONTROLDETAILS_LISTTEXT mixList[32]; + mixer->numInputs = control.cMultipleItems; mixer->muxID = control.dwControlID; @@ -261,12 +261,16 @@ mixer->speakerID = 0; if (mixer->hOutputMixer) { + MIXERLINE line; line.cbStruct = sizeof(MIXERLINE); line.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; result = mixerGetLineInfo(mixer->hOutputMixer, &line, MIXER_GETLINEINFOF_COMPONENTTYPE); if (result == MMSYSERR_NOERROR) { + MIXERLINECONTROLS controls; + MIXERCONTROL control; + controls.cbStruct = sizeof(MIXERLINECONTROLS); controls.dwLineID = line.dwLineID; controls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-03-18 14:26:12
|
Revision: 1375 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1375&view=rev Author: jpgrayson Date: 2008-03-18 07:26:16 -0700 (Tue, 18 Mar 2008) Log Message: ----------- - Integrate portmixer fixes from ste...@gm.... -- Fixes problem preventing portmixer to set the input level for USB audio input devices on Windows XP. -- See this iaxclient-devel thread for more details: http://sourceforge.net/mailarchive/forum.php?thread_name=004e01c88494%24b1623a10%249600a8c0%40xppnb64&forum_name=iaxclient-devel Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 14:00:28 UTC (rev 1374) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-03-18 14:26:16 UTC (rev 1375) @@ -35,6 +35,14 @@ * */ +#if defined(WIN32) || defined(_WIN32_WCE) +#include <stdlib.h> +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#else +#include <strings.h> +#endif + #include <windows.h> #include "portaudio.h" @@ -161,48 +169,57 @@ } mixer->numInputs = 0; - mixer->muxID = 0; + mixer->muxID = -1; /* ??? win32 default for wave control seems to be 0 ??? */ mixer->waveID = 0 ; - /* - * Find the input source selector (mux or mixer) and - * get the names and IDs of all of the input sources - */ - - if (mixer->hInputMixer) { + if (mixer->hInputMixer) + { MIXERLINE line; line.cbStruct = sizeof(MIXERLINE); line.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN; + result = mixerGetLineInfo(mixer->hInputMixer, &line, MIXER_GETLINEINFOF_COMPONENTTYPE); - if (result == MMSYSERR_NOERROR) { - int j; + if (result == MMSYSERR_NOERROR) + { + /* if the WaveInDestination has an InputSelectorControl (Mux or Mixer) + * get the names and IDs of all of the input sources + * make sure the name of the MicrophoneSource (if there is one) + * is "microphone" since pa_start() checks for it + */ + MIXERLINECONTROLS controls; MIXERCONTROL control; controls.cbStruct = sizeof(MIXERLINECONTROLS); - controls.dwLineID = line.dwLineID; - controls.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX; controls.cbmxctrl = sizeof(MIXERCONTROL); controls.pamxctrl = &control; control.cbStruct = sizeof(MIXERCONTROL); + controls.dwLineID = line.dwLineID; + controls.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX; result = mixerGetLineControls(mixer->hInputMixer, &controls, MIXER_GETLINECONTROLSF_ONEBYTYPE); - if (result != MMSYSERR_NOERROR) { + if (result != MMSYSERR_NOERROR) + { controls.dwControlType = MIXERCONTROL_CONTROLTYPE_MIXER; result = mixerGetLineControls(mixer->hInputMixer, &controls, MIXER_GETLINECONTROLSF_ONEBYTYPE); } - if (result == MMSYSERR_NOERROR) { + if (result == MMSYSERR_NOERROR) + { + int j; + int exactMic = -1; + int startMic = -1; + int firstMic = -1; MIXERCONTROLDETAILS details; MIXERCONTROLDETAILS_LISTTEXT mixList[32]; @@ -216,6 +233,7 @@ details.paDetails = (LPMIXERCONTROLDETAILS_LISTTEXT)&mixList[0]; details.cMultipleItems = mixer->numInputs; + controls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; result = mixerGetControlDetails(mixer->hInputMixer, (LPMIXERCONTROLDETAILS)&details, MIXER_GETCONTROLDETAILSF_LISTTEXT); @@ -223,33 +241,110 @@ if (result != MMSYSERR_NOERROR) mixer->numInputs = 0; - for(j=0; j<mixer->numInputs; j++) { + for (j=0; j < mixer->numInputs; j++) + { mixer->src[j].lineID = mixList[j].dwParam1; + + controls.dwLineID = mixer->src[j].lineID; + result = mixerGetLineControls(mixer->hInputMixer, + &controls, + MIXER_GETLINECONTROLSF_ONEBYTYPE); + if (result == MMSYSERR_NOERROR) + { + /* mark as volume control */ + mixer->src[j].controlID = control.dwControlID; + } + else + { + /* mark as NOT volume control */ + mixer->src[j].controlID = 0; + } + + line.dwLineID = mixer->src[j].lineID; + + result = mixerGetLineInfo(mixer->hInputMixer, &line, MIXER_GETLINEINFOF_LINEID); + if (result == MMSYSERR_NOERROR && + line.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) + { + if (exactMic == -1) + { + if (strcasecmp(mixList[j].szName, "microphone") == 0) + { + exactMic = j; + } + else if (startMic == -1) + { + if (strncasecmp(mixList[j].szName, "microphone", + strlen("microphone")) == 0) + { + startMic = j; + } + else if (firstMic == -1) + { + firstMic = j; + } + } + } + } strcpy(mixer->src[j].name, mixList[j].szName); } + + if (exactMic == -1) + { + if (startMic != -1) + { + strcpy(mixer->src[startMic].name, "microphone"); + } + else if (firstMic != -1) + { + strcpy(mixer->src[firstMic].name, "microphone"); + } + } } - - /* - * We've found the names - now we need to find the volume - * controls for each one - */ - - for(j=0; j<mixer->numInputs; j++) { - controls.cbStruct = sizeof(MIXERLINECONTROLS); - controls.dwLineID = mixer->src[j].lineID; + else + { + /* if the WaveInDestination does not have an InputSelector + * see if the WaveInDestination SourceLine has a VolumeControl + */ controls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; - controls.cbmxctrl = sizeof(MIXERCONTROL); - controls.pamxctrl = &control; - - control.cbStruct = sizeof(MIXERCONTROL); - result = mixerGetLineControls(mixer->hInputMixer, &controls, MIXER_GETLINECONTROLSF_ONEBYTYPE); if (result == MMSYSERR_NOERROR) - mixer->src[j].controlID = control.dwControlID; + { + mixer->src[0].lineID = line.dwLineID; + strcpy(mixer->src[0].name, line.szName); + mixer->src[0].controlID = control.dwControlID; + mixer->numInputs = 1; + } else - mixer->src[j].controlID = 0; + { + line.dwSource = 0; + result = mixerGetLineInfo(mixer->hInputMixer, + &line, + MIXER_GETLINEINFOF_SOURCE); + if (result == MMSYSERR_NOERROR) + { + mixer->src[0].lineID = line.dwLineID; + strcpy(mixer->src[0].name, line.szName); + + controls.dwLineID = line.dwLineID; + result = mixerGetLineControls(mixer->hInputMixer, + &controls, + MIXER_GETLINECONTROLSF_ONEBYTYPE); + + if (result == MMSYSERR_NOERROR) + { + mixer->src[0].controlID = control.dwControlID; + } + else + { + mixer->src[0].controlID = 0; + } + + mixer->numInputs = 1; + } + } } } } @@ -856,7 +951,7 @@ for ( x = 0 ; x < info->numInputs ; ++x ) { // compare passed name with control name - if ( strncasecmp( info->src[x].name, name, strlen( name ) ) == 0 ) + if ( strcasecmp( info->src[x].name, name ) == 0 ) { // set input source Px_SetCurrentInputSource( mixer, x ) ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-03 21:37:55
|
Revision: 1388 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1388&view=rev Author: jpgrayson Date: 2008-04-03 14:38:02 -0700 (Thu, 03 Apr 2008) Log Message: ----------- Apply patch from stevebvt -- thank you! This fixes an issue with portmixer and certain usb audio devices, for example the vitelix vx200 and polycom cx100. These devices show up not as speaker destinations but as undefined. This patch searches for volume controls preferring speaker destinations, then headphone destinations, and finally undefined destinations. This patch also makes it so we find the wave output volume mixer control in Px_OpenMixer(). We then use the same mixerGetControlDetails()/mixerSetControlDetails() API to manipulate the volume for both Px_Get/SetPCMOutputVolume() and Px_Get/SetMasterVolume(). We used to use the waveOutGet/SetVolume() functions to manipulate the PCM volume. Thanks again to stevebvt for this carefully constructed patch. Modified Paths: -------------- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-04-03 21:27:37 UTC (rev 1387) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2008-04-03 21:38:02 UTC (rev 1388) @@ -171,9 +171,6 @@ mixer->numInputs = 0; mixer->muxID = -1; - /* ??? win32 default for wave control seems to be 0 ??? */ - mixer->waveID = 0 ; - if (mixer->hInputMixer) { MIXERLINE line; @@ -349,20 +346,40 @@ } } - /* - * Find the ID of the output speaker volume control - */ + // mixer->speakerID = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS/VolumeControl + // mixer->speakerID = MIXERLINE_COMPONENTTYPE_DST_HEADPHONES/VolumeControl + // mixer->speakerID = MIXERLINE_COMPONENTTYPE_DST_UNDEFINED/VolumeControl - mixer->speakerID = 0; + mixer->speakerID = -1; + mixer->waveID = -1; if (mixer->hOutputMixer) { + + const DWORD componentTypes [] = + { + MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, + MIXERLINE_COMPONENTTYPE_DST_HEADPHONES, + MIXERLINE_COMPONENTTYPE_DST_UNDEFINED, + }; + const size_t componentTypeLen = sizeof(componentTypes) / sizeof(DWORD); + DWORD j; + MIXERLINE line; line.cbStruct = sizeof(MIXERLINE); - line.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; - result = mixerGetLineInfo(mixer->hOutputMixer, - &line, - MIXER_GETLINEINFOF_COMPONENTTYPE); - if (result == MMSYSERR_NOERROR) { + + for (j = 0; j < componentTypeLen; j++) + { + line.dwComponentType = componentTypes[j]; + result = mixerGetLineInfo(mixer->hOutputMixer, + &line, + MIXER_GETLINEINFOF_COMPONENTTYPE); + + if (result == MMSYSERR_NOERROR) + break; + } + + if (result == MMSYSERR_NOERROR) + { MIXERLINECONTROLS controls; MIXERCONTROL control; @@ -380,6 +397,31 @@ if (result == MMSYSERR_NOERROR) mixer->speakerID = control.dwControlID; + + // mixer->waveID = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT/VolumeControl + + const DWORD numSources = line.cConnections; + + for (j = 0; j < numSources; j++) + { + line.dwSource = j; + result = mixerGetLineInfo(mixer->hOutputMixer, + &line, + MIXER_GETLINEINFOF_SOURCE); + if (result == MMSYSERR_NOERROR && + line.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT) + { + controls.dwLineID = line.dwLineID; + result = mixerGetLineControls(mixer->hOutputMixer, + &controls, + MIXER_GETLINECONTROLSF_ONEBYTYPE); + if (result == MMSYSERR_NOERROR) + { + mixer->waveID = control.dwControlID; + break; + } + } + } } } @@ -465,50 +507,22 @@ PxVolume Px_GetPCMOutputVolume( PxMixer *mixer ) { - MMRESULT result; - DWORD vol = 0; - unsigned short mono_vol = 0; PxInfo *info = (PxInfo *)mixer; + PxVolume vol; - /* invalid waveID, return zero */ - if ( info->waveID == -1 ) - return 0.0 ; - - /* get the wave output volume */ - result = waveOutGetVolume( (HWAVEOUT)( info->waveID ), &vol); - - /* on failure, mark waveID as invalid and return zero */ - if ( result != MMSYSERR_NOERROR ) - { - info->waveID = -1 ; - return 0.0 ; - } - - mono_vol = (unsigned short)vol; - return (PxVolume)mono_vol/65535.0F; + vol = -1.0; + VolumeFunction(info->hOutputMixer, info->waveID, &vol); + return vol; } void Px_SetPCMOutputVolume( PxMixer *mixer, PxVolume volume ) { - MMRESULT result; PxInfo *info = (PxInfo *)mixer; - /* invalid waveID */ - if ( info->waveID == -1 ) - return ; + VolumeFunction(info->hOutputMixer, info->waveID, &volume); +} - /* set the wave output volume */ - result = waveOutSetVolume( (HWAVEOUT)( info->waveID ), MAKELONG(volume*0xFFFF, volume*0xFFFF)); - /* on failure, mark waveID as invalid */ - if ( result != MMSYSERR_NOERROR ) - { - info->waveID = -1 ; - } - - return ; -} - /* All output volumes */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |