mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-08 09:04:17 +00:00
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.
This commit is contained in:
parent
a0e5eab525
commit
6f621b03a8
2 changed files with 56 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2008-11-11 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||
|
||||
* docs/random/wtay/poll-timeout:
|
||||
Some pseudo code for how we could implement clock timeouts with GstPoll.
|
||||
|
||||
2008-11-10 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* plugins/elements/gstfilesink.c:
|
||||
|
|
51
docs/random/wtay/poll-timeout
Normal file
51
docs/random/wtay/poll-timeout
Normal file
|
@ -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
|
Loading…
Reference in a new issue