]> git.alsa-project.org Git - alsa-lib.git/commitdiff
include: prefer alsa/asoundlib.h for apps, dependency cleanups
authorJaroslav Kysela <perex@perex.cz>
Sun, 2 Feb 2025 12:46:12 +0000 (13:46 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 2 Feb 2025 17:56:47 +0000 (18:56 +0100)
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>
28 files changed:
configure.ac
include/Makefile.am
include/asoundef.h
include/asoundlib-head.h
include/conf.h
include/control.h
include/control_external.h
include/error.h
include/global.h
include/hwdep.h
include/input.h
include/local.h
include/mixer.h
include/output.h
include/pcm.h
include/pcm_external.h
include/pcm_extplug.h
include/pcm_ioplug.h
include/pcm_old.h
include/pcm_rate.h
include/rawmidi.h
include/seq.h
include/seq_event.h
include/seq_midi_event.h
include/seqmid.h
include/timer.h
include/ump.h
include/ump_msg.h

index 69aeb978af0d0e90e7d6629d43d83f7d6fc1e786..75c655303edcc07bca94d97553968905fc16b2db 100644 (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
index 16d68b511297010fc1c7c888f6f58c144fbed149..c1885e1d51b0f0a00d42cf7101f20aa97dc94284 100644 (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
index 261db40bab3e879f51113184d63c89e6902e827d..5e158b352ed5bade70bd8eec9bde12e5beb8cc36 100644 (file)
  *
  */
 
+#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
 
index 7cfa440d4a7da69d82d1ccad8c956f5b5c2f90df..382a0a581fd0c6bbc1e16420192b9a647f2382ed 100644 (file)
@@ -38,3 +38,5 @@
 #include <poll.h>
 #include <errno.h>
 #include <stdarg.h>
+#include <stdint.h>
+#include <time.h>
index 09da0e9aa37a86d254dafbc165546d24695c48ae..327659c934957142550769cf64eafb1036d75862 100644 (file)
  *
  */
 
+#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
 
index e7541d56d6363966bbed266d3758026567b9402b..b206fbb0022c606f417cfe30ff1286759007f447 100644 (file)
  *
  */
 
+#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
 
index 488fa6e285be3c9e72122f3df9f5f63990b40940..2baaea26eb7693f39f58695729d19be2a7a75108 100644 (file)
  *   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" {
index 7239db85264111347ff79c5d2d6c0f1b024097a2..8a2a9abc70b78ac27a38e6fff47144cb220b103d 100644 (file)
  *
  */
 
+#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
 
index 3ecaeee898c593f4371d1fd51b06220d5d6215cb..84a40557add2af64d1a22d9c48d2a2a30831cb37 100644 (file)
  *
  */
 
+#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
index 46ed1f7801e19e5d65e851d4a46c621b6342026d..174aa899fcd2119400d4ec5f0a3996a744eac646 100644 (file)
  *
  */
 
+#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
 
index f84954a9a56ded3b27a5666cdebaf51dba25ed17..80fc862428f686f3a5183665c6d0652082977b0a 100644 (file)
  *
  */
 
+#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
 
index 2b38ce64724371fac2a049919bf6a7ae4c0db5a2..55f252dfbc52528911b287c42b74bddc661167df 100644 (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)
 #include "hwdep.h"
 #include "control.h"
 #include "mixer.h"
+#include "ump_msg.h"
 #include "seq_event.h"
 #include "seq.h"
 
index 735dfdd8433d11cdbe8523d6c4bea9bfc93987fd..93dd70cd59b9e8baa28d029005470c0f8e480ac9 100644 (file)
  *
  */
 
+#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
 
index 5e16420b5a428fac576787a689f9f3e2b420d5ae..14089c051ebfe82ddcae76bbf6b01e0c61e8d219 100644 (file)
  *
  */
 
+#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
index b5c6788985be410ee25690db60ad5dee66c1bf96..3fa9203e517623e9f7e16435006ef86ab637843a 100644 (file)
  *
  */
 
+#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.
index a6005b34ca210dc97354e6c96297a2744e989ae7..27e53fc03b4410fead8ae8e670c3b3a7dfdf847d 100644 (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" {
index e5c02d4ddbe5c56d4244bed06c29ba0405035bd6..09d7c7cb71f1212f8842e955bbba5cb9f81c24fc 100644 (file)
  *
  */
 
+#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
 
index 81ac8613130c4edb8bb5b6ab71fdbcdf0ca7942e..457b3e8bef9f79ecb0a226cb03e8074a7effcaa5 100644 (file)
  *
  */
 
+#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
 
index a9f5308ff81231ce68e266f848bd86c06f718952..3ff5f82cc6dfb2bb9e6305a7c2f10062cf4b0e3d 100644 (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
  */
index 48473ed4ea0439d97ec709afbbdf5eb3d86e271d..0a914d86cf977add836c4d7480d4715f7217be48 100644 (file)
 #ifndef __ALSA_PCM_RATE_H
 #define __ALSA_PCM_RATE_H
 
+#ifndef __ASOUNDLIB_LOCAL
+#include <alsa/asoundlib.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 713258f2cd80e20d02d7ab4a89c44e7391628e1e..a144f6593ace663e28d30edadf19ce8791b1f16e 100644 (file)
  *
  */
 
+#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
 
index 5082ad0ad82bebe22a01b9e1cae5b32f237d1845..17bcfa532c04809f1c10fffc92c41ee9b4da31e0 100644 (file)
  *
  */
 
+#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
index da542b106a48feb377a8f9af2b02bf03f19e23e2..b27ce36c5897e100f0fb3ef57ecf0f97d982e0d0 100644 (file)
  *
  */
 
+#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
index 4cfb15c4416d2b9f95cb192a954ee92ab1b598cf..6fbbf400ab11d0495bf7f3ace8a7c64ad33eb32c 100644 (file)
  *
  */
 
+#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
 
index bf968a5b2c7b630a4d433d4420f7a1712e640505..6d22692fcf684962c4f5b8fb34513d8e902a5beb 100644 (file)
  *
  */
 
+#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
 
index dc5ca69e5b0fd20d9c0a3e3a897980939174916f..09283ce0d194bbd2f9c200df15b1bf21f28863e5 100644 (file)
  *
  */
 
+#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
 
index 06c86a5e8ba32e16a29a607b56915d37b7e45881..d19ab5570bfbfcb8f851d3eb0bccb8fb11db7539 100644 (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
index 5f0a45acd44cdb7b04a3ef3de83368f153b4fcb3..f846ffe9f433d240811e4ebbd18f349cd174013c 100644 (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