diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-14 12:19:48 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-21 16:23:54 -0400 |
commit | d40a598970b04bfe3a867a5e12debc45c149b46b (patch) | |
tree | 26e974f910f7d3047adfbc536d8e10c2d973b7e9 /lib/rbcodec | |
parent | 2fb2364686e5470437f0ee3d214662d51067eb90 (diff) | |
download | rockbox-d40a598970b04bfe3a867a5e12debc45c149b46b.tar.gz rockbox-d40a598970b04bfe3a867a5e12debc45c149b46b.zip |
plugins: Simplify plugin/codec API versioning
Replace the minimum version bound with a check on the size of
the API struct. The version only needs to be incremented for
ABI breaking changes. Additions to the API won't need to touch
the version number, resulting in fewer merge conflicts.
Change-Id: I916a04a7bf5890dcf5d615ce30087643165f8e1f
Diffstat (limited to 'lib/rbcodec')
-rw-r--r-- | lib/rbcodec/codecs/codecs.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/rbcodec/codecs/codecs.h b/lib/rbcodec/codecs/codecs.h index fd19dcb6b5..aa9d2e8a0d 100644 --- a/lib/rbcodec/codecs/codecs.h +++ b/lib/rbcodec/codecs/codecs.h | |||
@@ -71,13 +71,12 @@ | |||
71 | /* magic for encoder codecs */ | 71 | /* magic for encoder codecs */ |
72 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ | 72 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ |
73 | 73 | ||
74 | /* increase this every time the api struct changes */ | 74 | /* |
75 | #define CODEC_API_VERSION 49 | 75 | * Increment this whenever a change breaks the codec ABI, |
76 | 76 | * when this happens please take the opportunity to sort in | |
77 | /* update this to latest version if a change to the api struct breaks | 77 | * any new functions "waiting" at the end of the list. |
78 | backwards compatibility (and please take the opportunity to sort in any | 78 | */ |
79 | new function which are "waiting" at the end of the function table) */ | 79 | #define CODEC_API_VERSION 50 |
80 | #define CODEC_MIN_API_VERSION 49 | ||
81 | 80 | ||
82 | /* reasons for calling codec main entrypoint */ | 81 | /* reasons for calling codec main entrypoint */ |
83 | enum codec_entry_call_reason { | 82 | enum codec_entry_call_reason { |
@@ -228,6 +227,7 @@ struct codec_header { | |||
228 | enum codec_status(*entry_point)(enum codec_entry_call_reason reason); | 227 | enum codec_status(*entry_point)(enum codec_entry_call_reason reason); |
229 | enum codec_status(*run_proc)(void); | 228 | enum codec_status(*run_proc)(void); |
230 | struct codec_api **api; | 229 | struct codec_api **api; |
230 | size_t api_size; | ||
231 | void * rec_extension[]; /* extension for encoders */ | 231 | void * rec_extension[]; /* extension for encoders */ |
232 | }; | 232 | }; |
233 | 233 | ||
@@ -241,15 +241,16 @@ extern unsigned char plugin_end_addr[]; | |||
241 | const struct codec_header __header \ | 241 | const struct codec_header __header \ |
242 | __attribute__ ((section (".header")))= { \ | 242 | __attribute__ ((section (".header")))= { \ |
243 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | 243 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
244 | plugin_start_addr, plugin_end_addr }, codec_start, \ | 244 | plugin_start_addr, plugin_end_addr }, \ |
245 | codec_run, &ci }; | 245 | codec_start, codec_run, &ci, sizeof(struct codec_api) }; |
246 | /* encoders */ | 246 | /* encoders */ |
247 | #define CODEC_ENC_HEADER \ | 247 | #define CODEC_ENC_HEADER \ |
248 | const struct codec_header __header \ | 248 | const struct codec_header __header \ |
249 | __attribute__ ((section (".header")))= { \ | 249 | __attribute__ ((section (".header")))= { \ |
250 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ | 250 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ |
251 | plugin_start_addr, plugin_end_addr }, codec_start, \ | 251 | plugin_start_addr, plugin_end_addr }, \ |
252 | codec_run, &ci, { enc_callback } }; | 252 | codec_start, codec_run, &ci, sizeof(struct codec_api), \ |
253 | { enc_callback } }; | ||
253 | 254 | ||
254 | #else /* def SIMULATOR */ | 255 | #else /* def SIMULATOR */ |
255 | /* decoders */ | 256 | /* decoders */ |
@@ -257,13 +258,14 @@ extern unsigned char plugin_end_addr[]; | |||
257 | const struct codec_header __header \ | 258 | const struct codec_header __header \ |
258 | __attribute__((visibility("default"))) = { \ | 259 | __attribute__((visibility("default"))) = { \ |
259 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ | 260 | { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ |
260 | codec_start, codec_run, &ci }; | 261 | codec_start, codec_run, &ci, sizeof(struct codec_api) }; |
261 | /* encoders */ | 262 | /* encoders */ |
262 | #define CODEC_ENC_HEADER \ | 263 | #define CODEC_ENC_HEADER \ |
263 | const struct codec_header __header \ | 264 | const struct codec_header __header \ |
264 | __attribute__((visibility("default"))) = { \ | 265 | __attribute__((visibility("default"))) = { \ |
265 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ | 266 | { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ |
266 | codec_start, codec_run, &ci, { enc_callback } }; | 267 | codec_start, codec_run, &ci, sizeof(struct codec_api), \ |
268 | { enc_callback } }; | ||
267 | #endif /* SIMULATOR */ | 269 | #endif /* SIMULATOR */ |
268 | #endif /* CODEC */ | 270 | #endif /* CODEC */ |
269 | 271 | ||