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>
This commit is contained in:
Sean Bartell 2011-10-30 12:05:04 -04:00 committed by Nils Wallménius
parent 5f0cb71361
commit cadb3627fc
70 changed files with 430 additions and 81 deletions

22
apps/rbcodecconfig.h Normal file
View File

@ -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

35
apps/rbcodecplatform.h Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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"

View File

@ -23,7 +23,6 @@
# define LIBMAD_FRAME_H
# include "fixed.h"
# include "timer.h"
# include "stream.h"
enum mad_layer {

View File

@ -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)

View File

@ -39,9 +39,9 @@
#pragma once
#endif
#include "platform.h"
#include "reader.h"
#include "streaminfo.h"
#include "config.h"
#ifdef __cplusplus
extern "C" {

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -37,7 +37,9 @@
#endif
#include "modes.h"
#ifndef FIXED_POINT
#include <math.h>
#endif
#include "os_support.h"
#ifndef NULL

View File

@ -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 {

View File

@ -21,7 +21,6 @@
#include <errno.h>
#include <string.h>
#include <math.h>
#include "system.h"
#include "ivorbiscodec.h"
#include "ivorbisfile.h"

View File

@ -15,7 +15,6 @@
// the malloc() system is provided.
#include "wavpack.h"
#include "system.h"
#include <string.h>

View File

@ -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[] =
{

View File

@ -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"

View File

@ -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"

View File

@ -24,7 +24,6 @@
#include <ctype.h>
#include <inttypes.h>
#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"

View File

@ -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)

View File

@ -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 */

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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)
{

View File

@ -46,6 +46,7 @@
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include "platform.h"
#include "metadata.h"
#include "metadata_parsers.h"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

122
lib/rbcodec/platform.h Normal file
View File

@ -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 */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,2 @@
#include "../rbcodecconfig-example.h"

View File

@ -0,0 +1,2 @@
#include "../rbcodecplatform-unix.h"

View File

@ -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,

View File

@ -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

View File

@ -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) | \