Thu, 05 Jan 2006 05:29:51 +0000
[gaim-migrate @ 15077]
jabber.c:389: warning: ISO C90 forbids mixed declarations and code
| 12024 | 1 | /* |
| 2 | The mediastreamer library aims at providing modular media processing and I/O | |
| 3 | for linphone, but also for any telephony application. | |
| 4 | Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public | |
| 8 | License as published by the Free Software Foundation; either | |
| 9 | version 2.1 of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with this library; if not, write to the Free Software | |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | */ | |
| 20 | ||
| 21 | #ifndef MS_SYNC_H | |
| 22 | #define MS_SYNC_H | |
| 23 | ||
| 24 | ||
| 25 | #include "msfilter.h" | |
| 26 | ||
| 27 | struct _MSSync | |
| 28 | { | |
| 29 | struct _MSSyncClass *klass; | |
| 30 | GMutex *lock; | |
| 31 | MSFilter **attached_filters; /* pointer to a table of pointer of filters*/ | |
| 32 | GList *execution_list; /* the list of filters to be executed. This is filled with compilation */ | |
| 33 | gint filters; /*number of filters attached to the sync */ | |
| 34 | gint run; /* flag to indicate whether the sync must be run or not */ | |
| 35 | GThread * thread; /* the thread ressource if this sync is run by a thread*/ | |
| 36 | GCond *thread_cond; | |
| 37 | GCond *stop_cond; | |
| 38 | guint32 flags; | |
| 39 | gint interval; /* in miliseconds*/ | |
| 40 | #define MS_SYNC_NEED_UPDATE (0x0001) /* a modification has occured in the processing chains | |
| 41 | attached to this sync; so the execution list has to be updated */ | |
| 42 | guint samples_per_tick; /* number of bytes produced by sources of the processing chains*/ | |
| 43 | guint32 ticks; | |
| 44 | guint32 time; /* a time since the start of the sync expressed in milisec*/ | |
| 45 | }; | |
| 46 | ||
| 47 | typedef struct _MSSync MSSync; | |
| 48 | ||
| 49 | typedef void (*MSSyncDestroyFunc)(MSSync*); | |
| 50 | typedef void (*MSSyncSyncFunc)(MSSync*); | |
| 51 | typedef int (*MSSyncAttachFunc)(MSSync*,MSFilter*); | |
| 52 | typedef int (*MSSyncDetachFunc)(MSSync*,MSFilter*); | |
| 53 | ||
| 54 | typedef struct _MSSyncClass | |
| 55 | { | |
| 56 | gint max_filters; /* the maximum number of filters that can be attached to this sync*/ | |
| 57 | MSSyncSyncFunc synchronize; | |
| 58 | MSSyncDestroyFunc destroy; | |
| 59 | MSSyncAttachFunc attach; | |
| 60 | MSSyncDetachFunc detach; | |
| 61 | } MSSyncClass; | |
| 62 | ||
| 63 | /* private */ | |
| 64 | void ms_sync_init(MSSync *sync); | |
| 65 | void ms_sync_class_init(MSSyncClass *klass); | |
| 66 | ||
| 67 | int ms_sync_attach_generic(MSSync *sync,MSFilter *f); | |
| 68 | int ms_sync_detach_generic(MSSync *sync,MSFilter *f); | |
| 69 | ||
| 70 | /* public*/ | |
| 71 | ||
| 72 | #define MS_SYNC(sync) ((MSSync*)(sync)) | |
| 73 | #define MS_SYNC_CLASS(klass) ((MSSyncClass*)(klass)) | |
| 74 | ||
| 75 | #define ms_sync_synchronize(_sync) \ | |
| 76 | do \ | |
| 77 | { \ | |
| 78 | MSSync *__sync=_sync; \ | |
| 79 | __sync->ticks++; \ | |
| 80 | ((__sync)->klass->synchronize((__sync))); \ | |
| 81 | }while(0) | |
| 82 | ||
| 83 | void ms_sync_setup(MSSync *sync); | |
| 84 | ||
| 85 | void ms_sync_unsetup(MSSync *sync); | |
| 86 | ||
| 87 | #define ms_sync_update(sync) (sync)->flags|=MS_SYNC_NEED_UPDATE | |
| 88 | ||
| 89 | #define ms_sync_get_samples_per_tick(sync) ((sync)->samples_per_tick) | |
| 90 | ||
| 91 | void ms_sync_set_samples_per_tick(MSSync *sync,gint size); | |
| 92 | ||
| 93 | #define ms_sync_get_tick_count(sync) ((sync)->ticks) | |
| 94 | ||
| 95 | #define ms_sync_suspend(sync) g_cond_wait((sync)->thread_cond,(sync)->lock) | |
| 96 | ||
| 97 | #define ms_sync_lock(sync) g_mutex_lock((sync)->lock) | |
| 98 | ||
| 99 | #define ms_sync_unlock(sync) g_mutex_unlock((sync)->lock) | |
| 100 | ||
| 101 | #define ms_sync_trylock(sync) g_mutex_trylock((sync)->lock) | |
| 102 | ||
| 103 | /** | |
| 104 | * function_name:ms_sync_attach | |
| 105 | * @sync: A #MSSync object. | |
| 106 | * @f: A #MSFilter object. | |
| 107 | * | |
| 108 | * Attach a chain of filters to a synchronisation source. Filter @f must be the first filter of the processing chain. | |
| 109 | * | |
| 110 | * Returns: 0 if successfull, a negative value reprensenting the errno.h error. | |
| 111 | */ | |
| 112 | int ms_sync_attach(MSSync *sync,MSFilter *f); | |
| 113 | ||
| 114 | /** | |
| 115 | * ms_sync_detach: | |
| 116 | * @sync: A #MSSync object. | |
| 117 | * @f: A #MSFilter object. | |
| 118 | * | |
| 119 | * Dettach a chain of filters to a synchronisation source. Filter @f must be the first filter of the processing chain. | |
| 120 | * The processing chain will no more be executed. | |
| 121 | * | |
| 122 | * Returns: 0 if successfull, a negative value reprensenting the errno.h error. | |
| 123 | */ | |
| 124 | int ms_sync_detach(MSSync *sync,MSFilter *f); | |
| 125 | ||
| 126 | int ms_sync_uninit(MSSync *sync); | |
| 127 | ||
| 128 | #define ms_sync_start(sync) ms_start((sync)) | |
| 129 | #define ms_sync_stop(sync) ms_stop((sync)) | |
| 130 | ||
| 131 | ||
| 132 | /*destroy*/ | |
| 133 | #define ms_sync_destroy(sync) (sync)->klass->destroy((sync)) | |
| 134 | ||
| 135 | ||
| 136 | #endif |