aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-02 21:05:48 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-02 21:05:48 +0000
commit875342e4d0114e626dcf502362787d048d5e12fc (patch)
tree9ae7e303b3310a892c219b702f36005336ad5eff /src/conversation
parent18b62beec7902acecaad00c0470f2f1d4d98b244 (diff)
downloadgnunet-875342e4d0114e626dcf502362787d048d5e12fc.tar.gz
gnunet-875342e4d0114e626dcf502362787d048d5e12fc.zip
-fix logging
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/conversation.h7
-rw-r--r--src/conversation/gnunet-helper-audio-playback.c136
-rw-r--r--src/conversation/gnunet-helper-audio-record.c151
-rw-r--r--src/conversation/gnunet-service-conversation.c55
-rw-r--r--src/conversation/microphone.c5
-rw-r--r--src/conversation/speaker.c2
6 files changed, 173 insertions, 183 deletions
diff --git a/src/conversation/conversation.h b/src/conversation/conversation.h
index 91630d8c2..12a62c1f7 100644
--- a/src/conversation/conversation.h
+++ b/src/conversation/conversation.h
@@ -396,11 +396,8 @@ struct AudioMessage
396 * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO 396 * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
397 */ 397 */
398 struct GNUNET_MessageHeader header; 398 struct GNUNET_MessageHeader header;
399 int32_t SequenceNumber; 399
400 struct GNUNET_TIME_Absolute time; 400 /* followed by audio data */
401 int32_t length;
402 int32_t encrypted;
403 uint8_t audio[200];
404 401
405}; 402};
406 403
diff --git a/src/conversation/gnunet-helper-audio-playback.c b/src/conversation/gnunet-helper-audio-playback.c
index 91231a87e..97664d0f5 100644
--- a/src/conversation/gnunet-helper-audio-playback.c
+++ b/src/conversation/gnunet-helper-audio-playback.c
@@ -55,77 +55,77 @@ static pa_sample_spec sample_spec = {
55}; 55};
56 56
57/** 57/**
58* Pulseaudio mainloop api 58 * Pulseaudio mainloop api
59*/ 59 */
60static pa_mainloop_api *mainloop_api; 60static pa_mainloop_api *mainloop_api;
61 61
62/** 62/**
63* Pulseaudio threaded mainloop 63 * Pulseaudio threaded mainloop
64*/ 64 */
65static pa_threaded_mainloop *m; 65static pa_threaded_mainloop *m;
66 66
67/** 67/**
68* Pulseaudio context 68 * Pulseaudio context
69*/ 69 */
70static pa_context *context; 70static pa_context *context;
71 71
72/** 72/**
73* Pulseaudio output stream 73 * Pulseaudio output stream
74*/ 74 */
75static pa_stream *stream_out; 75static pa_stream *stream_out;
76 76
77/** 77/**
78* Pulseaudio io events 78 * Pulseaudio io events
79*/ 79 */
80static pa_io_event *stdio_event; 80static pa_io_event *stdio_event;
81 81
82/** 82/**
83* OPUS decoder 83 * OPUS decoder
84*/ 84 */
85static OpusDecoder *dec; 85static OpusDecoder *dec;
86 86
87/** 87/**
88* PCM data buffer 88 * PCM data buffer
89*/ 89 */
90static float *pcm_buffer; 90static float *pcm_buffer;
91 91
92/** 92/**
93* Length of PCM buffer 93 * Length of PCM buffer
94*/ 94 */
95static int pcm_length; 95static int pcm_length;
96 96
97/** 97/**
98* Number of samples for one frame 98 * Number of samples for one frame
99*/ 99 */
100static int frame_size; 100static int frame_size;
101 101
102/** 102/**
103* The sampling rate used in Pulseaudio specification 103 * The sampling rate used in Pulseaudio specification
104*/ 104 */
105static opus_int32 sampling_rate; 105static opus_int32 sampling_rate;
106 106
107/** 107/**
108* Audio buffer 108 * Audio buffer
109*/ 109 */
110static void *buffer; 110static void *buffer;
111 111
112/** 112/**
113* Length of audio buffer 113 * Length of audio buffer
114*/ 114 */
115static size_t buffer_length; 115static size_t buffer_length;
116 116
117/** 117/**
118* Read index for transmit buffer 118 * Read index for transmit buffer
119*/ 119 */
120static size_t buffer_index; 120static size_t buffer_index;
121 121
122 122
123
124/** 123/**
125* Message callback 124 * Message callback
126*/ 125 */
127static void 126static void
128stdin_receiver (void *cls, const struct GNUNET_MessageHeader *msg) 127stdin_receiver (void *cls,
128 const struct GNUNET_MessageHeader *msg)
129{ 129{
130 struct AudioMessage *audio; 130 struct AudioMessage *audio;
131 131
@@ -135,9 +135,12 @@ stdin_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
135 audio = (struct AudioMessage *) msg; 135 audio = (struct AudioMessage *) msg;
136 136
137 int len = 137 int len =
138 opus_decode_float (dec, audio->audio, audio->length, pcm_buffer, 138 opus_decode_float (dec,
139 (const unsigned char *) &audio[1],
140 ntohs (audio->header.size) - sizeof (struct AudioMessage),
141 pcm_buffer,
139 frame_size, 0); 142 frame_size, 0);
140 143 // FIXME: pcm_length != len???
141 if (pa_stream_write 144 if (pa_stream_write
142 (stream_out, (uint8_t *) pcm_buffer, pcm_length, NULL, 0, 145 (stream_out, (uint8_t *) pcm_buffer, pcm_length, NULL, 0,
143 PA_SEEK_RELATIVE) < 0) 146 PA_SEEK_RELATIVE) < 0)
@@ -156,9 +159,10 @@ stdin_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
156 } 159 }
157} 160}
158 161
162
159/** 163/**
160* Pulseaudio shutdown task 164 * Pulseaudio shutdown task
161*/ 165 */
162static void 166static void
163quit (int ret) 167quit (int ret)
164{ 168{
@@ -166,9 +170,10 @@ quit (int ret)
166 exit (ret); 170 exit (ret);
167} 171}
168 172
173
169/** 174/**
170* Write some data to the stream 175 * Write some data to the stream
171*/ 176 */
172static void 177static void
173do_stream_write (size_t length) 178do_stream_write (size_t length)
174{ 179{
@@ -210,9 +215,10 @@ do_stream_write (size_t length)
210 } 215 }
211} 216}
212 217
218
213/** 219/**
214* Callback when data is there for playback 220 * Callback when data is there for playback
215*/ 221 */
216static void 222static void
217stream_write_callback (pa_stream * s, size_t length, void *userdata) 223stream_write_callback (pa_stream * s, size_t length, void *userdata)
218{ 224{
@@ -232,9 +238,10 @@ stream_write_callback (pa_stream * s, size_t length, void *userdata)
232 do_stream_write (length); 238 do_stream_write (length);
233} 239}
234 240
241
235/** 242/**
236* Exit callback for SIGTERM and SIGINT 243 * Exit callback for SIGTERM and SIGINT
237*/ 244 */
238static void 245static void
239exit_signal_callback (pa_mainloop_api * m, pa_signal_event * e, int sig, 246exit_signal_callback (pa_mainloop_api * m, pa_signal_event * e, int sig,
240 void *userdata) 247 void *userdata)
@@ -244,9 +251,10 @@ exit_signal_callback (pa_mainloop_api * m, pa_signal_event * e, int sig,
244 quit (1); 251 quit (1);
245} 252}
246 253
254
247/** 255/**
248* Pulseaudio stream state callback 256 * Pulseaudio stream state callback
249*/ 257 */
250static void 258static void
251context_state_callback (pa_context * c, void *userdata) 259context_state_callback (pa_context * c, void *userdata)
252{ 260{
@@ -309,13 +317,13 @@ context_state_callback (pa_context * c, void *userdata)
309 317
310fail: 318fail:
311 quit (1); 319 quit (1);
312
313} 320}
314 321
322
315/** 323/**
316* Pulseaudio initialization 324 * Pulseaudio initialization
317*/ 325 */
318void 326static void
319pa_init () 327pa_init ()
320{ 328{
321 int r; 329 int r;
@@ -365,10 +373,11 @@ pa_init ()
365 } 373 }
366} 374}
367 375
376
368/** 377/**
369* OPUS initialization 378 * OPUS initialization
370*/ 379 */
371void 380static void
372opus_init () 381opus_init ()
373{ 382{
374 int err; 383 int err;
@@ -381,6 +390,7 @@ opus_init ()
381 pcm_buffer = (float *) pa_xmalloc (frame_size * channels * sizeof (float)); 390 pcm_buffer = (float *) pa_xmalloc (frame_size * channels * sizeof (float));
382} 391}
383 392
393
384/** 394/**
385 * The main function for the playback helper. 395 * The main function for the playback helper.
386 * 396 *
@@ -394,25 +404,25 @@ main (int argc, char *argv[])
394 char readbuf[MAXLINE]; 404 char readbuf[MAXLINE];
395 struct MessageStreamTokenizer *stdin_mst; 405 struct MessageStreamTokenizer *stdin_mst;
396 406
407 GNUNET_assert (GNUNET_OK ==
408 GNUNET_log_setup ("gnunet-helper-audio-playback",
409 "WARNING",
410 NULL));
397 stdin_mst = mst_create (&stdin_receiver, NULL); 411 stdin_mst = mst_create (&stdin_receiver, NULL);
398
399 opus_init (); 412 opus_init ();
400 pa_init (); 413 pa_init ();
401
402 while (1) 414 while (1)
415 {
416 ssize_t ret = read (0, readbuf, sizeof (readbuf));
417 if (0 > ret)
403 { 418 {
404 ssize_t ret = read (0, readbuf, sizeof (readbuf)); 419 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
405 420 _("Read error from STDIN: %s\n"),
406 if (0 > ret) 421 strerror (errno));
407 { 422 break;
408 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 423 }
409 _("Read error from STDIN: %s\n"), strerror (errno)); 424 mst_receive (stdin_mst, readbuf, ret);
410 break; 425 }
411 }
412
413 mst_receive (stdin_mst, readbuf, ret);
414 }
415 mst_destroy (stdin_mst); 426 mst_destroy (stdin_mst);
416
417 return 0; 427 return 0;
418} 428}
diff --git a/src/conversation/gnunet-helper-audio-record.c b/src/conversation/gnunet-helper-audio-record.c
index 5d4c0399a..a3e760794 100644
--- a/src/conversation/gnunet-helper-audio-record.c
+++ b/src/conversation/gnunet-helper-audio-record.c
@@ -74,11 +74,6 @@ static pa_stream *stream_in;
74static pa_io_event *stdio_event; 74static pa_io_event *stdio_event;
75 75
76/** 76/**
77 * Message tokenizer
78 */
79static struct MessageStreamTokenizer *stdin_mst;
80
81/**
82 * OPUS encoder 77 * OPUS encoder
83 */ 78 */
84static OpusEncoder *enc; 79static OpusEncoder *enc;
@@ -148,55 +143,57 @@ packetizer ()
148{ 143{
149 while (transmit_buffer_length >= transmit_buffer_index + pcm_length) 144 while (transmit_buffer_length >= transmit_buffer_index + pcm_length)
150 { 145 {
151 int ret; 146 ssize_t ret;
152 int len; 147 int len; // FIXME: int?
153 148 size_t msg_size;
154 size_t msg_size = sizeof (struct AudioMessage); 149
155 150 memcpy (pcm_buffer,
156 memcpy (pcm_buffer, 151 (float *) transmit_buffer +
157 (float *) transmit_buffer + 152 (transmit_buffer_index / sizeof (float)), pcm_length);
158 (transmit_buffer_index / sizeof (float)), pcm_length); 153 len =
159 len = 154 opus_encode_float (enc, pcm_buffer, frame_size, opus_data,
160 opus_encode_float (enc, pcm_buffer, frame_size, opus_data, 155 max_payload_bytes);
161 max_payload_bytes); 156 if (len > UINT16_MAX - sizeof (struct AudioMessage))
162 157 {
163 audio_message->length = len; 158 GNUNET_break (0);
164 memcpy (audio_message->audio, opus_data, len); 159 len = UINT16_MAX - sizeof (struct AudioMessage);
165
166 if ((ret = write (1, audio_message, msg_size)) != msg_size)
167 {
168 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("write"));
169 return;
170 }
171
172 transmit_buffer_index += pcm_length;
173 } 160 }
161 msg_size = sizeof (struct AudioMessage) + len;
162 audio_message->header.size = htons ((uint16_t) msg_size);
163 memcpy (&audio_message[1], opus_data, len);
174 164
175 int new_size = transmit_buffer_length - transmit_buffer_index; 165 // FIXME: handle partial writes better...
176 166 if ((ret = write (1, audio_message, msg_size)) != msg_size)
177 if (0 != new_size)
178 { 167 {
168 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("write"));
169 return;
170 }
171 transmit_buffer_index += pcm_length;
172 }
179 173
180 transmit_buffer = pa_xrealloc (transmit_buffer, new_size); 174 int new_size = transmit_buffer_length - transmit_buffer_index;
181 memcpy (transmit_buffer, transmit_buffer + transmit_buffer_index, 175 if (0 != new_size)
182 new_size); 176 {
183 177 transmit_buffer = pa_xrealloc (transmit_buffer, new_size);
184 transmit_buffer_index = 0; 178 memcpy (transmit_buffer, transmit_buffer + transmit_buffer_index,
185 transmit_buffer_length = new_size; 179 new_size);
186 } 180
187 181 transmit_buffer_index = 0;
182 transmit_buffer_length = new_size;
183 }
188} 184}
189 185
186
190/** 187/**
191* Pulseaudio callback when new data is available. 188 * Pulseaudio callback when new data is available.
192*/ 189 */
193static void 190static void
194stream_read_callback (pa_stream * s, size_t length, void *userdata) 191stream_read_callback (pa_stream * s, size_t length, void *userdata)
195{ 192{
196 const void *data; 193 const void *data;
194
197 GNUNET_assert (s); 195 GNUNET_assert (s);
198 GNUNET_assert (length > 0); 196 GNUNET_assert (length > 0);
199
200 if (stdio_event) 197 if (stdio_event)
201 mainloop_api->io_enable (stdio_event, PA_IO_EVENT_OUTPUT); 198 mainloop_api->io_enable (stdio_event, PA_IO_EVENT_OUTPUT);
202 199
@@ -212,39 +209,43 @@ stream_read_callback (pa_stream * s, size_t length, void *userdata)
212 GNUNET_assert (length > 0); 209 GNUNET_assert (length > 0);
213 210
214 if (transmit_buffer) 211 if (transmit_buffer)
215 { 212 {
216 transmit_buffer = 213 transmit_buffer =
217 pa_xrealloc (transmit_buffer, transmit_buffer_length + length); 214 pa_xrealloc (transmit_buffer, transmit_buffer_length + length);
218 memcpy ((uint8_t *) transmit_buffer + transmit_buffer_length, data, 215 memcpy ((uint8_t *) transmit_buffer + transmit_buffer_length, data,
219 length); 216 length);
220 transmit_buffer_length += length; 217 transmit_buffer_length += length;
221 } 218 }
222 else 219 else
223 { 220 {
224 transmit_buffer = pa_xmalloc (length); 221 transmit_buffer = pa_xmalloc (length);
225 memcpy (transmit_buffer, data, length); 222 memcpy (transmit_buffer, data, length);
226 transmit_buffer_length = length; 223 transmit_buffer_length = length;
227 transmit_buffer_index = 0; 224 transmit_buffer_index = 0;
228 } 225 }
229
230 pa_stream_drop (s); 226 pa_stream_drop (s);
231 packetizer (); 227 packetizer ();
232} 228}
233 229
230
234/** 231/**
235* Exit callback for SIGTERM and SIGINT 232 * Exit callback for SIGTERM and SIGINT
236*/ 233 */
237static void 234static void
238exit_signal_callback (pa_mainloop_api * m, pa_signal_event * e, int sig, 235exit_signal_callback (pa_mainloop_api * m,
236 pa_signal_event * e,
237 int sig,
239 void *userdata) 238 void *userdata)
240{ 239{
241 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Got signal, exiting.\n")); 240 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
241 _("Got signal, exiting.\n"));
242 quit (1); 242 quit (1);
243} 243}
244 244
245
245/** 246/**
246* Pulseaudio stream state callback 247 * Pulseaudio stream state callback
247*/ 248 */
248static void 249static void
249stream_state_callback (pa_stream * s, void *userdata) 250stream_state_callback (pa_stream * s, void *userdata)
250{ 251{
@@ -305,11 +306,13 @@ stream_state_callback (pa_stream * s, void *userdata)
305 } 306 }
306} 307}
307 308
309
308/** 310/**
309* Pulseaudio context state callback 311 * Pulseaudio context state callback
310*/ 312 */
311static void 313static void
312context_state_callback (pa_context * c, void *userdata) 314context_state_callback (pa_context * c,
315 void *userdata)
313{ 316{
314 GNUNET_assert (c); 317 GNUNET_assert (c);
315 318
@@ -370,13 +373,13 @@ context_state_callback (pa_context * c, void *userdata)
370 373
371fail: 374fail:
372 quit (1); 375 quit (1);
373
374} 376}
375 377
378
376/** 379/**
377 * Pulsaudio init 380 * Pulsaudio init
378 */ 381 */
379void 382static void
380pa_init () 383pa_init ()
381{ 384{
382 int r; 385 int r;
@@ -425,28 +428,26 @@ pa_init ()
425 } 428 }
426} 429}
427 430
431
428/** 432/**
429 * OPUS init 433 * OPUS init
430 */ 434 */
431void 435static void
432opus_init () 436opus_init ()
433{ 437{
434 opus_int32 sampling_rate = 48000; 438 opus_int32 sampling_rate = 48000;
435 frame_size = sampling_rate / 50;
436 int channels = 1; 439 int channels = 1;
437
438 pcm_length = frame_size * channels * sizeof (float);
439
440 int err; 440 int err;
441 441
442 frame_size = sampling_rate / 50;
443 pcm_length = frame_size * channels * sizeof (float);
442 enc = 444 enc =
443 opus_encoder_create (sampling_rate, channels, OPUS_APPLICATION_VOIP, 445 opus_encoder_create (sampling_rate, channels, OPUS_APPLICATION_VOIP,
444 &err); 446 &err);
445 pcm_buffer = (float *) pa_xmalloc (pcm_length); 447 pcm_buffer = (float *) pa_xmalloc (pcm_length);
446 opus_data = (unsigned char *) calloc (max_payload_bytes, sizeof (char)); 448 opus_data = (unsigned char *) calloc (max_payload_bytes, sizeof (char));
447 449
448 audio_message = pa_xmalloc (sizeof (struct AudioMessage)); 450 audio_message = pa_xmalloc (UINT16_MAX);
449 audio_message->header.size = htons (sizeof (struct AudioMessage));
450 audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); 451 audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
451} 452}
452 453
@@ -461,6 +462,10 @@ opus_init ()
461int 462int
462main (int argc, char *argv[]) 463main (int argc, char *argv[])
463{ 464{
465 GNUNET_assert (GNUNET_OK ==
466 GNUNET_log_setup ("gnunet-helper-audio-record",
467 "WARNING",
468 NULL));
464 opus_init (); 469 opus_init ();
465 pa_init (); 470 pa_init ();
466 471
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c
index 5575b23fc..4c4bdc133 100644
--- a/src/conversation/gnunet-service-conversation.c
+++ b/src/conversation/gnunet-service-conversation.c
@@ -128,36 +128,31 @@ static struct GNUNET_MESH_Tunnel *tunnel_unreliable;
128/** 128/**
129* List for missed calls 129* List for missed calls
130*/ 130*/
131struct GNUNET_CONTAINER_SList *missed_calls; 131static struct GNUNET_CONTAINER_SList *missed_calls;
132 132
133/** 133/**
134* List for peers to notify that we are available again 134* List for peers to notify that we are available again
135*/ 135*/
136struct GNUNET_CONTAINER_SList *peers_to_notify; 136static struct GNUNET_CONTAINER_SList *peers_to_notify;
137 137
138/** 138/**
139* Audio buffer (outgoing) 139* Audio buffer (outgoing)
140*/ 140*/
141struct GNUNET_CONTAINER_SList *audio_buffer; 141static struct GNUNET_CONTAINER_SList *audio_buffer;
142 142
143/** 143/**
144* The pointer to the task for sending audio 144* The pointer to the task for sending audio
145*/ 145*/
146GNUNET_SCHEDULER_TaskIdentifier audio_task; 146static GNUNET_SCHEDULER_TaskIdentifier audio_task;
147 147
148/** 148/**
149* The pointer to the task for checking timeouts an calling a peer 149* The pointer to the task for checking timeouts an calling a peer
150*/ 150*/
151GNUNET_SCHEDULER_TaskIdentifier timeout_task; 151static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
152 152
153/** 153/**
154* Sequencenumber for the pakets (for evaltuation purposes) 154 * Timestamp for call statistics
155*/ 155 */
156int SequenceNumber = 0;
157
158/**
159* Timestamp for call statistics
160*/
161static struct GNUNET_TIME_Absolute start_time; 156static struct GNUNET_TIME_Absolute start_time;
162 157
163/** 158/**
@@ -891,8 +886,6 @@ transmit_mesh_message (void *cls, size_t size, void *buf)
891{ 886{
892 struct VoIPMeshMessageHeader *msg_header = 887 struct VoIPMeshMessageHeader *msg_header =
893 (struct VoIPMeshMessageHeader *) cls; 888 (struct VoIPMeshMessageHeader *) cls;
894 msg_header->SequenceNumber = SequenceNumber += 1;
895 msg_header->time = GNUNET_TIME_absolute_get ();
896 889
897 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transmitting message over mesh\n")); 890 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transmitting message over mesh\n"));
898 891
@@ -984,9 +977,6 @@ transmit_audio_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
984 iterator = GNUNET_CONTAINER_slist_begin (audio_buffer); 977 iterator = GNUNET_CONTAINER_slist_begin (audio_buffer);
985 msg = 978 msg =
986 (struct AudioMessage *) GNUNET_CONTAINER_slist_get (&iterator, NULL); 979 (struct AudioMessage *) GNUNET_CONTAINER_slist_get (&iterator, NULL);
987 msg->SequenceNumber = SequenceNumber += 1;
988 msg->time = GNUNET_TIME_absolute_get ();
989
990 GNUNET_CONTAINER_slist_erase (&iterator); 980 GNUNET_CONTAINER_slist_erase (&iterator);
991 GNUNET_CONTAINER_slist_iter_destroy (&iterator); 981 GNUNET_CONTAINER_slist_iter_destroy (&iterator);
992 } 982 }
@@ -1344,30 +1334,19 @@ handle_mesh_audio_message (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
1344 void **tunnel_ctx, 1334 void **tunnel_ctx,
1345 const struct GNUNET_MessageHeader *message) 1335 const struct GNUNET_MessageHeader *message)
1346{ 1336{
1337 const struct AudioMessage *audio;
1338 audio = (const struct AudioMessage *) message;
1347 1339
1348 GNUNET_MESH_receive_done (tunnel); 1340 GNUNET_MESH_receive_done (tunnel);
1349
1350 if (CONNECTED != connection.status) 1341 if (CONNECTED != connection.status)
1351 return GNUNET_OK; 1342 return GNUNET_OK;
1352 1343 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1353 1344 "[RECV] %dbytes\n",
1354 struct AudioMessage *audio; 1345 ntohs (audio->header.size));
1355 size_t msg_size;
1356 msg_size = sizeof (struct AudioMessage);
1357
1358 audio = (struct AudioMessage *) message;
1359
1360 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "[RECV] %dbytes\n", audio->length);
1361
1362 if (NULL == playback_helper) 1346 if (NULL == playback_helper)
1363 return GNUNET_OK; 1347 return GNUNET_OK;
1364
1365 (void) GNUNET_HELPER_send (playback_helper, 1348 (void) GNUNET_HELPER_send (playback_helper,
1366 message, GNUNET_YES, NULL, NULL); 1349 message, GNUNET_YES, NULL, NULL);
1367
1368 data_received++;
1369 data_received_size += msg_size;
1370
1371 return GNUNET_OK; 1350 return GNUNET_OK;
1372} 1351}
1373 1352
@@ -1387,14 +1366,14 @@ static int
1387process_record_messages (void *cls GNUNET_UNUSED, void *client, 1366process_record_messages (void *cls GNUNET_UNUSED, void *client,
1388 const struct GNUNET_MessageHeader *msg) 1367 const struct GNUNET_MessageHeader *msg)
1389{ 1368{
1390 size_t msg_size; 1369 const struct AudioMessage *message = (const struct AudioMessage *) msg;
1391 struct AudioMessage *message = (struct AudioMessage *) msg;
1392 msg_size = sizeof (struct AudioMessage);
1393 1370
1394 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " [REC] %dbyte\n", message->length); 1371 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1372 " [REC] %dbyte\n",
1373 ntohs (message->header.size));
1395 GNUNET_CONTAINER_slist_add_end (audio_buffer, 1374 GNUNET_CONTAINER_slist_add_end (audio_buffer,
1396 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, 1375 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
1397 message, msg_size); 1376 message, ntohs (message->header.size));
1398 1377
1399 return GNUNET_OK; 1378 return GNUNET_OK;
1400} 1379}
diff --git a/src/conversation/microphone.c b/src/conversation/microphone.c
index 53ac5cb86..f42f571c8 100644
--- a/src/conversation/microphone.c
+++ b/src/conversation/microphone.c
@@ -75,14 +75,13 @@ process_record_messages (void *cls,
75{ 75{
76 struct Microphone *mic = cls; 76 struct Microphone *mic = cls;
77 77
78 if ( (ntohs (msg->size) != sizeof (struct AudioMessage)) || 78 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO)
79 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO) )
80 { 79 {
81 GNUNET_break (0); 80 GNUNET_break (0);
82 return GNUNET_SYSERR; 81 return GNUNET_SYSERR;
83 } 82 }
84 mic->rdc (mic->rdc_cls, 83 mic->rdc (mic->rdc_cls,
85 sizeof (struct AudioMessage), 84 ntohs (msg->size),
86 (const char *) msg); 85 (const char *) msg);
87 return GNUNET_OK; 86 return GNUNET_OK;
88} 87}
diff --git a/src/conversation/speaker.c b/src/conversation/speaker.c
index 255b79ee3..81c62da81 100644
--- a/src/conversation/speaker.c
+++ b/src/conversation/speaker.c
@@ -137,7 +137,7 @@ play (void *cls,
137 GNUNET_break (0); 137 GNUNET_break (0);
138 return; 138 return;
139 } 139 }
140 if (sizeof (struct AudioMessage) != data_size) 140 if (sizeof (struct AudioMessage) > data_size)
141 { 141 {
142 GNUNET_break (0); 142 GNUNET_break (0);
143 return; 143 return;