From 6f621b03a8add859b32fe99b43169ff698196a74 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 11 Nov 2008 14:50:24 +0000 Subject: [PATCH] docs/random/wtay/poll-timeout: Some pseudo code for how we could implement clock timeouts with GstPoll. Original commit message from CVS: * docs/random/wtay/poll-timeout: Some pseudo code for how we could implement clock timeouts with GstPoll. --- ChangeLog | 5 +++++ docs/random/wtay/poll-timeout | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/random/wtay/poll-timeout diff --git a/ChangeLog b/ChangeLog index c070ce0..7d2b68f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-11 Wim Taymans + + * docs/random/wtay/poll-timeout: + Some pseudo code for how we could implement clock timeouts with GstPoll. + 2008-11-10 Thomas Vander Stichele * plugins/elements/gstfilesink.c: diff --git a/docs/random/wtay/poll-timeout b/docs/random/wtay/poll-timeout new file mode 100644 index 0000000..30f3828 --- /dev/null +++ b/docs/random/wtay/poll-timeout @@ -0,0 +1,51 @@ +create clock id: + + id->state = OK; + + +waiting for id: + + lock + /* once unscheduled, the id cannot be used anymore */ + while (id->state != unscheduled) { + id->state = busy; + unlock + + ret = gstpoll (timeout); + + lock + if (id->state == unscheduled) { + /* id became unscheduled, read the fd and broadcast */ + read (fd) + cond_broadcast () + } + else { + if (ret != 0) { + /* some other id got unlocked */ + /* mark ourselves as EARLY, we release the lock and we could be + * unscheduled ourselves but we don't want the unscheduling thread + * to write on the fd */ + id->state = EARLY; + /* wait until it reads the fd and signals us */ + cond_wait () + } + else { + /* we timed out */ + id->state = OK | EARLY; + } + } + } + unlock + return id->state; + + +unschedule id: + + lock + /* when it leaves the poll, it'll detect the unscheduled. */ + id->state = unscheduled; + /* if it's busy waiting in poll, write to the fd */ + if (id->state == busy) { + write (fd) + } + unlock -- 2.7.4