]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Disable using linear mixer scale for the time being.
authorMike Brady <mikebrady@eircom.net>
Sat, 3 Oct 2015 20:33:10 +0000 (21:33 +0100)
committerMike Brady <mikebrady@eircom.net>
Sat, 3 Oct 2015 20:33:10 +0000 (21:33 +0100)
audio_alsa.c
player.c

index 7a3fe45e5381f4c7bc841ca919d47753083ec82e..e050e88a7028c903a62101e6ce9b8733a2922a41 100644 (file)
@@ -236,7 +236,8 @@ static int init(int argc, char **argv) {
             (1.0 * alsa_mix_maxdb) / 100.0);
     } else {
       // use the linear scale and do the db conversion ourselves
-      debug(1, "note: the hardware mixer specified -- \"%s\" -- does not have dB volume -- using the [hopefully] linear settings.",alsa_mix_ctrl);
+      debug(1, "note: the hardware mixer specified -- \"%s\" -- does not have a dB volume scale, so it can't be used.",alsa_mix_ctrl);
+      /*
       debug(1, "Min and max volumes are %d and %d.",alsa_mix_minv,alsa_mix_maxv);
       alsa_mix_maxdb = 0;
       if ((alsa_mix_maxv!=0) && (alsa_mix_minv!=0))
@@ -246,6 +247,7 @@ static int init(int argc, char **argv) {
       audio_alsa.volume = &linear_volume; // insert the linear volume function
       audio_alsa.parameters = &parameters; // likewise the parameters stuff
       debug(1,"Max and min dB calculated are %d and %d.",alsa_mix_maxdb,alsa_mix_mindb);
+      */
      }
   }
   if (snd_mixer_selem_has_playback_switch(alsa_mix_elem)) {
@@ -409,6 +411,7 @@ static void parameters(audio_parameters *info) {
 }
 
 static void volume(double vol) {
+  // debug(1,"Volume called %f.",vol);
   set_volume = vol;
   double vol_setting = vol2attn(vol, alsa_mix_maxdb, alsa_mix_mindb);
   // debug(1,"Setting volume db to %f, for volume input of %f.",vol_setting/100,vol);
index b7224e5eeeebfc3a8a9e3ecc4e8ae67fe0f01320..c28ad726def51c40c5eb84f8bb2728310e2330b3 100644 (file)
--- a/player.c
+++ b/player.c
@@ -492,12 +492,12 @@ static abuf_t *buffer_get_frame(void) {
 
       if (curframe->ready) {
         if (ab_buffering) { // if we are getting packets but not yet forwarding them to the player
+          uint32_t reference_timestamp;
+          uint64_t reference_timestamp_time,remote_reference_timestamp_time;
+          get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time, &remote_reference_timestamp_time);
           if (first_packet_timestamp == 0) { // if this is the very first packet
             // debug(1,"First frame seen, time %u, with %d
             // frames...",curframe->timestamp,seq_diff(ab_read, ab_write));
-            uint32_t reference_timestamp;
-            uint64_t reference_timestamp_time,remote_reference_timestamp_time;
-            get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time, &remote_reference_timestamp_time);
             if (reference_timestamp) { // if we have a reference time
               // debug(1,"First frame seen with timestamp...");
               first_packet_timestamp = curframe->timestamp; // we will keep buffering until we are
@@ -527,7 +527,6 @@ static abuf_t *buffer_get_frame(void) {
               // -4410 frames.
 
               int64_t delta = ((int64_t)first_packet_timestamp - (int64_t)reference_timestamp);
-
               first_packet_time_to_play =
                   reference_timestamp_time +
                   ((delta + (int64_t)config.latency + (int64_t)config.audio_backend_latency_offset)
@@ -544,6 +543,13 @@ static abuf_t *buffer_get_frame(void) {
           }
 
           if (first_packet_time_to_play != 0) {
+            // recalculate first_packet_time_to_play -- the latency might change
+            int64_t delta = ((int64_t)first_packet_timestamp - (int64_t)reference_timestamp);
+            first_packet_time_to_play =
+                reference_timestamp_time +
+                ((delta + (int64_t)config.latency + (int64_t)config.audio_backend_latency_offset)
+                 << 32) /
+                    44100;
 
             uint32_t filler_size = frame_size;
             uint32_t max_dac_delay = 4410;
@@ -1210,12 +1216,13 @@ void player_volume(double f) {
   // it back to a number.
 
   double scaled_volume = vol2attn(f, 0, -9630);
-  double linear_volume = pow(10, scaled_volume / 20*100);
+  double linear_volume = pow(10, scaled_volume / 2000);
 
   if (f == -144.0)
     linear_volume = 0.0;
 
   if (config.output->volume) {
+    // debug(1,"Set volume to %f.",f);
     config.output->volume(f); // volume will be sent as metadata by the config.output device
     linear_volume = 1.0; // no attenuation needed -- this value is used as a flag to avoid calculations
   }
@@ -1231,6 +1238,7 @@ void player_volume(double f) {
     audio_information.is_muted = 0;
   }
   audio_information.valid = 1;
+  // debug(1,"Software volume set to %f on scale with a %f dB",f,linear_volume);
   pthread_mutex_lock(&vol_mutex);
   software_mixer_volume = linear_volume;
   fix_volume = 65536.0 * software_mixer_volume;