diff --git a/src/lib/condition.c b/src/lib/condition.c index 0d731f959..dfc79c7c5 100644 --- a/src/lib/condition.c +++ b/src/lib/condition.c @@ -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) { diff --git a/src/lib/condition.h b/src/lib/condition.h index a34ce45ff..7925fd993 100644 --- a/src/lib/condition.h +++ b/src/lib/condition.h @@ -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); diff --git a/src/lib/error.c b/src/lib/error.c index a5268a07f..d5ea88f01 100644 --- a/src/lib/error.c +++ b/src/lib/error.c @@ -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 () { diff --git a/src/lib/error.h b/src/lib/error.h index 071a3c914..2b5051652 100644 --- a/src/lib/error.h +++ b/src/lib/error.h @@ -31,7 +31,7 @@ extern "C" { #include /** - * 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 (); diff --git a/src/lib/framerate.c b/src/lib/framerate.c index 138a338a3..b70121a37 100644 --- a/src/lib/framerate.c +++ b/src/lib/framerate.c @@ -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"); diff --git a/src/lib/framerate.h b/src/lib/framerate.h index 2df5971fb..1e862ed0d 100644 --- a/src/lib/framerate.h +++ b/src/lib/framerate.h @@ -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 diff --git a/src/lib/locking.h b/src/lib/locking.h index fce854b0d..6e53fee97 100644 --- a/src/lib/locking.h +++ b/src/lib/locking.h @@ -28,6 +28,10 @@ #include "lib/error.h" +/** + * @file Shared declarations for all locking primitives. + */ + /** * used to store the current lock state. * diff --git a/src/lib/mutex.c b/src/lib/mutex.c index be36f58d2..1425fdd02 100644 --- a/src/lib/mutex.c +++ b/src/lib/mutex.c @@ -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) { diff --git a/src/lib/mutex.h b/src/lib/mutex.h index d9a26ef61..a359d9b75 100644 --- a/src/lib/mutex.h +++ b/src/lib/mutex.h @@ -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); diff --git a/src/lib/plugin.c b/src/lib/plugin.c index 4005bb204..184b0cb06 100644 --- a/src/lib/plugin.c +++ b/src/lib/plugin.c @@ -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) { diff --git a/src/lib/plugin.h b/src/lib/plugin.h index b787870d2..a31e69199 100644 --- a/src/lib/plugin.h +++ b/src/lib/plugin.h @@ -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); diff --git a/src/lib/references.h b/src/lib/references.h index dd5988ec7..5f5543787 100644 --- a/src/lib/references.h +++ b/src/lib/references.h @@ -24,6 +24,11 @@ #include +/** + * @file Strong and Weak references, header. + */ + + typedef struct cinelerra_reference_struct cinelerra_reference; typedef cinelerra_reference* CinelerraReference; diff --git a/src/lib/rwlock.c b/src/lib/rwlock.c index 018c69f63..48becb14d 100644 --- a/src/lib/rwlock.c +++ b/src/lib/rwlock.c @@ -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) { diff --git a/src/lib/rwlock.h b/src/lib/rwlock.h index 9bc07f9f3..21ad1e054 100644 --- a/src/lib/rwlock.h +++ b/src/lib/rwlock.h @@ -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); diff --git a/src/lib/time.h b/src/lib/time.h index a2dea483b..4203ece49 100644 --- a/src/lib/time.h +++ b/src/lib/time.h @@ -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)