aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-helper-audio-playback.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation/gnunet-helper-audio-playback.c')
-rw-r--r--src/conversation/gnunet-helper-audio-playback.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/conversation/gnunet-helper-audio-playback.c b/src/conversation/gnunet-helper-audio-playback.c
index c0ef217cd..97abd4430 100644
--- a/src/conversation/gnunet-helper-audio-playback.c
+++ b/src/conversation/gnunet-helper-audio-playback.c
@@ -102,7 +102,7 @@ static int ready_pipe[2];
102 * Message callback 102 * Message callback
103 */ 103 */
104static int 104static int
105stdin_receiver (void *cls, 105stdin_receiver (void *cls,
106 void *client, 106 void *client,
107 const struct GNUNET_MessageHeader *msg) 107 const struct GNUNET_MessageHeader *msg)
108{ 108{
@@ -113,7 +113,7 @@ stdin_receiver (void *cls,
113 { 113 {
114 case GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO: 114 case GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO:
115 audio = (struct AudioMessage *) msg; 115 audio = (struct AudioMessage *) msg;
116 116
117 ret = opus_decode_float (dec, 117 ret = opus_decode_float (dec,
118 (const unsigned char *) &audio[1], 118 (const unsigned char *) &audio[1],
119 ntohs (audio->header.size) - sizeof (struct AudioMessage), 119 ntohs (audio->header.size) - sizeof (struct AudioMessage),
@@ -132,12 +132,12 @@ stdin_receiver (void *cls,
132 if (pa_stream_write 132 if (pa_stream_write
133 (stream_out, pcm_buffer, pcm_length, NULL, 0, 133 (stream_out, pcm_buffer, pcm_length, NULL, 0,
134 PA_SEEK_RELATIVE) < 0) 134 PA_SEEK_RELATIVE) < 0)
135 { 135 {
136 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 136 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
137 _("pa_stream_write() failed: %s\n"), 137 _("pa_stream_write() failed: %s\n"),
138 pa_strerror (pa_context_errno (context))); 138 pa_strerror (pa_context_errno (context)));
139 return GNUNET_OK; 139 return GNUNET_OK;
140 } 140 }
141 break; 141 break;
142 default: 142 default:
143 break; 143 break;
@@ -161,8 +161,8 @@ quit (int ret)
161 * Callback when data is there for playback 161 * Callback when data is there for playback
162 */ 162 */
163static void 163static void
164stream_write_callback (pa_stream * s, 164stream_write_callback (pa_stream * s,
165 size_t length, 165 size_t length,
166 void *userdata) 166 void *userdata)
167{ 167{
168 /* unblock 'main' */ 168 /* unblock 'main' */
@@ -192,7 +192,7 @@ exit_signal_callback (pa_mainloop_api * m, pa_signal_event * e, int sig,
192 * Pulseaudio stream state callback 192 * Pulseaudio stream state callback
193 */ 193 */
194static void 194static void
195context_state_callback (pa_context * c, 195context_state_callback (pa_context * c,
196 void *userdata) 196 void *userdata)
197{ 197{
198 int p; 198 int p;
@@ -203,7 +203,7 @@ context_state_callback (pa_context * c,
203 case PA_CONTEXT_CONNECTING: 203 case PA_CONTEXT_CONNECTING:
204 case PA_CONTEXT_AUTHORIZING: 204 case PA_CONTEXT_AUTHORIZING:
205 case PA_CONTEXT_SETTING_NAME: 205 case PA_CONTEXT_SETTING_NAME:
206 break; 206 break;
207 case PA_CONTEXT_READY: 207 case PA_CONTEXT_READY:
208 { 208 {
209 GNUNET_assert (!stream_out); 209 GNUNET_assert (!stream_out);
@@ -216,12 +216,12 @@ context_state_callback (pa_context * c,
216 _("pa_stream_new() failed: %s\n"), 216 _("pa_stream_new() failed: %s\n"),
217 pa_strerror (pa_context_errno (c))); 217 pa_strerror (pa_context_errno (c)));
218 goto fail; 218 goto fail;
219 } 219 }
220 pa_stream_set_write_callback (stream_out, 220 pa_stream_set_write_callback (stream_out,
221 &stream_write_callback, 221 &stream_write_callback,
222 NULL); 222 NULL);
223 if ((p = 223 if ((p =
224 pa_stream_connect_playback (stream_out, NULL, 224 pa_stream_connect_playback (stream_out, NULL,
225 NULL, 225 NULL,
226 PA_STREAM_ADJUST_LATENCY | PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE, 226 PA_STREAM_ADJUST_LATENCY | PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE,
227 NULL, NULL)) < 0) 227 NULL, NULL)) < 0)
@@ -232,19 +232,19 @@ context_state_callback (pa_context * c,
232 goto fail; 232 goto fail;
233 } 233 }
234 break; 234 break;
235 } 235 }
236 case PA_CONTEXT_TERMINATED: 236 case PA_CONTEXT_TERMINATED:
237 quit (0); 237 quit (0);
238 break; 238 break;
239 239
240 case PA_CONTEXT_FAILED: 240 case PA_CONTEXT_FAILED:
241 default: 241 default:
242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
243 _("Connection failure: %s\n"), 243 _("Connection failure: %s\n"),
244 pa_strerror (pa_context_errno (c))); 244 pa_strerror (pa_context_errno (c)));
245 goto fail; 245 goto fail;
246 } 246 }
247 return; 247 return;
248 fail: 248 fail:
249 quit (1); 249 quit (1);
250} 250}
@@ -260,13 +260,13 @@ pa_init ()
260 260
261 if (!pa_sample_spec_valid (&sample_spec)) 261 if (!pa_sample_spec_valid (&sample_spec))
262 { 262 {
263 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 263 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
264 _("Wrong Spec\n")); 264 _("Wrong Spec\n"));
265 } 265 }
266 /* set up threaded playback mainloop */ 266 /* set up threaded playback mainloop */
267 if (!(m = pa_threaded_mainloop_new ())) 267 if (!(m = pa_threaded_mainloop_new ()))
268 { 268 {
269 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 269 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
270 _("pa_mainloop_new() failed.\n")); 270 _("pa_mainloop_new() failed.\n"));
271 } 271 }
272 mainloop_api = pa_threaded_mainloop_get_api (m); 272 mainloop_api = pa_threaded_mainloop_get_api (m);
@@ -280,9 +280,9 @@ pa_init ()
280 /* connect to the main pulseaudio context */ 280 /* connect to the main pulseaudio context */
281 if (!(context = pa_context_new (mainloop_api, "GNUnet VoIP"))) 281 if (!(context = pa_context_new (mainloop_api, "GNUnet VoIP")))
282 { 282 {
283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
284 _("pa_context_new() failed.\n")); 284 _("pa_context_new() failed.\n"));
285 } 285 }
286 pa_context_set_state_callback (context, context_state_callback, NULL); 286 pa_context_set_state_callback (context, context_state_callback, NULL);
287 287
288 if (pa_context_connect (context, NULL, 0, NULL) < 0) 288 if (pa_context_connect (context, NULL, 0, NULL) < 0)
@@ -290,10 +290,10 @@ pa_init ()
290 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 290 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
291 _("pa_context_connect() failed: %s\n"), 291 _("pa_context_connect() failed: %s\n"),
292 pa_strerror (pa_context_errno (context))); 292 pa_strerror (pa_context_errno (context)));
293 } 293 }
294 if (pa_threaded_mainloop_start (m) < 0) 294 if (pa_threaded_mainloop_start (m) < 0)
295 { 295 {
296 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 296 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
297 _("pa_mainloop_run() failed.\n")); 297 _("pa_mainloop_run() failed.\n"));
298 } 298 }
299} 299}
@@ -354,7 +354,7 @@ main (int argc, char *argv[])
354 ready_pipe[1] = -1; 354 ready_pipe[1] = -1;
355 while (1) 355 while (1)
356 { 356 {
357 ret = read (0, readbuf, sizeof (readbuf)); 357 ret = read (0, readbuf, sizeof (readbuf));
358 toff += ret; 358 toff += ret;
359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
360 "Received %d bytes of audio data (total: %llu)\n", 360 "Received %d bytes of audio data (total: %llu)\n",
@@ -363,10 +363,10 @@ main (int argc, char *argv[])
363 if (0 > ret) 363 if (0 > ret)
364 { 364 {
365 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 365 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
366 _("Read error from STDIN: %s\n"), 366 _("Read error from STDIN: %s\n"),
367 strerror (errno)); 367 strerror (errno));
368 break; 368 break;
369 } 369 }
370 if (0 == ret) 370 if (0 == ret)
371 break; 371 break;
372 GNUNET_SERVER_mst_receive (stdin_mst, NULL, 372 GNUNET_SERVER_mst_receive (stdin_mst, NULL,