diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2006-11-06 18:07:30 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2006-11-06 18:07:30 +0000 |
commit | 0f5cb94aa4a334366a746fcbb22f3335ca413265 (patch) | |
tree | 8f89a96628c1810d51ee9816daf78edb8c76fcd4 /apps/codecs.h | |
parent | 0b22795e26ee09de14f6ac23219adeda12f2fd5b (diff) | |
download | rockbox-0f5cb94aa4a334366a746fcbb22f3335ca413265.tar.gz rockbox-0f5cb94aa4a334366a746fcbb22f3335ca413265.zip |
Big Patch adds primarily: Samplerate and format selection to recording for SWCODEC. Supprort for samplerates changing in playback (just goes with the recording part inseparably). Samplerates to all encoders. Encoders can be configured individually on a menu specific to the encoder in the recording menu. File creation is delayed until flush time to reduce spinups when splitting. Misc: statusbar icons for numbers are individual digits to display any number. Audio buffer was rearranged to maximize memory available to recording and properly reinitialized when trashed. ColdFire PCM stuff moved to target tree to avoid a complicated mess when adding samplerate switching. Some needed API changes and to neaten up growing gap between hardware and software codecs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11452 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs.h')
-rw-r--r-- | apps/codecs.h | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/apps/codecs.h b/apps/codecs.h index 96804a889b..0b90ef9c19 100644 --- a/apps/codecs.h +++ b/apps/codecs.h | |||
@@ -46,7 +46,7 @@ | |||
46 | #include "profile.h" | 46 | #include "profile.h" |
47 | #endif | 47 | #endif |
48 | #if (CONFIG_CODEC == SWCODEC) | 48 | #if (CONFIG_CODEC == SWCODEC) |
49 | #if !defined(SIMULATOR) | 49 | #if !defined(SIMULATOR) && defined(HAVE_RECORDING) |
50 | #include "pcm_record.h" | 50 | #include "pcm_record.h" |
51 | #endif | 51 | #endif |
52 | #include "dsp.h" | 52 | #include "dsp.h" |
@@ -84,15 +84,18 @@ | |||
84 | #define PREFIX(_x_) _x_ | 84 | #define PREFIX(_x_) _x_ |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | /* magic for normal codecs */ | ||
87 | #define CODEC_MAGIC 0x52434F44 /* RCOD */ | 88 | #define CODEC_MAGIC 0x52434F44 /* RCOD */ |
89 | /* magic for encoder codecs */ | ||
90 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ | ||
88 | 91 | ||
89 | /* increase this every time the api struct changes */ | 92 | /* increase this every time the api struct changes */ |
90 | #define CODEC_API_VERSION 9 | 93 | #define CODEC_API_VERSION 10 |
91 | 94 | ||
92 | /* update this to latest version if a change to the api struct breaks | 95 | /* update this to latest version if a change to the api struct breaks |
93 | backwards compatibility (and please take the opportunity to sort in any | 96 | backwards compatibility (and please take the opportunity to sort in any |
94 | new function which are "waiting" at the end of the function table) */ | 97 | new function which are "waiting" at the end of the function table) */ |
95 | #define CODEC_MIN_API_VERSION 8 | 98 | #define CODEC_MIN_API_VERSION 10 |
96 | 99 | ||
97 | /* codec return codes */ | 100 | /* codec return codes */ |
98 | enum codec_status { | 101 | enum codec_status { |
@@ -176,6 +179,7 @@ struct codec_api { | |||
176 | int (*PREFIX(remove))(const char* pathname); | 179 | int (*PREFIX(remove))(const char* pathname); |
177 | int (*PREFIX(rename))(const char* path, const char* newname); | 180 | int (*PREFIX(rename))(const char* path, const char* newname); |
178 | int (*PREFIX(ftruncate))(int fd, off_t length); | 181 | int (*PREFIX(ftruncate))(int fd, off_t length); |
182 | int (*PREFIX(fsync))(int fd); | ||
179 | 183 | ||
180 | int (*fdprintf)(int fd, const char *fmt, ...); | 184 | int (*fdprintf)(int fd, const char *fmt, ...); |
181 | int (*read_line)(int fd, char* buffer, int buffer_size); | 185 | int (*read_line)(int fd, char* buffer, int buffer_size); |
@@ -232,7 +236,8 @@ struct codec_api { | |||
232 | /* sound */ | 236 | /* sound */ |
233 | void (*sound_set)(int setting, int value); | 237 | void (*sound_set)(int setting, int value); |
234 | #ifndef SIMULATOR | 238 | #ifndef SIMULATOR |
235 | void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size)); | 239 | void (*mp3_play_data)(const unsigned char* start, |
240 | int size, void (*get_more)(unsigned char** start, int* size)); | ||
236 | void (*mp3_play_pause)(bool play); | 241 | void (*mp3_play_pause)(bool play); |
237 | void (*mp3_play_stop)(void); | 242 | void (*mp3_play_stop)(void); |
238 | bool (*mp3_is_playing)(void); | 243 | bool (*mp3_is_playing)(void); |
@@ -263,6 +268,10 @@ struct codec_api { | |||
263 | struct tm* (*get_time)(void); | 268 | struct tm* (*get_time)(void); |
264 | int (*set_time)(const struct tm *tm); | 269 | int (*set_time)(const struct tm *tm); |
265 | void* (*plugin_get_audio_buffer)(int* buffer_size); | 270 | void* (*plugin_get_audio_buffer)(int* buffer_size); |
271 | int (*round_value_to_list32)(unsigned long value, | ||
272 | const unsigned long list[], | ||
273 | int count, | ||
274 | bool signd); | ||
266 | 275 | ||
267 | #if defined(DEBUG) || defined(SIMULATOR) | 276 | #if defined(DEBUG) || defined(SIMULATOR) |
268 | void (*debugf)(const char *fmt, ...); | 277 | void (*debugf)(const char *fmt, ...); |
@@ -291,18 +300,14 @@ struct codec_api { | |||
291 | #endif | 300 | #endif |
292 | 301 | ||
293 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) | 302 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) |
294 | bool enc_codec_loaded; | 303 | volatile int enc_codec_loaded; /* <0=error, 0=pending, >0=ok */ |
295 | void (*enc_get_inputs)(int *buffer_size, | 304 | void (*enc_get_inputs)(struct enc_inputs *inputs); |
296 | int *channels, int *quality); | 305 | void (*enc_set_parameters)(struct enc_parameters *params); |
297 | void (*enc_set_parameters)(int chunk_size, int num_chunks, | 306 | struct enc_chunk_hdr * (*enc_get_chunk)(void); |
298 | int samp_per_chunk, char *head_ptr, int head_size, | 307 | void (*enc_finish_chunk)(void); |
299 | int enc_id); | 308 | int (*enc_pcm_buf_near_empty)(void); |
300 | unsigned int* (*enc_alloc_chunk)(void); | 309 | unsigned char * (*enc_get_pcm_data)(size_t size); |
301 | void (*enc_free_chunk)(void); | 310 | size_t (*enc_unget_pcm_data)(size_t size); |
302 | int (*enc_wavbuf_near_empty)(void); | ||
303 | char* (*enc_get_wav_data)(int size); | ||
304 | void (**enc_set_header_callback)(void *head_buffer, | ||
305 | int head_size, int num_samples, bool is_file_header); | ||
306 | #endif | 311 | #endif |
307 | 312 | ||
308 | /* new stuff at the end, sort into place next time | 313 | /* new stuff at the end, sort into place next time |
@@ -312,34 +317,49 @@ struct codec_api { | |||
312 | 317 | ||
313 | /* codec header */ | 318 | /* codec header */ |
314 | struct codec_header { | 319 | struct codec_header { |
315 | unsigned long magic; | 320 | unsigned long magic; /* RCOD or RENC */ |
316 | unsigned short target_id; | 321 | unsigned short target_id; |
317 | unsigned short api_version; | 322 | unsigned short api_version; |
318 | unsigned char *load_addr; | 323 | unsigned char *load_addr; |
319 | unsigned char *end_addr; | 324 | unsigned char *end_addr; |
320 | enum codec_status(*entry_point)(struct codec_api*); | 325 | enum codec_status(*entry_point)(struct codec_api*); |
321 | }; | 326 | }; |
327 | |||
322 | #ifdef CODEC | 328 | #ifdef CODEC |
323 | #ifndef SIMULATOR | 329 | #ifndef SIMULATOR |
324 | /* plugin_* is correct, codecs use the plugin linker script */ | 330 | /* plugin_* is correct, codecs use the plugin linker script */ |
325 | extern unsigned char plugin_start_addr[]; | 331 | extern unsigned char plugin_start_addr[]; |
326 | extern unsigned char plugin_end_addr[]; | 332 | extern unsigned char plugin_end_addr[]; |
333 | /* decoders */ | ||
327 | #define CODEC_HEADER \ | 334 | #define CODEC_HEADER \ |
328 | const struct codec_header __header \ | 335 | const struct codec_header __header \ |
329 | __attribute__ ((section (".header")))= { \ | 336 | __attribute__ ((section (".header")))= { \ |
330 | CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | 337 | CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
331 | plugin_start_addr, plugin_end_addr, codec_start }; | 338 | plugin_start_addr, plugin_end_addr, codec_start }; |
332 | #else /* SIMULATOR */ | 339 | /* encoders */ |
340 | #define CODEC_ENC_HEADER \ | ||
341 | const struct codec_header __header \ | ||
342 | __attribute__ ((section (".header")))= { \ | ||
343 | CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | ||
344 | plugin_start_addr, plugin_end_addr, codec_start }; | ||
345 | |||
346 | #else /* def SIMULATOR */ | ||
347 | /* decoders */ | ||
333 | #define CODEC_HEADER \ | 348 | #define CODEC_HEADER \ |
334 | const struct codec_header __header = { \ | 349 | const struct codec_header __header = { \ |
335 | CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | 350 | CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
336 | NULL, NULL, codec_start }; | 351 | NULL, NULL, codec_start }; |
337 | #endif | 352 | /* encoders */ |
338 | #endif | 353 | #define CODEC_ENC_HEADER \ |
354 | const struct codec_header __header = { \ | ||
355 | CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | ||
356 | NULL, NULL, codec_start }; | ||
357 | #endif /* SIMULATOR */ | ||
358 | #endif /* CODEC */ | ||
339 | 359 | ||
340 | /* create full codec path from filenames in audio_formats[] | 360 | /* create full codec path from root filenames in audio_formats[] |
341 | assumes buffer size is MAX_PATH */ | 361 | assumes buffer size is MAX_PATH */ |
342 | void codec_get_full_path(char *path, const char *codec_fn); | 362 | void codec_get_full_path(char *path, const char *codec_root_fn); |
343 | 363 | ||
344 | /* defined by the codec loader (codec.c) */ | 364 | /* defined by the codec loader (codec.c) */ |
345 | int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap, | 365 | int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap, |