X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fvideo_source.cc;h=2de4db68d75657a55a2a05f49a0a86914781f908;hb=f861018389acd9d277fe34d7621182b9b54f977f;hp=87b33026e109a1b053bed6ae27d69d6f51d4a4e4;hpb=ac0a9000d5d6a62c4ef3e4902611b180501e09e1;p=dcpomatic.git diff --git a/src/lib/video_source.cc b/src/lib/video_source.cc index 87b33026e..2de4db68d 100644 --- a/src/lib/video_source.cc +++ b/src/lib/video_source.cc @@ -1,11 +1,57 @@ +/* + Copyright (C) 2012 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #include "video_source.h" #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)); + /* 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 +TimedVideoSource::connect_video (shared_ptr s) +{ + Video.connect (bind (&TimedVideoSink::process_video, s, _1, _2, _3, _4)); +} + +void +TimedVideoSource::connect_video (shared_ptr s) +{ + Video.connect (bind (&VideoSink::process_video, s, _1, _2, _3)); +} + +