X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fvideo_source.cc;fp=src%2Flib%2Fvideo_source.cc;h=2de4db68d75657a55a2a05f49a0a86914781f908;hp=539243402e0824f7551940fe0cb12d2313d77acf;hb=f861018389acd9d277fe34d7621182b9b54f977f;hpb=86011ad6b4ea0004a51c59b0563cf89c0947546d diff --git a/src/lib/video_source.cc b/src/lib/video_source.cc index 539243402..2de4db68d 100644 --- a/src/lib/video_source.cc +++ b/src/lib/video_source.cc @@ -21,12 +21,25 @@ #include "video_sink.h" using boost::shared_ptr; +using boost::weak_ptr; using boost::bind; +static void +process_video_proxy (weak_ptr sink, shared_ptr i, bool same, shared_ptr s) +{ + shared_ptr p = sink.lock (); + if (p) { + p->process_video (i, same, s); + } +} + void VideoSource::connect_video (shared_ptr s) { - Video.connect (bind (&VideoSink::process_video, s, _1, _2, _3)); + /* If we bind, say, a Playlist (as the VideoSink) to a Decoder (which is owned + by the Playlist) we create a cycle. Use a weak_ptr to break it. + */ + Video.connect (bind (process_video_proxy, boost::weak_ptr (s), _1, _2, _3)); } void