diff --git a/Makefile.am b/Makefile.am index 72d0dcb43..fbaecd794 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,10 +25,18 @@ BUILT_SOURCES = EXTRA_DIST = SUBDIRS = +# Only use subdirs if really needed, prefer the include scheme below #SUBDIRS += +# core include $(top_srcdir)/src/lib/Makefile.am +# plugins +#include $(top_srcdir)/src... + +# tests +include $(top_srcdir)/tests/examples/Makefile.am + #EXTRA_DIST += admin debian doc depcomp README.BUILD LICENSE \ # cinelerra-cvs-current.spec AUTOMAKE_OPTIONS=foreign diff --git a/src/lib/plugin.c b/src/lib/plugin.c index 92149ad51..ec7b3f0a6 100644 --- a/src/lib/plugin.c +++ b/src/lib/plugin.c @@ -44,7 +44,7 @@ NOBUG_DEFINE_FLAG (cinelerra_plugin); /* errors */ const char* CINELERRA_PLUGIN_SUCCESS = NULL; const char* CINELERRA_PLUGIN_EDLOPEN = "Could not open plugin"; -const char* CINELERRA_PLUGIN_EDHOOK = "Hook function failed"; +const char* CINELERRA_PLUGIN_EHOOK = "Hook function failed"; const char* CINELERRA_PLUGIN_ENFOUND = "No such plugin"; const char* CINELERRA_PLUGIN_ENIFACE = "No such interface"; const char* CINELERRA_PLUGIN_EREVISION = "Interface revision too old"; @@ -304,11 +304,13 @@ cinelerra_interface_open (const char* name, const char* interface, size_t min_re } void -cinelerra_interface_close (struct cinelerra_interface* self) +cinelerra_interface_close (void* ptr) { - if(!self) + if(!ptr) return; + struct cinelerra_interface* self = (struct cinelerra_interface*) ptr; + pthread_mutex_lock (&cinelerra_plugin_mutex); struct cinelerra_plugin* plugin = self->plugin; diff --git a/src/lib/plugin.h b/src/lib/plugin.h index 605da329c..74ab964b3 100644 --- a/src/lib/plugin.h +++ b/src/lib/plugin.h @@ -109,7 +109,7 @@ cinelerra_interface_open (const char* plugin, const char* name, size_t min_revis * @param self interface to be closed */ void -cinelerra_interface_close (struct cinelerra_interface* self); +cinelerra_interface_close (void* self); /** * Tries to unload a plugin. diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am new file mode 100644 index 000000000..c3ee8e033 --- /dev/null +++ b/tests/examples/Makefile.am @@ -0,0 +1,26 @@ +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# +# 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +examples_srcdir = $(top_srcdir)/tests/examples +noinst_PROGRAMS += plugin_example + +plugin_example_CFLAGS = $(CFLAGS) -std=gnu99 -Wall -Werror +plugin_example_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/ +plugin_example_LDADD = -lnobugmt -lpthread -ldl $(builddir)/libcin3.a + +plugin_example_SOURCES = $(examples_srcdir)/plugin_main.c +noinst_HEADERS += $(examples_srcdir)/hello_interface.h diff --git a/tests/examples/hello_interface.h b/tests/examples/hello_interface.h index 58483e6ff..183a22c54 100644 --- a/tests/examples/hello_interface.h +++ b/tests/examples/hello_interface.h @@ -1,6 +1,6 @@ #include "plugin.h" CINELERRA_INTERFACE(hello, 1, - CINELERRA_INTERFACE_PROTO(void, hello, (void)), - CINELERRA_INTERFACE_PROTO(void, goodbye, (const char*)), + CINELERRA_INTERFACE_PROTO(void, hello, (void)) + CINELERRA_INTERFACE_PROTO(void, goodbye, (const char*)) ); diff --git a/tests/examples/plugin_main.c b/tests/examples/plugin_main.c index 1902fc5fe..427f88655 100644 --- a/tests/examples/plugin_main.c +++ b/tests/examples/plugin_main.c @@ -12,20 +12,22 @@ main(int argc, char** argv) open both try them, close them. */ - struct hello_interface_1* hello_de = - cinelerra_interface_open ("hello_1", "german_1", sizeof(struct hello_interface_1)); - if (!hello_de) CINELERRA_DIE; + TODO("macros, doing casting and typing"); - hello_de->say_hello(); + CINELERRA_INTERFACE_TYPE(hello, 1)* hello_de = (CINELERRA_INTERFACE_TYPE(hello, 1)*) + cinelerra_interface_open ("hello_1", "german_1", sizeof(CINELERRA_INTERFACE_TYPE(hello, 1))); + TODO("new error handling, when finished if (!hello_de) CINELERRA_DIE"); + + hello_de->hello(); - struct hello_interface_1* hello_en = - cinelerra_interface_open ("hello_1", "english_1", sizeof(struct hello_interface_1)); - if (!hello_en) CINELERRA_DIE; + // struct hello_interface_1* hello_en = + // cinelerra_interface_open ("hello_1", "english_1", sizeof(struct hello_interface_1)); + // TODO if (!hello_en) CINELERRA_DIE; - hello_en->say_hello(); + //hello_en->hello(); - cinelerra_interface_close (hello_en); + //cinelerra_interface_close (hello_en); cinelerra_interface_close (hello_de); #if 0