Use Suffix Extensions in Makefiles (doc, src/{arm,dht,integration,statistics}) for...
[oweals/gnunet.git] / src / conversation / speaker.c
index 255b79ee3496759a2a216a242de29fe0e4a38b0e..deff9e3194b7d8d25ccb94698a72181e27f0b9cd 100644 (file)
@@ -1,21 +1,21 @@
 /*
   This file is part of GNUnet
-  (C) 2013 Christian Grothoff (and other contributing authors)
-  
+  Copyright (C) 2013 GNUnet e.V.
+
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
   by the Free Software Foundation; either version 3, or (at your
   option) any later version.
-  
+
   GNUnet is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
-  
+
   You should have received a copy of the GNU General Public License
   along with GNUnet; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-  Boston, MA 02111-1307, USA.
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
  */
 
 /**
@@ -57,17 +57,17 @@ struct Speaker
 static int
 enable (void *cls)
 {
-  struct Speaker *spe = cls;  
-  static char *playback_helper_argv[] = 
+  struct Speaker *spe = cls;
+  static char *playback_helper_argv[] =
   {
     "gnunet-helper-audio-playback",
     NULL
   };
-  
+
   spe->playback_helper = GNUNET_HELPER_start (GNUNET_NO,
                                              "gnunet-helper-audio-playback",
                                              playback_helper_argv,
-                                             NULL, 
+                                             NULL,
                                              NULL, spe);
   if (NULL == spe->playback_helper)
   {
@@ -130,22 +130,21 @@ play (void *cls,
       const void *data)
 {
   struct Speaker *spe = cls;
-  const struct AudioMessage *am;
+  char buf[sizeof (struct AudioMessage) + data_size];
+  struct AudioMessage *am;
 
   if (NULL == spe->playback_helper)
   {
     GNUNET_break (0);
     return;
   }
-  if (sizeof (struct AudioMessage) != data_size)
-  {
-    GNUNET_break (0);
-    return;
-  }
-  am = (const struct AudioMessage *) data;
+  am = (struct AudioMessage *) buf;
+  am->header.size = htons (sizeof (struct AudioMessage) + data_size);
+  am->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
+  GNUNET_memcpy (&am[1], data, data_size);
   (void) GNUNET_HELPER_send (spe->playback_helper,
-                            &am->header, 
-                            GNUNET_YES, 
+                            &am->header,
+                            GNUNET_NO,
                             NULL, NULL);
 }