From 07620f9eed0135b2e44eab7709f6639825038989 Mon Sep 17 00:00:00 2001 From: Martin Spasov Date: Fri, 15 Apr 2011 17:42:17 +0800 Subject: [PATCH 1/7] Added LICENSE file. --- LICENSE | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..6bb1c607 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From 1a2be8a4fb31c113eb327ed6b586c8a8f237b759 Mon Sep 17 00:00:00 2001 From: okertanov Date: Fri, 15 Apr 2011 19:12:32 +0800 Subject: [PATCH 2/7] fix O2 optimization distorsions --- Makefile | 2 +- hairtunes.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 546bd900..1b119446 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PKGFLAGS:=$(shell pkg-config --cflags --libs openssl ao) -CFLAGS:=-O0 +CFLAGS:=-O2 LDFLAGS:=-lm -lpthread PAUFLAGS:=-lportaudio diff --git a/hairtunes.c b/hairtunes.c index d637d653..60817f95 100644 --- a/hairtunes.c +++ b/hairtunes.c @@ -628,6 +628,8 @@ int stuff_buffer(double playback_rate, short *inptr, short *outptr) { *outptr++ = dithered_vol(*inptr++); } } + + return stuffsamp; } void *audio_thread_func(void *arg) { From 5a0e3fb95fdfc14fa839743a3bdc2989c817ac07 Mon Sep 17 00:00:00 2001 From: jhl Date: Fri, 15 Apr 2011 20:35:07 +0800 Subject: [PATCH 3/7] Fix compile bug on some IPv4 platforms. --- hairtunes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hairtunes.c b/hairtunes.c index 60817f95..737df046 100644 --- a/hairtunes.c +++ b/hairtunes.c @@ -424,7 +424,9 @@ int init_rtp(void) { si.sin6_flowinfo = 0; #else si.sin_family = AF_INET; - si.sin_len = sizeof(si); + #ifdef SIN_LEN + si.sin_len = sizeof(si); + #endif si.sin_addr.s_addr = htonl(INADDR_ANY); #endif From 76c6c77283d4724f2d7c4b992d86212feb969517 Mon Sep 17 00:00:00 2001 From: jhl Date: Fri, 15 Apr 2011 20:47:03 +0800 Subject: [PATCH 4/7] fix missing return value fix - replacing right bug, wrong fix. --- hairtunes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hairtunes.c b/hairtunes.c index 737df046..e785baac 100644 --- a/hairtunes.c +++ b/hairtunes.c @@ -631,7 +631,7 @@ int stuff_buffer(double playback_rate, short *inptr, short *outptr) { } } - return stuffsamp; + return frame_size + stuff; } void *audio_thread_func(void *arg) { From 11e3eb183bca4239e1567e903fde43c590f812fc Mon Sep 17 00:00:00 2001 From: okertanov Date: Fri, 15 Apr 2011 21:01:10 +0800 Subject: [PATCH 5/7] Compilation fixes: -Wall warnings. unistd.h included, forward function ptototypes, loop/assignment parentheses, proper return pathes, buffers signed/unsigned __attribute__((unused)) --- Makefile | 2 +- hairtunes.c | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 1b119446..80278687 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PKGFLAGS:=$(shell pkg-config --cflags --libs openssl ao) -CFLAGS:=-O2 +CFLAGS:=-O2 -Wall LDFLAGS:=-lm -lpthread PAUFLAGS:=-lportaudio diff --git a/hairtunes.c b/hairtunes.c index e785baac..03342f0d 100644 --- a/hairtunes.c +++ b/hairtunes.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -84,8 +85,11 @@ int fancy_resampling = 1; SRC_STATE *src; #endif -void rtp_request_resend(seq_t first, seq_t last); +int init_rtp(void); void init_buffer(void); +int init_output(void); +int uninit_output(void); +void rtp_request_resend(seq_t first, seq_t last); void ab_resync(void); // interthread variables @@ -160,7 +164,7 @@ int main(int argc, char **argv) { char *arg; int i; assert(RAND_MAX >= 0x10000); // XXX move this to compile time - while (arg = *++argv) { + while ( (arg = *++argv) ) { if (!strcasecmp(arg, "iv")) { hexaesiv = *++argv; argc--; @@ -203,7 +207,7 @@ int main(int argc, char **argv) { memset(fmtp, 0, sizeof(fmtp)); i = 0; - while (arg = strsep(&fmtpstr, " \t")) + while ( (arg = strsep(&fmtpstr, " \t")) ) fmtp[i++] = atoi(arg); init_decoder(); @@ -247,6 +251,8 @@ int main(int argc, char **argv) { fflush(stderr); uninit_output(); + + return EXIT_SUCCESS; } void init_buffer(void) { @@ -271,14 +277,14 @@ static inline int seq_order(seq_t a, seq_t b) { } void alac_decode(short *dest, char *buf, int len) { - char packet[MAX_PACKET]; + unsigned char packet[MAX_PACKET]; assert(len<=MAX_PACKET); - char iv[16]; + unsigned char iv[16]; int i; memcpy(iv, aesiv, sizeof(iv)); for (i=0; i+16<=len; i += 16) - AES_cbc_encrypt(buf+i, packet+i, 0x10, &aes, iv, AES_DECRYPT); + AES_cbc_encrypt((unsigned char*)buf+i, packet+i, 0x10, &aes, iv, AES_DECRYPT); if (len & 0xf) memcpy(packet+i, buf+i, len & 0xf); @@ -378,6 +384,8 @@ void *rtp_thread_func(void *arg) { buffer_put_packet(seqno, pktp+12, plen-12); } } + + return 0; } void rtp_request_resend(seq_t first, seq_t last) { @@ -406,7 +414,7 @@ int init_rtp(void) { #ifdef AF_INET6 struct sockaddr_in6 si; int type = AF_INET6; - short *sin_port = &si.sin6_port; + unsigned short *sin_port = &si.sin6_port; #else struct sockaddr_in si; int type = AF_INET; @@ -508,9 +516,11 @@ static void biquad_lpf(biquad_t *bq, double freq, double Q) { static double biquad_filt(biquad_t *bq, double in) { double w = in - bq->a[0]*bq->hist[0] - bq->a[1]*bq->hist[1]; - double out = bq->b[1]*bq->hist[0] + bq->b[2]*bq->hist[1] + bq->b[0]*w; + double out __attribute__((unused)) = bq->b[1]*bq->hist[0] + bq->b[2]*bq->hist[1] + bq->b[0]*w; bq->hist[1] = bq->hist[0]; bq->hist[0] = w; + + return w; } double bf_playback_rate = 1.0; @@ -640,9 +650,9 @@ void *audio_thread_func(void *arg) { #else PaStream* stream = arg; #endif - int i, play_samples; + int i __attribute__((unused)), play_samples; - signed short buf_fill; + signed short buf_fill __attribute__((unused)); signed short *inbuf, *outbuf; outbuf = malloc(OUTFRAME_BYTES); @@ -697,7 +707,7 @@ void *audio_thread_func(void *arg) { #define NUM_CHANNELS 2 int init_output(void) { - int err; + int err __attribute__((unused)); #if HAVE_AO ao_initialize(); int driver = ao_default_driver_id(); @@ -760,6 +770,8 @@ int init_output(void) { pthread_t audio_thread; pthread_create(&audio_thread, NULL, audio_thread_func, arg); + + return 0; } int uninit_output(void) { From 8e8841c5d1c2479c7fe37fdb8115524f985ed68e Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Fri, 15 Apr 2011 21:29:06 +0800 Subject: [PATCH 6/7] fixed missing return --- hairtunes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hairtunes.c b/hairtunes.c index 03342f0d..70cd6e31 100644 --- a/hairtunes.c +++ b/hairtunes.c @@ -702,6 +702,8 @@ void *audio_thread_func(void *arg) { } #endif } + + return 0; } #define NUM_CHANNELS 2 From b20401789ec9c9da94a21dec01679fbb412de36f Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Fri, 15 Apr 2011 21:29:33 +0800 Subject: [PATCH 7/7] small fix for Makefile This fails if for example only hairtunes.c was changed but not alac.c. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 80278687..4cd42fd1 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ PAUFLAGS:=-lportaudio all: hairtunes hairtunes: hairtunes.c alac.c - $(CC) $(CFLAGS) $(PKGFLAGS) $(LDFLAGS) $? -o $@ + $(CC) $(CFLAGS) $(PKGFLAGS) $(LDFLAGS) hairtunes.c alac.c -o $@ clean: -@rm -rf hairtunes