mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 05:35:40 +00:00
[AUDIO] Implement volume control support (#6922)
Implement volume level changing for Aux/MidiOut/WaveOut devices. It's represented the following WINMM functions: - auxGetVolume, - auxSetVolume, - midiOutGetVolume, - midiOutSetVolume, - waveOutGetVolume, - waveOutSetVolume, which are calling the followind messages appropriately: - AUXDM_GETVOLUME, - AUXDM_SETVOLUME, - MODM_GETVOLUME, - MODM_SETVOLUME, - WODM_GETVOLUME, - WODM_SETVOLUME. This fixes volume control for several 3rd-party programs (like Fox Audio Player 0.10.2 from Rapps, Winamp 2.95 with WaveOut plugin). However it does not fix changing the volume in system volume mixers (SndVol32, MMSys), since they are using their own functionality instead. They technically do the same things, but apart from the functions mentioned above. CORE-14780
This commit is contained in:
parent
e1db293f12
commit
9046cc97ee
9 changed files with 323 additions and 0 deletions
|
@ -45,6 +45,24 @@ auxMessage(
|
|||
Parameter2);
|
||||
break;
|
||||
}
|
||||
|
||||
case AUXDM_GETVOLUME:
|
||||
{
|
||||
Result = MmeGetVolume(AUX_DEVICE_TYPE,
|
||||
DeviceId,
|
||||
PrivateHandle,
|
||||
Parameter1);
|
||||
break;
|
||||
}
|
||||
|
||||
case AUXDM_SETVOLUME:
|
||||
{
|
||||
Result = MmeSetVolume(AUX_DEVICE_TYPE,
|
||||
DeviceId,
|
||||
PrivateHandle,
|
||||
Parameter1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SND_TRACE(L"auxMessage returning MMRESULT %d\n", Result);
|
||||
|
|
|
@ -75,6 +75,23 @@ modMessage(
|
|||
break;
|
||||
}
|
||||
|
||||
case MODM_GETVOLUME:
|
||||
{
|
||||
Result = MmeGetVolume(MIDI_OUT_DEVICE_TYPE,
|
||||
DeviceId,
|
||||
PrivateHandle,
|
||||
Parameter1);
|
||||
break;
|
||||
}
|
||||
|
||||
case MODM_SETVOLUME:
|
||||
{
|
||||
Result = MmeSetVolume(MIDI_OUT_DEVICE_TYPE,
|
||||
DeviceId,
|
||||
PrivateHandle,
|
||||
Parameter1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SND_TRACE(L"modMessage returning MMRESULT %d\n", Result);
|
||||
|
|
|
@ -365,3 +365,82 @@ MmeGetPosition(
|
|||
return Result;
|
||||
}
|
||||
|
||||
MMRESULT
|
||||
MmeGetVolume(
|
||||
_In_ MMDEVICE_TYPE DeviceType,
|
||||
_In_ DWORD DeviceId,
|
||||
_In_ DWORD_PTR PrivateHandle,
|
||||
_Out_ DWORD_PTR pdwVolume)
|
||||
{
|
||||
MMRESULT Result;
|
||||
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
|
||||
PSOUND_DEVICE SoundDevice;
|
||||
PMMFUNCTION_TABLE FunctionTable;
|
||||
|
||||
/* Sanity check */
|
||||
SND_ASSERT(DeviceType == AUX_DEVICE_TYPE ||
|
||||
DeviceType == MIDI_OUT_DEVICE_TYPE ||
|
||||
DeviceType == WAVE_OUT_DEVICE_TYPE);
|
||||
|
||||
VALIDATE_MMSYS_PARAMETER(PrivateHandle);
|
||||
SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE)PrivateHandle;
|
||||
|
||||
if (!IsValidSoundDeviceInstance(SoundDeviceInstance))
|
||||
return MMSYSERR_INVALHANDLE;
|
||||
|
||||
Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
|
||||
if (!MMSUCCESS(Result))
|
||||
return TranslateInternalMmResult(Result);
|
||||
|
||||
Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
|
||||
if (!MMSUCCESS(Result))
|
||||
return TranslateInternalMmResult(Result);
|
||||
|
||||
if (!FunctionTable->GetVolume)
|
||||
return MMSYSERR_NOTSUPPORTED;
|
||||
|
||||
/* Call the driver */
|
||||
Result = FunctionTable->GetVolume(SoundDeviceInstance, DeviceId, (PDWORD)pdwVolume);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
MMRESULT
|
||||
MmeSetVolume(
|
||||
_In_ MMDEVICE_TYPE DeviceType,
|
||||
_In_ DWORD DeviceId,
|
||||
_In_ DWORD_PTR PrivateHandle,
|
||||
_In_ DWORD_PTR dwVolume)
|
||||
{
|
||||
MMRESULT Result;
|
||||
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
|
||||
PSOUND_DEVICE SoundDevice;
|
||||
PMMFUNCTION_TABLE FunctionTable;
|
||||
|
||||
/* Sanity check */
|
||||
SND_ASSERT(DeviceType == AUX_DEVICE_TYPE ||
|
||||
DeviceType == MIDI_OUT_DEVICE_TYPE ||
|
||||
DeviceType == WAVE_OUT_DEVICE_TYPE);
|
||||
|
||||
VALIDATE_MMSYS_PARAMETER(PrivateHandle);
|
||||
SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE)PrivateHandle;
|
||||
|
||||
if (!IsValidSoundDeviceInstance(SoundDeviceInstance))
|
||||
return MMSYSERR_INVALHANDLE;
|
||||
|
||||
Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
|
||||
if (!MMSUCCESS(Result))
|
||||
return TranslateInternalMmResult(Result);
|
||||
|
||||
Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
|
||||
if (!MMSUCCESS(Result))
|
||||
return TranslateInternalMmResult(Result);
|
||||
|
||||
if (!FunctionTable->SetVolume)
|
||||
return MMSYSERR_NOTSUPPORTED;
|
||||
|
||||
/* Call the driver */
|
||||
Result = FunctionTable->SetVolume(SoundDeviceInstance, DeviceId, (DWORD)dwVolume);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,24 @@ wodMessage(
|
|||
break;
|
||||
}
|
||||
|
||||
case WODM_GETVOLUME:
|
||||
{
|
||||
Result = MmeGetVolume(WAVE_OUT_DEVICE_TYPE,
|
||||
DeviceId,
|
||||
PrivateHandle,
|
||||
Parameter1);
|
||||
break;
|
||||
}
|
||||
|
||||
case WODM_SETVOLUME:
|
||||
{
|
||||
Result = MmeSetVolume(WAVE_OUT_DEVICE_TYPE,
|
||||
DeviceId,
|
||||
PrivateHandle,
|
||||
Parameter1);
|
||||
break;
|
||||
}
|
||||
|
||||
case DRV_QUERYDEVICEINTERFACESIZE :
|
||||
{
|
||||
Result = MmeGetDeviceInterfaceString(WAVE_OUT_DEVICE_TYPE, DeviceId, NULL, 0, (DWORD*)Parameter1); //FIXME DWORD_PTR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue