2006-02-23 20:46:33 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Overlay loader
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Jens Arnold
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-02-23 20:46:33 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
2008-05-04 13:21:07 +00:00
|
|
|
#include "overlay.h"
|
2006-02-23 20:46:33 +00:00
|
|
|
|
|
|
|
/* load and run a plugin linked as an overlay.
|
|
|
|
|
|
|
|
arguments:
|
|
|
|
parameter = plugin parameter, passed on to the overlay
|
|
|
|
filename = overlay file name, absolute path as usual
|
|
|
|
name = overlay display name
|
|
|
|
|
|
|
|
result:
|
|
|
|
return value from the overlay
|
|
|
|
|
|
|
|
As long as a large plugin to be overlayed doesn't use the audiobuffer
|
|
|
|
itself, no adjustments in the plugin source code are necessary to make
|
|
|
|
it work as an overlay, it only needs an adapted linker script.
|
|
|
|
|
|
|
|
If the overlayed plugin *does* use the audiobuffer itself, it needs
|
|
|
|
to make sure not to overwrite itself.
|
|
|
|
|
|
|
|
The linker script for the overlay should use a base address towards the
|
|
|
|
end of the audiobuffer, just low enough to make the overlay fit. */
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status run_overlay(const void* parameter,
|
2006-02-23 20:46:33 +00:00
|
|
|
unsigned char *filename, unsigned char *name)
|
|
|
|
{
|
2010-05-07 19:27:42 +00:00
|
|
|
size_t audiobuf_size;
|
2006-02-23 20:46:33 +00:00
|
|
|
unsigned char *audiobuf;
|
2010-09-09 16:17:21 +00:00
|
|
|
void *handle;
|
|
|
|
struct plugin_header *p_hdr;
|
|
|
|
struct lc_header *hdr;
|
2006-02-23 20:46:33 +00:00
|
|
|
|
2010-09-09 16:17:21 +00:00
|
|
|
audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
|
|
|
|
if (!audiobuf)
|
2006-02-23 20:46:33 +00:00
|
|
|
{
|
2010-09-09 16:17:21 +00:00
|
|
|
rb->splash(2*HZ, "Can't optain memory");
|
|
|
|
goto error;
|
2006-02-23 20:46:33 +00:00
|
|
|
}
|
|
|
|
|
2010-09-09 16:17:21 +00:00
|
|
|
handle = rb->lc_open(filename, audiobuf, audiobuf_size);
|
|
|
|
if (!handle)
|
2006-02-23 20:46:33 +00:00
|
|
|
{
|
2010-09-09 16:17:21 +00:00
|
|
|
rb->splashf(2*HZ, "Can't open %s", filename);
|
|
|
|
goto error;
|
2006-02-23 20:46:33 +00:00
|
|
|
}
|
|
|
|
|
2010-09-09 16:17:21 +00:00
|
|
|
p_hdr = rb->lc_get_header(handle);
|
|
|
|
if (!p_hdr)
|
2006-02-23 20:46:33 +00:00
|
|
|
{
|
2010-09-09 16:17:21 +00:00
|
|
|
rb->splash(2*HZ, "Can't get header");
|
|
|
|
goto error_close;
|
2006-02-23 20:46:33 +00:00
|
|
|
}
|
2010-09-09 16:17:21 +00:00
|
|
|
else
|
|
|
|
hdr = &p_hdr->lc_hdr;
|
2006-02-23 20:46:33 +00:00
|
|
|
|
2010-09-09 16:17:21 +00:00
|
|
|
if (hdr->magic != PLUGIN_MAGIC || hdr->target_id != TARGET_ID)
|
2006-02-23 20:46:33 +00:00
|
|
|
{
|
2010-09-09 16:17:21 +00:00
|
|
|
rb->splashf(2*HZ, "%s overlay: Incompatible model.", name);
|
|
|
|
goto error_close;
|
2006-02-23 20:46:33 +00:00
|
|
|
}
|
|
|
|
|
2010-09-09 16:17:21 +00:00
|
|
|
|
|
|
|
if (hdr->api_version > PLUGIN_API_VERSION
|
|
|
|
|| hdr->api_version < PLUGIN_MIN_API_VERSION)
|
2006-02-23 20:46:33 +00:00
|
|
|
{
|
2010-09-09 16:17:21 +00:00
|
|
|
rb->splashf(2*HZ, "%s overlay: Incompatible version.", name);
|
|
|
|
goto error_close;
|
2006-02-23 20:46:33 +00:00
|
|
|
}
|
2006-04-06 18:26:14 +00:00
|
|
|
|
2010-09-09 16:17:21 +00:00
|
|
|
rb->lc_close(handle);
|
|
|
|
|
|
|
|
*(p_hdr->api) = rb;
|
|
|
|
return p_hdr->entry_point(parameter);
|
|
|
|
|
|
|
|
error_close:
|
|
|
|
rb->lc_close(handle);
|
|
|
|
error:
|
|
|
|
return PLUGIN_ERROR;
|
2006-02-23 20:46:33 +00:00
|
|
|
}
|