mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
[SNDVOL32] Do the volume trackbar calculation like it is done in mmsys.cpl.
This commit is contained in:
parent
dfa5ff553b
commit
e2d8e588bb
4 changed files with 18 additions and 20 deletions
|
@ -175,7 +175,7 @@ AddDialogControl(
|
|||
/* Vertical trackbar: Volume */
|
||||
|
||||
/* set up range */
|
||||
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, VOLUME_STEPS));
|
||||
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(VOLUME_MIN, VOLUME_MAX));
|
||||
|
||||
/* set up page size */
|
||||
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)VOLUME_PAGE_SIZE);
|
||||
|
@ -184,10 +184,10 @@ AddDialogControl(
|
|||
SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)0);
|
||||
|
||||
/* Calculate and set ticks */
|
||||
nSteps = (VOLUME_STEPS / (VOLUME_TICKS + 1));
|
||||
if (VOLUME_STEPS % (VOLUME_TICKS + 1) != 0)
|
||||
nSteps = (VOLUME_MAX / (VOLUME_TICKS + 1));
|
||||
if (VOLUME_MAX % (VOLUME_TICKS + 1) != 0)
|
||||
nSteps++;
|
||||
for (i = nSteps; i < VOLUME_STEPS; i += nSteps)
|
||||
for (i = nSteps; i < VOLUME_MAX; i += nSteps)
|
||||
SendMessage(hwnd, TBM_SETTIC, 0, (LPARAM)i);
|
||||
}
|
||||
else
|
||||
|
@ -449,7 +449,7 @@ EnumConnectionsCallback(
|
|||
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) != FALSE)
|
||||
{
|
||||
/* now go through all controls and update their states */
|
||||
for(Index = 0; Index < Line->cControls; Index++)
|
||||
for (Index = 0; Index < Line->cControls; Index++)
|
||||
{
|
||||
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
|
||||
{
|
||||
|
@ -483,11 +483,10 @@ EnumConnectionsCallback(
|
|||
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
||||
{
|
||||
/* update dialog control */
|
||||
DWORD Position;
|
||||
DWORD Step = 0x10000 / VOLUME_STEPS;
|
||||
DWORD Position, Step;
|
||||
|
||||
/* FIXME: give me granularity */
|
||||
Position = VOLUME_STEPS - (Details.dwValue / Step);
|
||||
Step = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
|
||||
Position = (Details.dwValue - Control[Index].Bounds.dwMinimum) / Step;
|
||||
|
||||
/* FIXME support left - right slider */
|
||||
wID = (PrefContext->Count + 1) * IDC_LINE_SLIDER_VERT;
|
||||
|
@ -502,7 +501,7 @@ EnumConnectionsCallback(
|
|||
if (OldPosition != Position)
|
||||
{
|
||||
/* update control state */
|
||||
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, Position + Index);
|
||||
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, VOLUME_MAX - Position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ SndMixerSetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cbDet
|
|||
MixerDetails.cbDetails = cbDetails;
|
||||
MixerDetails.paDetails = paDetails;
|
||||
|
||||
if (mixerSetControlDetails((HMIXEROBJ)Mixer->hmx, &MixerDetails, MIXER_GETCONTROLDETAILSF_VALUE | MIXER_OBJECTF_HMIXER) == MMSYSERR_NOERROR)
|
||||
if (mixerSetControlDetails((HMIXEROBJ)Mixer->hmx, &MixerDetails, MIXER_SETCONTROLDETAILSF_VALUE | MIXER_OBJECTF_HMIXER) == MMSYSERR_NOERROR)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -657,11 +657,10 @@ SetVolumeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Ctx)
|
|||
{
|
||||
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
||||
{
|
||||
/* FIXME: give me granularity */
|
||||
DWORD Step = 0x10000 / VOLUME_STEPS;
|
||||
DWORD Step = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
|
||||
|
||||
/* set up details */
|
||||
uDetails.dwValue = 0x10000 - Step * Context->SliderPos;
|
||||
uDetails.dwValue = ((VOLUME_MAX - Context->SliderPos) * Step) + Control[Index].Bounds.dwMinimum;
|
||||
|
||||
/* set volume */
|
||||
SndMixerSetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&uDetails);
|
||||
|
@ -745,14 +744,13 @@ MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVO
|
|||
if (SndMixerGetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
||||
{
|
||||
/* update dialog control */
|
||||
DWORD Position;
|
||||
DWORD Step = 0x10000 / VOLUME_STEPS;
|
||||
DWORD Position, Step;
|
||||
|
||||
/* FIXME: give me granularity */
|
||||
Position = VOLUME_STEPS - (Details.dwValue / Step);
|
||||
Step = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
|
||||
Position = (Details.dwValue - Control[Index].Bounds.dwMinimum) / Step;
|
||||
|
||||
/* update volume control slider */
|
||||
UpdateDialogLineSliderControl(&Preferences, Line, Control[Index].dwControlID, IDC_LINE_SLIDER_VERT, Position);
|
||||
UpdateDialogLineSliderControl(&Preferences, Line, Control[Index].dwControlID, IDC_LINE_SLIDER_VERT, VOLUME_MAX - Position);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
#include "resources.h"
|
||||
|
||||
#define VOLUME_STEPS 500
|
||||
#define VOLUME_MIN 0
|
||||
#define VOLUME_MAX 500
|
||||
#define VOLUME_TICKS 5
|
||||
#define VOLUME_PAGE_SIZE 100
|
||||
#define BALANCE_STEPS 64
|
||||
|
|
Loading…
Reference in a new issue