lib/alsa: require alsa-lib 1.1 or later

This commit is contained in:
Max Kellermann 2023-03-10 12:43:29 +01:00
parent 43b26ee612
commit 1410bcbce9
4 changed files with 4 additions and 23 deletions

1
NEWS
View File

@ -27,6 +27,7 @@ ver 0.24 (not yet released)
* tags
- new tags "TitleSort", "Mood"
* output
- alsa: require alsa-lib 1.1 or later
- pipewire: fix corruption bug due to missing lock
- pipewire: map tags "Date" and "Comment"
* switch to C++20

View File

@ -1,27 +1,15 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#ifndef MPD_ALSA_FORMAT_HXX
#define MPD_ALSA_FORMAT_HXX
#pragma once
#include "pcm/SampleFormat.hxx"
#include "util/Compiler.h"
#include "config.h"
#include <alsa/asoundlib.h>
#include <cassert>
#if SND_LIB_VERSION >= 0x1001c
/* alsa-lib supports DSD since version 1.0.27.1 */
#define HAVE_ALSA_DSD
#endif
#if SND_LIB_VERSION >= 0x1001d
/* alsa-lib supports DSD_U32 since version 1.0.29 */
#define HAVE_ALSA_DSD_U32
#endif
/**
* Convert MPD's #SampleFormat enum to libasound's snd_pcm_format_t
* enum. Returns SND_PCM_FORMAT_UNKNOWN if there is no according ALSA
@ -36,11 +24,7 @@ ToAlsaPcmFormat(SampleFormat sample_format) noexcept
return SND_PCM_FORMAT_UNKNOWN;
case SampleFormat::DSD:
#ifdef HAVE_ALSA_DSD
return SND_PCM_FORMAT_DSD_U8;
#else
return SND_PCM_FORMAT_UNKNOWN;
#endif
case SampleFormat::S8:
return SND_PCM_FORMAT_S8;
@ -85,7 +69,6 @@ ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt) noexcept
case SND_PCM_FORMAT_S32_BE: return SND_PCM_FORMAT_S32_LE;
#ifdef HAVE_ALSA_DSD_U32
case SND_PCM_FORMAT_DSD_U16_LE:
return SND_PCM_FORMAT_DSD_U16_BE;
@ -97,7 +80,6 @@ ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt) noexcept
case SND_PCM_FORMAT_DSD_U32_BE:
return SND_PCM_FORMAT_DSD_U32_LE;
#endif
default: return SND_PCM_FORMAT_UNKNOWN;
}
@ -121,5 +103,3 @@ PackAlsaPcmFormat(snd_pcm_format_t fmt) noexcept
return SND_PCM_FORMAT_UNKNOWN;
}
}
#endif

View File

@ -80,7 +80,7 @@ TryFormatDsd(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
{
int err = TryFormatOrByteSwap(pcm, hwparams, fmt, params);
#if defined(ENABLE_DSD) && defined(HAVE_ALSA_DSD_U32)
#ifdef ENABLE_DSD
if (err == -EINVAL && fmt == SND_PCM_FORMAT_DSD_U8) {
/* attempt to switch to DSD_U32 */
fmt = IsLittleEndian()

View File

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