https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e2d8e588bb896635517dcfe0133cc4a482afea7f

commit e2d8e588bb896635517dcfe0133cc4a482afea7f
Author:     Eric Kohl <[email protected]>
AuthorDate: Mon Jan 28 00:59:33 2019 +0100
Commit:     Eric Kohl <[email protected]>
CommitDate: Mon Jan 28 00:59:33 2019 +0100

    [SNDVOL32] Do the volume trackbar calculation like it is done in mmsys.cpl.
---
 base/applications/sndvol32/dialog.c   | 19 +++++++++----------
 base/applications/sndvol32/mixer.c    |  2 +-
 base/applications/sndvol32/sndvol32.c | 14 ++++++--------
 base/applications/sndvol32/sndvol32.h |  3 ++-
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/base/applications/sndvol32/dialog.c 
b/base/applications/sndvol32/dialog.c
index ccaaf318f1..b3d52d57ed 100644
--- a/base/applications/sndvol32/dialog.c
+++ b/base/applications/sndvol32/dialog.c
@@ -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);
                                   }
                               }
                           }
diff --git a/base/applications/sndvol32/mixer.c 
b/base/applications/sndvol32/mixer.c
index 1f1be9451e..768aa658f5 100644
--- a/base/applications/sndvol32/mixer.c
+++ b/base/applications/sndvol32/mixer.c
@@ -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;
         }
diff --git a/base/applications/sndvol32/sndvol32.c 
b/base/applications/sndvol32/sndvol32.c
index 4e3523ff7f..5484a8357f 100644
--- a/base/applications/sndvol32/sndvol32.c
+++ b/base/applications/sndvol32/sndvol32.c
@@ -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;
diff --git a/base/applications/sndvol32/sndvol32.h 
b/base/applications/sndvol32/sndvol32.h
index cd0192de78..a68cb37778 100644
--- a/base/applications/sndvol32/sndvol32.h
+++ b/base/applications/sndvol32/sndvol32.h
@@ -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

Reply via email to