diff options
author | Michael Roitzsch <mroi@users.sourceforge.net> | 2004-02-12 18:19:00 +0000 |
---|---|---|
committer | Michael Roitzsch <mroi@users.sourceforge.net> | 2004-02-12 18:19:00 +0000 |
commit | ca2ac6410b4f348e0aaba232eb089d78bc0fbdfa (patch) | |
tree | c2fa6089615fa64fe11544843c8f94915c512fc6 /src/xine-engine/xine_internal.h | |
parent | c2637f6fbd4a06ff0c433eccb705f52b35d46043 (diff) | |
download | xine-lib-ca2ac6410b4f348e0aaba232eb089d78bc0fbdfa.tar.gz xine-lib-ca2ac6410b4f348e0aaba232eb089d78bc0fbdfa.tar.bz2 |
big commit of the new ticket system to protect the rewiring and more
(as discussed on xine-devel, slightly improved to block acquires from
different threads between atomic revoke and issue)
* xine_ticket_t is declared in xine_internal.h and implemented in xine.c
* the ticket is acquired for (hopefully) all port operations
(no modifications to decoders needed, decoder loop does this)
* the ticket is revoked on pausing and on rewiring
* OSD does not store the port pointer any more (which was very dangerous,
since the pointer can change on rewire)
CVS patchset: 6137
CVS date: 2004/02/12 18:19:00
Diffstat (limited to 'src/xine-engine/xine_internal.h')
-rw-r--r-- | src/xine-engine/xine_internal.h | 67 |
1 files changed, 58 insertions, 9 deletions
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 3bd7c319c..7953fd8cf 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_internal.h,v 1.153 2004/01/11 15:54:23 jstembridge Exp $ + * $Id: xine_internal.h,v 1.154 2004/02/12 18:19:00 mroi Exp $ * */ @@ -89,6 +89,8 @@ extern "C" { #define XINE_STREAM_INFO_MAX 99 +typedef struct xine_ticket_s xine_ticket_t; + /* * the "big" xine struct, holding everything together */ @@ -111,6 +113,61 @@ struct xine_s { pthread_mutex_t streams_lock; metronom_clock_t *clock; + +#ifdef XINE_ENGINE_INTERNAL + xine_ticket_t *port_ticket; +#endif +}; + +/* + * xine thread tickets + */ + +struct xine_ticket_s { + + /* the ticket owner must assure to check for ticket revocation in + * intervals of finite length; this means that you must release + * the ticket before any operation that might block + * + * you must never write to this member directly + */ + int ticket_revoked; + + /* apply for a ticket; between acquire and relese of an irrevocable + * ticket (be sure to pair them properly!), it is guaranteed that you + * will never be blocked by ticket revocation */ + void (*acquire)(xine_ticket_t *self, int irrevocable); + + /* give a ticket back */ + void (*release)(xine_ticket_t *self, int irrevocable); + + /* renew a ticket, when it has been revoked, see ticket_revoked above; + * irrevocable must be set to one, if your thread might have acquired + * irrevocable tickets you don't know of; set it to zero only when + * you know that this is impossible */ + void (*renew)(xine_ticket_t *self, int irrevocable); + +#ifdef XINE_ENGINE_INTERNAL + /* allow handing out new tickets */ + void (*issue)(xine_ticket_t *self, int atomic); + + /* revoke all tickets and deny new ones; + * a pair of atomic revoke and issue cannot be interrupted by another + * revocation or by other threads acquiring tickets */ + void (*revoke)(xine_ticket_t *self, int atomic); + + void (*dispose)(xine_ticket_t *self); + + pthread_mutex_t lock; + pthread_mutex_t revoke_lock; + pthread_cond_t issued; + pthread_cond_t revoked; + int tickets_granted; + int irrevocable_tickets; + int pending_revocations; + int atomic_revoke; + pthread_t atomic_revoker_thread; +#endif }; /* @@ -264,14 +321,6 @@ struct xine_stream_s { int err; - /* on-the-fly port rewiring */ - xine_video_port_t *next_video_port; - xine_audio_port_t *next_audio_port; - pthread_mutex_t next_video_port_lock; - pthread_mutex_t next_audio_port_lock; - pthread_cond_t next_video_port_wired; - pthread_cond_t next_audio_port_wired; - broadcaster_t *broadcaster; #endif }; |