2
0

gnunet_speaker_lib.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /**
  18. * @author Simon Dieterle
  19. * @author Andreas Fuchs
  20. * @author Christian Grothoff
  21. *
  22. * @file
  23. * API to access an audio speaker; provides access to hardware speakers
  24. *
  25. * @defgroup speaker Speaker service
  26. * Access hardware audio speakers.
  27. * @{
  28. */
  29. #ifndef GNUNET_SPEAKER_SERVICE_H
  30. #define GNUNET_SPEAKER_SERVICE_H
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #if 0 /* keep Emacsens' auto-indent happy */
  35. }
  36. #endif
  37. #endif
  38. #include "gnunet_util_lib.h"
  39. /**
  40. * Function that enables a speaker.
  41. *
  42. * @param cls closure
  43. * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  44. */
  45. typedef int (*GNUNET_SPEAKER_EnableCallback)(void *cls);
  46. /**
  47. * Function that disables a speaker.
  48. *
  49. * @param cls closure
  50. */
  51. typedef void (*GNUNET_SPEAKER_DisableCallback)(void *cls);
  52. /**
  53. * Function to destroy a speaker.
  54. *
  55. * @param cls closure
  56. */
  57. typedef void (*GNUNET_SPEAKER_DestroyCallback)(void *cls);
  58. /**
  59. * Function to cause a speaker to play audio data.
  60. *
  61. * @param cls closure
  62. * @param data_size number of bytes in @a data
  63. * @param data audio data to play, format is
  64. * opaque to the API but should be OPUS.
  65. */
  66. typedef void (*GNUNET_SPEAKER_PlayCallback)(void *cls,
  67. size_t data_size,
  68. const void *data);
  69. /**
  70. * A speaker is a device that can play or record audio data.
  71. */
  72. struct GNUNET_SPEAKER_Handle
  73. {
  74. /**
  75. * Turn on the speaker.
  76. */
  77. GNUNET_SPEAKER_EnableCallback enable_speaker;
  78. /**
  79. * Play audio.
  80. */
  81. GNUNET_SPEAKER_PlayCallback play;
  82. /**
  83. * Turn the speaker off.
  84. */
  85. GNUNET_SPEAKER_DisableCallback disable_speaker;
  86. /**
  87. * Destroy the speaker. Called by #GNUNET_SPEAKER_destroy.
  88. */
  89. GNUNET_SPEAKER_DestroyCallback destroy_speaker;
  90. /**
  91. * Closure for the callbacks.
  92. */
  93. void *cls;
  94. };
  95. /**
  96. * Create a speaker that corresponds to the speaker hardware
  97. * of our system.
  98. *
  99. * @param cfg configuration to use
  100. * @return NULL on error
  101. */
  102. struct GNUNET_SPEAKER_Handle *
  103. GNUNET_SPEAKER_create_from_hardware (const struct 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 */