From 981f9cb15d3b6517fa75652843d6af09914c5f3f Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 15 May 2015 09:12:37 +0000
Subject: Haiku patch


diff --git a/configure.ac b/configure.ac
index edff53f..37563cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,6 +106,7 @@ fi
 
 LT_LIB_M
 AC_CHECK_LIB([winmm], [main])
+AC_CHECK_LIB([network], [socket])
 
 dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
diff --git a/src/opusrtp.c b/src/opusrtp.c
index 8ee793d..df7d3c9 100644
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -494,9 +494,10 @@ int update_rtp_header(rtp_header *rtp)
 int send_rtp_packet(int fd, struct sockaddr *sin,
     rtp_header *rtp, const unsigned char *opus)
 {
-  update_rtp_header(rtp);
-  unsigned char *packet = malloc(rtp->header_size + rtp->payload_size);
   int ret;
+  unsigned char *packet;
+  update_rtp_header(rtp);
+  packet = malloc(rtp->header_size + rtp->payload_size);
 
   if (!packet) {
     fprintf(stderr, "Couldn't allocate packet buffer\n");
@@ -521,6 +522,15 @@ int rtp_send_file(const char *filename, const char *dest, int port)
   struct sockaddr_in sin;
   int optval = 0;
   int ret;
+  FILE *in;
+  ogg_sync_state oy;
+  ogg_stream_state os;
+  ogg_page og;
+  ogg_packet op;
+  int headers = 0;
+  char *in_data;
+  const long in_size = 8192;
+  size_t in_read;
 
   if (fd < 0) {
     fprintf(stderr, "Couldn't create socket\n");
@@ -553,15 +563,7 @@ int rtp_send_file(const char *filename, const char *dest, int port)
   rtp.payload_size = 0;
 
   fprintf(stderr, "Sending %s...\n", filename);
-  FILE *in = fopen(filename, "rb");
-  ogg_sync_state oy;
-  ogg_stream_state os;
-  ogg_page og;
-  ogg_packet op;
-  int headers = 0;
-  char *in_data;
-  const long in_size = 8192;
-  size_t in_read;
+  in = fopen(filename, "rb");
 
   if (!in) {
     fprintf(stderr, "Couldn't open input file '%s'\n", filename);
-- 
2.2.2

