Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Oct 2012 07:55:29 GMT
From:      Manuel Creach <manuel.creach@icloud.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/172775: New port: audio/libshairport a library for Airport Extreme Emulation
Message-ID:  <201210160755.q9G7tTcW043072@red.freebsd.org>
Resent-Message-ID: <201210160800.q9G800JH027051@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         172775
>Category:       ports
>Synopsis:       New port: audio/libshairport a library for Airport Extreme Emulation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 16 08:00:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Manuel Creach
>Release:        9.1-RC2
>Organization:
>Environment:
FreeBSD j1 9.1-RC2 FreeBSD 9.1-RC2 #1 r241574: Mon Oct 15 10:52:07 CEST 2012     root@hpjm-bsd:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
New port Makefile for libshairport, a fork of shairport, an Airport Extreme Emulator
>How-To-Repeat:

>Fix:
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	libshairport
#	libshairport/Makefile
#	libshairport/files
#	libshairport/files/patch-configure.in
#	libshairport/files/patch-src-Makefile.am
#	libshairport/files/patch-src-alac.c
#	libshairport/files/patch-src-ao.h
#	libshairport/files/patch-src-hairtunes.c
#	libshairport/files/patch-src-hairtunes.h
#	libshairport/files/patch-src-shairport.c
#	libshairport/files/patch-src-shairport.h
#	libshairport/files/patch-src-socketlib.c
#	libshairport/distinfo
#	libshairport/pkg-descr
#	libshairport/pkg-plist
#
echo c - libshairport
mkdir -p libshairport > /dev/null 2>&1
echo x - libshairport/Makefile
sed 's/^X//' >libshairport/Makefile << '5c7418efc11c80978c212e0f06c251eb'
X# New ports collection makefile for:    libshairport
X# Date created:                         2012.10.16
X# Whom:                                 Manuel Creach <manuel.creach@icloud.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	libshairport
XPORTVERSION=	1.2.0.20310
XCATEGORIES=	audio
XMASTER_SITES=	http://mirrors.xbmc.org/build-deps/darwin-libs/
XDISTFILES=	libshairport-${PORTVERSION}_lib.tar.gz
X
XMAINTAINER=	manuel.creach@icloud.com
XCOMMENT=	An Airport Extreme Emulator
X
XPORT_REVISION=	1
XWRKSRC=		${WRKDIR}/libshairport-${PORTVERSION}_lib
X
XLICENSE_FILE=	${WRKSRC}/COPYING
X
XFETCH_ARGS=
XUSE_GMAKE=      yes
XUSE_AUTORECONF=	yes
XUSE_AUTOTOOLS=	aclocal autoheader automake autoconf libtoolize
XACLOCAL_ARGS=	-I.
XAUTOMAKE_ARGS=	--add-missing
XUSE_LDCONFIG=	yes
X
XCPPFLAGS+=	-isystem${LOCALBASE}/include
XLDFLAGS+=	-L${LOCALBASE}/lib
X
X.include <bsd.port.mk>
5c7418efc11c80978c212e0f06c251eb
echo c - libshairport/files
mkdir -p libshairport/files > /dev/null 2>&1
echo x - libshairport/files/patch-configure.in
sed 's/^X//' >libshairport/files/patch-configure.in << 'ca708c4d87ce58c88fcd9e21bdd9cb0e'
X--- configure.in.orig	2011-09-23 22:56:46.000000000 +0200
X+++ configure.in	2012-10-09 12:09:33.000000000 +0200
X@@ -11,8 +11,9 @@
X 
X # Checks for libraries.
X #AC_CHECK_LIB([c],   [main])
X-#AC_CHECK_LIB([m],   [main])
X+AC_CHECK_LIB([m],   [main])
X AC_CHECK_LIB([ssl], [main],, AC_MSG_ERROR($missing_library))
X+AC_CHECK_LIB([crypto], [main],, AC_MSG_ERROR($missing_library))
X AC_CHECK_LIB([pthread], [main],, AC_MSG_ERROR($missing_library))
X 
X OUTPUT_FILES="Makefile"
X@@ -21,4 +22,4 @@
X 
X AC_CONFIG_FILES([${OUTPUT_FILES}])
X AC_OUTPUT(Makefile src/Makefile)
X-AC_OUTPUT
X\ No newline at end of file
X+AC_OUTPUT
ca708c4d87ce58c88fcd9e21bdd9cb0e
echo x - libshairport/files/patch-src-Makefile.am
sed 's/^X//' >libshairport/files/patch-src-Makefile.am << 'e23117e18e22c967e6bfc1bda7b3024c'
X--- src/Makefile.am.orig	2011-09-23 23:14:39.000000000 +0200
X+++ src/Makefile.am	2012-10-09 12:09:33.000000000 +0200
X@@ -1,7 +1,7 @@
X lib_LTLIBRARIES=libshairport.la
X 
X-library_includedir=$(includedir)
X-library_include_HEADERS = shairport.h
X+library_includedir=$(includedir)/shairport
X+library_include_HEADERS = shairport.h ao.h socketlib.h
X 
X libshairport_la_SOURCES=shairport.c hairtunes.c socketlib.c alac.c
X libshairport_la_LDFLAGS=-dynamiclib
e23117e18e22c967e6bfc1bda7b3024c
echo x - libshairport/files/patch-src-alac.c
sed 's/^X//' >libshairport/files/patch-src-alac.c << '4e0672ca3fb3fad3df189af3a9387410'
X--- src/alac.c.orig	2011-08-21 00:06:21.000000000 +0200
X+++ src/alac.c	2012-10-09 12:09:33.000000000 +0200
X@@ -804,7 +804,7 @@
X             }
X             else
X             {
X-                fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type);
X+                xprintf("FIXME: unhandled predicition type: %i\n", prediction_type);
X                 /* i think the only other prediction type (or perhaps this is just a
X                  * boolean?) runs adaptive fir twice.. like:
X                  * predictor_decompress_fir_adapt(predictor_error, tempout, ...)
X@@ -885,7 +885,7 @@
X         }
X         case 20:
X         case 32:
X-            fprintf(stderr, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
X+            xprintf("FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
X             break;
X         default:
X             break;
X@@ -1004,7 +1004,7 @@
X             }
X             else
X             { /* see mono case */
X-                fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a);
X+                xprintf("FIXME: unhandled predicition type: %i\n", prediction_type_a);
X             }
X 
X             /* channel 2 */
X@@ -1029,7 +1029,7 @@
X             }
X             else
X             {
X-                fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_b);
X+                xprintf("FIXME: unhandled predicition type: %i\n", prediction_type_b);
X             }
X         }
X         else
X@@ -1106,7 +1106,7 @@
X         }
X         case 20:
X         case 32:
X-            fprintf(stderr, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
X+            xprintf("FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
X             break;
X         default:
X             break;
4e0672ca3fb3fad3df189af3a9387410
echo x - libshairport/files/patch-src-ao.h
sed 's/^X//' >libshairport/files/patch-src-ao.h << '4ca661ecb85e5cf2d56a0ce029946698'
X--- src/ao.h.orig	2012-10-09 12:33:01.000000000 +0200
X+++ src/ao.h	2012-10-09 12:09:33.000000000 +0200
X@@ -0,0 +1,158 @@
X+/*
X+ *
X+ *  ao.h 
X+ *
X+ *  Original Copyright (C) Aaron Holtzman - May 1999
X+ *      Modifications Copyright (C) Stan Seibert - July 2000, July 2001
X+ *      More Modifications Copyright (C) Jack Moffitt - October 2000
X+ *
X+ *  This file is part of libao, a cross-platform audio outputlibrary.  See
X+ *  README for a history of this source code.
X+ *
X+ *  libao is free software; you can redistribute it and/or modify
X+ *  it under the terms of the GNU General Public License as published by
X+ *  the Free Software Foundation; either version 2, or (at your option)
X+ *  any later version.
X+ *
X+ *  libao is distributed in the hope that it will be useful,
X+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
X+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X+ *  GNU General Public License for more details.
X+ *
X+ *  You should have received a copy of the GNU General Public License
X+ *  along with GNU Make; see the file COPYING.  If not, write to
X+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
X+ *
X+ */
X+#ifndef __AO_H__
X+#define __AO_H__
X+
X+#ifdef __cplusplus
X+extern "C"
X+{
X+#endif /* __cplusplus */
X+
X+#include <stdio.h>
X+#include <stdlib.h>
X+#include <stdint.h>
X+#include <errno.h>
X+
X+/* --- Constants ---*/
X+
X+#define AO_TYPE_LIVE 1
X+#define AO_TYPE_FILE 2
X+
X+
X+#define AO_ENODRIVER   1
X+#define AO_ENOTFILE    2
X+#define AO_ENOTLIVE    3
X+#define AO_EBADOPTION  4
X+#define AO_EOPENDEVICE 5
X+#define AO_EOPENFILE   6
X+#define AO_EFILEEXISTS 7
X+#define AO_EBADFORMAT  8
X+
X+#define AO_EFAIL       100
X+
X+
X+#define AO_FMT_LITTLE 1
X+#define AO_FMT_BIG    2
X+#define AO_FMT_NATIVE 4
X+
X+/* --- Structures --- */
X+
X+typedef struct ao_info {
X+  int  type; /* live output or file output? */
X+  char *name; /* full name of driver */
X+  char *short_name; /* short name of driver */
X+        char *author; /* driver author */
X+  char *comment; /* driver comment */
X+  int  preferred_byte_format;
X+  int  priority;
X+  char **options;
X+  int  option_count;
X+} ao_info;
X+
X+typedef struct ao_functions ao_functions;
X+typedef struct ao_device ao_device;
X+
X+typedef struct ao_sample_format {
X+  int  bits; /* bits per sample */
X+  int  rate; /* samples per second (in a single channel) */
X+  int  channels; /* number of audio channels */
X+  int  byte_format; /* Byte ordering in sample, see constants below */
X+        char *matrix; /* input channel location/ordering */
X+} ao_sample_format;
X+
X+typedef struct ao_option {
X+  char *key;
X+  char *value;
X+  struct ao_option *next;
X+} ao_option;
X+
X+#if defined(AO_BUILDING_LIBAO)
X+#include "ao_private.h"
X+#endif
X+
X+/* --- Functions --- */
X+
X+/* library setup/teardown */
X+void ao_initialize(void);
X+void ao_shutdown(void);
X+
X+/* device setup/playback/teardown */
X+int   ao_append_global_option(const char *key,
X+                              const char *value);
X+int          ao_append_option(ao_option **options,
X+                              const char *key,
X+                              const char *value);
X+void          ao_free_options(ao_option *options);
X+
X+char* ao_get_option(ao_option *options, const char* key);
X+
X+ao_device*       ao_open_live(int driver_id,
X+                              ao_sample_format *format,
X+                              ao_option *option);
X+ao_device*       ao_open_file(int driver_id,
X+                              const char *filename,
X+                              int overwrite,
X+                              ao_sample_format *format,
X+                              ao_option *option);
X+
X+int                   ao_play(ao_device *device,
X+                              char *output_samples,
X+                              uint32_t num_bytes);
X+int                  ao_close(ao_device *device);
X+
X+/* driver information */
X+int              ao_driver_id(const char *short_name);
X+int      ao_default_driver_id(void);
X+ao_info       *ao_driver_info(int driver_id);
X+ao_info **ao_driver_info_list(int *driver_count);
X+char       *ao_file_extension(int driver_id);
X+
X+/* miscellaneous */
X+int          ao_is_big_endian(void);
X+
X+
X+#ifdef __cplusplus
X+}
X+#endif /* __cplusplus */
X+
X+#endif  /* __AO_H__ */
X+
X+extern struct AudioOutput g_ao;
X+struct AudioOutput                                                                                                                                                                                              
X+  {                                                                                                                                                                                                              
X+      void (*ao_initialize)(void);                                                                                                                                                                               
X+      int (*ao_play)(ao_device *, char *, uint32_t);                                                                                                                                                             
X+      int (*ao_default_driver_id)(void);                                                                                                                                                                         
X+      ao_device* (*ao_open_live)( int, ao_sample_format *, ao_option *);                                                                                                                                         
X+      int (*ao_close)(ao_device *);                                                                                                                                                                              
X+      /* -- Device Setup/Playback/Teardown -- */                                                                                                                                                                 
X+      int (*ao_append_option)(ao_option **, const char *, const char *);                                                                                                                                         
X+      void (*ao_free_options)(ao_option *);                                                                                                                                                                      
X+      char* (*ao_get_option)(ao_option *, const char* );
X+      void (*ao_set_metadata)(const char *buffer, unsigned int size);                                                                                                                                                         
X+      void (*ao_set_metadata_coverart)(const char *buffer, unsigned int size);
X+  }; 
4ca661ecb85e5cf2d56a0ce029946698
echo x - libshairport/files/patch-src-hairtunes.c
sed 's/^X//' >libshairport/files/patch-src-hairtunes.c << '27ab793ce245aded2b52c65d3b10412c'
X--- src/hairtunes.c.orig	2011-09-23 21:55:48.000000000 +0200
X+++ src/hairtunes.c	2012-10-09 12:09:33.000000000 +0200
X@@ -25,7 +25,7 @@
X  */
X 
X #define XBMC
X-//#defined HAS_AO
X+#define HAS_AO
X 
X #include <stdio.h>
X #include <stdlib.h>
X@@ -45,7 +45,7 @@
X #include <sys/signal.h>
X #include <fcntl.h>
X #ifdef HAS_AO
X-#include <ao/ao.h>
X+#include "ao.h"
X #endif
X 
X #ifdef FANCY_RESAMPLING
X@@ -89,7 +89,6 @@
X // maximal resampling shift - conservative
X #define OUTFRAME_BYTES (4*(frame_size+3))
X 
X-
X alac_file *decoder_info;
X 
X #ifdef FANCY_RESAMPLING
X@@ -122,8 +121,8 @@
X pthread_cond_t ab_buffer_ready;
X 
X static void die(char *why) {
X-    fprintf(stderr, "FATAL: %s\n", why);
X-    exit(1);
X+    xprintf("FATAL: %s\n", why);
X+    //exit(1);
X }
X 
X static int hex2bin(unsigned char *buf, char *hex) {
X@@ -246,13 +245,13 @@
X             continue;
X         }
X         if (!strcmp(line, "exit\n")) {
X-            exit(0);
X+            ;//exit(0);
X         }
X         if (!strcmp(line, "flush\n")) {
X             hairtunes_flush();
X         }
X     }
X-    fprintf(stderr, "bye!\n");
X+    xprintf("bye!\n");
X     fflush(stderr);
X #endif
X 
X@@ -263,18 +262,28 @@
X {
X   assert(f<=0);
X   if (debug)
X-      fprintf(stderr, "VOL: %lf\n", f);
X+      xprintf("VOL: %lf\n", f);
X   volume = pow(10.0,0.05*f);
X   fix_volume = 65536.0 * volume;
X }
X 
X+void hairtunes_set_metadata(const char *buffer, unsigned int size)
X+{
X+  g_ao.ao_set_metadata(buffer, size);
X+}
X+
X+void hairtunes_set_metadata_coverart(const char *buffer, unsigned int size)
X+{
X+  g_ao.ao_set_metadata_coverart(buffer, size);
X+}
X+
X void hairtunes_flush(void)
X {
X   pthread_mutex_lock(&ab_mutex);
X   ab_resync();
X   pthread_mutex_unlock(&ab_mutex);
X   if (debug)
X-      fprintf(stderr, "FLUSH\n");
X+      xprintf("FLUSH\n");
X }
X 
X #ifdef HAIRTUNES_STANDALONE
X@@ -424,7 +433,7 @@
X     } else if (seq_order(ab_read, seqno)) {     // late but not yet played
X         abuf = audio_buffer + BUFIDX(seqno);
X     } else {    // too late.
X-        fprintf(stderr, "\nlate packet %04X (%04X:%04X)\n", seqno, ab_read, ab_write);
X+        xprintf("\nlate packet %04X (%04X:%04X)\n", seqno, ab_read, ab_write);
X     }
X     buf_fill = ab_write - ab_read;
X     pthread_mutex_unlock(&ab_mutex);
X@@ -521,7 +530,7 @@
X     if (seq_order(last, first))
X         return;
X 
X-    fprintf(stderr, "requesting resend on %d packets (port %d)\n", last-first+1, controlport);
X+    xprintf("requesting resend on %d packets (port %d)\n", last-first+1, controlport);
X 
X     char req[8];    // *not* a standard RTCP NACK
X     req[0] = 0x80;
X@@ -605,8 +614,8 @@
X         port += 3;
X     }
X 
X-    printf("port: %d\n", port); // let our handler know where we end up listening
X-    printf("cport: %d\n", port+1);
X+    xprintf("port: %d\n", port); // let our handler know where we end up listening
X+    xprintf("cport: %d\n", port+1);
X 
X     rtp_sockets[0] = sock;
X     rtp_sockets[1] = csock;
X@@ -709,7 +718,7 @@
X     bf_est_drift = biquad_filt(&bf_drift_lpf, CONTROL_B*(bf_est_err*CONTROL_A + err_deriv) + bf_est_drift);
X 
X     if (debug)
X-        fprintf(stderr, "bf %d err %f drift %f desiring %f ed %f estd %f\r", fill, bf_est_err, bf_est_drift, desired_fill, err_deriv, err_deriv + CONTROL_A*bf_est_err);
X+        xprintf("bf %d err %f drift %f desiring %f ed %f estd %f\r", fill, bf_est_err, bf_est_drift, desired_fill, err_deriv, err_deriv + CONTROL_A*bf_est_err);
X     bf_playback_rate = 1.0 + CONTROL_A*bf_est_err + bf_est_drift;
X 
X     bf_last_err = bf_est_err;
X@@ -725,7 +734,7 @@
X     buf_fill = ab_write - ab_read;
X     if (buf_fill < 1 || !ab_synced || ab_buffering) {    // init or underrun. stop and wait
X         if (ab_synced)
X-          fprintf(stderr, "\nunderrun\n");
X+          xprintf("\nunderrun\n");
X 
X         ab_buffering = 1;
X         pthread_cond_wait(&ab_buffer_ready, &ab_mutex);
X@@ -737,7 +746,7 @@
X         return 0;
X     }
X     if (buf_fill >= BUFFER_FRAMES) {   // overrunning! uh-oh. restart at a sane distance
X-        fprintf(stderr, "\noverrun.\n");
X+        xprintf("\noverrun.\n");
X         ab_read = ab_write - START_FILL;
X     }
X     read = ab_read;
X@@ -749,7 +758,7 @@
X 
X     volatile abuf_t *curframe = audio_buffer + BUFIDX(read);
X     if (!curframe->ready) {
X-        fprintf(stderr, "\nmissing frame.\n");
X+        xprintf("\nmissing frame.\n");
X         memset(curframe->data, 0, FRAME_BYTES);
X     }
X     curframe->ready = 0;
X@@ -776,13 +785,13 @@
X     if (stuff) {
X         if (stuff==1) {
X             if (debug)
X-                fprintf(stderr, "+++++++++\n");
X+                xprintf("+++++++++\n");
X             // interpolate one sample
X             *outptr++ = dithered_vol(((long)inptr[-2] + (long)inptr[0]) >> 1);
X             *outptr++ = dithered_vol(((long)inptr[-1] + (long)inptr[1]) >> 1);
X         } else if (stuff==-1) {
X             if (debug)
X-                fprintf(stderr, "---------\n");
X+                xprintf("---------\n");
X             inptr++;
X             inptr++;
X         }
X@@ -849,6 +858,11 @@
X             inbuf = buffer_get_frame();
X         } while (!inbuf && audio_running);
X 
X+        if(!audio_running)
X+        {
X+          return 0; //don't access inbuf if audio stopped
X+        }
X+
X #ifdef FANCY_RESAMPLING
X         if (fancy_resampling) {
X 	        int i;
X@@ -881,7 +895,7 @@
X             }
X #ifdef HAS_AO
X         } else {
X-            ao_play(dev, (char *)outbuf, play_samples*4);
X+            g_ao.ao_play(dev, (char *)outbuf, play_samples*4);
X #endif
X         }
X     }
X@@ -906,7 +920,7 @@
X ao_device *dev;
X 
X void* init_ao() {
X-    ao_initialize();
X+    g_ao.ao_initialize();
X 
X     int driver;
X #ifndef XBMC
X@@ -921,7 +935,7 @@
X #endif
X     {
X         // otherwise choose the default
X-        driver = ao_default_driver_id();
X+        driver = g_ao.ao_default_driver_id();
X     }
X 
X     ao_sample_format fmt;
X@@ -944,9 +958,9 @@
X     }
X #endif
X 
X-    ao_append_option(&ao_opts, "name", "Streaming...");
X+    g_ao.ao_append_option(&ao_opts, "name", "Streaming...");
X 
X-    dev = ao_open_live(driver, &fmt, ao_opts);
X+    dev = g_ao.ao_open_live(driver, &fmt, ao_opts);
X     if (dev == NULL) {
X         die("Could not open ao device");
X     }
X@@ -985,12 +999,13 @@
X   audio_running = 0;
X   pthread_join(audio_thread, NULL);
X #ifdef HAS_AO
X-  ao_close(dev);
X+  g_ao.ao_close(dev);
X #endif
X }
X 
X void hairtunes_cleanup(void)
X {
X+  pthread_cond_signal(&ab_buffer_ready);
X   clean_output();
X   clean_rtp();
X   clean_buffer();
27ab793ce245aded2b52c65d3b10412c
echo x - libshairport/files/patch-src-hairtunes.h
sed 's/^X//' >libshairport/files/patch-src-hairtunes.h << 'ea63c8a5bc9eabbf0c06b0e12d17b384'
X--- src/hairtunes.h.orig	2011-08-21 00:06:21.000000000 +0200
X+++ src/hairtunes.h	2012-10-09 12:09:33.000000000 +0200
X@@ -4,6 +4,8 @@
X int hairtunes_init(char *pAeskey, char *pAesiv, char *pFmtpstr, int pCtrlPort, int pTimingPort,
X          int pDataPort, char *pRtpHost, char*pPipeName, char *pLibaoDriver, char *pLibaoDeviceName, char *pLibaoDeviceId);
X void hairtunes_setvolume(float vol);
X+void hairtunes_set_metadata(const char *buffer, unsigned int size);
X+void hairtunes_set_metadata_coverart(const char *buffer, unsigned int size);
X void hairtunes_flush(void);
X void hairtunes_cleanup(void);
X 
ea63c8a5bc9eabbf0c06b0e12d17b384
echo x - libshairport/files/patch-src-shairport.c
sed 's/^X//' >libshairport/files/patch-src-shairport.c << '9b81ded57db6ede748e65e727bbde045'
X--- src/shairport.c.orig	2011-08-21 01:57:56.000000000 +0200
X+++ src/shairport.c	2012-10-09 12:09:33.000000000 +0200
X@@ -31,6 +31,27 @@
X #include "shairport.h"
X #include "hairtunes.h"
X 
X+static struct printfPtr g_printf={NULL};
X+
X+int xprintf(const char *format, ...)
X+{
X+  char dbg[2048];
X+  va_list args;
X+  va_start(args, format);
X+  vsnprintf(dbg, sizeof(dbg), format, args);
X+  va_end(args);
X+  if(g_printf.extprintf)
X+  {
X+    g_printf.extprintf(dbg, sizeof(dbg));
X+  }
X+  else 
X+  {
X+    printf(dbg);
X+  }
X+
X+  return 1;
X+}
X+
X #ifndef TRUE
X #define TRUE (-1)
X #endif
X@@ -92,13 +113,26 @@
X static char tPassword[56] = "";
X static char tHWID[HWID_SIZE] = {0,51,52,53,54,55};
X 
X+#ifdef XBMC
X+struct AudioOutput g_ao;
X+void shairport_set_ao(struct AudioOutput *ao)
X+{
X+ g_ao=*ao;
X+}
X+
X+void shairport_set_printf(struct printfPtr *funcPtr)
X+{
X+  g_printf = *funcPtr;
X+}
X+#endif
X+
X #ifndef XBMC
X int main(int argc, char **argv)
X #else
X int shairport_main(int argc, char **argv)
X #endif
X {
X-  printf("initializing shairport\n");
X+  xprintf("initializing shairport\n",NULL);
X   char tHWID_Hex[HWID_SIZE * 2 + 1];
X   char tKnownHwid[32];
X 
X@@ -177,22 +211,22 @@
X     }    
X     else if(!strcmp(arg, "-h") || !strcmp(arg, "--help"))
X     {
X-      slog(LOG_INFO, "ShairPort version 0.05 C port - Airport Express emulator\n");
X-      slog(LOG_INFO, "Usage:\nshairport [OPTION...]\n\nOptions:\n");
X-      slog(LOG_INFO, "  -a, --apname=AirPort    Sets Airport name\n");
X-      slog(LOG_INFO, "  -p, --password=secret   Sets Password (not working)\n");
X-      slog(LOG_INFO, "  -o, --server_port=5000  Sets Port for Avahi/dns-sd\n");
X-      slog(LOG_INFO, "  -b, --buffer=282        Sets Number of frames to buffer before beginning playback\n");
X-      slog(LOG_INFO, "  -d                      Daemon mode\n");
X-      slog(LOG_INFO, "  -q, --quiet             Supresses all output.\n");
X-      slog(LOG_INFO, "  -v,-v2,-v3,-vv          Various debugging levels\n");
X-      slog(LOG_INFO, "\n");
X+      xprintf("ShairPort version 0.05 C port - Airport Express emulator\n");
X+      xprintf("Usage:\nshairport [OPTION...]\n\nOptions:\n");
X+      xprintf("  -a, --apname=AirPort    Sets Airport name\n");
X+      xprintf("  -p, --password=secret   Sets Password (not working)\n");
X+      xprintf("  -o, --server_port=5000  Sets Port for Avahi/dns-sd\n");
X+      xprintf("  -b, --buffer=282        Sets Number of frames to buffer before beginning playback\n");
X+      xprintf("  -d                      Daemon mode\n");
X+      xprintf("  -q, --quiet             Supresses all output.\n");
X+      xprintf("  -v,-v2,-v3,-vv          Various debugging levels\n");
X+      xprintf("\n");
X       return 0;
X     }    
X   }
X 
X   if ( buffer_start_fill < 30 || buffer_start_fill > BUFFER_FRAMES ) { 
X-     fprintf(stderr, "buffer value must be > 30 and < %d\n", BUFFER_FRAMES);
X+     xprintf("buffer value must be > 30 and < %d\n", BUFFER_FRAMES);
X      return(0);
X   }
X 
X@@ -201,11 +235,11 @@
X     int tPid = fork();
X     if(tPid < 0)
X     {
X-      exit(1); // Error on fork
X+      //exit(1); // Error on fork
X     }
X     else if(tPid > 0)
X     {
X-      exit(0);
X+      //exit(0);
X     }
X     else
X     {
X@@ -246,10 +280,10 @@
X     sscanf(tHWID_Hex, "%02X%02X%02X%02X%02X%02X", &tHWID[0], &tHWID[1], &tHWID[2], &tHWID[3], &tHWID[4], &tHWID[5]);
X   }
X 
X-  slog(LOG_INFO, "LogLevel: %d\n", kCurrentLogLevel);
X-  slog(LOG_INFO, "AirName: %s\n", tServerName);
X-  slog(LOG_INFO, "HWID: %.*s\n", HWID_SIZE, tHWID+1);
X-  slog(LOG_INFO, "HWID_Hex(%d): %s\n", strlen(tHWID_Hex), tHWID_Hex);
X+  xprintf("LogLevel: %d\n", kCurrentLogLevel);
X+  xprintf("AirName: %s\n", tServerName);
X+  xprintf("HWID: %.*s\n", HWID_SIZE, tHWID+1);
X+  xprintf("HWID_Hex(%d): %s\n", strlen(tHWID_Hex), tHWID_Hex);
X 
X   if(tSimLevel >= 1)
X   {
X@@ -263,12 +297,12 @@
X #ifndef XBMC
X     startAvahi(tHWID_Hex, tServerName, tPort);
X #endif
X-    slog(LOG_DEBUG_V, "Starting connection server: specified server port: %d\n", tPort);
X+    xprintf("Starting connection server: specified server port: %d\n", tPort);
X     tServerSock = setupListenServer(&tAddrInfo, tPort);
X     if(tServerSock < 0)
X     {
X       freeaddrinfo(tAddrInfo);
X-      slog(LOG_INFO, "Error setting up server socket on port %d, try specifying a different port\n", tPort);
X+      xprintf("Error setting up server socket on port %d, try specifying a different port\n", tPort);
X       return 0;
X     }
X 
X@@ -295,7 +329,7 @@
X 
X     int readsock;
X 
X-    slog(LOG_DEBUG_V, "Waiting for clients to connect\n");
X+    xprintf("Waiting for clients to connect\n");
X 
X     while(m_running)
X     {
X@@ -327,7 +361,7 @@
X         {
X           freeaddrinfo(tAddrInfo);
X           tAddrInfo = NULL;
X-          slog(LOG_DEBUG, "...Accepted Client Connection..\n");
X+          xprintf("...Accepted Client Connection..\n");
X           close(tServerSock);
X           handleClient(tClientSock, tPassword, tHWID);
X           //close(tClientSock);
X@@ -335,11 +369,11 @@
X         }
X         else
X         {
X-          slog(LOG_DEBUG_VV, "Child now busy handling new client\n");
X+          xprintf("Child now busy handling new client\n");
X           close(tClientSock);
X         }
X #else
X-      slog(LOG_DEBUG, "...Accepted Client Connection..\n");
X+      xprintf("...Accepted Client Connection..\n");
X       handleClient(tClientSock, tPassword, tHWID);
X #endif
X       }
X@@ -349,7 +383,7 @@
X       }
X   }
X 
X-  slog(LOG_DEBUG_VV, "Finished\n");
X+  xprintf("Finished\n");
X   if(tAddrInfo != NULL)
X   {
X     freeaddrinfo(tAddrInfo);
X@@ -360,6 +394,7 @@
X void shairport_exit(void)
X {
X   m_running = 0;
X+  close(tServerSock);
X }
X 
X int shairport_is_running(void)
X@@ -407,7 +442,7 @@
X 
X void handleClient(int pSock, char *pPassword, char *pHWADDR)
X {
X-  slog(LOG_DEBUG_VV, "In Handle Client\n");
X+  xprintf("In Handle Client\n");
X   fflush(stdout);
X 
X   socklen_t len;
X@@ -426,7 +461,7 @@
X 
X   // deal with both IPv4 and IPv6:
X   if (addr.ss_family == AF_INET) {
X-      slog(LOG_DEBUG_V, "Constructing ipv4 address\n");
X+      xprintf("Constructing ipv4 address\n");
X       struct sockaddr_in *s = (struct sockaddr_in *)&addr;
X       port = ntohs(s->sin_port);
X       inet_ntop(AF_INET, &s->sin_addr, ipstr, sizeof ipstr);
X@@ -446,20 +481,20 @@
X       if(memcmp(&addr.bin[0], "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\x00\x00\xff\xff", 12) == 0)
X       {
X         // its ipv4...
X-        slog(LOG_DEBUG_V, "Constructing ipv4 from ipv6 address\n");
X+        xprintf("Constructing ipv4 from ipv6 address\n");
X         memcpy(ipbin, &addr.bin[12], 4);
X         ipbinlen = 4;
X       }
X       else
X       {
X-        slog(LOG_DEBUG_V, "Constructing ipv6 address\n");
X+        xprintf("Constructing ipv6 address\n");
X         memcpy(ipbin, &s->sin6_addr, 16);
X         ipbinlen = 16;
X       }
X   }
X 
X-  slog(LOG_DEBUG_V, "Peer IP address: %s\n", ipstr);
X-  slog(LOG_DEBUG_V, "Peer port      : %d\n", port);
X+  xprintf("Peer IP address: %s\n", ipstr);
X+  xprintf("Peer port      : %d\n", port);
X 
X   int tMoreDataNeeded = 1;
X   struct keyring     tKeys;
X@@ -478,18 +513,19 @@
X     while(1 == tMoreDataNeeded)
X     {
X       tError = readDataFromClient(pSock, &(tConn.recv));
X-      if(!tError && strlen(tConn.recv.data) > 0)
X+      //if(!tError && strlen(tConn.recv.data) > 0)
X+      if(!tError && tConn.recv.current > 0)
X       {
X-        slog(LOG_DEBUG_VV, "Finished Reading some data from client\n");
X+        xprintf("Finished Reading some data from client\n");
X         // parse client request
X         tMoreDataNeeded = parseMessage(&tConn, ipbin, ipbinlen, pHWADDR);
X         if(1 == tMoreDataNeeded)
X         {
X-          slog(LOG_DEBUG_VV, "\n\nNeed to read more data\n");
X+          xprintf("\n\nNeed to read more data\n");
X         }
X         else if(-1 == tMoreDataNeeded) // Forked process down below ended.
X         {
X-          slog(LOG_DEBUG_V, "Forked Process ended...cleaning up\n");
X+          xprintf("Forked Process ended...cleaning up\n");
X           cleanup(&tConn);
X           // pSock was already closed
X           return;
X@@ -498,13 +534,13 @@
X       }
X       else
X       {
X-        slog(LOG_DEBUG, "Error reading from socket, closing client\n");
X+        xprintf("Error reading from socket, closing client\n");
X         // Error reading data....quit.
X         cleanup(&tConn);
X         return;
X       }
X     }
X-    slog(LOG_DEBUG_VV, "Writing: %d chars to socket\n", tConn.resp.current);
X+    xprintf("Writing: %d chars to socket\n", tConn.resp.current);
X     //tConn->resp.data[tConn->resp.current-1] = '\0';
X     writeDataToClient(pSock, &(tConn.resp));
X    // Finished reading one message...
X@@ -517,9 +553,9 @@
X 
X void writeDataToClient(int pSock, struct shairbuffer *pResponse)
X {
X-  slog(LOG_DEBUG_VV, "\n----Beg Send Response Header----\n%.*s\n", pResponse->current, pResponse->data);
X+  xprintf("\n----Beg Send Response Header----\n%.*s\n", pResponse->current, pResponse->data);
X   send(pSock, pResponse->data, pResponse->current,0);
X-  slog(LOG_DEBUG_VV, "----Send Response Header----\n");
X+  xprintf("----Send Response Header----\n");
X }
X 
X int readDataFromClient(int pSock, struct shairbuffer *pClientBuffer)
X@@ -532,7 +568,7 @@
X   while(tRetval > 0 && tEnd < 0)
X   {
X      // Read from socket until \n\n, \r\n\r\n, or \r\r is found
X-      slog(LOG_DEBUG_V, "Waiting To Read...\n");
X+      xprintf("Waiting To Read...\n");
X       fflush(stdout);
X       tRetval = read(pSock, tReadBuf, MAX_SIZE);
X       // if new buffer contains the end of request string, only copy partial buffer?
X@@ -543,40 +579,40 @@
X         {
X           pClientBuffer->marker = tEnd+1; // Marks start of content
X         }
X-        slog(SOCKET_LOG_LEVEL, "Found end of http request at: %d\n", tEnd);
X+        xprintf("Found end of http request at: %d\n", tEnd);
X         fflush(stdout);        
X       }
X       else
X       {
X         tEnd = MAX_SIZE;
X-        slog(SOCKET_LOG_LEVEL, "Read %d of data so far\n%s\n", tRetval, tReadBuf);
X+        xprintf("Read %d of data so far\n%s\n", tRetval, tReadBuf);
X         fflush(stdout);
X       }
X       if(tRetval > 0)
X       {
X         // Copy read data into tReceive;
X-        slog(SOCKET_LOG_LEVEL, "Read %d data, using %d of it\n", tRetval, tEnd);
X+        xprintf("Read %d data, using %d of it\n", tRetval, tEnd);
X         addNToShairBuffer(pClientBuffer, tReadBuf, tRetval);
X-        slog(LOG_DEBUG_VV, "Finished copying data\n");
X+        xprintf("Finished copying data\n");
X       }
X       else
X       {
X-        slog(LOG_DEBUG, "Error reading data from socket, got: %d bytes", tRetval);
X+        xprintf("Error reading data from socket, got: %d bytes", tRetval);
X         return tRetval;
X       }
X   }
X   if(tEnd + 1 != tRetval)
X   {
X-    slog(SOCKET_LOG_LEVEL, "Read more data after end of http request. %d instead of %d\n", tRetval, tEnd+1);
X+    xprintf("Read more data after end of http request. %d instead of %d\n", tRetval, tEnd+1);
X   }
X-  slog(SOCKET_LOG_LEVEL, "Finished Reading Data:\n%s\nEndOfData\n", pClientBuffer->data);
X+  xprintf("Finished Reading Data:\n%s\nEndOfData\n", pClientBuffer->data);
X   fflush(stdout);
X   return 0;
X }
X 
X char *getFromBuffer(char *pBufferPtr, const char *pField, int pLenAfterField, int *pReturnSize, char *pDelims)
X {
X-  slog(LOG_DEBUG_V, "GettingFromBuffer: %s\n", pField);
X+  xprintf("GettingFromBuffer: %s\n", pField);
X   char* tFound = strstr(pBufferPtr, pField);
X   int tSize = 0;
X   if(tFound != NULL)
X@@ -597,7 +633,7 @@
X     }
X     
X     tSize = (int) (tShortest - tFound);
X-    slog(LOG_DEBUG_VV, "Found %.*s  length: %d\n", tSize, tFound, tSize);
X+    xprintf("Found %s  length: %d\n",tFound, tSize);
X     if(pReturnSize != NULL)
X     {
X       *pReturnSize = tSize;
X@@ -605,7 +641,7 @@
X   }
X   else
X   {
X-    slog(LOG_DEBUG_V, "Not Found\n");
X+    xprintf("Not Found\n");
X   }
X   return tFound;
X }
X@@ -639,10 +675,10 @@
X   {
X     char tTrim[tFoundSize + 2];
X     getTrimmed(tFound, tFoundSize, TRUE, TRUE, tTrim);
X-    slog(LOG_DEBUG_VV, "HeaderChallenge:  [%s] len: %d  sizeFound: %d\n", tTrim, strlen(tTrim), tFoundSize);
X+    xprintf("HeaderChallenge:  [%s] len: %d  sizeFound: %d\n", tTrim, strlen(tTrim), tFoundSize);
X     int tChallengeDecodeSize = 16;
X     char *tChallenge = decode_base64((unsigned char *)tTrim, tFoundSize, &tChallengeDecodeSize);
X-    slog(LOG_DEBUG_VV, "Challenge Decode size: %d  expected 16\n", tChallengeDecodeSize);
X+    xprintf("Challenge Decode size: %d  expected 16\n", tChallengeDecodeSize);
X 
X     int tCurSize = 0;
X     unsigned char tChalResp[38];
X@@ -664,7 +700,7 @@
X     }
X 
X     char *tTmp = encode_base64((unsigned char *)tChalResp, tCurSize);
X-    slog(LOG_DEBUG_VV, "Full sig: %s\n", tTmp);
X+    xprintf("Full sig: %s\n", tTmp);
X     free(tTmp);
X 
X     // RSA Encrypt
X@@ -709,15 +745,15 @@
X   if(tContent != NULL)
X   {
X     int tContentSize = atoi(tContent);
X-    if(pConn->recv.marker == 0 || strlen(pConn->recv.data+pConn->recv.marker) != tContentSize)
X+    if(pConn->recv.marker == 0 || pConn->recv.current-pConn->recv.marker != tContentSize)
X     {
X       if(isLogEnabledFor(HEADER_LOG_LEVEL))
X       {
X-        slog(HEADER_LOG_LEVEL, "Content-Length: %s value -> %d\n", tContent, tContentSize);
X+        xprintf("Content-Length: %s value -> %d\n", tContent, tContentSize);
X         if(pConn->recv.marker != 0)
X         {
X-          slog(HEADER_LOG_LEVEL, "ContentPtr has %d, but needs %d\n", 
X-                  strlen(pConn->recv.data+pConn->recv.marker), tContentSize);
X+          xprintf("ContentPtr has %d, but needs %d\n", 
X+                  (pConn->recv.current-pConn->recv.marker), tContentSize);
X         }
X       }
X       // check if value in tContent > 2nd read from client.
X@@ -726,7 +762,7 @@
X   }
X   else
X   {
X-    slog(LOG_DEBUG_VV, "No content, header only\n");
X+    xprintf("No content, header only\n");
X   }
X 
X   // "Creates" a new Response Header for our response message
X@@ -739,7 +775,7 @@
X     {
X       tLen = 20;
X     }
X-    slog(LOG_INFO, "********** RECV %.*s **********\n", tLen, pConn->recv.data);
X+    xprintf("********** RECV %.*s **********\n", tLen, pConn->recv.data);
X   }
X 
X   if(pConn->password != NULL)
X@@ -749,7 +785,7 @@
X 
X   if(buildAppleResponse(pConn, pIpBin, pIpBinLen, pHWID)) // need to free sig
X   {
X-    slog(LOG_DEBUG_V, "Added AppleResponse to Apple-Challenge request\n");
X+    xprintf("Added AppleResponse to Apple-Challenge request\n");
X   }
X 
X   // Find option, then based on option, do different actions.
X@@ -769,14 +805,14 @@
X       int tKeySize = 0;
X       char tEncodedAesIV[tSize + 2];
X       getTrimmed(tHeaderVal, tSize, TRUE, TRUE, tEncodedAesIV);
X-      slog(LOG_DEBUG_VV, "AESIV: [%.*s] Size: %d  Strlen: %d\n", tSize, tEncodedAesIV, tSize, strlen(tEncodedAesIV));
X+      xprintf("AESIV: [%.*s] Size: %d  Strlen: %d\n", tSize, tEncodedAesIV, tSize, strlen(tEncodedAesIV));
X       char *tDecodedIV =  decode_base64((unsigned char*) tEncodedAesIV, tSize, &tSize);
X 
X       // grab the key, copy it out of the receive buffer
X       tHeaderVal = getFromContent(tContent, "a=rsaaeskey", &tKeySize);
X       char tEncodedAesKey[tKeySize + 2]; // +1 for nl, +1 for \0
X       getTrimmed(tHeaderVal, tKeySize, TRUE, TRUE, tEncodedAesKey);
X-      slog(LOG_DEBUG_VV, "AES KEY: [%s] Size: %d  Strlen: %d\n", tEncodedAesKey, tKeySize, strlen(tEncodedAesKey));
X+      xprintf("AES KEY: [%s] Size: %d  Strlen: %d\n", tEncodedAesKey, tKeySize, strlen(tEncodedAesKey));
X       // remove base64 coding from key
X       char *tDecodedAesKey = decode_base64((unsigned char*) tEncodedAesKey,
X                               tKeySize, &tKeySize);  // Need to free DecodedAesKey
X@@ -785,7 +821,7 @@
X       int tFmtpSize = 0;
X       char *tFmtp = getFromContent(tContent, "a=fmtp", &tFmtpSize);  // Don't need to free
X       tFmtp = getTrimmedMalloc(tFmtp, tFmtpSize, TRUE, FALSE); // will need to free
X-      slog(LOG_DEBUG_VV, "Format: %s\n", tFmtp);
X+      xprintf("Format: %s\n", tFmtp);
X 
X       RSA *rsa = loadKey();
X       // Decrypt the binary aes key
X@@ -794,11 +830,11 @@
X       if(RSA_private_decrypt(tKeySize, (unsigned char *)tDecodedAesKey, 
X       (unsigned char*) tDecryptedKey, rsa, RSA_PKCS1_OAEP_PADDING) >= 0)
X       {
X-        slog(LOG_DEBUG, "Decrypted AES key from RSA Successfully\n");
X+        xprintf("Decrypted AES key from RSA Successfully\n");
X       }
X       else
X       {
X-        slog(LOG_INFO, "Error Decrypting AES key from RSA\n");
X+        xprintf("Error Decrypting AES key from RSA\n");
X       }
X       free(tDecodedAesKey);
X       RSA_free(rsa);
X@@ -814,13 +850,13 @@
X //    struct comms *tComms = pConn->hairtunes;
X //   if (! (pipe(tComms->in) == 0 && pipe(tComms->out) == 0))
X //    {
X-//      slog(LOG_INFO, "Error setting up hairtunes communications...some things probably wont work very well.\n");
X+//      xprintf("Error setting up hairtunes communications...some things probably wont work very well.\n");
X //    }
X     
X     // Setup fork
X     char tPort[8] = "6000";  // get this from dup()'d stdout of child pid
X 
X-    printf("******** SETUP!!!!!\n");
X+    xprintf("******** SETUP!!!!!\n",NULL);
X #ifndef XBMC
X     int tPid = fork();
X     if(tPid == 0)
X@@ -836,11 +872,11 @@
X       tFound = getFromSetup(pConn->recv.data, "timing_port", &tSize);
X       getTrimmed(tFound, tSize, 1, 0, tTPortStr);
X 
X-      slog(LOG_DEBUG_VV, "converting %s and %s from str->int\n", tCPortStr, tTPortStr);
X+      xprintf("converting %s and %s from str->int\n", tCPortStr, tTPortStr);
X       int tControlport = atoi(tCPortStr);
X       int tTimingport = atoi(tTPortStr);
X 
X-      slog(LOG_DEBUG_V, "Got %d for CPort and %d for TPort\n", tControlport, tTimingport);
X+      xprintf("Got %d for CPort and %d for TPort\n", tControlport, tTimingport);
X       char *tRtp = NULL;
X       char *tPipe = NULL;
X       char *tAoDriver = NULL;
X@@ -875,7 +911,7 @@
X                       tDataport, tRtp, tPipe, tAoDriver, tAoDeviceName, tAoDeviceId);
X #ifndef XBMC
X       // Quit when finished.
X-      slog(LOG_DEBUG, "Returned from hairtunes init....returning -1, should close out this whole side of the fork\n");
X+      xprintf("Returned from hairtunes init....returning -1, should close out this whole side of the fork\n");
X       return -1;
X     }
X     else if(tPid >0)
X@@ -888,7 +924,7 @@
X       int tRead = read(tComms->out[0], tFromHairtunes, 80);
X       if(tRead <= 0)
X       {
X-        slog(LOG_INFO, "Error reading port from hairtunes function, assuming default port: %d\n", tPort);
X+        xprintf("Error reading port from hairtunes function, assuming default port: %d\n", tPort);
X       }
X       else
X       {
X@@ -900,7 +936,7 @@
X         }
X         else
X         {
X-          slog(LOG_INFO, "Read %d bytes, Error translating %s into a port\n", tRead, tFromHairtunes);
X+          xprintf("Read %d bytes, Error translating %s into a port\n", tRead, tFromHairtunes);
X         }
X       }
X 
X@@ -921,7 +957,7 @@
X     }
X     else
X     {
X-      slog(LOG_INFO, "Error forking process....dere' be errors round here.\n");
X+      xprintf("Error forking process....dere' be errors round here.\n");
X       return -1;
X     }
X #endif
X@@ -933,7 +969,7 @@
X     propogateCSeq(pConn);
X #ifndef XBMC
X     close(pConn->hairtunes->in[1]);
X-    slog(LOG_DEBUG, "Tearing down connection, closing pipes\n");
X+    xprintf("Tearing down connection, closing pipes\n");
X #else
X     hairtunes_cleanup();
X #endif
X@@ -954,21 +990,73 @@
X   {
X     propogateCSeq(pConn);
X     int tSize = 0;
X+    char *buffer = NULL;
X+    char *contentType = getFromHeader(pConn->recv.data, "Content-Type", &tSize);
X+    char *tContent = getFromHeader(pConn->recv.data, "Content-Length", NULL);
X+    int iContentSize = 0;
X+    int isJpg = 0;
X+    
X+    if(tContent != NULL)
X+    {
X+      iContentSize = atoi(tContent);
X+    }
X+
X+    if( tSize > 1 && 
X+        (strncmp(contentType, "application/x-dmap-tagged", tSize) == 0) ||
X+        (strncmp(contentType, "image/jpeg", tSize) == 0)                 )
X+    {
X+      if( (pConn->recv.current - pConn->recv.marker) == iContentSize && pConn->recv.marker != 0)
X+      {
X+        if(strncmp(contentType, "image/jpeg", tSize) == 0)
X+        {
X+          isJpg = 1;
X+        }
X+        buffer = (char *)malloc(iContentSize * sizeof(char));
X+        memcpy(buffer, pConn->recv.data + pConn->recv.marker, iContentSize);                                                                                                                                     
X+      }
X+      else
X+      {
X+        iContentSize = 0;
X+      }
X+    }
X+    else
X+    {
X+      iContentSize = 0;
X+    }
X     char *tVol = getFromHeader(pConn->recv.data, "volume", &tSize);
X-    slog(LOG_DEBUG_VV, "About to write [vol: %.*s] data to hairtunes\n", tSize, tVol);
X+    if( tVol)
X+    {
X+      xprintf("About to write [vol: %.*s] data to hairtunes\n", tSize, tVol);
X+    }
X     // TBD VOLUME
X #ifndef XBMC
X     write(pConn->hairtunes->in[1], "vol: ", 5);
X     write(pConn->hairtunes->in[1], tVol, tSize);
X     write(pConn->hairtunes->in[1], "\n", 1);
X #else
X-    hairtunes_setvolume(atof(tVol));
X+    if(tVol)
X+    {
X+      hairtunes_setvolume(atof(tVol));
X+    }
X+    
X+    if(iContentSize)
X+    {
X+      if(isJpg)
X+      {
X+        hairtunes_set_metadata_coverart(buffer, iContentSize);      
X+      }
X+      else
X+      {
X+        hairtunes_set_metadata(buffer, iContentSize);
X+      }
X+      free(buffer);
X+    }
X #endif
X-    slog(LOG_DEBUG_VV, "Finished writing data write data to hairtunes\n");
X+    xprintf("Finished writing data write data to hairtunes\n");
X   }
X   else
X   {
X-    slog(LOG_DEBUG, "\n\nUn-Handled recv: %s\n", pConn->recv.data);
X+    xprintf("\n\nUn-Handled recv: %s\n", pConn->recv.data);
X     propogateCSeq(pConn);
X   }
X   addToShairBuffer(&(pConn->resp), "\r\n");
X@@ -1047,7 +1135,7 @@
X     char tName[100 + HWID_SIZE + 3];
X     if(strlen(pServerName) > tMaxServerName)
X     {
X-      slog(LOG_INFO,"Hey dog, we see you like long server names, "
X+      xprintf("Hey dog, we see you like long server names, "
X               "so we put a strncat in our command so we don't buffer overflow, while you listen to your flow.\n"
X               "We just used the first %d characters.  Pick something shorter if you want\n", tMaxServerName);
X     }
X@@ -1058,7 +1146,7 @@
X     strcat(tName, pHWStr);
X     strcat(tName, "@");
X     strncat(tName, pServerName, tMaxServerName);
X-    slog(AVAHI_LOG_LEVEL, "Avahi/DNS-SD Name: %s\n", tName);
X+    xprintf("Avahi/DNS-SD Name: %s\n", tName);
X     
X     execlp("avahi-publish-service", "avahi-publish-service", tName,
X          "_raop._tcp", tPort, "tp=UDP","sm=false","sv=false","ek=1","et=0,1",
X@@ -1070,12 +1158,12 @@
X             perror("error");
X     }
X 
X-    slog(LOG_INFO, "Bad error... couldn't find or failed to run: avahi-publish-service OR dns-sd\n");
X-    exit(1);
X+    xprintf("Bad error... couldn't find or failed to run: avahi-publish-service OR dns-sd\n");
X+    //exit(1);
X   }
X   else
X   {
X-    slog(LOG_DEBUG_VV, "Avahi/DNS-SD started on PID: %d\n", tPid);
X+    xprintf("Avahi/DNS-SD started on PID: %d\n", tPid);
X   }
X   return tPid;
X }
X@@ -1083,7 +1171,7 @@
X 
X void printBufferInfo(struct shairbuffer *pBuf, int pLevel)
X {
X-  slog(pLevel, "Buffer: [%s]  size: %d  maxchars:%d\n", pBuf->data, pBuf->current, pBuf->maxsize/sizeof(char));
X+  xprintf("Buffer: [%s]  size: %d  maxchars:%d\n", pBuf->data, pBuf->current, pBuf->maxsize/sizeof(char));
X }
X 
X int getAvailChars(struct shairbuffer *pBuf)
X@@ -1164,7 +1252,8 @@
X   {
X     va_list argp;
X     va_start(argp, pFormat);
X-    vprintf(pFormat, argp);
X+    xprintf(pFormat, argp);
X+    //vprintf(pFormat, argp);
X     va_end(argp);
X   }
X   //#endif
X@@ -1218,9 +1307,9 @@
X {
X   if(pBuf->data != NULL)
X   {
X-    slog(LOG_DEBUG_VV, "Hrm, buffer wasn't cleaned up....trying to free\n");
X+    xprintf("Hrm, buffer wasn't cleaned up....trying to free\n");
X     free(pBuf->data);
X-    slog(LOG_DEBUG_VV, "Free didn't seem to seg fault....huzzah\n");
X+    xprintf("Free didn't seem to seg fault....huzzah\n");
X   }
X   pBuf->current = 0;
X   pBuf->marker = 0;
X@@ -1278,6 +1367,6 @@
X   BIO *tBio = BIO_new_mem_buf(AIRPORT_PRIVATE_KEY, -1);
X   RSA *rsa = PEM_read_bio_RSAPrivateKey(tBio, NULL, NULL, NULL); //NULL, NULL, NULL);
X   BIO_free(tBio);
X-  slog(RSA_LOG_LEVEL, "RSA Key: %d\n", RSA_check_key(rsa));
X+  xprintf("RSA Key: %d\n", RSA_check_key(rsa));
X   return rsa;
X }
9b81ded57db6ede748e65e727bbde045
echo x - libshairport/files/patch-src-shairport.h
sed 's/^X//' >libshairport/files/patch-src-shairport.h << '4dac9cb821a29bdf3582be2a39fc0518'
X--- src/shairport.h.orig	2011-08-21 01:58:11.000000000 +0200
X+++ src/shairport.h	2012-10-09 12:09:33.000000000 +0200
X@@ -11,14 +11,22 @@
X #include <regex.h>
X #include <sys/types.h>
X #include <regex.h>
X+#include "ao.h"
X 
X 
X #define HWID_SIZE 6
X #define SHAIRPORT_LOG 1
X-#define LOG_INFO     1
X-#define LOG_DEBUG    5
X-#define LOG_DEBUG_V  6
X-#define LOG_DEBUG_VV 7
X+
X+#ifndef LOG_INFO
X+#define LOG_INFO     5
X+#endif
X+
X+#ifndef LOG_DEBUG
X+#define LOG_DEBUG    6
X+#endif
X+
X+#define LOG_DEBUG_V  7
X+#define LOG_DEBUG_VV 8
X 
X struct shairbuffer
X {
X@@ -58,13 +66,21 @@
X {
X #endif /* __cplusplus */
X 
X+struct printfPtr
X+{
X+  int (*extprintf)(const char* msg, size_t msgSize);
X+};
X+
X int shairport_main(int argc, char **argv);
X void shairport_exit(void);
X int shairport_loop(void);
X int shairport_is_running(void);
X+void shairport_set_ao(struct AudioOutput *ao);
X+void shairport_set_printf(struct printfPtr *funcPtr);
X 
X #ifdef __cplusplus
X }
X #endif /* __cplusplus */
X 
X #endif
X+
4dac9cb821a29bdf3582be2a39fc0518
echo x - libshairport/files/patch-src-socketlib.c
sed 's/^X//' >libshairport/files/patch-src-socketlib.c << 'f768460bd411e988cef1b23d1d39c15f'
X--- src/socketlib.c.orig	2011-09-23 22:00:48.000000000 +0200
X+++ src/socketlib.c	2012-10-09 12:09:33.000000000 +0200
X@@ -48,7 +48,7 @@
X   if((tSock==-1) && (pAddrInfo->ai_family == AF_INET6) && (errno == EAFNOSUPPORT))
X   {
X     //Fallback to ipv4
X-    perror("Failed to create ipv6 socket. Trying ipv4");
X+    xprintf("Failed to create ipv6 socket. Trying ipv4");
X     pAddrInfo->ai_family = AF_INET;
X     tSock = socket(pAddrInfo->ai_family, pAddrInfo->ai_socktype, 0);
X   }
X@@ -82,7 +82,7 @@
X       delay(RETRY_DELAY, &tRes);
X     }
X   }
X-  printf("%d Retry attempts exceeded\n", RETRY_COUNT);
X+  xprintf("%d Retry attempts exceeded\n", RETRY_COUNT);
X   return ERROR;
X }
X 
X@@ -102,7 +102,7 @@
X   tError = getaddrinfo(pHostname, pService, &hints, pAddrInfo);
X   if(tError != 0)
X   {
X-    printf("Error getting address info\n");
X+    xprintf("Error getting address info\n");
X   }
X   return tError;
X }
X@@ -158,8 +158,8 @@
X     sprintf(tService, "%d", pPort); // copies port to string
X     int tFamily = AF_INET;
X     #ifdef AF_INET6
X-    //printf("Listening on IPv6 Socket\n");
X-    //tFamily = AF_INET6;
X+    xprintf("Listening on IPv6 Socket\n");
X+    tFamily = AF_INET6;
X     #else
X     //printf("Listening on IPv4 Socket");
X     #endif
X@@ -200,7 +200,7 @@
X   else
X   {
X     // Invalid encoded data, no other cases are possible.
X-    printf("Unrecoverable error....base64 values are incorrectly encoded\n");
X+    xprintf("Unrecoverable error....base64 values are incorrectly encoded\n");
X     return pSize;
X   }
X }
X@@ -226,7 +226,7 @@
X     memset(input, 0, length);
X     memcpy(input, pInput, pLength);
X     memset(input+pLength, '=', length-pLength);
X-    printf("Fixed value: [%.*s]\n", length, input);
X+    xprintf("Fixed value: [%.*s]\n", length, input);
X   }
X   char *buffer = (char *)malloc(length);
X   memset(buffer, 0, length);
f768460bd411e988cef1b23d1d39c15f
echo x - libshairport/distinfo
sed 's/^X//' >libshairport/distinfo << '3d993072dda638893471ed8cff7044e3'
XSHA256 (libshairport-1.2.0.20310_lib.tar.gz) = 61602402d846a50e8ddf82c3fb5b81984de95ed56abfe0f1e22426d1901c564f
XSIZE (libshairport-1.2.0.20310_lib.tar.gz) = 32759
3d993072dda638893471ed8cff7044e3
echo x - libshairport/pkg-descr
sed 's/^X//' >libshairport/pkg-descr << '0aac892b83ad5e79b18ccc1bdbd13c9b'
Xlibshairport
X============
XCreated by Team XBMC
X
XThis is a fork of ShairPort written by James Laird <jhl@mafipulation.org>. The
XXBMC team decided to fork ShairPort and make it into a library.
X
XWhat it is
X----------
XThis program emulates an AirPort Express for the purpose of streaming music from
XiTunes and compatible iPods. It implements a server for the Apple RAOP protocol.
XShairPort does not support AirPlay v2 (video and photo streaming).
X
XIt supports multiple simultaneous streams, if your audio output chain (as
Xdetected by libao) does so.
X
XWWW: https://github.com/amejia1/libshairport
0aac892b83ad5e79b18ccc1bdbd13c9b
echo x - libshairport/pkg-plist
sed 's/^X//' >libshairport/pkg-plist << '523a1065c787d4c6e3c20af84c00093f'
Xlib/libshairport.la
Xlib/libshairport.so
Xlib/libshairport.so.0
Xinclude/shairport/shairport.h
Xinclude/shairport/ao.h
Xinclude/shairport/socketlib.h
X@dirrm include/shairport
523a1065c787d4c6e3c20af84c00093f
exit



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210160755.q9G7tTcW043072>