summaryrefslogtreecommitdiffstats
path: root/osdep/threads.c
Commit message (Collapse)AuthorAgeFilesLines
* threads: add a dispatch queue thingwm42014-02-101-0/+229
| | | | | | Makes working with the (still) single-threaded playback thread easier. Might be reusable for other stuff.
* threads: avoid timeout calculation overflowwm42014-02-101-0/+3
| | | | | | | | | It's quite possible to overflow the calculation by setting the timeout to high values. Limit it to INT_MAX, which should be safe. The issue is mainly the secs variable. timespec.tv_sec will normally be 64 bit on sane systems, and we assume it can't overflow by adding INT_MAX to it.
* threads: add function to calculate deadline for timed waitswm42014-01-311-3/+12
| | | | | | | | | | | | Usually, you have to call pthread_cond_timedwait() in a loop (because it can wake up sporadically). If this function is used by another higher level function, which uses a relative timeout, we actually have to reduce the timeout on each iteration - or, simpler, compute the "deadline" at the beginning of the function, and always pass the same absolute time to the waiting function. Might be unsafe if the system time is changed. On the other hand, this is a fundamental race condition with these APIs.
* threads: add wrapper for initializing recursive mutexeswm42014-01-311-0/+11
| | | | Damn this overly verbose pthread API.
* stream: split out pthread helper functionwm42013-11-171-0/+57
Also split the function itself into 3.