From 5ffd6a9e9b7a0d894d7513ad20c24c2727426ecd Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 8 Mar 2014 23:38:53 +0100 Subject: encode: add locking Since the AO will run in a thread, and there's lots of shared state with encoding, we have to add locking. One case this doesn't handle correctly are the encode_lavc_available() calls in ao_lavc.c and vo_lavc.c. They don't do much (and usually only to protect against doing --ao=lavc with normal playback), and changing it would be a bit messy. So just leave them. --- common/encode_lavc.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common/encode_lavc.h') diff --git a/common/encode_lavc.h b/common/encode_lavc.h index deaf42b684..af7f4fba3d 100644 --- a/common/encode_lavc.h +++ b/common/encode_lavc.h @@ -22,6 +22,8 @@ #ifndef MPLAYER_ENCODE_LAVC_H #define MPLAYER_ENCODE_LAVC_H +#include + #include #include #include @@ -37,6 +39,11 @@ struct encode_lavc_context { struct encode_output_conf *options; struct mp_log *log; + // All entry points must be guarded with the lock. Functions called by + // the playback core lock this automatically, but ao_lavc.c and vo_lavc.c + // must lock manually before accessing state. + pthread_mutex_t lock; + float vo_fps; // these are processed from the options -- cgit v1.2.3