2005-02-16 15:13:39 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Dave Chapman
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2005-02-16 18:51:21 +00:00
|
|
|
/* Various "helper functions" common to all the xxx2wav decoder plugins */
|
2005-02-16 15:13:39 +00:00
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
2005-02-16 19:39:48 +00:00
|
|
|
/* software codec platforms, not for simulator */
|
|
|
|
|
2005-06-22 19:41:30 +00:00
|
|
|
#include "codecs.h"
|
2005-02-16 18:51:21 +00:00
|
|
|
#include "xxx2wav.h"
|
2005-02-16 15:13:39 +00:00
|
|
|
|
2005-07-12 10:10:02 +00:00
|
|
|
extern struct codec_api* local_rb;
|
2005-02-16 15:13:39 +00:00
|
|
|
|
|
|
|
int mem_ptr;
|
|
|
|
int bufsize;
|
2005-07-12 10:01:55 +00:00
|
|
|
unsigned char* audiobuf; /* The actual audio buffer from Rockbox */
|
|
|
|
unsigned char* mallocbuf; /* 512K from the start of audio buffer */
|
|
|
|
unsigned char* filebuf; /* The rest of the audio buffer */
|
2005-02-16 15:13:39 +00:00
|
|
|
|
2005-06-22 19:41:30 +00:00
|
|
|
void* codec_malloc(size_t size)
|
|
|
|
{
|
|
|
|
void* x;
|
2005-02-16 15:13:39 +00:00
|
|
|
|
2005-08-21 06:38:34 +00:00
|
|
|
if (mem_ptr + (int)size > bufsize)
|
2005-08-20 21:17:41 +00:00
|
|
|
return NULL;
|
|
|
|
|
2005-06-22 19:41:30 +00:00
|
|
|
x=&mallocbuf[mem_ptr];
|
2005-07-12 10:10:02 +00:00
|
|
|
mem_ptr+=(size+3)&~3; /* Keep memory 32-bit aligned */
|
2005-03-09 19:36:53 +00:00
|
|
|
|
2005-06-22 19:41:30 +00:00
|
|
|
return(x);
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 19:41:30 +00:00
|
|
|
void* codec_calloc(size_t nmemb, size_t size)
|
|
|
|
{
|
|
|
|
void* x;
|
|
|
|
x = codec_malloc(nmemb*size);
|
2005-08-20 21:17:41 +00:00
|
|
|
if (x == NULL)
|
|
|
|
return NULL;
|
2005-06-22 19:41:30 +00:00
|
|
|
local_rb->memset(x,0,nmemb*size);
|
|
|
|
return(x);
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-09-18 12:44:27 +00:00
|
|
|
#if defined(SIMULATOR)
|
2005-06-22 19:41:30 +00:00
|
|
|
void* codec_alloca(size_t size)
|
|
|
|
{
|
|
|
|
void* x;
|
|
|
|
x = codec_malloc(size);
|
|
|
|
return(x);
|
2005-02-19 12:11:18 +00:00
|
|
|
}
|
2005-09-18 12:44:27 +00:00
|
|
|
#endif
|
2005-02-19 12:11:18 +00:00
|
|
|
|
2005-02-28 20:55:31 +00:00
|
|
|
void codec_free(void* ptr) {
|
2005-06-22 19:41:30 +00:00
|
|
|
(void)ptr;
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
void* codec_realloc(void* ptr, size_t size)
|
|
|
|
{
|
|
|
|
void* x;
|
|
|
|
(void)ptr;
|
2005-07-12 10:10:02 +00:00
|
|
|
x = codec_malloc(size);
|
|
|
|
return(x);
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-28 18:43:33 +00:00
|
|
|
size_t strlen(const char *s)
|
|
|
|
{
|
|
|
|
return(local_rb->strlen(s));
|
|
|
|
}
|
|
|
|
|
|
|
|
char *strcpy(char *dest, const char *src)
|
|
|
|
{
|
|
|
|
return(local_rb->strcpy(dest,src));
|
|
|
|
}
|
|
|
|
|
|
|
|
char *strcat(char *dest, const char *src)
|
|
|
|
{
|
|
|
|
return(local_rb->strcat(dest,src));
|
|
|
|
}
|
|
|
|
|
|
|
|
int strcmp(const char *s1, const char *s2)
|
|
|
|
{
|
|
|
|
return(local_rb->strcmp(s1,s2));
|
|
|
|
}
|
|
|
|
|
|
|
|
int strncasecmp(const char *s1, const char *s2, size_t n)
|
|
|
|
{
|
|
|
|
return(local_rb->strncasecmp(s1,s2,n));
|
|
|
|
}
|
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
void *memcpy(void *dest, const void *src, size_t n)
|
|
|
|
{
|
2005-07-12 10:10:02 +00:00
|
|
|
return(local_rb->memcpy(dest,src,n));
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
void *memset(void *s, int c, size_t n)
|
|
|
|
{
|
2005-07-12 10:10:02 +00:00
|
|
|
return(local_rb->memset(s,c,n));
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
int memcmp(const void *s1, const void *s2, size_t n)
|
|
|
|
{
|
2005-07-12 10:10:02 +00:00
|
|
|
return(local_rb->memcmp(s1,s2,n));
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
void* memchr(const void *s, int c, size_t n)
|
|
|
|
{
|
2005-07-05 08:43:36 +00:00
|
|
|
return(local_rb->memchr(s,c,n));
|
2005-02-19 12:11:18 +00:00
|
|
|
}
|
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
void* memmove(const void *s1, const void *s2, size_t n)
|
|
|
|
{
|
|
|
|
char* dest=(char*)s1;
|
|
|
|
char* src=(char*)s2;
|
|
|
|
size_t i;
|
|
|
|
|
2005-07-12 10:10:02 +00:00
|
|
|
for (i=0;i<n;i++)
|
|
|
|
dest[i]=src[i];
|
2005-02-16 15:13:39 +00:00
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
return(dest);
|
2005-02-16 15:13:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-12 10:01:55 +00:00
|
|
|
void qsort(void *base, size_t nmemb, size_t size,
|
2005-07-12 10:10:02 +00:00
|
|
|
int(*compar)(const void *, const void *))
|
2005-06-05 23:05:10 +00:00
|
|
|
{
|
2005-07-12 10:10:02 +00:00
|
|
|
local_rb->qsort(base,nmemb,size,compar);
|
2005-06-05 23:05:10 +00:00
|
|
|
}
|
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#endif /* CONFIG_CODEC == SWCODEC */
|