include: prefer alsa/asoundlib.h for apps, dependency cleanups

Fixes several issues with header files:

- prefer alsa/asoundlib.h file for the alsa-lib core functionalities
  (use #warning to inform current and future developers, do the job)
- include alsa/asoundlib.h in headers for external plugins by default
- pcm_external.h: dependencies cleanup
- as benefit, the parsers in IDEs should get all information for individial
  header files (see PR#435)

This change was mainly tergetted to fix errors caused by wrong include order
(like for endianness detection, missing typedefs etc.).

Closes: https://github.com/alsa-project/alsa-lib/issues/431
Link: https://github.com/alsa-project/alsa-lib/pull/435
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2025-02-02 13:46:12 +01:00
parent 35d2efefa9
commit ea8972c83b
28 changed files with 150 additions and 25 deletions

View file

@ -634,6 +634,7 @@ AM_CONDITIONAL([BUILD_PCM_PLUGIN_DSNOOP], [test x$build_pcm_dsnoop = xyes])
AM_CONDITIONAL([BUILD_PCM_PLUGIN_ASYM], [test x$build_pcm_asym = xyes])
AM_CONDITIONAL([BUILD_PCM_PLUGIN_IEC958], [test x$build_pcm_iec958 = xyes])
AM_CONDITIONAL([BUILD_PCM_PLUGIN_SOFTVOL], [test x$build_pcm_softvol = xyes])
AM_CONDITIONAL([BUILD_PCM_PLUGIN_EXTERNAL], [test x$build_pcm_extplug = xyes -o x$build_pcm_ioplug = xyes])
AM_CONDITIONAL([BUILD_PCM_PLUGIN_EXTPLUG], [test x$build_pcm_extplug = xyes])
AM_CONDITIONAL([BUILD_PCM_PLUGIN_IOPLUG], [test x$build_pcm_ioplug = xyes])
AM_CONDITIONAL([BUILD_PCM_PLUGIN_MMAP_EMUL], [test x$build_pcm_mmap_emul = xyes])
@ -826,6 +827,7 @@ test "$build_pcm" = "yes" && echo "#include <alsa/timer.h>" >> include/asoundlib
test "$build_hwdep" = "yes" && echo "#include <alsa/hwdep.h>" >> include/asoundlib.h
echo "#include <alsa/control.h>" >> include/asoundlib.h
test "$build_mixer" = "yes" && echo "#include <alsa/mixer.h>" >> include/asoundlib.h
test "$build_seq" = "yes" && echo "#include <alsa/ump_msg.h>" >> include/asoundlib.h
test "$build_seq" = "yes" && echo "#include <alsa/seq_event.h>" >> include/asoundlib.h
test "$build_seq" = "yes" && echo "#include <alsa/seq.h>" >> include/asoundlib.h
test "$build_seq" = "yes" && echo "#include <alsa/seqmid.h>" >> include/asoundlib.h

View file

@ -22,15 +22,16 @@ endif
if BUILD_PCM_PLUGIN_RATE
alsainclude_HEADERS += pcm_rate.h
endif
if BUILD_PCM_PLUGIN_EXTPLUG
alsainclude_HEADERS += pcm_external.h pcm_extplug.h
endif
if BUILD_PCM_PLUGIN_IOPLUG
if !BUILD_PCM_PLUGIN_EXTPLUG
alsainclude_HEADERS += pcm_external.h
endif
alsainclude_HEADERS += pcm_ioplug.h
if BUILD_PCM_PLUGIN_EXTERNAL
# FIXME: pcm_external.h includes both pcm_extplug.h and pcm_ioplug.h
alsainclude_HEADERS += pcm_external.h pcm_extplug.h pcm_ioplug.h
endif
#if BUILD_PCM_PLUGIN_EXTPLUG
#alsainclude_HEADERS += pcm_extplug.h
#endif
#if BUILD_PCM_PLUGIN_IOPLUG
#alsainclude_HEADERS += pcm_ioplug.h
#endif
endif
if BUILD_RAWMIDI

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/asoundef.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_ASOUNDEF_H
#define __ALSA_ASOUNDEF_H

View file

@ -38,3 +38,5 @@
#include <poll.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <time.h>

View file

@ -25,6 +25,11 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_CONF_H
#define __ALSA_CONF_H

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/control.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_CONTROL_H
#define __ALSA_CONTROL_H

View file

@ -23,10 +23,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __ALSA_CONTROL_EXTERNAL_H
#define __ALSA_CONTROL_EXTERNAL_H
#include "control.h"
#ifndef __ASOUNDLIB_LOCAL
#include <alsa/asoundlib.h>
#endif
#ifdef __cplusplus
extern "C" {

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/error.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_ERROR_H
#define __ALSA_ERROR_H

View file

@ -25,12 +25,15 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/global.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_GLOBAL_H_
#define __ALSA_GLOBAL_H_
/* for timeval and timespec */
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/hwdep.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_HWDEP_H
#define __ALSA_HWDEP_H

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/input.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_INPUT_H
#define __ALSA_INPUT_H

View file

@ -30,6 +30,9 @@
#include <string.h>
#include <fcntl.h>
#include <assert.h>
#include <stdint.h>
/* for timeval and timespec */
#include <time.h>
#ifdef HAVE_ENDIAN_H
#include <endian.h>
#elif defined(HAVE_SYS_ENDIAN_H)
@ -187,6 +190,7 @@
#include "hwdep.h"
#include "control.h"
#include "mixer.h"
#include "ump_msg.h"
#include "seq_event.h"
#include "seq.h"

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/mixer.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_MIXER_H
#define __ALSA_MIXER_H

View file

@ -25,11 +25,15 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/input.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_OUTPUT_H
#define __ALSA_OUTPUT_H
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -26,6 +26,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/pcm.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_PCM_H
#define __ALSA_PCM_H
@ -33,8 +39,6 @@
extern "C" {
#endif
#include <stdint.h>
/**
* \defgroup PCM PCM Interface
* See the \ref pcm page for more details.

View file

@ -26,7 +26,9 @@
#ifndef __ALSA_PCM_EXTERNAL_H
#define __ALSA_PCM_EXTERNAL_H
#include "pcm.h"
#ifndef __ASOUNDLIB_LOCAL
#include <alsa/asoundlib.h>
#endif
#ifdef __cplusplus
extern "C" {

View file

@ -28,6 +28,11 @@
*
*/
#ifndef __ALSA_PCM_EXTERNAL_H
#warning "use #include <alsa/pcm_external.h>, <alsa/pcm_extplug.h> should not be used directly"
#include <alsa/pcm_external.h>
#endif
#ifndef __ALSA_PCM_EXTPLUG_H
#define __ALSA_PCM_EXTPLUG_H

View file

@ -28,6 +28,11 @@
*
*/
#ifndef __ALSA_PCM_EXTERNAL_H
#warning "use #include <alsa/pcm_external.h>, <alsa/pcm_ioplug.h> should not be used directly"
#include <alsa/pcm_external.h>
#endif
#ifndef __ALSA_PCM_IOPLUG_H
#define __ALSA_PCM_IOPLUG_H

View file

@ -1,3 +1,8 @@
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#error "use #include <alsa/asoundlib.h>, <alsa/pcm_old.h> should not be used directly"
#endif
/*
* Old ALSA 0.9.x API
*/

View file

@ -31,6 +31,10 @@
#ifndef __ALSA_PCM_RATE_H
#define __ALSA_PCM_RATE_H
#ifndef __ASOUNDLIB_LOCAL
#include <alsa/asoundlib.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/rawmidi.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_RAWMIDI_H
#define __ALSA_RAWMIDI_H

View file

@ -26,11 +26,15 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/seq.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_SEQ_H
#define __ALSA_SEQ_H
#include "ump.h"
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -25,11 +25,15 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/seq_event.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_SEQ_EVENT_H
#define __ALSA_SEQ_EVENT_H
#include "ump_msg.h"
/**
* \defgroup SeqEvents Sequencer Event Definitions
* Sequencer Event Definitions

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/seq_midi_event.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_SEQ_MIDI_EVENT_H
#define __ALSA_SEQ_MIDI_EVENT_H

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/seqmid.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_SEQMID_H
#define __ALSA_SEQMID_H

View file

@ -25,6 +25,12 @@
*
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/timer.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_TIMER_H
#define __ALSA_TIMER_H

View file

@ -6,11 +6,15 @@
* API library for ALSA rawmidi/UMP interface
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/ump.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_UMP_H
#define __ALSA_UMP_H
#include "rawmidi.h"
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -6,11 +6,15 @@
* API library for ALSA rawmidi/UMP interface
*/
#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
#warning "use #include <alsa/asoundlib.h>, <alsa/ump_msg.h> should not be used directly"
#include <alsa/asoundlib.h>
#endif
#ifndef __ALSA_UMP_MSG_H
#define __ALSA_UMP_MSG_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif