aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-03 18:19:50 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-03 18:19:50 +0000
commit68d8369974476a78d6a6ca20b937fcd59530690a (patch)
treef4baabe7506e4b6941a5f93f5b312e799941380f
parent9fd836bda9b9255d84fcaa0a463c5427980b3e79 (diff)
downloadgnunet-68d8369974476a78d6a6ca20b937fcd59530690a.tar.gz
gnunet-68d8369974476a78d6a6ca20b937fcd59530690a.zip
-removing header to avoid double-encapsulation overhead when going from helper to API
-rw-r--r--src/conversation/microphone.c8
-rw-r--r--src/conversation/speaker.c14
2 files changed, 10 insertions, 12 deletions
diff --git a/src/conversation/microphone.c b/src/conversation/microphone.c
index d994db889..2c399c74d 100644
--- a/src/conversation/microphone.c
+++ b/src/conversation/microphone.c
@@ -74,17 +74,17 @@ process_record_messages (void *cls,
74 const struct GNUNET_MessageHeader *msg) 74 const struct GNUNET_MessageHeader *msg)
75{ 75{
76 struct Microphone *mic = cls; 76 struct Microphone *mic = cls;
77 const struct AudioMessage *am;
77 78
78 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO) 79 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO)
79 { 80 {
80 GNUNET_break (0); 81 GNUNET_break (0);
81 return GNUNET_SYSERR; 82 return GNUNET_SYSERR;
82 } 83 }
83 // FIXME: unbox here, instead of sending with overhead! 84 am = (const struct AudioMessage *) msg;
84 // (see speaker.c::play)
85 mic->rdc (mic->rdc_cls, 85 mic->rdc (mic->rdc_cls,
86 ntohs (msg->size), 86 ntohs (msg->size) - sizeof (struct AudioMessage),
87 (const char *) msg); 87 &am[1]);
88 return GNUNET_OK; 88 return GNUNET_OK;
89} 89}
90 90
diff --git a/src/conversation/speaker.c b/src/conversation/speaker.c
index 5fdfff3ee..d67346f1f 100644
--- a/src/conversation/speaker.c
+++ b/src/conversation/speaker.c
@@ -130,20 +130,18 @@ play (void *cls,
130 const void *data) 130 const void *data)
131{ 131{
132 struct Speaker *spe = cls; 132 struct Speaker *spe = cls;
133 const struct AudioMessage *am; 133 char buf[sizeof (struct AudioMessage) + data_size];
134 struct AudioMessage *am;
134 135
135 if (NULL == spe->playback_helper) 136 if (NULL == spe->playback_helper)
136 { 137 {
137 GNUNET_break (0); 138 GNUNET_break (0);
138 return; 139 return;
139 } 140 }
140 // FIXME: box here, instead of expecting boxed data! 141 am = (struct AudioMessage *) buf;
141 if (sizeof (struct AudioMessage) > data_size) 142 am->header.size = htons (sizeof (struct AudioMessage) + data_size);
142 { 143 am->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
143 GNUNET_break (0); 144 memcpy (&am[1], data, data_size);
144 return;
145 }
146 am = (const struct AudioMessage *) data;
147 (void) GNUNET_HELPER_send (spe->playback_helper, 145 (void) GNUNET_HELPER_send (spe->playback_helper,
148 &am->header, 146 &am->header,
149 GNUNET_NO, 147 GNUNET_NO,