]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
add ability to not use mmap
authorMike Brady <mikebrady@eircom.net>
Wed, 17 Aug 2016 18:59:26 +0000 (19:59 +0100)
committerMike Brady <mikebrady@eircom.net>
Wed, 17 Aug 2016 18:59:26 +0000 (19:59 +0100)
audio_alsa.c
common.h
scripts/shairport-sync.conf
shairport.c

index 76ab58c6d9982d4ed4bfa72ce3eb9244ce220921..ad5b0c741a7289045c6359db2224e2be81b2de00 100644 (file)
@@ -205,6 +205,15 @@ static int init(int argc, char **argv) {
         die("Invalid disable_synchronization option choice \"%s\". It should be \"yes\" or \"no\"");
     }
     
+    /* Get the use_mmap_if_available setting. */
+    if (config_lookup_string(config.cfg, "alsa.use_mmap_if_available", &str)) {
+      if (strcasecmp(str, "no") == 0)
+        config.no_mmap = 1;
+      else if (strcasecmp(str, "yes") == 0)
+        config.no_mmap = 0;
+      else
+        die("Invalid use_mmap_if_available option choice \"%s\". It should be \"yes\" or \"no\"");
+    }
     /* Get the optional period size value */
     if (config_lookup_int(config.cfg, "alsa.period_size",
                           &value)) {
@@ -393,7 +402,7 @@ int open_alsa_device(void) {
         alsa_out_dev);
   }
 
-  if (snd_pcm_hw_params_set_access(alsa_handle, alsa_params, SND_PCM_ACCESS_MMAP_INTERLEAVED) >= 0) {
+  if ((config.no_mmap == 0) && (snd_pcm_hw_params_set_access(alsa_handle, alsa_params, SND_PCM_ACCESS_MMAP_INTERLEAVED) >= 0)) {
        if (output_method_signalled==0) {
                debug(1,"Output written using MMAP");
                output_method_signalled=1;
index a67f95b4b8a45e3716bd2ef5bda025cd2fd9e7af..32ee301d188da78a03d84ee2ddfaaa6dbb6e6be2 100644 (file)
--- a/common.h
+++ b/common.h
@@ -66,6 +66,7 @@ typedef struct {
   int udp_port_range;
   int ignore_volume_control;
   int no_sync; // disable synchronisation, even if it's available
+  int no_mmap; // disable use of mmap-based output, even if it's available
   int resyncthreshold; // if it get's out of whack my more than this, resync. Zero means never
                        // resync.
   int allow_session_interruption;
index 05840df9ef3152d4141bfe40fbeca7f311c2c19c..bb737ee84323216bc90a1bfa648f7a5bc8ff0dd4 100644 (file)
@@ -62,7 +62,7 @@ alsa =
 //  audio_backend_buffer_desired_length = 6615; // If set too small, buffer underflow occurs on low-powered machines. Too long and the response times with software mixer become annoying.
 //  disable_synchronization = "no"; // Set to "yes" to disable synchronization. Default is "no".
 //  period_size = <number>; // Use this optional advanced setting to set the alsa period size near to this value
-//  buffer_size = <number>; // Use this optional advanced setting to set the alsa buffer size near to this value
+//  use_mmap_if_available = "yes"; // Use this optional advanced setting to control whether MMAP-based output is used to communicate  with the DAC. Default is "yes"
 };
 
 // These are parameters for the "pipe" audio back end, a back end that directs raw CD-style audio output to a pipe. No interpolation is done.
index df577348c4ad4a537eb342caad78adaf30ad4901..72ea8d0c0cb0548f1f9642eef0c9ddccefbd81b7 100644 (file)
@@ -1012,6 +1012,7 @@ int main(int argc, char **argv) {
   debug(1, "ignore_volume_control is %d.", config.ignore_volume_control);
   debug(1, "playback_mode is %d (0-stereo, 1-mono).", config.playback_mode);
   debug(1, "disable_synchronization is %d.", config.no_sync);
+  debug(1, "use_mmap_if_available is %d.", config.no_mmap ? 0 : 1);
   debug(1, "audio backend desired buffer length is %d.",
         config.audio_backend_buffer_desired_length);
   debug(1, "audio backend latency offset is %d.", config.audio_backend_latency_offset);