output/alsa: remove option "use_mmap"

MPD does not really take advantage of memory-mapped I/O by generating
data right into the ALSA buffer; using plain snd_pcm_mmap_writei() has
no advantage compared to snd_pcm_writei().  Let's kill this
non-feature.
This commit is contained in:
Max Kellermann 2016-02-28 09:30:59 +01:00
parent 111528e51c
commit 8ffcdb73e8
4 changed files with 9 additions and 56 deletions

1
NEWS
View File

@ -29,6 +29,7 @@ ver 0.20 (not yet released)
- flac: new plugin which reads the "CUESHEET" metadata block
* output
- alsa: fix multi-channel order
- alsa: remove option "use_mmap"
- jack: reduce CPU usage
- pulse: set channel map to WAVE-EX
- recorder: record tags

View File

@ -238,11 +238,6 @@ probably only useful if your alsa device has more than one
identically\-named mixer control. The default is "0". Use "amixer
scontrols" to see the list of controls with their indexes.
.TP
.B use_mmap <yes or no>
Setting this allows you to use memory-mapped I/O. Certain hardware setups may
benefit from this, but most do not. Most users do not need to set this. The
default is to not use memory-mapped I/O.
.TP
.B auto_resample <yes or no>
Setting this to "no" disables ALSA's software resampling, if the
hardware does not support a specific sample rate. This lets MPD do

View File

@ -2482,17 +2482,6 @@ buffer_size: 16384</programlisting>
...).
</entry>
</row>
<row>
<entry>
<varname>use_mmap</varname>
<parameter>yes|no</parameter>
</entry>
<entry>
If set to <parameter>yes</parameter>, then
<filename>libasound</filename> will try to use
memory mapped I/O.
</entry>
</row>
<row>
<entry>
<varname>buffer_time</varname>

View File

@ -50,9 +50,6 @@ static constexpr unsigned MPD_ALSA_BUFFER_TIME_US = 500000;
static constexpr unsigned MPD_ALSA_RETRY_NR = 5;
typedef snd_pcm_sframes_t alsa_writei_t(snd_pcm_t * pcm, const void *buffer,
snd_pcm_uframes_t size);
struct AlsaOutput {
AudioOutput base;
@ -64,9 +61,6 @@ struct AlsaOutput {
*/
std::string device;
/** use memory mapped I/O? */
bool use_mmap;
#ifdef ENABLE_DSD
/**
* Enable DSD over PCM according to the DoP standard standard?
@ -88,13 +82,6 @@ struct AlsaOutput {
/** the libasound PCM device handle */
snd_pcm_t *pcm;
/**
* a pointer to the libasound writei() function, which is
* snd_pcm_writei() or snd_pcm_mmap_writei(), depending on the
* use_mmap configuration
*/
alsa_writei_t *writei;
/**
* The size of one audio frame passed to method play().
*/
@ -136,7 +123,7 @@ struct AlsaOutput {
AlsaOutput()
:base(alsa_output_plugin),
mode(0), writei(snd_pcm_writei) {
mode(0) {
}
~AlsaOutput() {
@ -177,7 +164,7 @@ private:
* Write silence to the ALSA device.
*/
void WriteSilence(snd_pcm_uframes_t nframes) {
writei(pcm, silence, nframes);
snd_pcm_writei(pcm, silence, nframes);
}
};
@ -192,8 +179,6 @@ AlsaOutput::Configure(const ConfigBlock &block, Error &error)
device = block.GetBlockValue("device", "");
use_mmap = block.GetBlockValue("use_mmap", false);
#ifdef ENABLE_DSD
dop = block.GetBlockValue("dop", false) ||
/* legacy name from MPD 0.18 and older: */
@ -488,28 +473,11 @@ configure_hw:
if (err < 0)
goto error;
if (ad->use_mmap) {
err = snd_pcm_hw_params_set_access(ad->pcm, hwparams,
SND_PCM_ACCESS_MMAP_INTERLEAVED);
if (err < 0) {
FormatWarning(alsa_output_domain,
"Cannot set mmap'ed mode on ALSA device \"%s\": %s",
ad->GetDevice(), snd_strerror(-err));
LogWarning(alsa_output_domain,
"Falling back to direct write mode");
ad->use_mmap = false;
} else
ad->writei = snd_pcm_mmap_writei;
}
if (!ad->use_mmap) {
cmd = "snd_pcm_hw_params_set_access";
err = snd_pcm_hw_params_set_access(ad->pcm, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0)
goto error;
ad->writei = snd_pcm_writei;
}
cmd = "snd_pcm_hw_params_set_access";
err = snd_pcm_hw_params_set_access(ad->pcm, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0)
goto error;
err = alsa_output_setup_format(ad->pcm, hwparams, audio_format,
params);
@ -890,7 +858,7 @@ AlsaOutput::Play(const void *chunk, size_t size, Error &error)
assert(size > 0);
while (true) {
snd_pcm_sframes_t ret = writei(pcm, chunk, size);
snd_pcm_sframes_t ret = snd_pcm_writei(pcm, chunk, size);
if (ret > 0) {
period_position = (period_position + ret)
% period_frames;