Add a slot to set the progress bar value and a member to hide it.
[Rockbox.git] / apps / codecs / lib / codeclib.c
blob75f1d1a18a63256d4c47f04910916ea9d970b67c
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Dave Chapman
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 /* "helper functions" common to all codecs */
22 #include <string.h>
23 #include "codecs.h"
24 #include "dsp.h"
25 #include "codeclib.h"
26 #include "id3.h"
28 long mem_ptr;
29 long bufsize;
30 unsigned char* mp3buf; // The actual MP3 buffer from Rockbox
31 unsigned char* mallocbuf; // 512K from the start of MP3 buffer
32 unsigned char* filebuf; // The rest of the MP3 buffer
34 int codec_init(void)
36 mem_ptr = 0;
37 mallocbuf = (unsigned char *)ci->get_codec_memory((size_t *)&bufsize);
39 return 0;
42 void codec_set_replaygain(struct mp3entry* id3)
44 ci->configure(DSP_SET_TRACK_GAIN, id3->track_gain);
45 ci->configure(DSP_SET_ALBUM_GAIN, id3->album_gain);
46 ci->configure(DSP_SET_TRACK_PEAK, id3->track_peak);
47 ci->configure(DSP_SET_ALBUM_PEAK, id3->album_peak);
50 /* Various "helper functions" common to all the xxx2wav decoder plugins */
53 void* codec_malloc(size_t size)
55 void* x;
57 if (mem_ptr + (long)size > bufsize)
58 return NULL;
60 x=&mallocbuf[mem_ptr];
61 mem_ptr+=(size+3)&~3; /* Keep memory 32-bit aligned */
63 return(x);
66 void* codec_calloc(size_t nmemb, size_t size)
68 void* x;
69 x = codec_malloc(nmemb*size);
70 if (x == NULL)
71 return NULL;
72 ci->memset(x,0,nmemb*size);
73 return(x);
76 void codec_free(void* ptr) {
77 (void)ptr;
80 void* codec_realloc(void* ptr, size_t size)
82 void* x;
83 (void)ptr;
84 x = codec_malloc(size);
85 return(x);
88 size_t strlen(const char *s)
90 return(ci->strlen(s));
93 char *strcpy(char *dest, const char *src)
95 return(ci->strcpy(dest,src));
98 char *strcat(char *dest, const char *src)
100 return(ci->strcat(dest,src));
103 int strcmp(const char *s1, const char *s2)
105 return(ci->strcmp(s1,s2));
108 void *memcpy(void *dest, const void *src, size_t n)
110 return(ci->memcpy(dest,src,n));
113 void *memset(void *s, int c, size_t n)
115 return(ci->memset(s,c,n));
118 int memcmp(const void *s1, const void *s2, size_t n)
120 return(ci->memcmp(s1,s2,n));
123 void* memchr(const void *s, int c, size_t n)
125 return(ci->memchr(s,c,n));
128 void *memmove(void *dest, const void *src, size_t n)
130 return(ci->memmove(dest,src,n));
133 void qsort(void *base, size_t nmemb, size_t size,
134 int(*compar)(const void *, const void *))
136 ci->qsort(base,nmemb,size,compar);
139 #ifdef RB_PROFILE
140 void __cyg_profile_func_enter(void *this_fn, void *call_site) {
141 #ifdef CPU_COLDFIRE
142 (void)call_site;
143 ci->profile_func_enter(this_fn, __builtin_return_address(1));
144 #else
145 ci->profile_func_enter(this_fn, call_site);
146 #endif
149 void __cyg_profile_func_exit(void *this_fn, void *call_site) {
150 ci->profile_func_exit(this_fn,call_site);
152 #endif