Try to stop crashes when tests are torn down.
authorCarl Hetherington <cth@carlh.net>
Tue, 23 May 2017 13:52:08 +0000 (14:52 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 23 May 2017 13:52:08 +0000 (14:52 +0100)
src/lib/dcp_encoder.cc
src/lib/dcp_encoder.h
src/lib/encoder.cc
src/lib/encoder.h

index 522f02947ff728c77a487087443e0e72f1c71918..a3708040596c3c3aa9173f5e7e317fc03b094560 100644 (file)
@@ -68,6 +68,14 @@ DCPEncoder::DCPEncoder (shared_ptr<const Film> film, weak_ptr<Job> job)
        }
 }
 
+DCPEncoder::~DCPEncoder ()
+{
+       /* We must stop receiving more video data before we die */
+       _player_video_connection.release ();
+       _player_audio_connection.release ();
+       _player_subtitle_connection.release ();
+}
+
 void
 DCPEncoder::go ()
 {
index 38792197243a0bb4adc02ae1c9761ec25ef6d30d..d35b06184547b415d58e3f22871ae3a444416493 100644 (file)
@@ -36,6 +36,7 @@ class DCPEncoder : public Encoder
 {
 public:
        DCPEncoder (boost::shared_ptr<const Film> film, boost::weak_ptr<Job> job);
+       ~DCPEncoder ();
 
        void go ();
 
index 3af80efa51edeab31dd5b0b225e1049297978948..16d9923141080fc42bc0aacbcee039e6e1585db2 100644 (file)
@@ -43,7 +43,7 @@ Encoder::Encoder (shared_ptr<const Film> film, weak_ptr<Job> job)
        , _job (job)
        , _player (new Player (film, film->playlist ()))
 {
-       _player->Video.connect (bind (&Encoder::video, this, _1, _2));
-       _player->Audio.connect (bind (&Encoder::audio, this, _1, _2));
-       _player->Subtitle.connect (bind (&Encoder::subtitle, this, _1, _2));
+       _player_video_connection = _player->Video.connect (bind (&Encoder::video, this, _1, _2));
+       _player_audio_connection = _player->Audio.connect (bind (&Encoder::audio, this, _1, _2));
+       _player_subtitle_connection = _player->Subtitle.connect (bind (&Encoder::subtitle, this, _1, _2));
 }
index 79ad0ab4427b7cf6eb98c3fa7d797aade01be38b..64540195278ea0970f8b7e87d297fd937aa66e23 100644 (file)
@@ -24,6 +24,7 @@
 #include "types.h"
 #include "player_subtitles.h"
 #include <boost/weak_ptr.hpp>
+#include <boost/signals2.hpp>
 
 class Film;
 class Encoder;
@@ -55,6 +56,10 @@ protected:
        boost::shared_ptr<const Film> _film;
        boost::weak_ptr<Job> _job;
        boost::shared_ptr<Player> _player;
+
+       boost::signals2::scoped_connection _player_video_connection;
+       boost::signals2::scoped_connection _player_audio_connection;
+       boost::signals2::scoped_connection _player_subtitle_connection;
 };
 
 #endif