]> code.delx.au - pulseaudio/blobdiff - src/modules/module-alsa-sink.c
Merge branch 'master' of ssh://rootserver/home/lennart/git/public/pulseaudio
[pulseaudio] / src / modules / module-alsa-sink.c
index 95a8c97249b573c47d2483c3f1a928e8659bd055..f9fb9bd5d53f0d600964a1d52a674c93e1c0d694 100644 (file)
@@ -599,9 +599,9 @@ static int update_sw_params(struct userdata *u) {
             u->hwbuf_unused_frames = (snd_pcm_sframes_t)
                 (PA_LIKELY(b < u->hwbuf_size) ?
                  ((u->hwbuf_size - b) / u->frame_size) : 0);
-
-            fix_tsched_watermark(u);
         }
+
+        fix_tsched_watermark(u);
     }
 
     pa_log_debug("hwbuf_unused_frames=%lu", (unsigned long) u->hwbuf_unused_frames);
@@ -1506,28 +1506,35 @@ int pa__init(pa_module*m) {
                 suitable = TRUE;
             }
 
-            if (snd_mixer_selem_get_playback_dB_range(u->mixer_elem, &u->hw_dB_min, &u->hw_dB_max) < 0)
-                pa_log_info("Mixer doesn't support dB information.");
-            else {
+            if (suitable) {
+                if (snd_mixer_selem_get_playback_dB_range(u->mixer_elem, &u->hw_dB_min, &u->hw_dB_max) < 0)
+                    pa_log_info("Mixer doesn't support dB information.");
+                else {
 #ifdef HAVE_VALGRIND_MEMCHECK_H
-                VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_min, sizeof(u->hw_dB_min));
-                VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
+                    VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_min, sizeof(u->hw_dB_min));
+                    VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
 #endif
 
-                if (u->hw_dB_min >= u->hw_dB_max)
-                    pa_log_warn("Your kernel driver is broken: it reports a volume range from %0.2f dB to %0.2f dB which makes no sense.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
-                else {
-                    pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
-                    u->hw_dB_supported = TRUE;
+                    if (u->hw_dB_min >= u->hw_dB_max)
+                        pa_log_warn("Your kernel driver is broken: it reports a volume range from %0.2f dB to %0.2f dB which makes no sense.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
+                    else {
+                        pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
+                        u->hw_dB_supported = TRUE;
+
+                        if (u->hw_dB_max > 0) {
+                            u->sink->base_volume = pa_sw_volume_from_dB(- (double) u->hw_dB_max/100.0);
+                            pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->sink->base_volume));
+                        } else
+                            pa_log_info("No particular base volume set, fixing to 0 dB");
+                    }
                 }
-            }
 
-            if (suitable &&
-                !u->hw_dB_supported &&
-                u->hw_volume_max - u->hw_volume_min < 3) {
+                if (!u->hw_dB_supported &&
+                    u->hw_volume_max - u->hw_volume_min < 3) {
 
-                pa_log_info("Device doesn't do dB volume and has less than 4 volume levels. Falling back to software volume control.");
-                suitable = FALSE;
+                    pa_log_info("Device doesn't do dB volume and has less than 4 volume levels. Falling back to software volume control.");
+                    suitable = FALSE;
+                }
             }
 
             if (suitable) {