mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Fixed VolumeControl::getVolume() rounding bug on Windows.
This commit is contained in:
parent
07598b3d6f
commit
23d8856773
|
@ -284,7 +284,7 @@ int VolumeControl::getVolume() const
|
||||||
mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||||
if (mixerGetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR)
|
if (mixerGetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR)
|
||||||
{
|
{
|
||||||
volume = (uint8_t)((value.dwValue * 100) / 65535);
|
volume = (uint8_t)round((value.dwValue * 100) / 65535);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -297,7 +297,8 @@ int VolumeControl::getVolume() const
|
||||||
float floatVolume = 0.0f; //0-1
|
float floatVolume = 0.0f; //0-1
|
||||||
if (endpointVolume->GetMasterVolumeLevelScalar(&floatVolume) == S_OK)
|
if (endpointVolume->GetMasterVolumeLevelScalar(&floatVolume) == S_OK)
|
||||||
{
|
{
|
||||||
volume = (uint8_t)(floatVolume * 100.0f);
|
volume = (uint8_t)round(floatVolume * 100.0f);
|
||||||
|
LOG(LogInfo) << " getting volume as " << volume << " ( from float " << floatVolume << ")";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,7 +75,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
auto volume = std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%");
|
auto volume = std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%");
|
||||||
volume->setValue((float)VolumeControl::getInstance()->getVolume());
|
volume->setValue((float)VolumeControl::getInstance()->getVolume());
|
||||||
s->addWithLabel("SYSTEM VOLUME", volume);
|
s->addWithLabel("SYSTEM VOLUME", volume);
|
||||||
s->addSaveFunc([volume] { VolumeControl::getInstance()->setVolume((int)volume->getValue()); });
|
s->addSaveFunc([volume] { VolumeControl::getInstance()->setVolume((int)round(volume->getValue())); });
|
||||||
|
|
||||||
// disable sounds
|
// disable sounds
|
||||||
auto sounds_enabled = std::make_shared<SwitchComponent>(mWindow);
|
auto sounds_enabled = std::make_shared<SwitchComponent>(mWindow);
|
||||||
|
|
Loading…
Reference in a new issue