diff options
Diffstat (limited to 'src/conversation/speaker.c')
-rw-r--r-- | src/conversation/speaker.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/conversation/speaker.c b/src/conversation/speaker.c index 96fd42b8d..8703f269d 100644 --- a/src/conversation/speaker.c +++ b/src/conversation/speaker.c | |||
@@ -33,7 +33,8 @@ | |||
33 | /** | 33 | /** |
34 | * Internal data structures for the speaker. | 34 | * Internal data structures for the speaker. |
35 | */ | 35 | */ |
36 | struct Speaker { | 36 | struct Speaker |
37 | { | ||
37 | /** | 38 | /** |
38 | * Our configuration. | 39 | * Our configuration. |
39 | */ | 40 | */ |
@@ -53,26 +54,25 @@ struct Speaker { | |||
53 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 54 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
54 | */ | 55 | */ |
55 | static int | 56 | static int |
56 | enable(void *cls) | 57 | enable (void *cls) |
57 | { | 58 | { |
58 | struct Speaker *spe = cls; | 59 | struct Speaker *spe = cls; |
59 | static char *playback_helper_argv[] = | 60 | static char *playback_helper_argv[] = { |
60 | { | ||
61 | "gnunet-helper-audio-playback", | 61 | "gnunet-helper-audio-playback", |
62 | NULL | 62 | NULL |
63 | }; | 63 | }; |
64 | 64 | ||
65 | spe->playback_helper = GNUNET_HELPER_start(GNUNET_NO, | 65 | spe->playback_helper = GNUNET_HELPER_start (GNUNET_NO, |
66 | "gnunet-helper-audio-playback", | 66 | "gnunet-helper-audio-playback", |
67 | playback_helper_argv, | 67 | playback_helper_argv, |
68 | NULL, | 68 | NULL, |
69 | NULL, spe); | 69 | NULL, spe); |
70 | if (NULL == spe->playback_helper) | 70 | if (NULL == spe->playback_helper) |
71 | { | 71 | { |
72 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 72 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
73 | _("Could not start playback audio helper.\n")); | 73 | _ ("Could not start playback audio helper.\n")); |
74 | return GNUNET_SYSERR; | 74 | return GNUNET_SYSERR; |
75 | } | 75 | } |
76 | return GNUNET_OK; | 76 | return GNUNET_OK; |
77 | } | 77 | } |
78 | 78 | ||
@@ -83,18 +83,18 @@ enable(void *cls) | |||
83 | * @param cls closure with the `struct Speaker` | 83 | * @param cls closure with the `struct Speaker` |
84 | */ | 84 | */ |
85 | static void | 85 | static void |
86 | disable(void *cls) | 86 | disable (void *cls) |
87 | { | 87 | { |
88 | struct Speaker *spe = cls; | 88 | struct Speaker *spe = cls; |
89 | 89 | ||
90 | if (NULL == spe->playback_helper) | 90 | if (NULL == spe->playback_helper) |
91 | { | 91 | { |
92 | GNUNET_break(0); | 92 | GNUNET_break (0); |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | GNUNET_break(GNUNET_OK == | 95 | GNUNET_break (GNUNET_OK == |
96 | GNUNET_HELPER_kill(spe->playback_helper, GNUNET_NO)); | 96 | GNUNET_HELPER_kill (spe->playback_helper, GNUNET_NO)); |
97 | GNUNET_HELPER_destroy(spe->playback_helper); | 97 | GNUNET_HELPER_destroy (spe->playback_helper); |
98 | spe->playback_helper = NULL; | 98 | spe->playback_helper = NULL; |
99 | } | 99 | } |
100 | 100 | ||
@@ -105,12 +105,12 @@ disable(void *cls) | |||
105 | * @param cls closure with the `struct Speaker` | 105 | * @param cls closure with the `struct Speaker` |
106 | */ | 106 | */ |
107 | static void | 107 | static void |
108 | destroy(void *cls) | 108 | destroy (void *cls) |
109 | { | 109 | { |
110 | struct Speaker *spe = cls; | 110 | struct Speaker *spe = cls; |
111 | 111 | ||
112 | if (NULL != spe->playback_helper) | 112 | if (NULL != spe->playback_helper) |
113 | disable(spe); | 113 | disable (spe); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
@@ -123,27 +123,27 @@ destroy(void *cls) | |||
123 | * opaque to the API but should be OPUS. | 123 | * opaque to the API but should be OPUS. |
124 | */ | 124 | */ |
125 | static void | 125 | static void |
126 | play(void *cls, | 126 | play (void *cls, |
127 | size_t data_size, | 127 | size_t data_size, |
128 | const void *data) | 128 | const void *data) |
129 | { | 129 | { |
130 | struct Speaker *spe = cls; | 130 | struct Speaker *spe = cls; |
131 | char buf[sizeof(struct AudioMessage) + data_size]; | 131 | char buf[sizeof(struct AudioMessage) + data_size]; |
132 | struct AudioMessage *am; | 132 | struct AudioMessage *am; |
133 | 133 | ||
134 | if (NULL == spe->playback_helper) | 134 | if (NULL == spe->playback_helper) |
135 | { | 135 | { |
136 | GNUNET_break(0); | 136 | GNUNET_break (0); |
137 | return; | 137 | return; |
138 | } | 138 | } |
139 | am = (struct AudioMessage *)buf; | 139 | am = (struct AudioMessage *) buf; |
140 | am->header.size = htons(sizeof(struct AudioMessage) + data_size); | 140 | am->header.size = htons (sizeof(struct AudioMessage) + data_size); |
141 | am->header.type = htons(GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); | 141 | am->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); |
142 | GNUNET_memcpy(&am[1], data, data_size); | 142 | GNUNET_memcpy (&am[1], data, data_size); |
143 | (void)GNUNET_HELPER_send(spe->playback_helper, | 143 | (void) GNUNET_HELPER_send (spe->playback_helper, |
144 | &am->header, | 144 | &am->header, |
145 | GNUNET_NO, | 145 | GNUNET_NO, |
146 | NULL, NULL); | 146 | NULL, NULL); |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
@@ -155,14 +155,15 @@ play(void *cls, | |||
155 | * @return NULL on error | 155 | * @return NULL on error |
156 | */ | 156 | */ |
157 | struct GNUNET_SPEAKER_Handle * | 157 | struct GNUNET_SPEAKER_Handle * |
158 | GNUNET_SPEAKER_create_from_hardware(const struct GNUNET_CONFIGURATION_Handle *cfg) | 158 | GNUNET_SPEAKER_create_from_hardware (const struct |
159 | GNUNET_CONFIGURATION_Handle *cfg) | ||
159 | { | 160 | { |
160 | struct GNUNET_SPEAKER_Handle *speaker; | 161 | struct GNUNET_SPEAKER_Handle *speaker; |
161 | struct Speaker *spe; | 162 | struct Speaker *spe; |
162 | 163 | ||
163 | spe = GNUNET_new(struct Speaker); | 164 | spe = GNUNET_new (struct Speaker); |
164 | spe->cfg = cfg; | 165 | spe->cfg = cfg; |
165 | speaker = GNUNET_new(struct GNUNET_SPEAKER_Handle); | 166 | speaker = GNUNET_new (struct GNUNET_SPEAKER_Handle); |
166 | speaker->cls = spe; | 167 | speaker->cls = spe; |
167 | speaker->enable_speaker = &enable; | 168 | speaker->enable_speaker = &enable; |
168 | speaker->play = &play; | 169 | speaker->play = &play; |
@@ -178,10 +179,10 @@ GNUNET_SPEAKER_create_from_hardware(const struct GNUNET_CONFIGURATION_Handle *cf | |||
178 | * @param speaker speaker to destroy | 179 | * @param speaker speaker to destroy |
179 | */ | 180 | */ |
180 | void | 181 | void |
181 | GNUNET_SPEAKER_destroy(struct GNUNET_SPEAKER_Handle *speaker) | 182 | GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker) |
182 | { | 183 | { |
183 | speaker->destroy_speaker(speaker->cls); | 184 | speaker->destroy_speaker (speaker->cls); |
184 | GNUNET_free(speaker); | 185 | GNUNET_free (speaker); |
185 | } | 186 | } |
186 | 187 | ||
187 | /* end of speaker.c */ | 188 | /* end of speaker.c */ |