gnunet_speaker_lib.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @author Simon Dieterle
  18. * @author Andreas Fuchs
  19. * @author Christian Grothoff
  20. *
  21. * @file
  22. * API to access an audio speaker; provides access to hardware speakers
  23. *
  24. * @defgroup speaker Speaker service
  25. * Access hardware audio speakers.
  26. * @{
  27. */
  28. #ifndef GNUNET_SPEAKER_SERVICE_H
  29. #define GNUNET_SPEAKER_SERVICE_H
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #if 0 /* keep Emacsens' auto-indent happy */
  34. }
  35. #endif
  36. #endif
  37. #include "gnunet_util_lib.h"
  38. /**
  39. * Function that enables a speaker.
  40. *
  41. * @param cls closure
  42. * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  43. */
  44. typedef int (*GNUNET_SPEAKER_EnableCallback)(void *cls);
  45. /**
  46. * Function that disables a speaker.
  47. *
  48. * @param cls closure
  49. */
  50. typedef void (*GNUNET_SPEAKER_DisableCallback)(void *cls);
  51. /**
  52. * Function to destroy a speaker.
  53. *
  54. * @param cls closure
  55. */
  56. typedef void (*GNUNET_SPEAKER_DestroyCallback)(void *cls);
  57. /**
  58. * Function to cause a speaker to play audio data.
  59. *
  60. * @param cls closure
  61. * @param data_size number of bytes in @a data
  62. * @param data audio data to play, format is
  63. * opaque to the API but should be OPUS.
  64. */
  65. typedef void (*GNUNET_SPEAKER_PlayCallback)(void *cls,
  66. size_t data_size,
  67. const void *data);
  68. /**
  69. * A speaker is a device that can play or record audio data.
  70. */
  71. struct GNUNET_SPEAKER_Handle
  72. {
  73. /**
  74. * Turn on the speaker.
  75. */
  76. GNUNET_SPEAKER_EnableCallback enable_speaker;
  77. /**
  78. * Play audio.
  79. */
  80. GNUNET_SPEAKER_PlayCallback play;
  81. /**
  82. * Turn the speaker off.
  83. */
  84. GNUNET_SPEAKER_DisableCallback disable_speaker;
  85. /**
  86. * Destroy the speaker. Called by #GNUNET_SPEAKER_destroy.
  87. */
  88. GNUNET_SPEAKER_DestroyCallback destroy_speaker;
  89. /**
  90. * Closure for the callbacks.
  91. */
  92. void *cls;
  93. };
  94. /**
  95. * Create a speaker that corresponds to the speaker hardware
  96. * of our system.
  97. *
  98. * @param cfg configuration to use
  99. * @return NULL on error
  100. */
  101. struct GNUNET_SPEAKER_Handle *
  102. GNUNET_SPEAKER_create_from_hardware (const struct
  103. GNUNET_CONFIGURATION_Handle *cfg);
  104. /**
  105. * Destroy a speaker.
  106. *
  107. * @param speaker speaker to destroy
  108. */
  109. void
  110. GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker);
  111. #if 0 /* keep Emacsens' auto-indent happy */
  112. {
  113. #endif
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif
  118. /** @} */ /* end of group */
  119. /* end of gnunet_speaker_lib.h */