Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame^] | 10 | * Copyright (C) 2002 Björn Stenberg |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 11 | * |
| 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. |
| 14 | * |
| 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 16 | * KIND, either express or implied. |
| 17 | * |
| 18 | ****************************************************************************/ |
| 19 | #ifndef _CODECS_H_ |
| 20 | #define _CODECS_H_ |
| 21 | |
| 22 | /* instruct simulator code to not redefine any symbols when compiling codecs. |
| 23 | (the CODEC macro is defined in apps/codecs/Makefile) */ |
| 24 | #ifdef CODEC |
| 25 | #define NO_REDEFINES_PLEASE |
| 26 | #endif |
| 27 | |
| 28 | #ifndef MEM |
| 29 | #define MEM 2 |
| 30 | #endif |
| 31 | |
| 32 | #include <stdbool.h> |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 33 | #include <stdlib.h> |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 34 | #include "config.h" |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 35 | #include "kernel.h" |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 36 | #include "system.h" |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 37 | #include "id3.h" |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 38 | #include "audio.h" |
Brandon Low | 05dccc3 | 2006-01-18 20:54:13 +0000 | [diff] [blame] | 39 | #ifdef RB_PROFILE |
| 40 | #include "profile.h" |
Dave Chapman | 1feb8bd | 2007-05-07 13:32:56 +0000 | [diff] [blame] | 41 | #include "thread.h" |
Brandon Low | 05dccc3 | 2006-01-18 20:54:13 +0000 | [diff] [blame] | 42 | #endif |
Thom Johansen | 6dfe98e | 2005-10-10 15:54:36 +0000 | [diff] [blame] | 43 | #if (CONFIG_CODEC == SWCODEC) |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 44 | #if !defined(SIMULATOR) && defined(HAVE_RECORDING) |
Michael Sevakis | 4fc717a | 2006-08-28 22:38:41 +0000 | [diff] [blame] | 45 | #include "pcm_record.h" |
| 46 | #endif |
Thom Johansen | 6dfe98e | 2005-10-10 15:54:36 +0000 | [diff] [blame] | 47 | #include "dsp.h" |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 48 | #endif |
| 49 | #include "settings.h" |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 50 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 51 | #ifdef CODEC |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 52 | #if defined(DEBUG) || defined(SIMULATOR) |
| 53 | #undef DEBUGF |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 54 | #define DEBUGF ci->debugf |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 55 | #undef LDEBUGF |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 56 | #define LDEBUGF ci->debugf |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 57 | #else |
| 58 | #define DEBUGF(...) |
| 59 | #define LDEBUGF(...) |
| 60 | #endif |
| 61 | |
| 62 | #ifdef ROCKBOX_HAS_LOGF |
| 63 | #undef LOGF |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 64 | #define LOGF ci->logf |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 65 | #else |
| 66 | #define LOGF(...) |
| 67 | #endif |
| 68 | |
| 69 | #endif |
| 70 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 71 | #ifdef SIMULATOR |
| 72 | #define PREFIX(_x_) sim_ ## _x_ |
| 73 | #else |
| 74 | #define PREFIX(_x_) _x_ |
| 75 | #endif |
| 76 | |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 77 | /* magic for normal codecs */ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 78 | #define CODEC_MAGIC 0x52434F44 /* RCOD */ |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 79 | /* magic for encoder codecs */ |
| 80 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 81 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 82 | /* increase this every time the api struct changes */ |
Michael Sevakis | 4855e73 | 2008-03-29 06:36:53 +0000 | [diff] [blame] | 83 | #define CODEC_API_VERSION 24 |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 84 | |
| 85 | /* update this to latest version if a change to the api struct breaks |
Jens Arnold | 99a0598 | 2005-08-29 20:07:17 +0000 | [diff] [blame] | 86 | backwards compatibility (and please take the opportunity to sort in any |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 87 | new function which are "waiting" at the end of the function table) */ |
Michael Sevakis | 4855e73 | 2008-03-29 06:36:53 +0000 | [diff] [blame] | 88 | #define CODEC_MIN_API_VERSION 24 |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 89 | |
| 90 | /* codec return codes */ |
| 91 | enum codec_status { |
| 92 | CODEC_OK = 0, |
| 93 | CODEC_USB_CONNECTED, |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 94 | CODEC_ERROR = -1, |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 95 | }; |
| 96 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 97 | /* NOTE: To support backwards compatibility, only add new functions at |
| 98 | the end of the structure. Every time you add a new function, |
| 99 | remember to increase CODEC_API_VERSION. If you make changes to the |
| 100 | existing APIs then also update CODEC_MIN_API_VERSION to current |
| 101 | version |
| 102 | */ |
| 103 | struct codec_api { |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 104 | |
| 105 | off_t filesize; /* Total file length */ |
| 106 | off_t curpos; /* Current buffer position */ |
| 107 | |
| 108 | /* For gapless mp3 */ |
| 109 | struct mp3entry *id3; /* TAG metadata pointer */ |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 110 | bool *taginfo_ready; /* Is metadata read */ |
| 111 | |
| 112 | /* Codec should periodically check if stop_codec is set to true. |
Brandon Low | ebadcc6 | 2006-04-15 02:03:11 +0000 | [diff] [blame] | 113 | In case it is, codec must return immediately */ |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 114 | bool stop_codec; |
Brandon Low | ebadcc6 | 2006-04-15 02:03:11 +0000 | [diff] [blame] | 115 | /* Codec should periodically check if new_track is non zero. |
| 116 | When it is, the codec should request a new track. */ |
| 117 | int new_track; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 118 | /* If seek_time != 0, codec should seek to that song position (in ms) |
| 119 | if codec supports seeking. */ |
Jens Arnold | 8ac3ae7 | 2006-03-03 02:09:58 +0000 | [diff] [blame] | 120 | long seek_time; |
Michael Sevakis | 27cf677 | 2008-03-25 02:34:12 +0000 | [diff] [blame] | 121 | |
| 122 | /* The dsp instance to be used for audio output */ |
| 123 | struct dsp_config *dsp; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 124 | |
| 125 | /* Returns buffer to malloc array. Only codeclib should need this. */ |
Brandon Low | 86f1e2e | 2006-03-24 13:43:15 +0000 | [diff] [blame] | 126 | void* (*get_codec_memory)(size_t *size); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 127 | /* Insert PCM data into audio buffer for playback. Playback will start |
| 128 | automatically. */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 129 | bool (*pcmbuf_insert)(const void *ch1, const void *ch2, int count); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 130 | /* Set song position in WPS (value in ms). */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 131 | void (*set_elapsed)(unsigned int value); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 132 | |
| 133 | /* Read next <size> amount bytes from file buffer to <ptr>. |
| 134 | Will return number of bytes read or 0 if end of file. */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 135 | size_t (*read_filebuf)(void *ptr, size_t size); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 136 | /* Request pointer to file buffer which can be used to read |
| 137 | <realsize> amount of data. <reqsize> tells the buffer system |
| 138 | how much data it should try to allocate. If <realsize> is 0, |
| 139 | end of file is reached. */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 140 | void* (*request_buffer)(size_t *realsize, size_t reqsize); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 141 | /* Advance file buffer position by <amount> amount of bytes. */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 142 | void (*advance_buffer)(size_t amount); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 143 | /* Advance file buffer to a pointer location inside file buffer. */ |
| 144 | void (*advance_buffer_loc)(void *ptr); |
| 145 | /* Seek file buffer to position <newpos> beginning of file. */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 146 | bool (*seek_buffer)(size_t newpos); |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 147 | /* Codec should call this function when it has done the seeking. */ |
| 148 | void (*seek_complete)(void); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 149 | /* Request file change from file buffer. Returns true is next |
| 150 | track is available and changed. If return value is false, |
| 151 | codec should exit immediately with PLUGIN_OK status. */ |
| 152 | bool (*request_next_track)(void); |
Brandon Low | ebadcc6 | 2006-04-15 02:03:11 +0000 | [diff] [blame] | 153 | /* Free the buffer area of the current codec after its loaded */ |
| 154 | void (*discard_codec)(void); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 155 | |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 156 | void (*set_offset)(size_t value); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 157 | /* Configure different codec buffer parameters. */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 158 | void (*configure)(int setting, intptr_t value); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 159 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 160 | /* kernel/ system */ |
Steve Bavin | 135cc75 | 2008-03-28 12:51:33 +0000 | [diff] [blame] | 161 | void (*PREFIX(sleep))(int ticks); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 162 | void (*yield)(void); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 163 | |
Michael Sevakis | 27cf677 | 2008-03-25 02:34:12 +0000 | [diff] [blame] | 164 | #if NUM_CORES > 1 |
| 165 | struct thread_entry * |
| 166 | (*create_thread)(void (*function)(void), void* stack, |
| 167 | size_t stack_size, unsigned flags, const char *name |
| 168 | IF_PRIO(, int priority) |
| 169 | IF_COP(, unsigned int core)); |
| 170 | |
| 171 | void (*thread_thaw)(struct thread_entry *thread); |
| 172 | void (*thread_wait)(struct thread_entry *thread); |
| 173 | void (*semaphore_init)(struct semaphore *s, int max, int start); |
| 174 | void (*semaphore_wait)(struct semaphore *s); |
| 175 | void (*semaphore_release)(struct semaphore *s); |
| 176 | void (*event_init)(struct event *e, unsigned int flags); |
| 177 | void (*event_wait)(struct event *e, unsigned int for_state); |
| 178 | void (*event_set_state)(struct event *e, unsigned int state); |
| 179 | #endif /* NUM_CORES */ |
| 180 | |
| 181 | #ifdef CACHE_FUNCTIONS_AS_CALL |
| 182 | void (*flush_icache)(void); |
| 183 | void (*invalidate_icache)(void); |
| 184 | #endif |
| 185 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 186 | /* strings and memory */ |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 187 | char* (*strcpy)(char *dst, const char *src); |
| 188 | char* (*strncpy)(char *dst, const char *src, size_t length); |
| 189 | size_t (*strlen)(const char *str); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 190 | int (*strcmp)(const char *, const char *); |
Dave Chapman | 9a011f3 | 2007-05-07 11:09:45 +0000 | [diff] [blame] | 191 | char *(*strcat)(char *s1, const char *s2); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 192 | void* (*memset)(void *dst, int c, size_t length); |
| 193 | void* (*memcpy)(void *out, const void *in, size_t n); |
Brandon Low | 86f1e2e | 2006-03-24 13:43:15 +0000 | [diff] [blame] | 194 | void* (*memmove)(void *out, const void *in, size_t n); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 195 | int (*memcmp)(const void *s1, const void *s2, size_t n); |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 196 | void *(*memchr)(const void *s1, int c, size_t n); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 197 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 198 | #if defined(DEBUG) || defined(SIMULATOR) |
Jens Arnold | 79c8a8c | 2007-03-17 09:02:53 +0000 | [diff] [blame] | 199 | void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 200 | #endif |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 201 | #ifdef ROCKBOX_HAS_LOGF |
Jens Arnold | 79c8a8c | 2007-03-17 09:02:53 +0000 | [diff] [blame] | 202 | void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 203 | #endif |
Dave Chapman | 9a011f3 | 2007-05-07 11:09:45 +0000 | [diff] [blame] | 204 | |
| 205 | /* Tremor requires qsort */ |
| 206 | void (*qsort)(void *base, size_t nmemb, size_t size, |
| 207 | int(*compar)(const void *, const void *)); |
| 208 | |
| 209 | /* The ADX codec accesses global_settings to test for REPEAT_ONE mode */ |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 210 | struct user_settings* global_settings; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 211 | |
Brandon Low | 05dccc3 | 2006-01-18 20:54:13 +0000 | [diff] [blame] | 212 | #ifdef RB_PROFILE |
| 213 | void (*profile_thread)(void); |
| 214 | void (*profstop)(void); |
| 215 | void (*profile_func_enter)(void *this_fn, void *call_site); |
| 216 | void (*profile_func_exit)(void *this_fn, void *call_site); |
| 217 | #endif |
Michael Sevakis | 4fc717a | 2006-08-28 22:38:41 +0000 | [diff] [blame] | 218 | |
| 219 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) |
Michael Sevakis | 598629c | 2007-03-04 04:16:53 +0000 | [diff] [blame] | 220 | volatile bool stop_encoder; |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 221 | volatile int enc_codec_loaded; /* <0=error, 0=pending, >0=ok */ |
| 222 | void (*enc_get_inputs)(struct enc_inputs *inputs); |
| 223 | void (*enc_set_parameters)(struct enc_parameters *params); |
| 224 | struct enc_chunk_hdr * (*enc_get_chunk)(void); |
| 225 | void (*enc_finish_chunk)(void); |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 226 | unsigned char * (*enc_get_pcm_data)(size_t size); |
| 227 | size_t (*enc_unget_pcm_data)(size_t size); |
Dave Chapman | 9a011f3 | 2007-05-07 11:09:45 +0000 | [diff] [blame] | 228 | |
| 229 | /* file */ |
| 230 | int (*PREFIX(open))(const char* pathname, int flags); |
| 231 | int (*close)(int fd); |
| 232 | ssize_t (*read)(int fd, void* buf, size_t count); |
| 233 | off_t (*PREFIX(lseek))(int fd, off_t offset, int whence); |
| 234 | ssize_t (*write)(int fd, const void* buf, size_t count); |
Dave Chapman | 9a011f3 | 2007-05-07 11:09:45 +0000 | [diff] [blame] | 235 | int (*round_value_to_list32)(unsigned long value, |
| 236 | const unsigned long list[], |
| 237 | int count, |
| 238 | bool signd); |
Michael Sevakis | 4fc717a | 2006-08-28 22:38:41 +0000 | [diff] [blame] | 239 | #endif |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 240 | |
Brandon Low | d2e75bf | 2006-02-03 00:12:11 +0000 | [diff] [blame] | 241 | /* new stuff at the end, sort into place next time |
| 242 | the API gets incompatible */ |
| 243 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 244 | }; |
| 245 | |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 246 | /* codec header */ |
| 247 | struct codec_header { |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 248 | unsigned long magic; /* RCOD or RENC */ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 249 | unsigned short target_id; |
| 250 | unsigned short api_version; |
| 251 | unsigned char *load_addr; |
| 252 | unsigned char *end_addr; |
| 253 | enum codec_status(*entry_point)(struct codec_api*); |
| 254 | }; |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 255 | |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 256 | #ifdef CODEC |
| 257 | #ifndef SIMULATOR |
| 258 | /* plugin_* is correct, codecs use the plugin linker script */ |
| 259 | extern unsigned char plugin_start_addr[]; |
| 260 | extern unsigned char plugin_end_addr[]; |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 261 | /* decoders */ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 262 | #define CODEC_HEADER \ |
| 263 | const struct codec_header __header \ |
| 264 | __attribute__ ((section (".header")))= { \ |
| 265 | CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
| 266 | plugin_start_addr, plugin_end_addr, codec_start }; |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 267 | /* encoders */ |
| 268 | #define CODEC_ENC_HEADER \ |
| 269 | const struct codec_header __header \ |
| 270 | __attribute__ ((section (".header")))= { \ |
| 271 | CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
| 272 | plugin_start_addr, plugin_end_addr, codec_start }; |
| 273 | |
| 274 | #else /* def SIMULATOR */ |
| 275 | /* decoders */ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 276 | #define CODEC_HEADER \ |
Nils Wallménius | 605949d | 2007-10-02 09:08:08 +0000 | [diff] [blame] | 277 | const struct codec_header __header \ |
| 278 | __attribute__((visibility("default"))) = { \ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 279 | CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
| 280 | NULL, NULL, codec_start }; |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 281 | /* encoders */ |
| 282 | #define CODEC_ENC_HEADER \ |
| 283 | const struct codec_header __header = { \ |
| 284 | CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
| 285 | NULL, NULL, codec_start }; |
| 286 | #endif /* SIMULATOR */ |
| 287 | #endif /* CODEC */ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 288 | |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 289 | /* create full codec path from root filenames in audio_formats[] |
Michael Sevakis | 4fc717a | 2006-08-28 22:38:41 +0000 | [diff] [blame] | 290 | assumes buffer size is MAX_PATH */ |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 291 | void codec_get_full_path(char *path, const char *codec_root_fn); |
Michael Sevakis | 4fc717a | 2006-08-28 22:38:41 +0000 | [diff] [blame] | 292 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 293 | /* defined by the codec loader (codec.c) */ |
Brandon Low | 86919f4 | 2007-11-03 17:55:29 +0000 | [diff] [blame] | 294 | int codec_load_buf(unsigned int hid, struct codec_api *api); |
Miika Pekkarinen | 159c52d | 2005-08-20 11:13:19 +0000 | [diff] [blame] | 295 | int codec_load_file(const char* codec, struct codec_api *api); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 296 | |
| 297 | /* defined by the codec */ |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 298 | enum codec_status codec_start(struct codec_api* rockbox); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 299 | |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 300 | #ifndef CACHE_FUNCTION_WRAPPERS |
| 301 | |
| 302 | #ifdef CACHE_FUNCTIONS_AS_CALL |
| 303 | #define CACHE_FUNCTION_WRAPPERS(api) \ |
| 304 | void flush_icache(void) \ |
| 305 | { \ |
| 306 | (api)->flush_icache(); \ |
| 307 | } \ |
| 308 | void invalidate_icache(void) \ |
| 309 | { \ |
| 310 | (api)->invalidate_icache(); \ |
| 311 | } |
| 312 | #else |
| 313 | #define CACHE_FUNCTION_WRAPPERS(api) |
| 314 | #endif /* CACHE_FUNCTIONS_AS_CALL */ |
| 315 | |
| 316 | #endif /* CACHE_FUNCTION_WRAPPERS */ |
| 317 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 318 | #endif |