]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add a 'stats' function to the audio back ends to replace the 'rate_info' function...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Sat, 20 Nov 2021 13:59:16 +0000 (13:59 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Sat, 20 Nov 2021 13:59:16 +0000 (13:59 +0000)
12 files changed:
audio.h
audio_alsa.c
audio_ao.c
audio_dummy.c
audio_jack.c
audio_pa.c
audio_pipe.c
audio_pw.c
audio_sndio.c
audio_soundio.c
audio_stdout.c
player.c

diff --git a/audio.h b/audio.h
index f6ddcd9e43de7ff708da8fb85e8fb03c569a1e45..ad574adb0e722bce5fb36cc3ee078c6534ca27a0 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -39,7 +39,7 @@ typedef struct {
   // will change dynamically, so keep watching it. Implemented in ALSA only.
   // returns a negative error code if there's a problem
   int (*delay)(long *the_delay); // snd_pcm_sframes_t is a signed long
-  int (*rate_info)(uint64_t *measurement_time, uint64_t *delay,
+  int (*stats)(uint64_t *measurement_time, uint64_t *delay,
                    uint64_t *frames_sent_to_dac); // use this to get the true rate of the DAC
 
   // may be NULL, in which case soft volume is applied
index 0e4268edbb05983b57e2b4c2a930743171b52a95..3fcbde6615c4a9ab5234bf252d8e3a8c6ba8e272 100644 (file)
@@ -60,7 +60,7 @@ static int play(void *buf, int samples);
 static void stop(void);
 static void flush(void);
 int delay(long *the_delay);
-int play_stats(uint64_t *the_time, uint64_t *the_delay, uint64_t *frames_sent_to_dac);
+int stats(uint64_t *the_time, uint64_t *the_delay, uint64_t *frames_sent_to_dac);
 // int get_rate_information(uint64_t *elapsed_time, uint64_t *frames_played);
 void *alsa_buffer_monitor_thread_code(void *arg);
 
@@ -89,7 +89,7 @@ audio_output audio_alsa = {
     .flush = &flush,
     .delay = &delay,
     .play = &play,
-    .rate_info = &play_stats, // will also include frames of silence sent to stop
+    .stats = &stats, // will also include frames of silence sent to stop
                                               // standby mode
                                               //    .rate_info = NULL,
     .mute = NULL,        // a function will be provided if it can, and is allowed to,
@@ -1629,7 +1629,7 @@ int delay(long *the_delay) {
   return ret;
 }
 
-int play_stats(uint64_t *the_time, uint64_t *the_delay, uint64_t *frames_sent_to_dac) {
+int stats(uint64_t *the_time, uint64_t *the_delay, uint64_t *frames_sent_to_dac) {
   // returns 0 if the device is in a valid state -- SND_PCM_STATE_RUNNING or
   // SND_PCM_STATE_PREPARED
   // or SND_PCM_STATE_DRAINING
index 38953b69cb28244f5ae7fa5df9515ec0eccae143..40a94fdccdc5ce09d8c601dd73b8e864fdd75c85 100644 (file)
@@ -135,6 +135,7 @@ audio_output audio_ao = {.name = "ao",
                          .is_running = NULL,
                          .flush = NULL,
                          .delay = NULL,
+                         .stats = NULL,
                          .play = &play,
                          .volume = NULL,
                          .parameters = NULL,
index 5d16bf95e57ad6b65b28e4dba16755ca2bc33968..70ea755e324375017c7784eea05c99375e4edebe 100644 (file)
@@ -58,6 +58,7 @@ audio_output audio_dummy = {.name = "dummy",
                             .is_running = NULL,
                             .flush = NULL,
                             .delay = NULL,
+                            .stats = NULL,
                             .play = &play,
                             .volume = NULL,
                             .parameters = NULL,
index 21c3e5431f609f8a20134ddf53ae643da04a07db..e87e16a3816f97f68009d32633102e743f23a3c0 100644 (file)
@@ -63,6 +63,7 @@ audio_output audio_jack = {.name = "jack",
                            .is_running = NULL,
                            .flush = &jack_flush,
                            .delay = &jack_delay,
+                           .stats = NULL,
                            .play = &play,
                            .volume = NULL,
                            .parameters = NULL,
index 951860beb8375533840572f2395ed143c824a20d..9d37bc606aa47f326de6b719f2efae97a45dd1b2 100644 (file)
@@ -315,6 +315,7 @@ audio_output audio_pa = {.name = "pa",
                          .is_running = NULL,
                          .flush = &flush,
                          .delay = &pa_delay,
+                         .stats = NULL,
                          .play = &play,
                          .volume = NULL,
                          .parameters = NULL,
index a7925fbc565c71f7f1a8803f557b1c1c3e94e613..fcece96be6a4c9e6c0d34a6a15d285ae0bbe3262 100644 (file)
@@ -151,6 +151,7 @@ audio_output audio_pipe = {.name = "pipe",
                            .is_running = NULL,
                            .flush = NULL,
                            .delay = NULL,
+                           .stats = NULL,
                            .play = &play,
                            .volume = NULL,
                            .parameters = NULL,
index f25c045609b3a434d9942b8665e48072497f875b..52e6a8824a1a9f93de8240cfc91db225a4316f09 100644 (file)
@@ -481,6 +481,7 @@ audio_output audio_pw = {.name = "pw",
                          .is_running = NULL,
                          .flush = &flush,
                          .delay = NULL,
+                         .stats = NULL,
                          .play = &play,
                          .volume = NULL,
                          .parameters = NULL,
index f8582c8abb06b55143505fc0a23d6e9be2214f95..e32c1f4d32884bada7ff4d94db666aaeaf6e6708 100644 (file)
@@ -49,6 +49,7 @@ audio_output audio_sndio = {.name = "sndio",
                             .is_running = NULL,
                             .flush = &flush,
                             .delay = &delay,
+                            .stats = NULL,
                             .play = &play,
                             .volume = NULL,
                             .parameters = NULL,
index 501c6db2dbe0b8c602f0cfda565680b8fa38e140..28108a9fbc544987320835fd6c22b1dde5a4adec 100644 (file)
@@ -216,6 +216,7 @@ audio_output audio_soundio = {.name = "soundio",
                               .is_running = NULL,
                               .flush = &flush,
                               .delay = NULL,
+                              .stats = NULL,
                               .play = &play,
                               .volume = NULL,
                               .parameters = &parameters,
index 8b37883e0d6405a70f8c59bf6f1f3f87e8a0f31d..61fdc744228de313c77959d41b3f183bef984890 100644 (file)
@@ -84,6 +84,7 @@ audio_output audio_stdout = {.name = "stdout",
                              .is_running = NULL,
                              .flush = NULL,
                              .delay = NULL,
+                             .stats = NULL,
                              .play = &play,
                              .volume = NULL,
                              .parameters = NULL,
index c6e360e81cdb3af7943dfd17a12781d99da9d266..bc2956e083c14b499c457606b329fea5f29568d3 100644 (file)
--- a/player.c
+++ b/player.c
@@ -2019,7 +2019,7 @@ void *player_thread_func(void *arg) {
     }
   } else {
 #endif
-    if (config.output->delay) {
+    if (config.output->stats) {
       if (config.no_sync == 0)
         statistics_print_profile = ap1_synced_statistics_print_profile;
       else
@@ -2311,15 +2311,15 @@ void *player_thread_func(void *arg) {
           }
 
           int stats_status = -1;
-          if ((config.output->delay) && (config.no_sync == 0) && (config.output->rate_info)) {
+          if ((config.output->delay) && (config.no_sync == 0) && (config.output->stats)) {
             uint64_t frames_sent_for_play;
             uint64_t measurement_time;
             uint64_t actual_delay;
-            stats_status = config.output->rate_info(&measurement_time, &actual_delay, &frames_sent_for_play);
+            stats_status = config.output->stats(&measurement_time, &actual_delay, &frames_sent_for_play);
             // debug(1,"actual_delay: %" PRIu64 ", frames_sent_for_play: %" PRIu64 ", frames_played: %" PRIu64 ".", actual_delay, frames_sent_for_play, frames_sent_for_play - actual_delay);
             uint64_t frames_played = frames_sent_for_play - actual_delay;
             // If the status is zero, it means that there were no output problems since the
-            // last time the rate_info call was made. Thus, the frame rate should be valid.
+            // last time the stats call was made. Thus, the frame rate should be valid.
             if ((stats_status == 0) && (previous_frames_played_valid)) {
               uint64_t frames_played_in_this_interval = frames_played - previous_frames_played;
               uint64_t interval = measurement_time - previous_frames_played_time;