From ea8972c83b020d92e1a9f0a5c12eaee159bf6c63 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 2 Feb 2025 13:46:12 +0100 Subject: [PATCH] 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 --- configure.ac | 2 ++ include/Makefile.am | 17 +++++++++-------- include/asoundef.h | 6 ++++++ include/asoundlib-head.h | 2 ++ include/conf.h | 5 +++++ include/control.h | 6 ++++++ include/control_external.h | 5 ++++- include/error.h | 6 ++++++ include/global.h | 9 ++++++--- include/hwdep.h | 6 ++++++ include/input.h | 6 ++++++ include/local.h | 4 ++++ include/mixer.h | 6 ++++++ include/output.h | 8 ++++++-- include/pcm.h | 8 ++++++-- include/pcm_external.h | 4 +++- include/pcm_extplug.h | 5 +++++ include/pcm_ioplug.h | 5 +++++ include/pcm_old.h | 5 +++++ include/pcm_rate.h | 4 ++++ include/rawmidi.h | 6 ++++++ include/seq.h | 8 ++++++-- include/seq_event.h | 8 ++++++-- include/seq_midi_event.h | 6 ++++++ include/seqmid.h | 6 ++++++ include/timer.h | 6 ++++++ include/ump.h | 8 ++++++-- include/ump_msg.h | 8 ++++++-- 28 files changed, 150 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 69aeb978..75c65530 100644 --- a/configure.ac +++ b/configure.ac @@ -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 " >> include/asoundlib test "$build_hwdep" = "yes" && echo "#include " >> include/asoundlib.h echo "#include " >> include/asoundlib.h test "$build_mixer" = "yes" && echo "#include " >> include/asoundlib.h +test "$build_seq" = "yes" && echo "#include " >> include/asoundlib.h test "$build_seq" = "yes" && echo "#include " >> include/asoundlib.h test "$build_seq" = "yes" && echo "#include " >> include/asoundlib.h test "$build_seq" = "yes" && echo "#include " >> include/asoundlib.h diff --git a/include/Makefile.am b/include/Makefile.am index 16d68b51..c1885e1d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -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 diff --git a/include/asoundef.h b/include/asoundef.h index 261db40b..5e158b35 100644 --- a/include/asoundef.h +++ b/include/asoundef.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_ASOUNDEF_H #define __ALSA_ASOUNDEF_H diff --git a/include/asoundlib-head.h b/include/asoundlib-head.h index 7cfa440d..382a0a58 100644 --- a/include/asoundlib-head.h +++ b/include/asoundlib-head.h @@ -38,3 +38,5 @@ #include #include #include +#include +#include diff --git a/include/conf.h b/include/conf.h index 09da0e9a..327659c9 100644 --- a/include/conf.h +++ b/include/conf.h @@ -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 +#endif + #ifndef __ALSA_CONF_H #define __ALSA_CONF_H diff --git a/include/control.h b/include/control.h index e7541d56..b206fbb0 100644 --- a/include/control.h +++ b/include/control.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_CONTROL_H #define __ALSA_CONTROL_H diff --git a/include/control_external.h b/include/control_external.h index 488fa6e2..2baaea26 100644 --- a/include/control_external.h +++ b/include/control_external.h @@ -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 +#endif #ifdef __cplusplus extern "C" { diff --git a/include/error.h b/include/error.h index 7239db85..8a2a9abc 100644 --- a/include/error.h +++ b/include/error.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_ERROR_H #define __ALSA_ERROR_H diff --git a/include/global.h b/include/global.h index 3ecaeee8..84a40557 100644 --- a/include/global.h +++ b/include/global.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_GLOBAL_H_ #define __ALSA_GLOBAL_H_ -/* for timeval and timespec */ -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/include/hwdep.h b/include/hwdep.h index 46ed1f78..174aa899 100644 --- a/include/hwdep.h +++ b/include/hwdep.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_HWDEP_H #define __ALSA_HWDEP_H diff --git a/include/input.h b/include/input.h index f84954a9..80fc8624 100644 --- a/include/input.h +++ b/include/input.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_INPUT_H #define __ALSA_INPUT_H diff --git a/include/local.h b/include/local.h index 2b38ce64..55f252df 100644 --- a/include/local.h +++ b/include/local.h @@ -30,6 +30,9 @@ #include #include #include +#include +/* for timeval and timespec */ +#include #ifdef HAVE_ENDIAN_H #include #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" diff --git a/include/mixer.h b/include/mixer.h index 735dfdd8..93dd70cd 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_MIXER_H #define __ALSA_MIXER_H diff --git a/include/output.h b/include/output.h index 5e16420b..14089c05 100644 --- a/include/output.h +++ b/include/output.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_OUTPUT_H #define __ALSA_OUTPUT_H -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/include/pcm.h b/include/pcm.h index b5c67889..3fa9203e 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_PCM_H #define __ALSA_PCM_H @@ -33,8 +39,6 @@ extern "C" { #endif -#include - /** * \defgroup PCM PCM Interface * See the \ref pcm page for more details. diff --git a/include/pcm_external.h b/include/pcm_external.h index a6005b34..27e53fc0 100644 --- a/include/pcm_external.h +++ b/include/pcm_external.h @@ -26,7 +26,9 @@ #ifndef __ALSA_PCM_EXTERNAL_H #define __ALSA_PCM_EXTERNAL_H -#include "pcm.h" +#ifndef __ASOUNDLIB_LOCAL +#include +#endif #ifdef __cplusplus extern "C" { diff --git a/include/pcm_extplug.h b/include/pcm_extplug.h index e5c02d4d..09d7c7cb 100644 --- a/include/pcm_extplug.h +++ b/include/pcm_extplug.h @@ -28,6 +28,11 @@ * */ +#ifndef __ALSA_PCM_EXTERNAL_H +#warning "use #include , should not be used directly" +#include +#endif + #ifndef __ALSA_PCM_EXTPLUG_H #define __ALSA_PCM_EXTPLUG_H diff --git a/include/pcm_ioplug.h b/include/pcm_ioplug.h index 81ac8613..457b3e8b 100644 --- a/include/pcm_ioplug.h +++ b/include/pcm_ioplug.h @@ -28,6 +28,11 @@ * */ +#ifndef __ALSA_PCM_EXTERNAL_H +#warning "use #include , should not be used directly" +#include +#endif + #ifndef __ALSA_PCM_IOPLUG_H #define __ALSA_PCM_IOPLUG_H diff --git a/include/pcm_old.h b/include/pcm_old.h index a9f5308f..3ff5f82c 100644 --- a/include/pcm_old.h +++ b/include/pcm_old.h @@ -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 , should not be used directly" +#endif + /* * Old ALSA 0.9.x API */ diff --git a/include/pcm_rate.h b/include/pcm_rate.h index 48473ed4..0a914d86 100644 --- a/include/pcm_rate.h +++ b/include/pcm_rate.h @@ -31,6 +31,10 @@ #ifndef __ALSA_PCM_RATE_H #define __ALSA_PCM_RATE_H +#ifndef __ASOUNDLIB_LOCAL +#include +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/include/rawmidi.h b/include/rawmidi.h index 713258f2..a144f659 100644 --- a/include/rawmidi.h +++ b/include/rawmidi.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_RAWMIDI_H #define __ALSA_RAWMIDI_H diff --git a/include/seq.h b/include/seq.h index 5082ad0a..17bcfa53 100644 --- a/include/seq.h +++ b/include/seq.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_SEQ_H #define __ALSA_SEQ_H -#include "ump.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/include/seq_event.h b/include/seq_event.h index da542b10..b27ce36c 100644 --- a/include/seq_event.h +++ b/include/seq_event.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_SEQ_EVENT_H #define __ALSA_SEQ_EVENT_H -#include "ump_msg.h" - /** * \defgroup SeqEvents Sequencer Event Definitions * Sequencer Event Definitions diff --git a/include/seq_midi_event.h b/include/seq_midi_event.h index 4cfb15c4..6fbbf400 100644 --- a/include/seq_midi_event.h +++ b/include/seq_midi_event.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_SEQ_MIDI_EVENT_H #define __ALSA_SEQ_MIDI_EVENT_H diff --git a/include/seqmid.h b/include/seqmid.h index bf968a5b..6d22692f 100644 --- a/include/seqmid.h +++ b/include/seqmid.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_SEQMID_H #define __ALSA_SEQMID_H diff --git a/include/timer.h b/include/timer.h index dc5ca69e..09283ce0 100644 --- a/include/timer.h +++ b/include/timer.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_TIMER_H #define __ALSA_TIMER_H diff --git a/include/ump.h b/include/ump.h index 06c86a5e..d19ab557 100644 --- a/include/ump.h +++ b/include/ump.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_UMP_H #define __ALSA_UMP_H -#include "rawmidi.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/include/ump_msg.h b/include/ump_msg.h index 5f0a45ac..f846ffe9 100644 --- a/include/ump_msg.h +++ b/include/ump_msg.h @@ -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 , should not be used directly" +#include +#endif + #ifndef __ALSA_UMP_MSG_H #define __ALSA_UMP_MSG_H -#include - #ifdef __cplusplus extern "C" { #endif -- 2.47.1