summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Bartell <wingedtachikoma@gmail.com>2011-10-30 12:05:04 -0400
committerNils Wallménius <nils@rockbox.org>2012-05-03 14:49:35 +0200
commitcadb3627fcc32cec3a97183c0a1462fe0ff04755 (patch)
treeed3ec41d5231a604a7c3d368dbf8172d9ab1ea0a
parent5f0cb713615c844d9133f3664333a73816bbfd17 (diff)
downloadrockbox-cadb3627fcc32cec3a97183c0a1462fe0ff04755.tar.gz
rockbox-cadb3627fcc32cec3a97183c0a1462fe0ff04755.tar.bz2
rockbox-cadb3627fcc32cec3a97183c0a1462fe0ff04755.zip
Add rbcodecplatform.h and rbcodecconfig.h.
librbcodec users must provide these two files when the library is built. rbcodecconfig.h provides configuration #defines and basic types, and will be included by public librbcodec headers, so it must not conflict with the user's code. rbcodecplatform.h provides various OS functions, and will only be included by source files and private headers. This system is intended to provide maximum flexibility for use on embedded systems, where no operating system headers are included. Unix systems can just copy rbcodecconfig-example.h and rbcodecplatform-unix.h with minimal changes. Change-Id: I350a2274d173da391fd1ca00c4202e9760d91def Reviewed-on: http://gerrit.rockbox.org/143 Reviewed-by: Nils Wallménius <nils@rockbox.org> Tested-by: Nils Wallménius <nils@rockbox.org>
-rw-r--r--apps/rbcodecconfig.h22
-rw-r--r--apps/rbcodecplatform.h35
-rw-r--r--firmware/export/dsp-util.h2
-rw-r--r--lib/rbcodec/codecs/codecs.h6
-rw-r--r--lib/rbcodec/codecs/lib/codeclib.h4
-rw-r--r--lib/rbcodec/codecs/lib/ffmpeg_bswap.h32
-rw-r--r--lib/rbcodec/codecs/lib/ffmpeg_get_bits.h9
-rw-r--r--lib/rbcodec/codecs/libffmpegFLAC/bitstream.h3
-rw-r--r--lib/rbcodec/codecs/libmad/frame.c1
-rw-r--r--lib/rbcodec/codecs/libmad/frame.h1
-rw-r--r--lib/rbcodec/codecs/libmad/libmad.make2
-rw-r--r--lib/rbcodec/codecs/libmusepack/mpcdec.h2
-rw-r--r--lib/rbcodec/codecs/libspeex/filters.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/lsp.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/ltp.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/modes.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/modes_wb.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/nb_celp.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/quant_lsp.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/sb_celp.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/speex.c2
-rw-r--r--lib/rbcodec/codecs/libspeex/stereo.c2
-rw-r--r--lib/rbcodec/codecs/libtremor/vorbisfile.c1
-rw-r--r--lib/rbcodec/codecs/libwavpack/bits.c1
-rw-r--r--lib/rbcodec/metadata/a52.c2
-rw-r--r--lib/rbcodec/metadata/adx.c2
-rw-r--r--lib/rbcodec/metadata/aiff.c2
-rw-r--r--lib/rbcodec/metadata/ape.c1
-rw-r--r--lib/rbcodec/metadata/asap.c4
-rw-r--r--lib/rbcodec/metadata/asf.c2
-rw-r--r--lib/rbcodec/metadata/au.c2
-rw-r--r--lib/rbcodec/metadata/ay.c2
-rw-r--r--lib/rbcodec/metadata/flac.c2
-rw-r--r--lib/rbcodec/metadata/gbs.c2
-rw-r--r--lib/rbcodec/metadata/hes.c2
-rw-r--r--lib/rbcodec/metadata/id3tags.c4
-rw-r--r--lib/rbcodec/metadata/kss.c2
-rw-r--r--lib/rbcodec/metadata/metadata.c2
-rw-r--r--lib/rbcodec/metadata/metadata.h5
-rw-r--r--lib/rbcodec/metadata/metadata_common.c2
-rw-r--r--lib/rbcodec/metadata/mod.c2
-rw-r--r--lib/rbcodec/metadata/monkeys.c2
-rw-r--r--lib/rbcodec/metadata/mp3.c3
-rw-r--r--lib/rbcodec/metadata/mp3data.c3
-rw-r--r--lib/rbcodec/metadata/mp4.c2
-rw-r--r--lib/rbcodec/metadata/mpc.c2
-rw-r--r--lib/rbcodec/metadata/nsf.c2
-rw-r--r--lib/rbcodec/metadata/ogg.c4
-rw-r--r--lib/rbcodec/metadata/oma.c1
-rw-r--r--lib/rbcodec/metadata/replaygain.c2
-rw-r--r--lib/rbcodec/metadata/rm.c2
-rw-r--r--lib/rbcodec/metadata/sgc.c2
-rw-r--r--lib/rbcodec/metadata/sid.c2
-rw-r--r--lib/rbcodec/metadata/smaf.c2
-rw-r--r--lib/rbcodec/metadata/spc.c2
-rw-r--r--lib/rbcodec/metadata/tta.c2
-rw-r--r--lib/rbcodec/metadata/vgm.c2
-rw-r--r--lib/rbcodec/metadata/vorbis.c3
-rw-r--r--lib/rbcodec/metadata/vox.c2
-rw-r--r--lib/rbcodec/metadata/wave.c2
-rw-r--r--lib/rbcodec/metadata/wavpack.c2
-rw-r--r--lib/rbcodec/platform.h122
-rw-r--r--lib/rbcodec/rbcodec.make3
-rw-r--r--lib/rbcodec/rbcodecconfig-example.h32
-rw-r--r--lib/rbcodec/rbcodecplatform-unix.h77
-rw-r--r--lib/rbcodec/test/rbcodecconfig.h2
-rw-r--r--lib/rbcodec/test/rbcodecplatform.h2
-rw-r--r--lib/rbcodec/test/warble.c30
-rw-r--r--lib/rbcodec/test/warble.make16
-rw-r--r--tools/functions.make2
70 files changed, 430 insertions, 81 deletions
diff --git a/apps/rbcodecconfig.h b/apps/rbcodecconfig.h
new file mode 100644
index 0000000000..6c7a0749f0
--- /dev/null
+++ b/apps/rbcodecconfig.h
@@ -0,0 +1,22 @@
+#ifndef RBCODECCONFIG_H_INCLUDED
+#define RBCODECCONFIG_H_INCLUDED
+
+#include "config.h"
+
+#ifndef __ASSEMBLER__
+
+/* NULL, offsetof, size_t */
+#include <stddef.h>
+
+/* ssize_t, off_t, open, close, read, lseek, SEEK_SET, SEEK_CUR, SEEK_END,
+ * O_RDONLY, O_WRONLY, O_CREAT, O_APPEND, MAX_PATH, filesize */
+#include "file.h"
+
+/* {,u}int{8,16,32,64}_t, , intptr_t, uintptr_t, bool, true, false, swap16,
+ * swap32, hto{be,le}{16,32}, {be,le}toh{16,32}, ROCKBOX_{BIG,LITTLE}_ENDIAN,
+ * {,U}INT{8,16,32,64}_{MIN,MAX} */
+#include "system.h"
+
+#endif
+
+#endif
diff --git a/apps/rbcodecplatform.h b/apps/rbcodecplatform.h
new file mode 100644
index 0000000000..1dc72ac4e0
--- /dev/null
+++ b/apps/rbcodecplatform.h
@@ -0,0 +1,35 @@
+#ifndef RBCODECPLATFORM_H_INCLUDED
+#define RBCODECPLATFORM_H_INCLUDED
+#if 0
+/* assert */
+#include <assert.h>
+
+/* isdigit, islower, isprint, isspace, toupper */
+#include <ctype.h>
+
+/* {UCHAR,USHRT,UINT,ULONG,SCHAR,SHRT,INT,LONG}_{MIN,MAX} */
+#include <limits.h>
+
+/* memchr, memcmp, memcpy, memmove, memset, strcasecmp, strcat, strchr, strcmp,
+ * strcpy, strlen, strncmp, strrchr, strlcpy */
+#include <string.h>
+#include "string-extra.h"
+
+/* snprintf */
+#include <stdio.h>
+#endif
+/* abs, atoi, labs, rand */
+#include <stdlib.h>
+#if 0
+/* debugf */
+#include "debug.h"
+
+/* logf */
+#include "logf.h"
+
+/* clip_sample_16 */
+#include "dsp-util.h"
+#define HAVE_CLIP_SAMPLE_16
+#endif
+#endif
+
diff --git a/firmware/export/dsp-util.h b/firmware/export/dsp-util.h
index b86b2b776e..6ac878f64c 100644
--- a/firmware/export/dsp-util.h
+++ b/firmware/export/dsp-util.h
@@ -21,6 +21,8 @@
#ifndef DSP_UTIL_H
#define DSP_UTIL_H
+#include "gcc_extensions.h"
+
/** Clip sample to signed 16 bit range **/
#ifdef CPU_ARM
diff --git a/lib/rbcodec/codecs/codecs.h b/lib/rbcodec/codecs/codecs.h
index 91ce8698ab..03167f55bf 100644
--- a/lib/rbcodec/codecs/codecs.h
+++ b/lib/rbcodec/codecs/codecs.h
@@ -27,11 +27,7 @@
#define NO_REDEFINES_PLEASE
#endif
-#include <stdbool.h>
-#include <stdlib.h>
-#include "strlcpy.h"
-#include "config.h"
-#include "system.h"
+#include "rbcodecconfig.h"
#include "metadata.h"
#include "audio.h"
#ifdef RB_PROFILE
diff --git a/lib/rbcodec/codecs/lib/codeclib.h b/lib/rbcodec/codecs/lib/codeclib.h
index d0f985b8e1..18c1043b8c 100644
--- a/lib/rbcodec/codecs/lib/codeclib.h
+++ b/lib/rbcodec/codecs/lib/codeclib.h
@@ -22,9 +22,7 @@
#ifndef __CODECLIB_H__
#define __CODECLIB_H__
-#include <inttypes.h>
-#include <string.h>
-#include "config.h"
+#include "platform.h"
#include "codecs.h"
#include "mdct.h"
#include "fft.h"
diff --git a/lib/rbcodec/codecs/lib/ffmpeg_bswap.h b/lib/rbcodec/codecs/lib/ffmpeg_bswap.h
index 24a2aab7ea..70176db215 100644
--- a/lib/rbcodec/codecs/lib/ffmpeg_bswap.h
+++ b/lib/rbcodec/codecs/lib/ffmpeg_bswap.h
@@ -6,6 +6,32 @@
#ifndef __BSWAP_H__
#define __BSWAP_H__
+#include "platform.h"
+
+#ifndef bswap_16
+#define bswap_16(x) swap16(x)
+#endif
+#ifndef bswap_32
+#define bswap_32(x) swap32(x)
+#endif
+
+#ifndef bswap_64
+static inline uint64_t ByteSwap64(uint64_t x)
+{
+ union {
+ uint64_t ll;
+ struct {
+ uint32_t l,h;
+ } l;
+ } r;
+ r.l.l = bswap_32 (x);
+ r.l.h = bswap_32 (x>>32);
+ return r.ll;
+}
+#define bswap_64(x) ByteSwap64(x)
+#endif
+
+#if 0
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#else
@@ -13,9 +39,7 @@
#ifdef ROCKBOX
#include "codecs.h"
-/* rockbox' optimised inline functions */
-#define bswap_16(x) swap16(x)
-#define bswap_32(x) swap32(x)
+
static inline uint64_t ByteSwap64(uint64_t x)
{
@@ -127,7 +151,7 @@ static inline uint64_t ByteSwap64(uint64_t x)
#endif /* !ARCH_X86 */
#endif /* !HAVE_BYTESWAP_H */
-
+#endif
// be2me ... BigEndian to MachineEndian
// le2me ... LittleEndian to MachineEndian
diff --git a/lib/rbcodec/codecs/lib/ffmpeg_get_bits.h b/lib/rbcodec/codecs/lib/ffmpeg_get_bits.h
index 04eda021a7..e6f80ff45c 100644
--- a/lib/rbcodec/codecs/lib/ffmpeg_get_bits.h
+++ b/lib/rbcodec/codecs/lib/ffmpeg_get_bits.h
@@ -26,8 +26,9 @@
#ifndef AVCODEC_GET_BITS_H
#define AVCODEC_GET_BITS_H
-#include <stdint.h>
-#include <stdlib.h>
+//#include <stdint.h>
+//#include <stdlib.h>
+#include "platform.h"
#include "ffmpeg_intreadwrite.h"
//#include <assert.h>
//#include "libavutil/bswap.h"
@@ -39,8 +40,12 @@
#include "codecs.h"
/* rockbox' optimised inline functions */
+#ifndef bswap_16
#define bswap_16(x) swap16(x)
+#endif
+#ifndef bswap_32
#define bswap_32(x) swap32(x)
+#endif
#ifdef ROCKBOX_BIG_ENDIAN
#define be2me_16(x) (x)
diff --git a/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h
index 5fc3460c8e..2ec54c42fa 100644
--- a/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h
+++ b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h
@@ -10,8 +10,7 @@
#include "ffmpeg_get_bits.h"
#ifndef BUILD_STANDALONE
- #include <config.h>
- #include <system.h>
+ #include "platform.h"
#else
#include <stdio.h>
#define IBSS_ATTR
diff --git a/lib/rbcodec/codecs/libmad/frame.c b/lib/rbcodec/codecs/libmad/frame.c
index f17306285c..c1cc10396b 100644
--- a/lib/rbcodec/codecs/libmad/frame.c
+++ b/lib/rbcodec/codecs/libmad/frame.c
@@ -28,7 +28,6 @@
# include "bit.h"
# include "stream.h"
# include "frame.h"
-# include "timer.h"
# include "layer12.h"
# include "layer3.h"
# include "codeclib.h"
diff --git a/lib/rbcodec/codecs/libmad/frame.h b/lib/rbcodec/codecs/libmad/frame.h
index b1c6e0289d..a8eb2b51f9 100644
--- a/lib/rbcodec/codecs/libmad/frame.h
+++ b/lib/rbcodec/codecs/libmad/frame.h
@@ -23,7 +23,6 @@
# define LIBMAD_FRAME_H
# include "fixed.h"
-# include "timer.h"
# include "stream.h"
enum mad_layer {
diff --git a/lib/rbcodec/codecs/libmad/libmad.make b/lib/rbcodec/codecs/libmad/libmad.make
index 2a8c7b220f..16b2bd76a9 100644
--- a/lib/rbcodec/codecs/libmad/libmad.make
+++ b/lib/rbcodec/codecs/libmad/libmad.make
@@ -13,7 +13,7 @@
# Extract optimization level ('-O') from compile flags. Will be set later.
MADFLAGS = $(filter-out -O%,$(CODECFLAGS)) -I$(RBCODECLIB_DIR)/codecs/libmad
-MADFLAGS += -UDEBUG -DNDEBUG -DHAVE_LIMITS_H
+MADFLAGS += -UDEBUG -DNDEBUG -DHAVE_LIMITS_H -DHAVE_ASSERT_H
# libmad is faster on ARM-targets with -O1 than -O2
ifeq ($(ARCH),arch_arm)
diff --git a/lib/rbcodec/codecs/libmusepack/mpcdec.h b/lib/rbcodec/codecs/libmusepack/mpcdec.h
index 85536e726a..02003cb01b 100644
--- a/lib/rbcodec/codecs/libmusepack/mpcdec.h
+++ b/lib/rbcodec/codecs/libmusepack/mpcdec.h
@@ -39,9 +39,9 @@
#pragma once
#endif
+#include "platform.h"
#include "reader.h"
#include "streaminfo.h"
-#include "config.h"
#ifdef __cplusplus
extern "C" {
diff --git a/lib/rbcodec/codecs/libspeex/filters.c b/lib/rbcodec/codecs/libspeex/filters.c
index 09f93c2a59..7c4c90a636 100644
--- a/lib/rbcodec/codecs/libspeex/filters.c
+++ b/lib/rbcodec/codecs/libspeex/filters.c
@@ -39,7 +39,9 @@
#include "arch.h"
#include "math_approx.h"
#include "ltp.h"
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#ifdef _USE_SSE
#include "filters_sse.h"
diff --git a/lib/rbcodec/codecs/libspeex/lsp.c b/lib/rbcodec/codecs/libspeex/lsp.c
index 8408d782aa..83365a8639 100644
--- a/lib/rbcodec/codecs/libspeex/lsp.c
+++ b/lib/rbcodec/codecs/libspeex/lsp.c
@@ -83,7 +83,9 @@ Heavily modified by Jean-Marc Valin (c) 2002-2006 (fixed-point,
#include "config-speex.h"
#endif
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#include "lsp.h"
#include "stack_alloc.h"
#include "math_approx.h"
diff --git a/lib/rbcodec/codecs/libspeex/ltp.c b/lib/rbcodec/codecs/libspeex/ltp.c
index 9f10bc09d8..c81e8eb2f3 100644
--- a/lib/rbcodec/codecs/libspeex/ltp.c
+++ b/lib/rbcodec/codecs/libspeex/ltp.c
@@ -34,7 +34,9 @@
#include "config-speex.h"
#endif
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#include "ltp.h"
#include "stack_alloc.h"
#include "filters.h"
diff --git a/lib/rbcodec/codecs/libspeex/modes.c b/lib/rbcodec/codecs/libspeex/modes.c
index d1046f1cfb..a58c0786dd 100644
--- a/lib/rbcodec/codecs/libspeex/modes.c
+++ b/lib/rbcodec/codecs/libspeex/modes.c
@@ -44,7 +44,9 @@
#include "nb_celp.h"
#include "vbr.h"
#include "arch.h"
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#ifndef NULL
#define NULL 0
diff --git a/lib/rbcodec/codecs/libspeex/modes_wb.c b/lib/rbcodec/codecs/libspeex/modes_wb.c
index 93922afa2f..4055a2b074 100644
--- a/lib/rbcodec/codecs/libspeex/modes_wb.c
+++ b/lib/rbcodec/codecs/libspeex/modes_wb.c
@@ -44,7 +44,9 @@
#include "nb_celp.h"
#include "vbr.h"
#include "arch.h"
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#include "os_support.h"
diff --git a/lib/rbcodec/codecs/libspeex/nb_celp.c b/lib/rbcodec/codecs/libspeex/nb_celp.c
index 364f987472..a385500f90 100644
--- a/lib/rbcodec/codecs/libspeex/nb_celp.c
+++ b/lib/rbcodec/codecs/libspeex/nb_celp.c
@@ -33,7 +33,9 @@
#include "config-speex.h"
#endif
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#include "nb_celp.h"
#include "lpc.h"
#include "lsp.h"
diff --git a/lib/rbcodec/codecs/libspeex/quant_lsp.c b/lib/rbcodec/codecs/libspeex/quant_lsp.c
index 9b9104c842..c79942cd59 100644
--- a/lib/rbcodec/codecs/libspeex/quant_lsp.c
+++ b/lib/rbcodec/codecs/libspeex/quant_lsp.c
@@ -36,7 +36,9 @@
#include "quant_lsp.h"
#include "os_support.h"
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
diff --git a/lib/rbcodec/codecs/libspeex/sb_celp.c b/lib/rbcodec/codecs/libspeex/sb_celp.c
index b28744812f..45c8417022 100644
--- a/lib/rbcodec/codecs/libspeex/sb_celp.c
+++ b/lib/rbcodec/codecs/libspeex/sb_celp.c
@@ -33,7 +33,9 @@
#include "config-speex.h"
#endif
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#include "sb_celp.h"
#include "filters.h"
#include "lpc.h"
diff --git a/lib/rbcodec/codecs/libspeex/speex.c b/lib/rbcodec/codecs/libspeex/speex.c
index 0dcfb3f7f6..92e41f52ae 100644
--- a/lib/rbcodec/codecs/libspeex/speex.c
+++ b/lib/rbcodec/codecs/libspeex/speex.c
@@ -37,7 +37,9 @@
#endif
#include "modes.h"
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#include "os_support.h"
#ifndef NULL
diff --git a/lib/rbcodec/codecs/libspeex/stereo.c b/lib/rbcodec/codecs/libspeex/stereo.c
index 652d2a6e90..0aca1050fa 100644
--- a/lib/rbcodec/codecs/libspeex/stereo.c
+++ b/lib/rbcodec/codecs/libspeex/stereo.c
@@ -37,7 +37,9 @@
#include "speex/speex_callbacks.h"
#include "math_approx.h"
#include "vq.h"
+#ifndef FIXED_POINT
#include <math.h>
+#endif
#include "os_support.h"
typedef struct RealSpeexStereoState {
diff --git a/lib/rbcodec/codecs/libtremor/vorbisfile.c b/lib/rbcodec/codecs/libtremor/vorbisfile.c
index 271e5a09e3..688a864077 100644
--- a/lib/rbcodec/codecs/libtremor/vorbisfile.c
+++ b/lib/rbcodec/codecs/libtremor/vorbisfile.c
@@ -21,7 +21,6 @@
#include <errno.h>
#include <string.h>
#include <math.h>
-#include "system.h"
#include "ivorbiscodec.h"
#include "ivorbisfile.h"
diff --git a/lib/rbcodec/codecs/libwavpack/bits.c b/lib/rbcodec/codecs/libwavpack/bits.c
index 0f0e79c292..6d81b22773 100644
--- a/lib/rbcodec/codecs/libwavpack/bits.c
+++ b/lib/rbcodec/codecs/libwavpack/bits.c
@@ -15,7 +15,6 @@
// the malloc() system is provided.
#include "wavpack.h"
-#include "system.h"
#include <string.h>
diff --git a/lib/rbcodec/metadata/a52.c b/lib/rbcodec/metadata/a52.c
index a8aad3fa4f..ddd8310cf1 100644
--- a/lib/rbcodec/metadata/a52.c
+++ b/lib/rbcodec/metadata/a52.c
@@ -22,8 +22,8 @@
#include <stdio.h>
#include "metadata.h"
#include "logf.h"
-
#include "metadata_parsers.h"
+#include "platform.h"
static const unsigned short a52_bitrates[] =
{
diff --git a/lib/rbcodec/metadata/adx.c b/lib/rbcodec/metadata/adx.c
index 7c341b4835..6250ed176c 100644
--- a/lib/rbcodec/metadata/adx.c
+++ b/lib/rbcodec/metadata/adx.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/aiff.c b/lib/rbcodec/metadata/aiff.c
index 654f37cf98..6349335561 100644
--- a/lib/rbcodec/metadata/aiff.c
+++ b/lib/rbcodec/metadata/aiff.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/ape.c b/lib/rbcodec/metadata/ape.c
index 0bd2477431..ba0ad1598f 100644
--- a/lib/rbcodec/metadata/ape.c
+++ b/lib/rbcodec/metadata/ape.c
@@ -24,7 +24,6 @@
#include <ctype.h>
#include <inttypes.h>
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/asap.c b/lib/rbcodec/metadata/asap.c
index 9e7f227031..94e4dfce58 100644
--- a/lib/rbcodec/metadata/asap.c
+++ b/lib/rbcodec/metadata/asap.c
@@ -24,13 +24,13 @@
#include <ctype.h>
#include <inttypes.h>
-#include "system.h"
+
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "rbunicode.h"
#include "debug.h"
-
+#include "platform.h"
#define MAX_SONGS 32
static bool parse_dec(int *retval, const char *p, int minval, int maxval)
diff --git a/lib/rbcodec/metadata/asf.c b/lib/rbcodec/metadata/asf.c
index b815c09769..b88b8e77fe 100644
--- a/lib/rbcodec/metadata/asf.c
+++ b/lib/rbcodec/metadata/asf.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
#include "metadata.h"
#include "replaygain.h"
@@ -31,7 +32,6 @@
#include "rbunicode.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
-#include "system.h"
#include <codecs/libasf/asf.h>
/* TODO: Just read the GUIDs into a 16-byte array, and use memcmp to compare */
diff --git a/lib/rbcodec/metadata/au.c b/lib/rbcodec/metadata/au.c
index 94e7453644..07f354571e 100644
--- a/lib/rbcodec/metadata/au.c
+++ b/lib/rbcodec/metadata/au.c
@@ -21,8 +21,8 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/ay.c b/lib/rbcodec/metadata/ay.c
index 5d00264b3d..4230b44da0 100644
--- a/lib/rbcodec/metadata/ay.c
+++ b/lib/rbcodec/metadata/ay.c
@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/flac.c b/lib/rbcodec/metadata/flac.c
index 29937173fd..a8be4c6de4 100644
--- a/lib/rbcodec/metadata/flac.c
+++ b/lib/rbcodec/metadata/flac.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/gbs.c b/lib/rbcodec/metadata/gbs.c
index 68f2b2a393..9b02952e47 100644
--- a/lib/rbcodec/metadata/gbs.c
+++ b/lib/rbcodec/metadata/gbs.c
@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/hes.c b/lib/rbcodec/metadata/hes.c
index 6d99d523cb..87398461d7 100644
--- a/lib/rbcodec/metadata/hes.c
+++ b/lib/rbcodec/metadata/hes.c
@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/id3tags.c b/lib/rbcodec/metadata/id3tags.c
index 2dd1c662ed..0e27c0305b 100644
--- a/lib/rbcodec/metadata/id3tags.c
+++ b/lib/rbcodec/metadata/id3tags.c
@@ -35,11 +35,9 @@
#include <stdbool.h>
#include <stddef.h>
#include <ctype.h>
+#include "platform.h"
#include "string-extra.h"
-#include "config.h"
-#include "file.h"
#include "logf.h"
-#include "system.h"
#include "replaygain.h"
#include "rbunicode.h"
diff --git a/lib/rbcodec/metadata/kss.c b/lib/rbcodec/metadata/kss.c
index 2ae0cf50b0..195e8be38d 100644
--- a/lib/rbcodec/metadata/kss.c
+++ b/lib/rbcodec/metadata/kss.c
@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c
index 3fe9860441..668ece97cf 100644
--- a/lib/rbcodec/metadata/metadata.c
+++ b/lib/rbcodec/metadata/metadata.c
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <ctype.h>
#include "string-extra.h"
-
+#include "platform.h"
#include "debug.h"
#include "logf.h"
#include "cuesheet.h"
diff --git a/lib/rbcodec/metadata/metadata.h b/lib/rbcodec/metadata/metadata.h
index 6d711aff28..4b4a8337fb 100644
--- a/lib/rbcodec/metadata/metadata.h
+++ b/lib/rbcodec/metadata/metadata.h
@@ -22,10 +22,7 @@
#ifndef _METADATA_H
#define _METADATA_H
-#include <stdbool.h>
-#include "config.h"
-#include "file.h"
-
+#include "platform.h"
/* Audio file types. */
/* NOTE: The values of the AFMT_* items are used for the %fc tag in the WPS
diff --git a/lib/rbcodec/metadata/metadata_common.c b/lib/rbcodec/metadata/metadata_common.c
index e861644025..b062c5282d 100644
--- a/lib/rbcodec/metadata/metadata_common.c
+++ b/lib/rbcodec/metadata/metadata_common.c
@@ -24,7 +24,7 @@
#include <ctype.h>
#include <inttypes.h>
-#include "system.h"
+#include "platform.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/mod.c b/lib/rbcodec/metadata/mod.c
index de76823e91..b7f4913257 100644
--- a/lib/rbcodec/metadata/mod.c
+++ b/lib/rbcodec/metadata/mod.c
@@ -22,8 +22,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include <string-extra.h>
#include "metadata_common.h"
diff --git a/lib/rbcodec/metadata/monkeys.c b/lib/rbcodec/metadata/monkeys.c
index 4aff1412aa..ba4273466a 100644
--- a/lib/rbcodec/metadata/monkeys.c
+++ b/lib/rbcodec/metadata/monkeys.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/mp3.c b/lib/rbcodec/metadata/mp3.c
index feb1a52f77..661fea8e51 100644
--- a/lib/rbcodec/metadata/mp3.c
+++ b/lib/rbcodec/metadata/mp3.c
@@ -34,10 +34,9 @@
#include <stdbool.h>
#include "string-extra.h"
#include "config.h"
-#include "file.h"
#include "logf.h"
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "mp3data.h"
#include "metadata_common.h"
diff --git a/lib/rbcodec/metadata/mp3data.c b/lib/rbcodec/metadata/mp3data.c
index 13ff0a87a7..8a134dd534 100644
--- a/lib/rbcodec/metadata/mp3data.c
+++ b/lib/rbcodec/metadata/mp3data.c
@@ -37,8 +37,7 @@
#include "debug.h"
#include "logf.h"
#include "mp3data.h"
-#include "file.h"
-#include "system.h"
+#include "platform.h"
//#define DEBUG_VERBOSE
diff --git a/lib/rbcodec/metadata/mp4.c b/lib/rbcodec/metadata/mp4.c
index df164436f5..6973d3a314 100644
--- a/lib/rbcodec/metadata/mp4.c
+++ b/lib/rbcodec/metadata/mp4.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "errno.h"
#include "metadata.h"
#include "metadata_common.h"
diff --git a/lib/rbcodec/metadata/mpc.c b/lib/rbcodec/metadata/mpc.c
index 0b75ed04dd..3c0ee0707d 100644
--- a/lib/rbcodec/metadata/mpc.c
+++ b/lib/rbcodec/metadata/mpc.c
@@ -23,7 +23,7 @@
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
-#include "system.h"
+#include "platform.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/nsf.c b/lib/rbcodec/metadata/nsf.c
index 2fa6f36b12..3184897e22 100644
--- a/lib/rbcodec/metadata/nsf.c
+++ b/lib/rbcodec/metadata/nsf.c
@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/ogg.c b/lib/rbcodec/metadata/ogg.c
index 3a3cb29998..f3231c6f8a 100644
--- a/lib/rbcodec/metadata/ogg.c
+++ b/lib/rbcodec/metadata/ogg.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
@@ -68,7 +68,7 @@ bool get_ogg_metadata(int fd, struct mp3entry* id3)
{
return false;
}
-
+
/* All Ogg streams start with OggS */
if (memcmp(buf, "OggS", 4) != 0)
{
diff --git a/lib/rbcodec/metadata/oma.c b/lib/rbcodec/metadata/oma.c
index b82c0a4f73..3573d58808 100644
--- a/lib/rbcodec/metadata/oma.c
+++ b/lib/rbcodec/metadata/oma.c
@@ -46,6 +46,7 @@
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
+#include "platform.h"
#include "metadata.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/replaygain.c b/lib/rbcodec/metadata/replaygain.c
index a178321385..5e8c3a364a 100644
--- a/lib/rbcodec/metadata/replaygain.c
+++ b/lib/rbcodec/metadata/replaygain.c
@@ -25,9 +25,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
+#include "platform.h"
#include "strlcpy.h"
#include "strcasecmp.h"
-#include "system.h"
#include "metadata.h"
#include "debug.h"
#include "replaygain.h"
diff --git a/lib/rbcodec/metadata/rm.c b/lib/rbcodec/metadata/rm.c
index 27f541cb25..2a5a2892a3 100644
--- a/lib/rbcodec/metadata/rm.c
+++ b/lib/rbcodec/metadata/rm.c
@@ -23,9 +23,9 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
#include <codecs/librm/rm.h>
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/sgc.c b/lib/rbcodec/metadata/sgc.c
index 78cacb9b1b..11a574139f 100644
--- a/lib/rbcodec/metadata/sgc.c
+++ b/lib/rbcodec/metadata/sgc.c
@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/sid.c b/lib/rbcodec/metadata/sid.c
index 50b879b56d..3a276b3cde 100644
--- a/lib/rbcodec/metadata/sid.c
+++ b/lib/rbcodec/metadata/sid.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/smaf.c b/lib/rbcodec/metadata/smaf.c
index 1b745d3fa1..aeeadb431f 100644
--- a/lib/rbcodec/metadata/smaf.c
+++ b/lib/rbcodec/metadata/smaf.c
@@ -20,9 +20,9 @@
****************************************************************************/
#include <inttypes.h>
#include <stdio.h>
+#include "platform.h"
#include "string-extra.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/spc.c b/lib/rbcodec/metadata/spc.c
index 1c0206205d..6d4590de3b 100644
--- a/lib/rbcodec/metadata/spc.c
+++ b/lib/rbcodec/metadata/spc.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/tta.c b/lib/rbcodec/metadata/tta.c
index 1d3d95f118..5f99c4776e 100644
--- a/lib/rbcodec/metadata/tta.c
+++ b/lib/rbcodec/metadata/tta.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/vgm.c b/lib/rbcodec/metadata/vgm.c
index 9ea95b3939..7d3f45e204 100644
--- a/lib/rbcodec/metadata/vgm.c
+++ b/lib/rbcodec/metadata/vgm.c
@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/vorbis.c b/lib/rbcodec/metadata/vorbis.c
index 58bd781873..d020808c56 100644
--- a/lib/rbcodec/metadata/vorbis.c
+++ b/lib/rbcodec/metadata/vorbis.c
@@ -23,8 +23,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
-
-#include "system.h"
+#include "platform.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/vox.c b/lib/rbcodec/metadata/vox.c
index f6bc849a88..cf08b61f35 100644
--- a/lib/rbcodec/metadata/vox.c
+++ b/lib/rbcodec/metadata/vox.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/wave.c b/lib/rbcodec/metadata/wave.c
index 45acea1fa1..3fb051dd3c 100644
--- a/lib/rbcodec/metadata/wave.c
+++ b/lib/rbcodec/metadata/wave.c
@@ -22,8 +22,8 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/metadata/wavpack.c b/lib/rbcodec/metadata/wavpack.c
index f2811df8f3..4ea2684aaa 100644
--- a/lib/rbcodec/metadata/wavpack.c
+++ b/lib/rbcodec/metadata/wavpack.c
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
+#include "platform.h"
-#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
diff --git a/lib/rbcodec/platform.h b/lib/rbcodec/platform.h
new file mode 100644
index 0000000000..47df8fe6a2
--- /dev/null
+++ b/lib/rbcodec/platform.h
@@ -0,0 +1,122 @@
+#ifndef PLATFORM_H_INCLUDED
+#define PLATFORM_H_INCLUDED
+
+#include "rbcodecconfig.h"
+#include "rbcodecplatform.h"
+
+/*
+
+#ifndef ROCKBOX
+# define __PCTOOL__
+# define RBCODEC_NOT_ROCKBOX
+# define ROCKBOX
+#endif
+
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *dst, const char *src, size_t siz);
+#endif
+*/
+#ifndef ARRAYLEN
+# define ARRAYLEN(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
+#ifndef MIN
+# define MIN(x, y) ((x)<(y) ? (x) : (y))
+#endif
+
+#ifndef MAX
+# define MAX(x, y) ((x)>(y) ? (x) : (y))
+#endif
+
+#ifndef BIT_N
+# define BIT_N(n) (1U << (n))
+#endif
+/*
+#ifdef CODEC
+
+# ifdef debugf
+# undef debugf
+# endif
+
+# ifdef logf
+# undef logf
+# endif
+
+#else
+
+# ifndef DEBUGF
+# define DEBUGF debugf
+# endif
+
+# ifndef debugf
+# define debugf(...) do { } while (0)
+# endif
+
+# ifndef logf
+# define logf(...) do { } while (0)
+# endif
+
+#endif
+
+#ifndef ATTRIBUTE_PRINTF
+# define ATTRIBUTE_PRINTF(fmt, arg1)
+#endif
+
+#ifndef LIKELY
+# define LIKELY(x) (x)
+#endif
+
+#ifndef UNLIKELY
+# define UNLIKELY(x) (x)
+#endif
+*/
+#ifndef CACHEALIGN_ATTR
+# define CACHEALIGN_ATTR
+#endif
+/*
+#ifndef DATA_ATTR
+# define DATA_ATTR
+#endif
+*/
+#ifndef IBSS_ATTR
+# define IBSS_ATTR
+#endif
+
+#ifndef ICODE_ATTR
+# define ICODE_ATTR
+#endif
+
+#ifndef ICONST_ATTR
+# define ICONST_ATTR
+#endif
+
+#ifndef IDATA_ATTR
+# define IDATA_ATTR
+#endif
+/*
+#ifndef INIT_ATTR
+# define INIT_ATTR
+#endif
+*/
+#ifndef MEM_ALIGN_ATTR
+# define MEM_ALIGN_ATTR
+#endif
+/*
+#ifndef STATICIRAM
+# define STATICIRAM
+#endif
+*/
+#ifndef CACHEALIGN_SIZE
+# define CACHEALIGN_SIZE 1
+#endif
+/*
+#ifndef HAVE_CLIP_SAMPLE_16
+static inline int32_t clip_sample_16(int32_t sample)
+{
+ if ((int16_t)sample != sample)
+ sample = 0x7fff ^ (sample >> 31);
+ return sample;
+}
+#endif
+*/
+#endif /* PLATFORM_H_INCLUDED */
diff --git a/lib/rbcodec/rbcodec.make b/lib/rbcodec/rbcodec.make
index 3dfade1826..7aac57b87d 100644
--- a/lib/rbcodec/rbcodec.make
+++ b/lib/rbcodec/rbcodec.make
@@ -7,7 +7,8 @@
# RBCODEC_BLD is defined in the calling Makefile
RBCODECLIB_DIR := $(ROOTDIR)/lib/rbcodec
-RBCODECLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/SOURCES)
+RBCODECLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/SOURCES, \
+ $(RBCODEC_CFLAGS) -imacros rbcodecconfig.h)
RBCODECLIB_OBJ := $(call c2obj, $(RBCODECLIB_SRC))
RBCODECLIB := $(BUILDDIR)/lib/librbcodec.a
diff --git a/lib/rbcodec/rbcodecconfig-example.h b/lib/rbcodec/rbcodecconfig-example.h
new file mode 100644
index 0000000000..ad0f296a23
--- /dev/null
+++ b/lib/rbcodec/rbcodecconfig-example.h
@@ -0,0 +1,32 @@
+#ifndef RBCODECCONFIG_H_INCLUDED
+#define RBCODECCONFIG_H_INCLUDED
+
+#define HAVE_PITCHSCREEN
+//#define HAVE_SW_VOLUME_CONTROL
+#define HAVE_SW_TONE_CONTROLS
+#define HAVE_ALBUMART
+#define NUM_CORES 1
+
+#ifndef __ASSEMBLER__
+
+/* {,u}int{8,16,32,64}_t, {,U}INT{8,16,32,64}_{MIN,MAX}, intptr_t, uintptr_t */
+#include <inttypes.h>
+
+/* bool, true, false */
+#include <stdbool.h>
+
+/* NULL, offsetof, size_t */
+#include <stddef.h>
+
+/* ssize_t, off_t, open, close, read, lseek, SEEK_SET, SEEK_CUR, SEEK_END */
+#include <unistd.h>
+
+/* MAX_PATH, {UCHAR,USHRT,UINT,ULONG,SCHAR,SHRT,INT,LONG}_{MIN,MAX} */
+#include <limits.h>
+// FIXME changing MAX_PATH is broken for now
+//#define MAX_PATH PATH_MAX
+// set same as rb to avoid dragons
+#define MAX_PATH 260
+#endif
+
+#endif
diff --git a/lib/rbcodec/rbcodecplatform-unix.h b/lib/rbcodec/rbcodecplatform-unix.h
new file mode 100644
index 0000000000..c9c8a29642
--- /dev/null
+++ b/lib/rbcodec/rbcodecplatform-unix.h
@@ -0,0 +1,77 @@
+#ifndef RBCODECPLATFORM_H_INCLUDED
+#define RBCODECPLATFORM_H_INCLUDED
+
+/* assert */
+#include <assert.h>
+
+/* O_RDONLY, O_WRONLY, O_CREAT, O_APPEND */
+#include <fcntl.h>
+
+/* isdigit, islower, isprint, isspace, toupper */
+#include <ctype.h>
+
+/* memchr, memcmp, memcpy, memmove, memset, strcat, strchr, strcmp, strcpy,
+ * strlen, strncmp, strrchr */
+#include <string.h>
+
+/* strcasecmp */
+#include <strings.h>
+
+/* abs, atoi, labs, rand */
+#include <stdlib.h>
+
+/* swap16, swap32 */
+#include <byteswap.h>
+#ifndef swap16
+#define swap16(x) bswap_16(x)
+#endif
+#ifndef swap32
+#define swap32(x) bswap_32(x)
+#endif
+
+/* hto{be,le}{16,32}, {be,le}toh{16,32}, ROCKBOX_{BIG,LITTLE}_ENDIAN */
+#include <endian.h>
+#ifndef betoh16
+#define betoh16 be16toh
+#endif
+#ifndef betoh32
+#define betoh32 be32toh
+#endif
+#ifndef letoh16
+#define letoh16 le16toh
+#endif
+#ifndef letoh32
+#define letoh32 le32toh
+#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define ROCKBOX_LITTLE_ENDIAN 1
+#else
+#define ROCKBOX_BIG_ENDIAN 1
+#endif
+
+/* filesize */
+#include <sys/stat.h>
+off_t filesize(int fd);
+/*
+static inline off_t filesize(int fd) {
+ struct stat st;
+ fstat(fd, &st);
+ return st.st_size;
+}
+*/
+
+/* snprintf */
+#include <stdio.h>
+
+/* debugf, logf */
+/*
+#ifdef DEBUG
+#define debugf(...) fprintf(stderr, __VA_ARGS__)
+#ifndef logf
+#define logf(...) do { fprintf(stderr, __VA_ARGS__); \
+ putc('\n', stderr); \
+ } while (0)
+#endif
+#endif
+*/
+#endif
diff --git a/lib/rbcodec/test/rbcodecconfig.h b/lib/rbcodec/test/rbcodecconfig.h
new file mode 100644
index 0000000000..5e9c3bd0e8
--- /dev/null
+++ b/lib/rbcodec/test/rbcodecconfig.h
@@ -0,0 +1,2 @@
+#include "../rbcodecconfig-example.h"
+
diff --git a/lib/rbcodec/test/rbcodecplatform.h b/lib/rbcodec/test/rbcodecplatform.h
new file mode 100644
index 0000000000..1b51a9707c
--- /dev/null
+++ b/lib/rbcodec/test/rbcodecplatform.h
@@ -0,0 +1,2 @@
+#include "../rbcodecplatform-unix.h"
+
diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c
index 2f52062e50..53d360d89e 100644
--- a/lib/rbcodec/test/warble.c
+++ b/lib/rbcodec/test/warble.c
@@ -34,12 +34,13 @@
#include "buffering.h" /* TYPE_PACKET_AUDIO */
#include "codecs.h"
#include "core_alloc.h" /* core_allocator_init */
-#include "debug.h"
#include "dsp_core.h"
#include "metadata.h"
#include "settings.h"
#include "sound.h"
#include "tdspeed.h"
+#include "kernel.h"
+#include "platform.h"
/***************** EXPORTED *****************/
@@ -581,6 +582,29 @@ static unsigned ci_sleep(unsigned ticks)
return 0;
}
+static void ci_debugf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+#ifdef ROCKBOX_HAS_LOGF
+static void ci_logf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ putc('\n', stderr);
+ va_end(ap);
+}
+#endif
+
+static void commit_dcache(void) {}
+static void commit_discard_dcache(void) {}
+static void commit_discard_idcache(void) {}
+
static struct codec_api ci = {
0, /* filesize */
@@ -628,10 +652,10 @@ static struct codec_api ci = {
memcmp,
memchr,
#if defined(DEBUG) || defined(SIMULATOR)
- debugf,
+ ci_debugf,
#endif
#ifdef ROCKBOX_HAS_LOGF
- debugf, /* logf */
+ ci_logf,
#endif
qsort,
diff --git a/lib/rbcodec/test/warble.make b/lib/rbcodec/test/warble.make
index f2234c03b5..b238a2ed63 100644
--- a/lib/rbcodec/test/warble.make
+++ b/lib/rbcodec/test/warble.make
@@ -7,20 +7,20 @@
# $Id$
#
-
-
RBCODECLIB_DIR = $(ROOTDIR)/lib/rbcodec
RBCODEC_BLD = $(BUILDDIR)/lib/rbcodec
-GCCOPTS += -D__PCTOOL__ $(TARGET) -DDEBUG -g -std=gnu99 `$(SDLCONFIG) --cflags` -DCODECDIR="\"$(CODECDIR)\""
+GCCOPTS += -D__PCTOOL__ $(TARGET) -DDEBUG -g -std=gnu99 \
+ `$(SDLCONFIG) --cflags` -DCODECDIR="\"$(CODECDIR)\""
+RBCODEC_CFLAGS += -D_FILE_H_ #-DLOGF_H -DDEBUG_H -D_KERNEL_H_ # will be removed later
SRC= $(call preprocess, $(ROOTDIR)/lib/rbcodec/test/SOURCES)
-INCLUDES += -I$(ROOTDIR)/apps -I$(ROOTDIR)/apps/gui
-INCLUDES += -I$(ROOTDIR)/firmware/export -I$(ROOTDIR)/firmware/include \
- -I$(ROOTDIR)/firmware/target/hosted \
- -I$(ROOTDIR)/firmware/target/hosted/sdl
-
+INCLUDES += -I$(ROOTDIR)/lib/rbcodec/test \
+ -I$(ROOTDIR)/apps -I$(ROOTDIR)/apps/gui \
+ -I$(ROOTDIR)/firmware/export -I$(ROOTDIR)/firmware/include \
+ -I$(ROOTDIR)/firmware/target/hosted \
+ -I$(ROOTDIR)/firmware/target/hosted/sdl
.SECONDEXPANSION: # $$(OBJ) is not populated until after this
diff --git a/tools/functions.make b/tools/functions.make
index ead62f7b10..2a26e48bf2 100644
--- a/tools/functions.make
+++ b/tools/functions.make
@@ -15,7 +15,7 @@
# The sed line is to prepend the directory to all source files
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \
- grep -v '^\#' | \
+ grep -v '^\#' | grep -v "^ *$$" | \
sed -e 's:^..*:$(dir $(1))&:')
preprocess2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \