From ed2918ffffb3ac60f8211acc1f8a0497f83cca72 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Fri, 12 Aug 2011 01:26:56 -0400 Subject: [PATCH 7/7] rbcodec refactoring: miscellaneous --- lib/rbcodec/codecs/libtremor/SOURCES | 1 - lib/rbcodec/codecs/libtremor/ctype.c | 4 ---- lib/rbcodec/metadata/ape.c | 29 ++++++++++++++++------------- lib/rbcodec/test/Makefile | 10 ++-------- lib/rbcodec/test/warble.c | 21 --------------------- 5 files changed, 18 insertions(+), 47 deletions(-) delete mode 100644 lib/rbcodec/codecs/libtremor/ctype.c diff --git a/lib/rbcodec/codecs/libtremor/SOURCES b/lib/rbcodec/codecs/libtremor/SOURCES index c622699..4076694 100644 --- a/lib/rbcodec/codecs/libtremor/SOURCES +++ b/lib/rbcodec/codecs/libtremor/SOURCES @@ -12,5 +12,4 @@ sharedbook.c synthesis.c vorbisfile.c window.c -ctype.c oggmalloc.c diff --git a/lib/rbcodec/codecs/libtremor/ctype.c b/lib/rbcodec/codecs/libtremor/ctype.c deleted file mode 100644 index 9f22047..0000000 --- a/lib/rbcodec/codecs/libtremor/ctype.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "config.h" -#if (CONFIG_PLATFORM & PLATFORM_NATIVE) -#include "libc/ctype.c" -#endif diff --git a/lib/rbcodec/metadata/ape.c b/lib/rbcodec/metadata/ape.c index c423d9d..2939627 100644 --- a/lib/rbcodec/metadata/ape.c +++ b/lib/rbcodec/metadata/ape.c @@ -27,11 +27,8 @@ #include "metadata.h" #include "metadata_common.h" #include "metadata_parsers.h" -#include "structec.h" #define APETAG_HEADER_LENGTH 32 -#define APETAG_HEADER_FORMAT "8llll8" -#define APETAG_ITEM_HEADER_FORMAT "ll" #define APETAG_ITEM_TYPE_MASK 3 #ifdef HAVE_ALBUMART @@ -44,17 +41,17 @@ struct apetag_header { char id[8]; - long version; - long length; - long item_count; - long flags; + int32_t version; + int32_t length; + int32_t item_count; + int32_t flags; char reserved[8]; }; struct apetag_item_header { - long length; - long flags; + int32_t length; + int32_t flags; }; /* Read the items in an APEV2 tag. Only looks for a tag at the end of a @@ -65,13 +62,17 @@ bool read_ape_tags(int fd, struct mp3entry* id3) struct apetag_header header; if ((lseek(fd, -APETAG_HEADER_LENGTH, SEEK_END) < 0) - || (ecread(fd, &header, 1, APETAG_HEADER_FORMAT, IS_BIG_ENDIAN) - != APETAG_HEADER_LENGTH) + || (read(fd, &header, APETAG_HEADER_LENGTH) != APETAG_HEADER_LENGTH) || (memcmp(header.id, "APETAGEX", sizeof(header.id)))) { return false; } + header.version = betoh32(header.version); + header.length = betoh32(header.length); + header.item_count = betoh32(header.item_count); + header.flags = betoh32(header.flags); + if ((header.version == 2000) && (header.item_count > 0) && (header.length > APETAG_HEADER_LENGTH)) { @@ -98,11 +99,13 @@ bool read_ape_tags(int fd, struct mp3entry* id3) break; } - if (ecread(fd, &item, 1, APETAG_ITEM_HEADER_FORMAT, IS_BIG_ENDIAN) - < (long) sizeof(item)) + if (read(fd, &item, sizeof(item)) != (long) sizeof(item)) { return false; } + + item.flags = betoh32(item.flags); + item.length = betoh32(item.length); tag_remaining -= sizeof(item); r = read_string(fd, name, sizeof(name), 0, tag_remaining); diff --git a/lib/rbcodec/test/Makefile b/lib/rbcodec/test/Makefile index 39797b2..a56190a 100644 --- a/lib/rbcodec/test/Makefile +++ b/lib/rbcodec/test/Makefile @@ -4,10 +4,8 @@ default: all ROOTDIR = $(shell readlink -e ..) BUILDDIR = $(shell pwd)/build -APPSDIR = $(ROOTDIR)/apps -TOOLSDIR = $(ROOTDIR)/tools -RBCODEC_DIR = $(ROOTDIR)/lib/rbcodec -RBCODEC_BLD = $(BUILDDIR)/lib/rbcodec +RBCODEC_DIR = $(ROOTDIR) +RBCODEC_BLD = $(BUILDDIR) DEPFILE = $(BUILDDIR)/make.dep APP_TYPE = sdl-app SOFTWARECODECS = yes @@ -50,10 +48,6 @@ _ := $(shell [ ../rbcodecconfig-example.h -nt $(BUILDDIR)/rbcodecconfig.h ] && c _ := $(shell [ ../rbcodecplatform-unix.h -nt $(BUILDDIR)/rbcodecplatform.h ] && cp ../rbcodecplatform-unix.h $(BUILDDIR)/rbcodecplatform.h) include ../rbcodec.make -SRC = $(ROOTDIR)/firmware/common/unicode.c \ - $(ROOTDIR)/firmware/common/structec.c \ - $(ROOTDIR)/uisimulator/common/io.c - OBJ := $(SRC:.c=.o) OBJ := $(OBJ:.S=.o) OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ)) diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c index dccba13..5d95d04 100644 --- a/lib/rbcodec/test/warble.c +++ b/lib/rbcodec/test/warble.c @@ -42,30 +42,12 @@ /***************** EXPORTED *****************/ -struct user_settings global_settings; volatile long current_tick = 0; void yield(void) { } -void *buffer_alloc(size_t size) -{ - return malloc(size); -} - -void mutex_init(struct mutex *m) -{ -} - -void mutex_lock(struct mutex *m) -{ -} - -void mutex_unlock(struct mutex *m) -{ -} - /***************** INTERNAL *****************/ static enum { MODE_PLAY, MODE_WRITE } mode; @@ -688,9 +670,6 @@ static void print_mp3entry(const struct mp3entry *id3, FILE *f) static void decode_file(const char *input_fn) { - /* Set up global settings */ - memset(&global_settings, 0, sizeof(global_settings)); - global_settings.timestretch_enabled = true; dsp_timestretch_enable(malloc(dsp_timestretch_get_buffer_size())); /* Open file */ -- 1.7.6