Commit Graph

12 Commits

Author SHA1 Message Date
Kacper Michajłow 86abbb89a7 win32: fix platform checks 2024-05-06 22:01:17 +02:00
Kacper Michajłow 18ef834ef4 various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow 174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
NRK d05ef7fdc4 various: sort some standard headers
since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.

some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.

hopefully nothing breaks. if it does, the style guide is to blame.
2023-10-20 21:31:09 +02:00
NRK 450a69b1d6 various: remove ATOMIC_VAR_INIT
the fallback needed it due to the struct wrapper. but the fallback is
now removed so it's no longer needed.

as for standard atomics, it was never really needed either, was useless
and then made obsolete in C17 and removed in C23.

ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/
ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
2023-10-20 21:31:09 +02:00
NRK 2070331f64 osdep: remove atomic.h
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.

also add missing config.h includes on some files.
2023-10-20 21:31:09 +02:00
Kacper Michajłow 500eb3940d thread_tools: suppress -Wstringop-overflow false-positive 2023-10-19 14:03:23 +00:00
wm4 29a51900c6 player: some further cleanup of the mp_cancel crap
Alway give each demuxer its own mp_cancel instance. This makes
management of the mp_cancel things much easier. Also, instead of having
add/remove functions for mp_cancel slaves, replace them with a simpler
to use set_parent function. Remove cancel_and_free_demuxer(), which had
mpctx as parameter only to check an assumption. With this commit,
demuxers have their own mp_cancel, so add demux_cancel_and_free() which
makes use of it.
2018-05-24 19:56:35 +02:00
wm4 a253c72dbb thread_tools: unify mp_cancel POSIX/win32 paths, add features
The OS specifics are merged because the resulting ifdeffery is not much
worse than the old ifdeffery, but the logic that is now shared is
becoming more complex.

Create all objects lazily. The intention is to make mp_cancel instances
cheaper. POSIX pipes and win32 Events are pretty heavy weight, and are
only needed in special situations.

Add a mechanism to "chain" mp_cancel instances. Needed by the later
commits for whatever reasons.

Untested on win32.
2018-05-24 19:56:35 +02:00
wm4 094f6be600 thread_tools: minor simplification 2018-05-24 19:56:35 +02:00
wm4 31b78ad7fa misc: move mp_cancel from stream.c to thread_tools.c
It seems a bit inappropriate to have dumped this into stream.c, even if
it's roughly speaking its main user. At least it made its way somewhat
unfortunately to other components not related to the stream or demuxer
layer at all.

I'm too greedy to give this weird helper its own file, so dump it into
thread_tools.c.

Probably a somewhat pointless change.
2018-05-24 19:56:35 +02:00
wm4 22c002138d misc: add a synchronization helper
This is almost like rendezvous(), except it allows async wakeup, and
does not require global state. It will be used by a later commit.

struct mp_waiter is intended to be allocated on the stack, and uses an
initializer including PTHREAD_MUTEX_INITIALIZER. This is the first case
in mpv that it uses PTHREAD_MUTEX_INITIALIZER for stack-allocated
mutexes. It seems POSIX still does not allow this formally, but since
POSIX is worth less than used toilet paper, I don't really care. Modern
OSes use futexes, which means you can make _every_ memory location a
lock, and this code tries to make use of it, without using OS specific
code.

The name of the source file is rather generic, because I intend to dump
further small helpers there (or maybe move mp_rendezvous() to it).
2018-05-24 19:56:34 +02:00