1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
12 * Copyright (C) 2006 Jens Arnold
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
27 /* load and run a plugin linked as an overlay.
30 parameter = plugin parameter, passed on to the overlay
31 filename = overlay file name, absolute path as usual
32 name = overlay display name
35 return value from the overlay
37 As long as a large plugin to be overlayed doesn't use the audiobuffer
38 itself, no adjustments in the plugin source code are necessary to make
39 it work as an overlay, it only needs an adapted linker script.
41 If the overlayed plugin *does* use the audiobuffer itself, it needs
42 to make sure not to overwrite itself.
44 The linker script for the overlay should use a base address towards the
45 end of the audiobuffer, just low enough to make the overlay fit. */
47 enum plugin_status
run_overlay(const void* parameter
,
48 unsigned char *filename
, unsigned char *name
)
51 unsigned char *audiobuf
;
53 struct plugin_header
*p_hdr
;
54 struct lc_header
*hdr
;
56 audiobuf
= rb
->plugin_get_audio_buffer(&audiobuf_size
);
59 rb
->splash(2*HZ
, "Can't optain memory");
63 handle
= rb
->lc_open(filename
, audiobuf
, audiobuf_size
);
66 rb
->splashf(2*HZ
, "Can't open %s", filename
);
70 p_hdr
= rb
->lc_get_header(handle
);
73 rb
->splash(2*HZ
, "Can't get header");
79 if (hdr
->magic
!= PLUGIN_MAGIC
|| hdr
->target_id
!= TARGET_ID
)
81 rb
->splashf(2*HZ
, "%s overlay: Incompatible model.", name
);
86 if (hdr
->api_version
> PLUGIN_API_VERSION
87 || hdr
->api_version
< PLUGIN_MIN_API_VERSION
)
89 rb
->splashf(2*HZ
, "%s overlay: Incompatible version.", name
);
96 return p_hdr
->entry_point(parameter
);