bring along changes from Cehteh and Velmont

Merge commit 'pipapo/master'
This commit is contained in:
Fischlurch 2007-11-26 23:28:25 +01:00
commit 4593c0c6ff
18 changed files with 198 additions and 93 deletions

View file

@ -21,6 +21,15 @@
#include "lib/condition.h"
/**
* @file Condition variables
*/
/**
* Initialize a condition variable
* @param self is a pointer to the condition variable to be initialized
* @return self as given
*/
CinelerraCondition
cinelerra_condition_init (CinelerraCondition self)
{
@ -32,6 +41,12 @@ cinelerra_condition_init (CinelerraCondition self)
return self;
}
/**
* Destroy a condition variable
* @param self is a pointer to the condition variable to be destroyed
* @return self as given
*/
CinelerraCondition
cinelerra_condition_destroy (CinelerraCondition self)
{

View file

@ -24,6 +24,10 @@
#include "lib/locking.h"
/**
* @file Condition variables, header
*/
/**
* Condition variables.
@ -38,20 +42,10 @@ typedef struct cinelerra_condition_struct cinelerra_condition;
typedef cinelerra_condition* CinelerraCondition;
/**
* Initialize a condition variable
* @param self is a pointer to the condition variable to be initialized
* @return self as given
*/
CinelerraCondition
cinelerra_condition_init (CinelerraCondition self);
/**
* Destroy a condition variable
* @param self is a pointer to the condition variable to be destroyed
* @return self as given
*/
CinelerraCondition
cinelerra_condition_destroy (CinelerraCondition self);

View file

@ -23,6 +23,11 @@
#include "lib/error.h"
/**
* @file C Error handling in Cinelerra.
*/
/*
predefined errors
*/
@ -39,6 +44,13 @@ cinelerra_error_tls_init (void)
pthread_key_create (&cinelerra_error_tls, NULL);
}
/**
* Set error state for the current thread.
* If the error state of the current thread was cleared, then set it, else preserve the old state.
* @param nerr name of the error with 'CINELERRA_ERROR_' prefix (example: CINELERRA_ERROR_NO_MEMORY)
* @return old state, that is NULL for success, when the state was cleared and a pointer to a pending
* error when the error state was already set
*/
const char*
cinelerra_error_set (const char * nerr)
{
@ -52,6 +64,12 @@ cinelerra_error_set (const char * nerr)
}
/**
* Get and clear current error state.
* This function clears the error state, if it needs to be reused, one has to store it in a temporary
* variable.
* @return pointer to any pending error of this thread, NULL if no error is pending
*/
const char*
cinelerra_error ()
{

View file

@ -31,7 +31,7 @@ extern "C" {
#include <stdlib.h>
/**
* C Error handling in Cinelerra.
* @file C Error handling in Cinelerra, header.
*/
@ -67,20 +67,9 @@ const char* CINELERRA_ERROR_##err = "CINELERRA_ERROR_" #err ":" msg
(({ERROR (flag, "%s", strchr(CINELERRA_ERROR_##err, ':')+1);}), \
cinelerra_error_set(CINELERRA_ERROR_##err))
/**
* Set error state for the current thread.
* If the error state of the current thread was cleared, then set it, else preserve the old state.
* @param err name of the error with 'CINELERRA_ERROR_' prefix (example: CINELERRA_ERROR_NO_MEMORY)
* @return old state, that is NULL for success, when the state was cleared and a pointer to a pending error when the error state was already set
*/
const char*
cinelerra_error_set (const char * err);
/**
* Get and clear current error state.
* This function clears the error state, if it needs to be reused, one has to store it in a temporary variable.
* @return pointer to any pending error of this thread, NULL if no error is pending
*/
const char*
cinelerra_error ();

View file

@ -21,5 +21,10 @@
#include "lib/error.h"
/**
* @file Framerate calculations.
*/
CINELERRA_ERROR_DEFINE(FRAMERATE_ILLEGAL_TIME, "invalid time given");
CINELERRA_ERROR_DEFINE(FRAMERATE_ILLEGAL_FRAME, "invalid frame given");

View file

@ -27,6 +27,11 @@
#include "lib/error.h"
#include "lib/time.h"
/**
* @file Framerate calculations, header.
*/
/**
* framerates are defined as a rational number
* for example NTSC with 30000/1001fps

View file

@ -115,7 +115,6 @@ typedef llist ** LList_ref;
* @param node pointer to the iterated node
*/
#define LLIST_FOREACH(list, node) \
if (!list); else \
for (LList node = llist_head (list); \
! llist_is_end (node, list); \
llist_forward (&node))
@ -126,7 +125,6 @@ typedef llist ** LList_ref;
* @param node pointer to the iterated node
*/
#define LLIST_FOREACH_REV(list, node) \
if (!list); else \
for (LList node = llist_tail (list); \
! llist_is_end (node, list); \
llist_backward (&node))
@ -138,7 +136,6 @@ typedef llist ** LList_ref;
* @param head pointer to the head node
*/
#define LLIST_WHILE_HEAD(list, head) \
if (!list); else \
for (LList head = llist_head (list); \
!llist_is_empty (list); \
head = llist_head (list))
@ -150,7 +147,6 @@ typedef llist ** LList_ref;
* @param tail pointer to the tail node
*/
#define LLIST_WHILE_TAIL(list, tail) \
if (!list); else \
for (LList tail = llist_tail (list); \
!llist_is_empty (list); \
tail = llist_tail (list))

View file

@ -28,6 +28,10 @@
#include "lib/error.h"
/**
* @file Shared declarations for all locking primitives.
*/
/**
* used to store the current lock state.
*

View file

@ -21,6 +21,16 @@
#include "lib/mutex.h"
/**
* @file Mutual exclusion locking.
*/
/**
* Initialize a mutex variable
* @param self is a pointer to the mutex to be initialized
* @return self as given
*/
CinelerraMutex
cinelerra_mutex_init (CinelerraMutex self)
{
@ -31,6 +41,11 @@ cinelerra_mutex_init (CinelerraMutex self)
return self;
}
/**
* Destroy a mutex variable
* @param self is a pointer to the mutex to be destroyed
* @return self as given
*/
CinelerraMutex
cinelerra_mutex_destroy (CinelerraMutex self)
{

View file

@ -24,6 +24,11 @@
#include "lib/locking.h"
/**
* @file Mutual exclusion locking, header.
*/
/**
* Mutex.
*
@ -36,20 +41,10 @@ typedef struct cinelerra_mutex_struct cinelerra_mutex;
typedef cinelerra_mutex* CinelerraMutex;
/**
* Initialize a mutex variable
* @param self is a pointer to the mutex to be initialized
* @return self as given
*/
CinelerraMutex
cinelerra_mutex_init (CinelerraMutex self);
/**
* Destroy a mutex variable
* @param self is a pointer to the mutex to be destroyed
* @return self as given
*/
CinelerraMutex
cinelerra_mutex_destroy (CinelerraMutex self);

View file

@ -28,6 +28,11 @@
#include "plugin.h"
/**
* @file Plugin loader.
*/
/* TODO should be set by the build system to the actual plugin path */
#define CINELERRA_PLUGIN_PATH "~/.cinelerra3/plugins:/usr/local/lib/cinelerra3/plugins:.libs"
@ -93,19 +98,34 @@ void* cinelerra_plugin_registry = NULL;
/* plugin operations are protected by one big mutex */
pthread_mutex_t cinelerra_plugin_mutex = PTHREAD_MUTEX_INITIALIZER;
/* the compare function for the registry tree */
/**
* the compare function for the registry tree.
* Compares the names of two struct cinelerra_plugin.
* @return 0 if a and b are equal, just like strcmp. */
static int
cinelerra_plugin_name_cmp (const void* a, const void* b)
{
return strcmp (((struct cinelerra_plugin*) a)->name, ((struct cinelerra_plugin*) b)->name);
}
/**
* Initialize the plugin system.
* always succeeds or aborts
*/
void
cinelerra_init_plugin (void)
{
NOBUG_INIT_FLAG (cinelerra_plugin);
}
/**
* Find and set pathname for the plugin.
* Searches through given path for given plugin, trying to find the file's location in the filesystem.
* If found, self->pathname will be set to the found plugin file.
* @param self The cinelerra_plugin to open look for.
* @param path The path to search trough (paths seperated by ":")
* @return 0 on success. -1 on error, or if plugin not found in path.
*/
int
cinelerra_plugin_lookup (struct cinelerra_plugin* self, const char* path)
{
@ -149,6 +169,18 @@ cinelerra_plugin_lookup (struct cinelerra_plugin* self, const char* path)
return -1; /* plugin not found */
}
/**
* Make an interface available.
* To use an interface provided by a plugin it must be opened first. It is allowed to open an interface
* more than once. Each open must be paired with a close.
* @param name name of the plugin to use.
* @param interface name of the interface to open.
* @param min_revision the size of the interface structure is used as measure of a minimal required
* revision (new functions are appended at the end)
* @return handle to the interface or NULL in case of a error. The application shall cast this handle to
* the actual interface type.
*/
struct cinelerra_interface*
cinelerra_interface_open (const char* name, const char* interface, size_t min_revision)
{
@ -277,6 +309,11 @@ cinelerra_interface_open (const char* name, const char* interface, size_t min_re
return NULL;
}
/**
* Close an interface. Does not free associated resources
* Calling this function with self==NULL is legal. Every interface handle must be closed only once.
* @param ptr interface to be closed
*/
void
cinelerra_interface_close (void* ptr)
{

View file

@ -32,6 +32,11 @@ extern "C" {
#include "error.h"
/**
* @file Plugin loader, header.
*/
NOBUG_DECLARE_FLAG (cinelerra_plugin);
/* tool macros*/
@ -90,32 +95,14 @@ struct cinelerra_interface
int (*close)(void);
};
/**
* Initialize the plugin system.
* always succeeds or aborts
*/
void
cinelerra_init_plugin (void);
/**
* Make an interface available.
* To use an interface provided by a plugin it must be opened first. It is allowed to open an interface more than once.
* Each open must be paired with a close.
* @param plugin name of the plugin to use.
* @param name name of the interface to open.
* @param min_revision the size of the interface structure is used as measure of a minimal required revision (new functions are appended at the end)
* @return handle to the interface or NULL in case of a error. The application shall cast this handle to the actual interface type.
*/
struct cinelerra_interface*
cinelerra_interface_open (const char* plugin, const char* name, size_t min_revision);
/**
* Close an interface. Does not free associated resources
* Calling this function with self==NULL is legal. Every interface handle must be closed only once.
* @param self interface to be closed
*/
void
cinelerra_interface_close (void* self);

View file

@ -24,6 +24,11 @@
#include <nobug.h>
/**
* @file Strong and Weak references, header.
*/
typedef struct cinelerra_reference_struct cinelerra_reference;
typedef cinelerra_reference* CinelerraReference;

View file

@ -26,7 +26,16 @@
CINELERRA_ERROR_DEFINE(RWLOCK_AGAIN, "maximum number of readlocks exceed");
CINELERRA_ERROR_DEFINE(RWLOCK_DEADLOCK, "deadlock detected");
/**
* @file Read/write locks.
*/
/**
* Initialize a rwlock
* @param self is a pointer to the rwlock to be initialized
* @return self as given
*/
CinelerraRWLock
cinelerra_rwlock_init (CinelerraRWLock self)
{
@ -37,6 +46,11 @@ cinelerra_rwlock_init (CinelerraRWLock self)
return self;
}
/**
* destroy a rwlock
* @param self is a pointer to the rwlock to be initialized
* @return self on success or NULL at error
*/
CinelerraRWLock
cinelerra_rwlock_destroy (CinelerraRWLock self)
{
@ -51,6 +65,13 @@ cinelerra_rwlock_destroy (CinelerraRWLock self)
/**
* initialize a rwlockacquirer state
* @param self rwlockacquirer to be initialized, must be an automatic variable
* @param rwlock associated rwlock
* @param state initial state of the mutex, either CINELERRA_RDLOCKED, CINELERRA_WRLOCKED or CINELERRA_UNLOCKED
* @return self as given or NULL on error
*/
CinelerraRWLockacquirer
cinelerra_rwlockacquirer_init (CinelerraRWLockacquirer self, CinelerraRWLock rwlock, enum cinelerra_lockstate state)
{
@ -94,6 +115,12 @@ cinelerra_rwlockacquirer_init (CinelerraRWLockacquirer self, CinelerraRWLock rwl
}
/**
* readlock the rwlock.
* must not already be locked
* @param self rwlockacquirer associated with a rwlock
* @return self as given or NULL on error
*/
CinelerraRWLockacquirer
cinelerra_rwlockacquirer_rdlock (CinelerraRWLockacquirer self)
{
@ -119,6 +146,12 @@ cinelerra_rwlockacquirer_rdlock (CinelerraRWLockacquirer self)
}
/**
* writelock the rwlock.
* must not already be locked
* @param self rwlockacquirer associated with a rwlock
* @return self as given or NULL on error
*/
CinelerraRWLockacquirer
cinelerra_rwlockacquirer_wrlock (CinelerraRWLockacquirer self)
{

View file

@ -34,6 +34,10 @@
CINELERRA_ERROR_DECLARE(RWLOCK_AGAIN);
CINELERRA_ERROR_DECLARE(RWLOCK_DEADLOCK);
/**
* @file Read/write locks, header.
*/
/**
* RWLock.
@ -47,20 +51,10 @@ typedef struct cinelerra_rwlock_struct cinelerra_rwlock;
typedef cinelerra_rwlock* CinelerraRWLock;
/**
* Initialize a rwlock
* @param self is a pointer to the rwlock to be initialized
* @return self as given
*/
CinelerraRWLock
cinelerra_rwlock_init (CinelerraRWLock self);
/**
* destroy a rwlock
* @param self is a pointer to the rwlock to be initialized
* @return self on success or NULL at error
*/
CinelerraRWLock
cinelerra_rwlock_destroy (CinelerraRWLock self);
@ -90,32 +84,13 @@ cinelerra_rwlockacquirer_ensureunlocked (CinelerraRWLockacquirer self)
cinelerra_rwlockacquirer NOBUG_CLEANUP(cinelerra_rwlockacquirer_ensureunlocked)
/**
* initialize a rwlockacquirer state
* @param self rwlockacquirer to be initialized, must be an automatic variable
* @param cond associated rwlock
* @param state initial state of the mutex, either CINELERRA_RDLOCKED, CINELERRA_WRLOCKED or CINELERRA_UNLOCKED
* @return self as given or NULL on error
*/
CinelerraRWLockacquirer
cinelerra_rwlockacquirer_init (CinelerraRWLockacquirer self, CinelerraRWLock rwlock, enum cinelerra_lockstate state);
/**
* readlock the rwlock.
* must not already be locked
* @param self rwlockacquirer associated with a rwlock
* @return self as given or NULL on error
*/
CinelerraRWLockacquirer
cinelerra_rwlockacquirer_rdlock (CinelerraRWLockacquirer self);
/**
* writelock the rwlock.
* must not already be locked
* @param self rwlockacquirer associated with a rwlock
* @return self as given or NULL on error
*/
CinelerraRWLockacquirer
cinelerra_rwlockacquirer_wrlock (CinelerraRWLockacquirer self);

View file

@ -29,10 +29,15 @@
#include "lib/error.h"
/*
* @file Time calculations.
this time functions are small macro like wrapers, they are all inlined for performance reasons
time is passed around as pointers, this pointer must never be NULL
time is passed around as pointers, this pointer must never be NULL.
timehandling is a delicate business, be careful of precision errors accumulating, TODO explain how to use time
timehandling is a delicate business, be careful of precision errors accumulating
cinelerra_time is starting from zero, never becomes negative.
TODO explain how to use time
*/
@ -67,6 +72,8 @@ cinelerra_time_normalize (CinelerraTime time)
/**
* set a time value to zero.
* @param time Time to clear
* @return time as given
*/
static inline CinelerraTime
cinelerra_time_clear (CinelerraTime time)
@ -81,6 +88,8 @@ cinelerra_time_clear (CinelerraTime time)
/**
* get current time.
* @param time Time to put current time into.
* @return time as given
*/
static inline CinelerraTime
cinelerra_time_current (CinelerraTime time)
@ -96,6 +105,10 @@ cinelerra_time_current (CinelerraTime time)
/**
* init from floating point representation.
* @param time The time to be set
* @param fp Time in double
* @return time as given upon success, NULL if double time given was negative or given time didn't point
* anywhere
*/
static inline CinelerraTime
cinelerra_time_set_double (CinelerraTime time, double fp)
@ -120,6 +133,10 @@ cinelerra_time_set_double (CinelerraTime time, double fp)
/**
* initialize with seconds and microseconds.
* @param time Time to set
* @param sec Seconds to set
* @param usec Microseconds to set
* @param Time as given
*/
static inline CinelerraTime
cinelerra_time_init (CinelerraTime time, time_t sec, suseconds_t usec)
@ -135,6 +152,8 @@ cinelerra_time_init (CinelerraTime time, time_t sec, suseconds_t usec)
/**
* get the seconds part from a time.
* @param time Time to get seconds from
* @return Seconds elapsed, -1 on error
*/
static inline time_t
cinelerra_time_sec (CinelerraTime time)
@ -147,6 +166,8 @@ cinelerra_time_sec (CinelerraTime time)
/**
* get the microseconds part of a time.
* @param time Time to get microseconds from
* @return Microseconds elapsed, -1 on error
*/
static inline suseconds_t
cinelerra_time_usec (CinelerraTime time)
@ -159,6 +180,8 @@ cinelerra_time_usec (CinelerraTime time)
/**
* convert to floating point repesentation.
* @param time Time to get floating point representation from
* @return Floating point representation of time. NAN on error.
*/
static inline double
cinelerra_time_double_get (CinelerraTime time)
@ -177,6 +200,9 @@ cinelerra_time_double_get (CinelerraTime time)
/**
* copy time
* @param dest Time-pointer to copy to
* @param src Time-source to copy from
* @return dest as given
*/
static inline CinelerraTime
cinelerra_time_copy (CinelerraTime dest, const CinelerraTime src)
@ -191,6 +217,9 @@ cinelerra_time_copy (CinelerraTime dest, const CinelerraTime src)
/**
* add time.
* @param dest The result of the add
* @param src Time to add to dest
* @return dest as given, or NULL on overflow.
*/
static inline CinelerraTime
cinelerra_time_add (CinelerraTime dest, const CinelerraTime src)
@ -215,6 +244,9 @@ cinelerra_time_add (CinelerraTime dest, const CinelerraTime src)
/**
* substact time.
* @param dest The result of subtract
* @param src Time to subtract from dest
* @return dest as given, or NULL on underflow.
*/
static inline CinelerraTime
cinelerra_time_sub (CinelerraTime dest, const CinelerraTime src)

View file

@ -21,12 +21,12 @@ tests_srcdir = $(top_srcdir)/tests
check_PROGRAMS += test-error
test_error_SOURCES = $(tests_srcdir)/error/errortest.c
test_error_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
test_error_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl
test_error_LDADD = libcin3.a -lnobugmt -lpthread -ldl
check_PROGRAMS += test-time
test_time_SOURCES = $(tests_srcdir)/time/test-time.c
test_time_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
test_time_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl -lm
test_time_LDADD = libcin3.a -lnobugmt -lpthread -ldl -lm
check_PROGRAMS += test-locking
test_locking_SOURCES = \
@ -34,21 +34,21 @@ test_locking_SOURCES = \
$(tests_srcdir)/locking/mutex.c \
$(tests_srcdir)/locking/condition.c
test_locking_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
test_locking_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl -lm
test_locking_LDADD = libcin3.a -lnobugmt -lpthread -ldl -lm
check_PROGRAMS += test-llist
test_llist_SOURCES = $(tests_srcdir)/library/test-llist.c
test_llist_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
test_llist_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl -lm
test_llist_LDADD = libcin3.a -lnobugmt -lpthread -ldl -lm
check_PROGRAMS += test-references
test_references_SOURCES = $(tests_srcdir)/library/test-references.c
test_references_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
test_references_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl -lm -lrt
test_references_LDADD = libcin3.a -lnobugmt -lpthread -ldl -lm -lrt
#check_PROGRAMS += test-filehandles
#test_filehandles_SOURCES = $(tests_srcdir)/backend/test-filehandles.c
#test_filehandles_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
#test_filehandles_LDADD = $(builddir)/libcin3backend.a $(builddir)/libcin3.a -lnobugmt -lpthread -ldl -lm
#test_filehandles_LDADD = libcin3backend.a libcin3.a -lnobugmt -lpthread -ldl -lm
TESTS = $(tests_srcdir)/test.sh

View file

@ -20,7 +20,7 @@ noinst_PROGRAMS += test-plugin
test_plugin_CFLAGS = $(AM_CFLAGS) -std=gnu99 -Wall -Werror
test_plugin_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src
test_plugin_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl
test_plugin_LDADD = libcin3.a -lnobugmt -lpthread -ldl
test_plugin_SOURCES = $(examples_srcdir)/plugin_main.c
noinst_HEADERS += $(examples_srcdir)/hello_interface.h