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