global.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. * \file include/global.h
  3. * \brief Application interface library for the ALSA driver
  4. * \author Jaroslav Kysela <perex@perex.cz>
  5. * \author Abramo Bagnara <abramo@alsa-project.org>
  6. * \author Takashi Iwai <tiwai@suse.de>
  7. * \date 1998-2001
  8. *
  9. * Application interface library for the ALSA driver
  10. */
  11. /*
  12. * This library is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU Lesser General Public License as
  14. * published by the Free Software Foundation; either version 2.1 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with this library; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. *
  26. */
  27. #ifndef __ALSA_GLOBAL_H_
  28. #define __ALSA_GLOBAL_H_
  29. /* for timeval and timespec */
  30. #include <time.h>
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /**
  35. * \defgroup Global Global defines and functions
  36. * Global defines and functions.
  37. * \par
  38. * The ALSA library implementation uses these macros and functions.
  39. * Most applications probably do not need them.
  40. * \{
  41. */
  42. const char *snd_asoundlib_version(void);
  43. #ifndef ATTRIBUTE_UNUSED
  44. /** do not print warning (gcc) when function parameter is not used */
  45. #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
  46. #endif
  47. #ifdef PIC /* dynamic build */
  48. /** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */
  49. #define __SND_DLSYM_VERSION(name, version) _ ## name ## version
  50. /**
  51. * \hideinitializer
  52. * \brief Appends the build version to the name of a versioned dynamic symbol.
  53. */
  54. #define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version);
  55. #else /* static build */
  56. struct snd_dlsym_link {
  57. struct snd_dlsym_link *next;
  58. const char *dlsym_name;
  59. const void *dlsym_ptr;
  60. };
  61. extern struct snd_dlsym_link *snd_dlsym_start;
  62. /** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */
  63. #define __SND_DLSYM_VERSION(prefix, name, version) _ ## prefix ## name ## version
  64. /**
  65. * \hideinitializer
  66. * \brief Appends the build version to the name of a versioned dynamic symbol.
  67. */
  68. #define SND_DLSYM_BUILD_VERSION(name, version) \
  69. static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \
  70. void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \
  71. void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \
  72. __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \
  73. __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = # name; \
  74. __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \
  75. snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \
  76. }
  77. #endif
  78. #ifndef __STRING
  79. /** \brief Return 'x' argument as string */
  80. #define __STRING(x) #x
  81. #endif
  82. /** \brief Returns the version of a dynamic symbol as a string. */
  83. #define SND_DLSYM_VERSION(version) __STRING(version)
  84. void *snd_dlopen(const char *file, int mode);
  85. void *snd_dlsym(void *handle, const char *name, const char *version);
  86. int snd_dlclose(void *handle);
  87. /** \brief alloca helper macro. */
  88. #define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0)
  89. /**
  90. * \brief Internal structure for an async notification client handler.
  91. *
  92. * The ALSA library uses a pointer to this structure as a handle to an async
  93. * notification object. Applications don't access its contents directly.
  94. */
  95. typedef struct _snd_async_handler snd_async_handler_t;
  96. /**
  97. * \brief Async notification callback.
  98. *
  99. * See the #snd_async_add_handler function for details.
  100. */
  101. typedef void (*snd_async_callback_t)(snd_async_handler_t *handler);
  102. int snd_async_add_handler(snd_async_handler_t **handler, int fd,
  103. snd_async_callback_t callback, void *private_data);
  104. int snd_async_del_handler(snd_async_handler_t *handler);
  105. int snd_async_handler_get_fd(snd_async_handler_t *handler);
  106. int snd_async_handler_get_signo(snd_async_handler_t *handler);
  107. void *snd_async_handler_get_callback_private(snd_async_handler_t *handler);
  108. struct snd_shm_area *snd_shm_area_create(int shmid, void *ptr);
  109. struct snd_shm_area *snd_shm_area_share(struct snd_shm_area *area);
  110. int snd_shm_area_destroy(struct snd_shm_area *area);
  111. int snd_user_file(const char *file, char **result);
  112. #ifdef __GLIBC__
  113. #if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_SOURCE)
  114. struct timeval {
  115. time_t tv_sec; /* seconds */
  116. long tv_usec; /* microseconds */
  117. };
  118. struct timespec {
  119. time_t tv_sec; /* seconds */
  120. long tv_nsec; /* nanoseconds */
  121. };
  122. #endif
  123. #endif
  124. /** Timestamp */
  125. typedef struct timeval snd_timestamp_t;
  126. /** Hi-res timestamp */
  127. typedef struct timespec snd_htimestamp_t;
  128. /** \} */
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif /* __ALSA_GLOBAL_H */