]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/waveout.c
FSF address change.
[vlc] / modules / audio_output / waveout.c
index 86ff0107f005572d706acb7afcd54baa7f0cb4ac..fbee1c0ab161c6a4326f17ac621d617cbc86ad74 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -26,7 +26,6 @@
  *****************************************************************************/
 #include <string.h>                                            /* strerror() */
 #include <stdlib.h>                            /* calloc(), malloc(), free() */
-#include <math.h>                                                /* roundf() */
 
 #include <vlc/vlc.h>
 #include <vlc/aout.h>
  *****************************************************************************/
 #ifdef UNDER_CE
 #   define DWORD_PTR DWORD
+#   ifdef waveOutGetDevCaps
+#       undef waveOutGetDevCaps
+        MMRESULT WINAPI waveOutGetDevCaps(UINT, LPWAVEOUTCAPS, UINT);
+#   endif
 #endif
 
 #ifndef WAVE_FORMAT_IEEE_FLOAT
@@ -251,6 +254,8 @@ static int Open( vlc_object_t *p_this )
     }
     else
     {
+        WAVEOUTCAPS wocaps;
+
         if( val.i_int == AOUT_VAR_5_1 )
         {
             p_aout->output.output.i_physical_channels
@@ -293,9 +298,20 @@ static int Open( vlc_object_t *p_this )
 
         aout_VolumeSoftInit( p_aout );
 
-        p_aout->output.pf_volume_infos = VolumeInfos;
-        p_aout->output.pf_volume_get = VolumeGet;
-        p_aout->output.pf_volume_set = VolumeSet;
+        /* Check for hardware volume support */
+        if( waveOutGetDevCaps( (UINT_PTR)p_aout->output.p_sys->h_waveout,
+                               &wocaps, sizeof(wocaps) ) == MMSYSERR_NOERROR &&
+            wocaps.dwSupport & WAVECAPS_VOLUME )
+        {
+            DWORD i_dummy;
+            if( waveOutGetVolume( p_aout->output.p_sys->h_waveout, &i_dummy )
+                == MMSYSERR_NOERROR )
+            {
+                p_aout->output.pf_volume_infos = VolumeInfos;
+                p_aout->output.pf_volume_get = VolumeGet;
+                p_aout->output.pf_volume_set = VolumeSet;
+            }
+        }
     }
 
 
@@ -801,11 +817,8 @@ static int VolumeGet( aout_instance_t * p_aout, audio_volume_t * pi_volume )
 #endif
 
     i_waveout_vol &= 0xFFFF;
-    /* Force float computation, otherwise VolumeGet does not return the value
-     * which was set with VolumeSet, because of rounding issues */
     *pi_volume = p_aout->output.i_volume =
-        (audio_volume_t)roundf((float)i_waveout_vol * AOUT_VOLUME_MAX
-                               / 2.0 / 0xFFFF);
+        (i_waveout_vol * AOUT_VOLUME_MAX + 0xFFFF /*rounding*/) / 2 / 0xFFFF;
     return 0;
 }