]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Change node_name default to "Shairport Sync", parameterise a few settings.
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Thu, 5 Oct 2023 15:40:42 +0000 (16:40 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Thu, 5 Oct 2023 15:40:42 +0000 (16:40 +0100)
audio_pw.c
scripts/shairport-sync.conf

index 0dd3893934317812117348db1c7a902c16845f99..f77b8766c9ec35c445423dadbf1c58ca4de6d9ac 100644 (file)
@@ -207,7 +207,7 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
         config.pw_application_name = (char *)str;
       }
 
-      /* Get the PulseAudio node name. */
+      /* Get the PipeWire node name. */
       if (config_lookup_string(config.cfg, "pa.node_name", &str)) {
         config.pw_node_name = (char *)str;
       }      
@@ -246,7 +246,7 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
   
   char* nodename = config.pw_node_name;
   if (nodename == NULL)
-    nodename = config.appName;
+    nodename = "Shairport Sync";
   
   
 
@@ -257,15 +257,15 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
   data.stream = pw_stream_new_simple(pw_thread_loop_get_loop(data.loop), config.appName, props,
                                      &stream_events, &data);
 
-  /* Make one parameter with the supported formats. The SPA_PARAM_EnumFormat
-   * id means that this is a format enumeration (of 1 value). */
+  // Make one parameter with the supported formats. The SPA_PARAM_EnumFormat
+  // id means that this is a format enumeration (of 1 value).
   params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat,
                                          &SPA_AUDIO_INFO_RAW_INIT(.format = DEFAULT_FORMAT,
                                                                   .channels = DEFAULT_CHANNELS,
                                                                   .rate = DEFAULT_RATE));
 
-  /* Now connect this stream. We ask that our process function is
-   * called in a realtime thread. */
+  // Now connect this stream. We ask that our process function is
+  // called in a realtime thread.
   pw_stream_connect(data.stream, PW_DIRECTION_OUTPUT, PW_ID_ANY,
                     PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS |
                         PW_STREAM_FLAG_RT_PROCESS,
@@ -284,7 +284,7 @@ static int play(__attribute__((unused)) void *buf, int samples,
                 __attribute__((unused)) uint64_t playtime) {
   // copy the samples into the queue
   debug(3, "play %u samples; %u bytes already in the buffer.", samples, audio_occupancy);
-  size_t bytes_to_transfer = samples * 2 * 2;
+  size_t bytes_to_transfer = samples * DEFAULT_CHANNELS * DEFAULT_BYTES_PER_SAMPLE;
   pthread_mutex_lock(&buffer_mutex);
   size_t bytes_available = audio_size - audio_occupancy;
   if (bytes_available < bytes_to_transfer)
@@ -351,11 +351,12 @@ int delay(long *the_delay) {
     */
 
   } else {
-    debug(1, "can't get time info.");
+    warn("Shairport Sync's PipeWire backend can not get timing information from the PipeWire "
+         "system. Is PipeWire running?");
   }
 
   pthread_mutex_lock(&buffer_mutex);
-  result = total_delay_now_frames_long + audio_occupancy / (2 * 2);
+  result = total_delay_now_frames_long + audio_occupancy / (DEFAULT_BYTES_PER_SAMPLE * DEFAULT_CHANNELS);
   pthread_mutex_unlock(&buffer_mutex);
   *the_delay = result;
   return reply;
index 001a88d267532ffa25a540d802defa437e0c72ca..cddffeb7276de400edfc984a761f21845d60baa3 100644 (file)
@@ -159,8 +159,8 @@ sndio =
 // --with-pw
 pw =
 {
-//     application_name = "Shairport Sync"; // Set this to the name that should appear in the Sounds "Applications".
-//     node_name = "<application-name>"; // This is normally "shairport-sync".
+//     application_name = "Shairport Sync"; // Set this to the name that should appear in the Sounds "Applications" or "Volume Levels".
+//     node_name = "Shairport Sync"; // This appears in some PipeWire CLI tool outputs
 };
 
 // Parameters for the "pa" PulseAudio  backend.