Skip to content

Commit

Permalink
include: prefer alsa/asoundlib.h for apps, dependency cleanups
Browse files Browse the repository at this point in the history
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: #431
Link: #435
Signed-off-by: Jaroslav Kysela <[email protected]>
  • Loading branch information
perexg committed Feb 2, 2025
1 parent 35d2efe commit ea8972c
Show file tree
Hide file tree
Showing 28 changed files with 150 additions and 25 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions include/asoundef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions include/asoundlib-head.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@
#include <poll.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <time.h>
5 changes: 5 additions & 0 deletions include/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions include/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion include/control_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
6 changes: 6 additions & 0 deletions include/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions include/hwdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions include/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions include/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -187,6 +190,7 @@
#include "hwdep.h"
#include "control.h"
#include "mixer.h"
#include "ump_msg.h"
#include "seq_event.h"
#include "seq.h"

Expand Down
6 changes: 6 additions & 0 deletions include/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions include/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions include/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@
*
*/

#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

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

/**
* \defgroup PCM PCM Interface
* See the \ref pcm page for more details.
Expand Down
4 changes: 3 additions & 1 deletion include/pcm_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
5 changes: 5 additions & 0 deletions include/pcm_extplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions include/pcm_ioplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions include/pcm_old.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down
4 changes: 4 additions & 0 deletions include/pcm_rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions include/rawmidi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions include/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions include/seq_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions include/seq_midi_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions include/seqmid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions include/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions include/ump.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit ea8972c

Please sign in to comment.