lib/alsa/meson.build: require libasound 1.2 or later

This allows us to drop the 1.1.4 snd_pcm_drain() bug workaround (added
by commit f85d4d28d1).
This commit is contained in:
Max Kellermann 2024-07-29 15:41:26 +02:00
parent 3bef4f839a
commit 9c8f4aaf99
2 changed files with 2 additions and 37 deletions

View File

@ -3,7 +3,7 @@ if not is_linux
subdir_done() subdir_done()
endif endif
libasound_dep = dependency('alsa', version: '>= 1.1', required: get_option('alsa')) libasound_dep = dependency('alsa', version: '>= 1.2', required: get_option('alsa'))
if not libasound_dep.found() if not libasound_dep.found()
alsa_dep = dependency('', required: false) alsa_dep = dependency('', required: false)
subdir_done() subdir_done()

View File

@ -9,7 +9,6 @@
#include "lib/alsa/HwSetup.hxx" #include "lib/alsa/HwSetup.hxx"
#include "lib/alsa/NonBlock.hxx" #include "lib/alsa/NonBlock.hxx"
#include "lib/alsa/PeriodBuffer.hxx" #include "lib/alsa/PeriodBuffer.hxx"
#include "lib/alsa/Version.hxx"
#include "lib/fmt/RuntimeError.hxx" #include "lib/fmt/RuntimeError.hxx"
#include "lib/fmt/ToBuffer.hxx" #include "lib/fmt/ToBuffer.hxx"
#include "../OutputAPI.hxx" #include "../OutputAPI.hxx"
@ -175,17 +174,6 @@ class AlsaOutput final
bool need_thesycon_dsd_workaround = thesycon_dsd_workaround; bool need_thesycon_dsd_workaround = thesycon_dsd_workaround;
#endif #endif
/**
* Is this a buggy alsa-lib version, which needs a workaround
* for the snd_pcm_drain() bug always returning -EAGAIN? See
* alsa-lib commits fdc898d41135 and e4377b16454f for details.
* This bug was fixed in alsa-lib version 1.1.4.
*
* The workaround is to re-enable blocking mode for the
* snd_pcm_drain() call.
*/
bool work_around_drain_bug;
/** /**
* After Open() or Cancel(), has this output been activated by * After Open() or Cancel(), has this output been activated by
* a Play() command? * a Play() command?
@ -657,19 +645,6 @@ AlsaOutput::SetupOrDop(AudioFormat &audio_format, PcmExport::Params &params
#endif #endif
} }
static constexpr bool
MaybeDmix(snd_pcm_type_t type)
{
return type == SND_PCM_TYPE_DMIX || type == SND_PCM_TYPE_PLUG;
}
[[gnu::pure]]
static bool
MaybeDmix(snd_pcm_t *pcm) noexcept
{
return MaybeDmix(snd_pcm_type(pcm));
}
static const Alsa::AllowedFormat & static const Alsa::AllowedFormat &
BestMatch(const std::forward_list<Alsa::AllowedFormat> &haystack, BestMatch(const std::forward_list<Alsa::AllowedFormat> &haystack,
const AudioFormat &needle) const AudioFormat &needle)
@ -842,9 +817,6 @@ AlsaOutput::Open(AudioFormat &audio_format)
GetDevice())); GetDevice()));
} }
work_around_drain_bug = MaybeDmix(pcm) &&
GetRuntimeAlsaVersion() < MakeAlsaVersion(1, 1, 4);
snd_pcm_nonblock(pcm, 1); snd_pcm_nonblock(pcm, 1);
#ifdef ENABLE_DSD #ifdef ENABLE_DSD
@ -1058,14 +1030,7 @@ AlsaOutput::DrainInternal()
/* .. and finally drain the ALSA hardware buffer */ /* .. and finally drain the ALSA hardware buffer */
int result; const int result = snd_pcm_drain(pcm);
if (work_around_drain_bug) {
snd_pcm_nonblock(pcm, 0);
result = snd_pcm_drain(pcm);
snd_pcm_nonblock(pcm, 1);
} else
result = snd_pcm_drain(pcm);
if (result == 0) if (result == 0)
return true; return true;
else if (result == -EAGAIN) else if (result == -EAGAIN)