diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-04-27 03:08:23 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-04-27 03:08:23 +0000 |
commit | c537d5958e8b421ac4f9bef6c8b9e7425a6cf167 (patch) | |
tree | 7ed36518fb6524da7bbd913ba7619b85b5d15d23 /apps/codecs.h | |
parent | dcf0f8de4a37ff1d2ea510aef75fa67977a8bdcc (diff) | |
download | rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.tar.gz rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.zip |
Commit FS#12069 - Playback rework - first stages. Gives as thorough as possible a treatment of codec management, track change and metadata logic as possible while maintaining fairly narrow focus and not rewriting everything all at once. Please see the rockbox-dev mail archive on 2011-04-25 (Playback engine rework) for a more thorough manifest of what was addressed. Plugins and codecs become incompatible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29785 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs.h')
-rw-r--r-- | apps/codecs.h | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/apps/codecs.h b/apps/codecs.h index d96b2a7c9a..5c50116038 100644 --- a/apps/codecs.h +++ b/apps/codecs.h | |||
@@ -75,12 +75,18 @@ | |||
75 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ | 75 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ |
76 | 76 | ||
77 | /* increase this every time the api struct changes */ | 77 | /* increase this every time the api struct changes */ |
78 | #define CODEC_API_VERSION 41 | 78 | #define CODEC_API_VERSION 42 |
79 | 79 | ||
80 | /* update this to latest version if a change to the api struct breaks | 80 | /* update this to latest version if a change to the api struct breaks |
81 | backwards compatibility (and please take the opportunity to sort in any | 81 | backwards compatibility (and please take the opportunity to sort in any |
82 | new function which are "waiting" at the end of the function table) */ | 82 | new function which are "waiting" at the end of the function table) */ |
83 | #define CODEC_MIN_API_VERSION 41 | 83 | #define CODEC_MIN_API_VERSION 42 |
84 | |||
85 | /* reasons for calling codec main entrypoint */ | ||
86 | enum codec_entry_call_reason { | ||
87 | CODEC_LOAD = 0, | ||
88 | CODEC_UNLOAD | ||
89 | }; | ||
84 | 90 | ||
85 | /* codec return codes */ | 91 | /* codec return codes */ |
86 | enum codec_status { | 92 | enum codec_status { |
@@ -88,6 +94,13 @@ enum codec_status { | |||
88 | CODEC_ERROR = -1, | 94 | CODEC_ERROR = -1, |
89 | }; | 95 | }; |
90 | 96 | ||
97 | /* codec command action codes */ | ||
98 | enum codec_command_action { | ||
99 | CODEC_ACTION_HALT = -1, | ||
100 | CODEC_ACTION_NULL = 0, | ||
101 | CODEC_ACTION_SEEK_TIME = 1, | ||
102 | }; | ||
103 | |||
91 | /* NOTE: To support backwards compatibility, only add new functions at | 104 | /* NOTE: To support backwards compatibility, only add new functions at |
92 | the end of the structure. Every time you add a new function, | 105 | the end of the structure. Every time you add a new function, |
93 | remember to increase CODEC_API_VERSION. If you make changes to the | 106 | remember to increase CODEC_API_VERSION. If you make changes to the |
@@ -95,24 +108,12 @@ enum codec_status { | |||
95 | version | 108 | version |
96 | */ | 109 | */ |
97 | struct codec_api { | 110 | struct codec_api { |
98 | |||
99 | off_t filesize; /* Total file length */ | 111 | off_t filesize; /* Total file length */ |
100 | off_t curpos; /* Current buffer position */ | 112 | off_t curpos; /* Current buffer position */ |
101 | 113 | ||
102 | /* For gapless mp3 */ | ||
103 | struct mp3entry *id3; /* TAG metadata pointer */ | 114 | struct mp3entry *id3; /* TAG metadata pointer */ |
104 | bool *taginfo_ready; /* Is metadata read */ | 115 | int audio_hid; /* Current audio handle */ |
105 | 116 | ||
106 | /* Codec should periodically check if stop_codec is set to true. | ||
107 | In case it is, codec must return immediately */ | ||
108 | volatile bool stop_codec; | ||
109 | /* Codec should periodically check if new_track is non zero. | ||
110 | When it is, the codec should request a new track. */ | ||
111 | volatile int new_track; | ||
112 | /* If seek_time != 0, codec should seek to that song position (in ms) | ||
113 | if codec supports seeking. */ | ||
114 | volatile long seek_time; | ||
115 | |||
116 | /* The dsp instance to be used for audio output */ | 117 | /* The dsp instance to be used for audio output */ |
117 | struct dsp_config *dsp; | 118 | struct dsp_config *dsp; |
118 | 119 | ||
@@ -138,14 +139,12 @@ struct codec_api { | |||
138 | bool (*seek_buffer)(size_t newpos); | 139 | bool (*seek_buffer)(size_t newpos); |
139 | /* Codec should call this function when it has done the seeking. */ | 140 | /* Codec should call this function when it has done the seeking. */ |
140 | void (*seek_complete)(void); | 141 | void (*seek_complete)(void); |
141 | /* Request file change from file buffer. Returns true is next | 142 | /* Update the current position */ |
142 | track is available and changed. If return value is false, | ||
143 | codec should exit immediately with PLUGIN_OK status. */ | ||
144 | bool (*request_next_track)(void); | ||
145 | |||
146 | void (*set_offset)(size_t value); | 143 | void (*set_offset)(size_t value); |
147 | /* Configure different codec buffer parameters. */ | 144 | /* Configure different codec buffer parameters. */ |
148 | void (*configure)(int setting, intptr_t value); | 145 | void (*configure)(int setting, intptr_t value); |
146 | /* Obtain command action on what to do next */ | ||
147 | enum codec_command_action (*get_command)(intptr_t *param); | ||
149 | 148 | ||
150 | /* kernel/ system */ | 149 | /* kernel/ system */ |
151 | #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE | 150 | #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE |
@@ -231,7 +230,8 @@ struct codec_api { | |||
231 | /* codec header */ | 230 | /* codec header */ |
232 | struct codec_header { | 231 | struct codec_header { |
233 | struct lc_header lc_hdr; /* must be first */ | 232 | struct lc_header lc_hdr; /* must be first */ |
234 | enum codec_status(*entry_point)(void); | 233 | enum codec_status(*entry_point)(enum codec_entry_call_reason reason); |
234 | enum codec_status(*run_proc)(void); | ||
235 | struct codec_api **api; | 235 | struct codec_api **api; |
236 | }; | 236 | }; |
237 | 237 | ||
@@ -248,13 +248,15 @@ extern unsigned char plugin_end_addr[]; | |||
248 | const struct codec_header __header \ | 248 | const struct codec_header __header \ |
249 | __attribute__ ((section (".header")))= { \ | 249 | __attribute__ ((section (".header")))= { \ |
250 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | 250 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
251 | plugin_start_addr, plugin_end_addr }, codec_start, &ci }; | 251 | plugin_start_addr, plugin_end_addr }, codec_start, \ |
252 | codec_run, &ci }; | ||
252 | /* encoders */ | 253 | /* encoders */ |
253 | #define CODEC_ENC_HEADER \ | 254 | #define CODEC_ENC_HEADER \ |
254 | const struct codec_header __header \ | 255 | const struct codec_header __header \ |
255 | __attribute__ ((section (".header")))= { \ | 256 | __attribute__ ((section (".header")))= { \ |
256 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | 257 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
257 | plugin_start_addr, plugin_end_addr }, codec_start, &ci }; | 258 | plugin_start_addr, plugin_end_addr }, codec_start, \ |
259 | codec_run, &ci }; | ||
258 | 260 | ||
259 | #else /* def SIMULATOR */ | 261 | #else /* def SIMULATOR */ |
260 | /* decoders */ | 262 | /* decoders */ |
@@ -262,12 +264,12 @@ extern unsigned char plugin_end_addr[]; | |||
262 | const struct codec_header __header \ | 264 | const struct codec_header __header \ |
263 | __attribute__((visibility("default"))) = { \ | 265 | __attribute__((visibility("default"))) = { \ |
264 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ | 266 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ |
265 | codec_start, &ci }; | 267 | codec_start, codec_run, &ci }; |
266 | /* encoders */ | 268 | /* encoders */ |
267 | #define CODEC_ENC_HEADER \ | 269 | #define CODEC_ENC_HEADER \ |
268 | const struct codec_header __header = { \ | 270 | const struct codec_header __header = { \ |
269 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ | 271 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ |
270 | codec_start, &ci }; | 272 | codec_start, codec_run, &ci }; |
271 | #endif /* SIMULATOR */ | 273 | #endif /* SIMULATOR */ |
272 | #endif /* CODEC */ | 274 | #endif /* CODEC */ |
273 | 275 | ||
@@ -276,13 +278,14 @@ extern unsigned char plugin_end_addr[]; | |||
276 | void codec_get_full_path(char *path, const char *codec_root_fn); | 278 | void codec_get_full_path(char *path, const char *codec_root_fn); |
277 | 279 | ||
278 | /* defined by the codec loader (codec.c) */ | 280 | /* defined by the codec loader (codec.c) */ |
279 | void * codec_load_buf(int hid, struct codec_api *api); | 281 | int codec_load_buf(int hid, struct codec_api *api); |
280 | void * codec_load_file(const char* codec, struct codec_api *api); | 282 | int codec_load_file(const char* codec, struct codec_api *api); |
281 | int codec_begin(void *handle); | 283 | int codec_run_proc(void); |
282 | void codec_close(void *handle); | 284 | int codec_halt(void); |
285 | int codec_close(void); | ||
283 | 286 | ||
284 | /* defined by the codec */ | 287 | /* defined by the codec */ |
285 | enum codec_status codec_start(void); | 288 | enum codec_status codec_start(enum codec_entry_call_reason reason); |
286 | enum codec_status codec_main(void); | 289 | enum codec_status codec_run(void); |
287 | 290 | ||
288 | #endif | 291 | #endif /* _CODECS_H_ */ |