mirror of
https://github.com/reactos/reactos.git
synced 2025-01-02 12:32:47 +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 */
|
/* Vertical trackbar: Volume */
|
||||||
|
|
||||||
/* set up range */
|
/* 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 */
|
/* set up page size */
|
||||||
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)VOLUME_PAGE_SIZE);
|
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)VOLUME_PAGE_SIZE);
|
||||||
|
@ -184,10 +184,10 @@ AddDialogControl(
|
||||||
SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)0);
|
SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)0);
|
||||||
|
|
||||||
/* Calculate and set ticks */
|
/* Calculate and set ticks */
|
||||||
nSteps = (VOLUME_STEPS / (VOLUME_TICKS + 1));
|
nSteps = (VOLUME_MAX / (VOLUME_TICKS + 1));
|
||||||
if (VOLUME_STEPS % (VOLUME_TICKS + 1) != 0)
|
if (VOLUME_MAX % (VOLUME_TICKS + 1) != 0)
|
||||||
nSteps++;
|
nSteps++;
|
||||||
for (i = nSteps; i < VOLUME_STEPS; i += nSteps)
|
for (i = nSteps; i < VOLUME_MAX; i += nSteps)
|
||||||
SendMessage(hwnd, TBM_SETTIC, 0, (LPARAM)i);
|
SendMessage(hwnd, TBM_SETTIC, 0, (LPARAM)i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -449,7 +449,7 @@ EnumConnectionsCallback(
|
||||||
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) != FALSE)
|
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) != FALSE)
|
||||||
{
|
{
|
||||||
/* now go through all controls and update their states */
|
/* 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)
|
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)
|
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
||||||
{
|
{
|
||||||
/* update dialog control */
|
/* update dialog control */
|
||||||
DWORD Position;
|
DWORD Position, Step;
|
||||||
DWORD Step = 0x10000 / VOLUME_STEPS;
|
|
||||||
|
|
||||||
/* FIXME: give me granularity */
|
Step = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
|
||||||
Position = VOLUME_STEPS - (Details.dwValue / Step);
|
Position = (Details.dwValue - Control[Index].Bounds.dwMinimum) / Step;
|
||||||
|
|
||||||
/* FIXME support left - right slider */
|
/* FIXME support left - right slider */
|
||||||
wID = (PrefContext->Count + 1) * IDC_LINE_SLIDER_VERT;
|
wID = (PrefContext->Count + 1) * IDC_LINE_SLIDER_VERT;
|
||||||
|
@ -502,7 +501,7 @@ EnumConnectionsCallback(
|
||||||
if (OldPosition != Position)
|
if (OldPosition != Position)
|
||||||
{
|
{
|
||||||
/* update control state */
|
/* 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.cbDetails = cbDetails;
|
||||||
MixerDetails.paDetails = paDetails;
|
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;
|
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)
|
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
||||||
{
|
{
|
||||||
/* FIXME: give me granularity */
|
DWORD Step = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
|
||||||
DWORD Step = 0x10000 / VOLUME_STEPS;
|
|
||||||
|
|
||||||
/* set up details */
|
/* set up details */
|
||||||
uDetails.dwValue = 0x10000 - Step * Context->SliderPos;
|
uDetails.dwValue = ((VOLUME_MAX - Context->SliderPos) * Step) + Control[Index].Bounds.dwMinimum;
|
||||||
|
|
||||||
/* set volume */
|
/* set volume */
|
||||||
SndMixerSetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&uDetails);
|
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)
|
if (SndMixerGetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
||||||
{
|
{
|
||||||
/* update dialog control */
|
/* update dialog control */
|
||||||
DWORD Position;
|
DWORD Position, Step;
|
||||||
DWORD Step = 0x10000 / VOLUME_STEPS;
|
|
||||||
|
|
||||||
/* FIXME: give me granularity */
|
Step = (Control[Index].Bounds.dwMaximum - Control[Index].Bounds.dwMinimum) / (VOLUME_MAX - VOLUME_MIN);
|
||||||
Position = VOLUME_STEPS - (Details.dwValue / Step);
|
Position = (Details.dwValue - Control[Index].Bounds.dwMinimum) / Step;
|
||||||
|
|
||||||
/* update volume control slider */
|
/* 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;
|
break;
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
|
||||||
#define VOLUME_STEPS 500
|
#define VOLUME_MIN 0
|
||||||
|
#define VOLUME_MAX 500
|
||||||
#define VOLUME_TICKS 5
|
#define VOLUME_TICKS 5
|
||||||
#define VOLUME_PAGE_SIZE 100
|
#define VOLUME_PAGE_SIZE 100
|
||||||
#define BALANCE_STEPS 64
|
#define BALANCE_STEPS 64
|
||||||
|
|
Loading…
Reference in a new issue