Beispiel #1
0
static void PlatGetCDDAVolumeControl(void)
{
	MMRESULT mmres;
	unsigned int numAuxDevs,i;
	
	numAuxDevs = auxGetNumDevs();
	/* search the auxilary device list for the cd player */
	for(i=0;i<numAuxDevs;i++)
	{
		AUXCAPS devCaps;
		mmres = auxGetDevCaps(i,&devCaps,sizeof(AUXCAPS));
		if(mmres==MMSYSERR_NOERROR)
		{
			if((devCaps.wTechnology&AUXCAPS_CDAUDIO)&&(devCaps.dwSupport&AUXCAPS_VOLUME))
			{								
						cdAuxDeviceID = i;					
			}
		}
	}
}
Beispiel #2
0
void CD_FindCDAux(void)
{
	UINT NumDevs,counter;
	MMRESULT Result;
	AUXCAPS Caps;

	CD_ID = -1;
	if (!COM_CheckParm("-usecdvolume"))
		return;
	NumDevs = auxGetNumDevs();
	for(counter=0;counter<NumDevs;counter++)
	{
		Result = auxGetDevCaps(counter,&Caps,sizeof(Caps));
		if (!Result) // valid
		{
			if (Caps.wTechnology == AUXCAPS_CDAUDIO)
			{
				CD_ID = counter;
				auxGetVolume(CD_ID,&CD_OrigVolume);
				return;
			}
		}
	}
}
void Win32RedBookDevice::openVolume()
{
   setLastError("");

   // first attempt to get the volume control through the mixer API
   S32 i;
   for(i = mixerGetNumDevs() - 1; i >= 0; i--)
   {
      // open the mixer
      if(mixerOpen((HMIXER*)&mVolumeDeviceId, i, 0, 0, 0) == MMSYSERR_NOERROR)
      {
         MIXERLINE lineInfo;
         memset(&lineInfo, 0, sizeof(lineInfo));
         lineInfo.cbStruct = sizeof(lineInfo);
         lineInfo.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC;

         // get the cdaudio line
         if(mixerGetLineInfo(mVolumeDeviceId, &lineInfo, MIXER_GETLINEINFOF_COMPONENTTYPE) == MMSYSERR_NOERROR)
         {
            MIXERLINECONTROLS lineControls;
            MIXERCONTROL volumeControl;

            memset(&lineControls, 0, sizeof(lineControls));
            lineControls.cbStruct = sizeof(lineControls);
            lineControls.dwLineID = lineInfo.dwLineID;
            lineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
            lineControls.cControls = 1;
            lineControls.cbmxctrl = sizeof(volumeControl);
            lineControls.pamxctrl = &volumeControl;

            memset(&volumeControl, 0, sizeof(volumeControl));
            volumeControl.cbStruct = sizeof(volumeControl);

            // get the volume control
            if(mixerGetLineControls(mVolumeDeviceId, &lineControls, MIXER_GETLINECONTROLSF_ONEBYTYPE) == MMSYSERR_NOERROR)
            {
               memset(&mMixerVolumeDetails, 0, sizeof(mMixerVolumeDetails));
               mMixerVolumeDetails.cbStruct = sizeof(mMixerVolumeDetails);
               mMixerVolumeDetails.dwControlID = volumeControl.dwControlID;
               mMixerVolumeDetails.cChannels = 1;
               mMixerVolumeDetails.cbDetails = sizeof(mMixerVolumeValue);
               mMixerVolumeDetails.paDetails = &mMixerVolumeValue;

               memset(&mMixerVolumeValue, 0, sizeof(mMixerVolumeValue));

               // query the current value
               if(mixerGetControlDetails(mVolumeDeviceId, &mMixerVolumeDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR)
               {
                  mUsingMixer = true;
                  mVolumeInitialized = true;
                  mOriginalVolume = mMixerVolumeValue.dwValue;
                  return;
               }
            }
         }
      }

      mixerClose((HMIXER)mVolumeDeviceId);
   }

   // try aux
   for(i = auxGetNumDevs() - 1; i >= 0; i--)
   {
      AUXCAPS caps;
      auxGetDevCaps(i, &caps, sizeof(AUXCAPS));
      if((caps.wTechnology == AUXCAPS_CDAUDIO) && (caps.dwSupport & AUXCAPS_VOLUME))
      {
         mAuxVolumeDeviceId = i;
         mVolumeInitialized = true;
         mUsingMixer = false;
         auxGetVolume(i, (unsigned long *)&mOriginalVolume);
         return;
      }
   }

   setLastError("Volume failed to initialize");
}