From: Mike Brady Date: Wed, 17 Aug 2016 18:59:26 +0000 (+0100) Subject: add ability to not use mmap X-Git-Tag: 2.8.4.6~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1e07b98d1f96d3caef0fb6d7f678857800bea07;p=thirdparty%2Fshairport-sync.git add ability to not use mmap --- diff --git a/audio_alsa.c b/audio_alsa.c index 76ab58c6..ad5b0c74 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -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; diff --git a/common.h b/common.h index a67f95b4..32ee301d 100644 --- 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; diff --git a/scripts/shairport-sync.conf b/scripts/shairport-sync.conf index 05840df9..bb737ee8 100644 --- a/scripts/shairport-sync.conf +++ b/scripts/shairport-sync.conf @@ -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 = ; // Use this optional advanced setting to set the alsa period size near to this value -// buffer_size = ; // 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. diff --git a/shairport.c b/shairport.c index df577348..72ea8d0c 100644 --- a/shairport.c +++ b/shairport.c @@ -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);