mpv/common
wm4 2fd34889fe msg: make --log-file buffered through a thread
Until now --log-file performed a blocking write to the log file, which
made any calling thread block for I/O. It even explicitly flushed after
every line (to make it tail-able, or to ensure a hard crash wouldn't
lose any of the output). This wasn't so good, because it could cause
real playback problems, which made it infeasible to enable it by
default.

Try to buffer it through a ring buffer and a thread. There's no other
choice but to use a thread, since async I/O on files is generally a big
and unportable pain. (We very much prefer portable pain.) Fortunately,
there's already a ring buffer (mp_log_buffer, normally for the client
API logging hook). This still involves some pretty messy locking. Give
each mp_log_buffer its own lock to make this easier.

This still makes calling threads block if the log buffer is full (unlike
with client API log buffers, which just drop messages). I don't want log
messages to get lost for this purpose. This also made locking pretty
complicated (without it, mp_log_buffer wouldn't have needed its own
lock). Maybe I'll remove this blocking again when it turns out to be
nonsense.

(We could avoid wasting an entire thread by "reusing" some other thread.
E.g. pick some otherwise not real time thread, and make it react to the
log buffer's wakeup callback. But let's not. It's complicated to abuse
random threads for this. It'd also raise locking complexity, because we
still want it to block on a full buffer.)
2020-01-29 23:34:59 +01:00
..
av_common.c demux: use no overlapping packets for lossless audio 2019-09-19 20:37:04 +02:00
av_common.h demux: use no overlapping packets for lossless audio 2019-09-19 20:37:04 +02:00
av_log.c player: accept compatible later FFmpeg library runtime versions 2019-10-11 21:28:04 +02:00
av_log.h
codecs.c codecs: remove unused family field 2018-02-01 10:21:55 +01:00
codecs.h codecs: remove unused family field 2018-02-01 10:21:55 +01:00
common.c common: add a helper to round up to next power of 2 2019-11-06 21:35:49 +01:00
common.h common: add a helper to round up to next power of 2 2019-11-06 21:35:49 +01:00
encode.h encode: get rid of the output packet queue 2018-05-03 01:08:44 +03:00
encode_lavc.c stream, demux: redo origin policy thing 2019-12-20 13:00:39 +01:00
encode_lavc.h encode: get rid of the output packet queue 2018-05-03 01:08:44 +03:00
global.h player: get rid of mpv_global.opts 2018-05-24 19:56:35 +02:00
msg.c msg: make --log-file buffered through a thread 2020-01-29 23:34:59 +01:00
msg.h msg: try to document purpose of log levels better 2019-11-07 22:53:13 +01:00
msg_control.h msg: make --log-file buffered through a thread 2020-01-29 23:34:59 +01:00
playlist.c command: add a playlist-unshuffle command 2019-12-28 21:32:15 +01:00
playlist.h command: add a playlist-unshuffle command 2019-12-28 21:32:15 +01:00
recorder.c recorder: don't use a magic index for mp_recorder_get_sink() 2019-09-29 01:41:19 +02:00
recorder.h recorder: don't use a magic index for mp_recorder_get_sink() 2019-09-29 01:41:19 +02:00
tags.c demux: support for some kinds of timed metadata 2018-04-18 01:17:42 +03:00
tags.h demux: support for some kinds of timed metadata 2018-04-18 01:17:42 +03:00
version.c build: move copyright statement to a shared location 2018-01-01 21:05:09 +00:00