glitch in the license text detected by hyazinthe, thank you!
[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
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
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #if 0                           /* keep Emacsens' auto-indent happy */
35 }
36 #endif
37 #endif
38
39 #include "gnunet_util_lib.h"
40
41 /**
42  * Function that enables a speaker.
43  *
44  * @param cls closure
45  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
46  */
47 typedef int (*GNUNET_SPEAKER_EnableCallback)(void *cls);
48
49 /**
50  * Function that disables a speaker.
51  *
52  * @param cls closure
53  */
54 typedef void (*GNUNET_SPEAKER_DisableCallback)(void *cls);
55
56 /**
57  * Function to destroy a speaker.
58  *
59  * @param cls closure
60  */
61 typedef void (*GNUNET_SPEAKER_DestroyCallback)(void *cls);
62
63 /**
64  * Function to cause a speaker to play audio data.
65  *
66  * @param cls closure
67  * @param data_size number of bytes in @a data
68  * @param data audio data to play, format is
69  *        opaque to the API but should be OPUS.
70  */
71 typedef void (*GNUNET_SPEAKER_PlayCallback)(void *cls,
72                                             size_t data_size,
73                                             const void *data);
74
75
76 /**
77  * A speaker is a device that can play or record audio data.
78  */
79 struct GNUNET_SPEAKER_Handle
80 {
81
82   /**
83    * Turn on the speaker.
84    */
85   GNUNET_SPEAKER_EnableCallback enable_speaker;
86
87   /**
88    * Play audio.
89    */
90   GNUNET_SPEAKER_PlayCallback play;
91
92   /**
93    * Turn the speaker off.
94    */
95   GNUNET_SPEAKER_DisableCallback disable_speaker;
96
97   /**
98    * Destroy the speaker.  Called by #GNUNET_SPEAKER_destroy.
99    */
100   GNUNET_SPEAKER_DestroyCallback destroy_speaker;
101
102   /**
103    * Closure for the callbacks.
104    */
105   void *cls;
106
107 };
108
109
110 /**
111  * Create a speaker that corresponds to the speaker hardware
112  * of our system.
113  *
114  * @param cfg configuration to use
115  * @return NULL on error
116  */
117 struct GNUNET_SPEAKER_Handle *
118 GNUNET_SPEAKER_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle *cfg);
119
120
121 /**
122  * Destroy a speaker.
123  *
124  * @param speaker speaker to destroy
125  */
126 void
127 GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker);
128
129
130 #if 0                           /* keep Emacsens' auto-indent happy */
131 {
132 #endif
133 #ifdef __cplusplus
134 }
135 #endif
136
137 #endif
138
139 /** @} */ /* end of group */
140
141 /* end of gnunet_speaker_lib.h */