1
mirror of https://github.com/mpv-player/mpv synced 2024-11-14 22:48:35 +01:00
mpv/player
wm4 f9ba1a3ddf demux: remove weird tripple-buffering for the sh_stream list
The demuxer infrastructure was originally single-threaded. To make it
suitable for multithreading (specifically, demuxing and decoding on
separate threads), some sort of tripple-buffering was introduced. There
are separate "struct demuxer" allocations. The demuxer thread sets the
state on d_thread. If anything changes, the state is copied to d_buffer
(the copy is protected by a lock), and the decoder thread is notified.
Then the decoder thread copies the state from d_buffer to d_user (again
while holding a lock). This avoids the need for locking in the
demuxer/decoder code itself (only demux.c needs an internal, "invisible"
lock.)

Remove the streams/num_streams fields from this tripple-buffering
schema. Move them to the internal struct, and protect them with the
internal lock. Use accessors for read access outside of demux.c.

Other than replacing all field accesses with accessors, this separates
allocating and adding sh_streams. This is needed to avoid race
conditions. Before this change, this was awkwardly handled by first
initializing the sh_stream, and then sending a stream change event. Now
the stream is allocated, then initialized, and then declared as
immutable and added (at which point it becomes visible to the decoder
thread immediately).

This change is useful for PR #2626. And eventually, we should probably
get entirely of the tripple buffering, and this makes a nice first step.
2015-12-23 21:52:16 +01:00
..
lua ytdl: disable --all-subs if "sub-lang" is in raw-options 2015-10-24 17:30:22 +02:00
audio.c player: use demuxer ts offset to simplify timeline ts handling 2015-11-16 23:17:33 +01:00
client.c client API: disallow masking MPV_EVENT_SHUTDOWN 2015-12-02 23:08:43 +01:00
client.h vo_opengl_cb: don't render OSD while VO is not created 2015-03-23 16:32:59 +01:00
command.c input: add key name to script-binding command response 2015-12-23 19:10:48 +01:00
command.h video: always re-probe auto deint filter on filter reconfig 2015-07-21 21:54:15 +02:00
configfiles.c command: make time properties unavailable if timestamp is unknown 2015-10-16 16:16:10 +02:00
core.h player: minor simplification 2015-12-23 15:49:20 +01:00
external_files.c external_files: deduplicate bstr functions 2015-11-09 22:41:19 -08:00
external_files.h player: rename and move find_subfiles.c 2015-09-20 18:05:06 +02:00
loadfile.c demux: remove weird tripple-buffering for the sh_stream list 2015-12-23 21:52:16 +01:00
lua.c osd: delay libass initialization as far as possible 2015-09-07 14:26:01 +02:00
main.c options: handle terminal/logging settings eagerly 2015-11-04 21:49:54 +01:00
misc.c demux: remove weird tripple-buffering for the sh_stream list 2015-12-23 21:52:16 +01:00
osd.c osd: do not let OSD messages overwrite --osd-msgN text 2015-11-29 17:56:08 +01:00
playloop.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
screenshot.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00
screenshot.h client API: add a screenshot_raw command 2015-04-20 23:11:03 +02:00
scripting.c path: make mp_path_join accept normal C strings 2015-05-09 15:26:47 +02:00
sub.c demux: remove weird tripple-buffering for the sh_stream list 2015-12-23 21:52:16 +01:00
video.c video: switch from using display aspect to sample aspect 2015-12-19 20:45:36 +01:00