Split Empty into two separate classes, EmptyAudio and EmptyVideo.
authorCarl Hetherington <cth@carlh.net>
Sun, 15 May 2022 20:44:19 +0000 (22:44 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 16 May 2022 19:39:01 +0000 (21:39 +0200)
src/lib/empty.cc [deleted file]
src/lib/empty.h [deleted file]
src/lib/empty_audio.cc [new file with mode: 0644]
src/lib/empty_audio.h [new file with mode: 0644]
src/lib/empty_video.cc [new file with mode: 0644]
src/lib/empty_video.h [new file with mode: 0644]
src/lib/player.cc
src/lib/player.h
src/lib/wscript
test/empty_test.cc

diff --git a/src/lib/empty.cc b/src/lib/empty.cc
deleted file mode 100644 (file)
index 96d0364..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-    Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic 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.
-
-    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#include "empty.h"
-#include "film.h"
-#include "playlist.h"
-#include "content.h"
-#include "content_part.h"
-#include "dcp_content.h"
-#include "dcpomatic_time_coalesce.h"
-#include "piece.h"
-#include <iostream>
-
-
-using std::cout;
-using std::list;
-using std::shared_ptr;
-using std::dynamic_pointer_cast;
-using std::function;
-using namespace dcpomatic;
-
-
-Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, function<bool (shared_ptr<const Content>)> part, DCPTime length)
-{
-       list<DCPTimePeriod> full;
-       for (auto i: playlist->content()) {
-               if (part(i) && i->paths_valid()) {
-                       full.push_back (DCPTimePeriod(i->position(), i->end(film)));
-               }
-       }
-
-       _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full));
-
-       if (!_periods.empty()) {
-               _position = _periods.front().from;
-       }
-}
-
-
-void
-Empty::set_position (DCPTime position)
-{
-       _position = position;
-
-       for (auto i: _periods) {
-               if (i.contains(_position)) {
-                       return;
-               }
-       }
-
-       for (auto i: _periods) {
-               if (i.from > _position) {
-                       _position = i.from;
-                       return;
-               }
-       }
-}
-
-
-DCPTimePeriod
-Empty::period_at_position () const
-{
-       for (auto i: _periods) {
-               if (i.contains(_position)) {
-                       return DCPTimePeriod (_position, i.to);
-               }
-       }
-
-       DCPOMATIC_ASSERT (false);
-}
-
-
-bool
-Empty::done () const
-{
-       DCPTime latest;
-       for (auto i: _periods) {
-               latest = max (latest, i.to);
-       }
-
-       return _position >= latest;
-}
diff --git a/src/lib/empty.h b/src/lib/empty.h
deleted file mode 100644 (file)
index 145b840..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic 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.
-
-    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#ifndef DCPOMATIC_EMPTY_H
-#define DCPOMATIC_EMPTY_H
-
-
-#include "playlist.h"
-#include "dcpomatic_time.h"
-#include "content_part.h"
-#include <list>
-
-
-struct empty_test1;
-struct empty_test2;
-struct empty_test3;
-struct empty_test_with_overlapping_content;
-struct player_subframe_test;
-
-
-class Empty
-{
-public:
-       Empty () {}
-       Empty (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, std::function<bool (std::shared_ptr<const Content>)> part, dcpomatic::DCPTime length);
-
-       dcpomatic::DCPTime position () const {
-               return _position;
-       }
-
-       dcpomatic::DCPTimePeriod period_at_position () const;
-
-       bool done () const;
-
-       void set_position (dcpomatic::DCPTime amount);
-
-private:
-       friend struct ::empty_test1;
-       friend struct ::empty_test2;
-       friend struct ::empty_test3;
-       friend struct ::empty_test_with_overlapping_content;
-       friend struct ::player_subframe_test;
-
-       std::list<dcpomatic::DCPTimePeriod> _periods;
-       dcpomatic::DCPTime _position;
-};
-
-
-#endif
diff --git a/src/lib/empty_audio.cc b/src/lib/empty_audio.cc
new file mode 100644 (file)
index 0000000..a2d914b
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+    Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "content.h"
+#include "content_part.h"
+#include "dcp_content.h"
+#include "dcpomatic_time_coalesce.h"
+#include "empty_audio.h"
+#include "film.h"
+#include "piece.h"
+#include "playlist.h"
+#include <iostream>
+
+
+using std::cout;
+using std::dynamic_pointer_cast;
+using std::function;
+using std::list;
+using std::shared_ptr;
+using namespace dcpomatic;
+
+
+EmptyAudio::EmptyAudio (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, DCPTime length)
+{
+       list<DCPTimePeriod> full;
+       for (auto i: playlist->content()) {
+               if (i->audio && i->paths_valid()) {
+                       full.push_back (DCPTimePeriod(i->position(), i->end(film)));
+               }
+       }
+
+       _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full));
+
+       if (!_periods.empty()) {
+               _position = _periods.front().from;
+       }
+}
+
+
+void
+EmptyAudio::set_position (DCPTime position)
+{
+       _position = position;
+
+       for (auto i: _periods) {
+               if (i.contains(_position)) {
+                       return;
+               }
+       }
+
+       for (auto i: _periods) {
+               if (i.from > _position) {
+                       _position = i.from;
+                       return;
+               }
+       }
+}
+
+
+DCPTimePeriod
+EmptyAudio::period_at_position () const
+{
+       for (auto i: _periods) {
+               if (i.contains(_position)) {
+                       return DCPTimePeriod (_position, i.to);
+               }
+       }
+
+       DCPOMATIC_ASSERT (false);
+}
+
+
+bool
+EmptyAudio::done () const
+{
+       DCPTime latest;
+       for (auto i: _periods) {
+               latest = max (latest, i.to);
+       }
+
+       return _position >= latest;
+}
diff --git a/src/lib/empty_audio.h b/src/lib/empty_audio.h
new file mode 100644 (file)
index 0000000..2aae7ca
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_EMPTY_AUDIO_H
+#define DCPOMATIC_EMPTY_AUDIO_H
+
+
+#include "content_part.h"
+#include "dcpomatic_time.h"
+#include "playlist.h"
+#include <list>
+
+
+struct empty_audio_test1;
+struct empty_audio_test2;
+struct empty_audio_test3;
+struct empty_audio_test_with_overlapping_content;
+struct player_subframe_test;
+
+
+class EmptyAudio
+{
+public:
+       EmptyAudio () {}
+       EmptyAudio (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, dcpomatic::DCPTime length);
+
+       dcpomatic::DCPTime position () const {
+               return _position;
+       }
+
+       dcpomatic::DCPTimePeriod period_at_position () const;
+
+       bool done () const;
+
+       void set_position (dcpomatic::DCPTime amount);
+
+private:
+       friend struct ::empty_audio_test1;
+       friend struct ::empty_audio_test2;
+       friend struct ::empty_audio_test3;
+       friend struct ::empty_audio_test_with_overlapping_content;
+       friend struct ::player_subframe_test;
+
+       std::list<dcpomatic::DCPTimePeriod> _periods;
+       dcpomatic::DCPTime _position;
+};
+
+
+#endif
diff --git a/src/lib/empty_video.cc b/src/lib/empty_video.cc
new file mode 100644 (file)
index 0000000..c578559
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+    Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "content.h"
+#include "content_part.h"
+#include "dcp_content.h"
+#include "dcpomatic_time_coalesce.h"
+#include "empty_video.h"
+#include "film.h"
+#include "piece.h"
+#include "playlist.h"
+#include "video_content.h"
+#include <iostream>
+
+
+using std::cout;
+using std::dynamic_pointer_cast;
+using std::function;
+using std::list;
+using std::shared_ptr;
+using namespace dcpomatic;
+
+
+EmptyVideo::EmptyVideo (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, DCPTime length)
+{
+       list<DCPTimePeriod> full;
+       for (auto i: playlist->content()) {
+               if (i->video && i->video->use() && i->can_be_played() && i->paths_valid()) {
+                       full.push_back (DCPTimePeriod(i->position(), i->end(film)));
+               }
+       }
+
+       _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full));
+
+       if (!_periods.empty()) {
+               _position = _periods.front().from;
+       }
+}
+
+
+void
+EmptyVideo::set_position (DCPTime position)
+{
+       _position = position;
+
+       for (auto i: _periods) {
+               if (i.contains(_position)) {
+                       return;
+               }
+       }
+
+       for (auto i: _periods) {
+               if (i.from > _position) {
+                       _position = i.from;
+                       return;
+               }
+       }
+}
+
+
+DCPTimePeriod
+EmptyVideo::period_at_position () const
+{
+       for (auto i: _periods) {
+               if (i.contains(_position)) {
+                       return DCPTimePeriod (_position, i.to);
+               }
+       }
+
+       DCPOMATIC_ASSERT (false);
+}
+
+
+bool
+EmptyVideo::done () const
+{
+       DCPTime latest;
+       for (auto i: _periods) {
+               latest = max (latest, i.to);
+       }
+
+       return _position >= latest;
+}
diff --git a/src/lib/empty_video.h b/src/lib/empty_video.h
new file mode 100644 (file)
index 0000000..cf315bc
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_EMPTY_VIDEO_H
+#define DCPOMATIC_EMPTY_VIDEO_H
+
+
+#include "content_part.h"
+#include "dcpomatic_time.h"
+#include "playlist.h"
+#include <list>
+
+
+struct empty_video_test1;
+struct empty_video_test2;
+struct empty_video_test3;
+struct empty_video_test_with_overlapping_content;
+struct player_subframe_test;
+
+
+class EmptyVideo
+{
+public:
+       EmptyVideo () {}
+       EmptyVideo (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, dcpomatic::DCPTime length);
+
+       dcpomatic::DCPTime position () const {
+               return _position;
+       }
+
+       dcpomatic::DCPTimePeriod period_at_position () const;
+
+       bool done () const;
+
+       void set_position (dcpomatic::DCPTime amount);
+
+private:
+       friend struct ::empty_video_test1;
+       friend struct ::empty_video_test2;
+       friend struct ::empty_video_test3;
+       friend struct ::empty_video_test_with_overlapping_content;
+       friend struct ::player_subframe_test;
+
+       std::list<dcpomatic::DCPTimePeriod> _periods;
+       dcpomatic::DCPTime _position;
+};
+
+
+#endif
index 94bb807797e7240bd443c617b1a4837cb0694692..cf286f4a582fb0a4de592a6511ef347b8c0ae38f 100644 (file)
@@ -144,20 +144,6 @@ Player::setup_pieces ()
 }
 
 
-bool
-have_video (shared_ptr<const Content> content)
-{
-       return static_cast<bool>(content->video) && content->video->use() && content->can_be_played();
-}
-
-
-bool
-have_audio (shared_ptr<const Content> content)
-{
-       return static_cast<bool>(content->audio);
-}
-
-
 void
 Player::setup_pieces_unlocked ()
 {
@@ -288,8 +274,8 @@ Player::setup_pieces_unlocked ()
                }
        }
 
-       _black = Empty (_film, playlist(), bind(&have_video, _1), _playback_length);
-       _silent = Empty (_film, playlist(), bind(&have_audio, _1), _playback_length);
+       _black = EmptyVideo (_film, playlist(), _playback_length);
+       _silent = EmptyAudio (_film, playlist(), _playback_length);
 
        _next_video_time = boost::none;
        _next_video_eyes = Eyes::BOTH;
index 7d99c22c65ccca0448b73ec428b81572db8bc081..9318cff5a0a1f211c07b304d047e8c3cfa89c9f4 100644 (file)
@@ -31,7 +31,8 @@
 #include "content_audio.h"
 #include "content_text.h"
 #include "content_video.h"
-#include "empty.h"
+#include "empty_audio.h"
+#include "empty_video.h"
 #include "film.h"
 #include "image.h"
 #include "player_text.h"
@@ -225,8 +226,8 @@ private:
        };
        std::map<AudioStreamPtr, StreamState> _stream_states;
 
-       Empty _black;
-       Empty _silent;
+       EmptyVideo _black;
+       EmptyAudio _silent;
 
        ActiveText _active_texts[static_cast<int>(TextType::COUNT)];
        std::shared_ptr<AudioProcessor> _audio_processor;
index 7400c5bf11ab2863fb78b4f4c4ab3afc01dee60a..f83adedbdf729f3fb786d0711045c249974dbec3 100644 (file)
@@ -85,7 +85,8 @@ sources = """
           dkdm_wrapper.cc
           dolby_cp750.cc
           emailer.cc
-          empty.cc
+          empty_audio.cc
+          empty_video.cc
           encoder.cc
           encode_server.cc
           encode_server_finder.cc
index b186954b3790916098cc0b5a2d88bf6fc444ce67..5e6424a2abb5db915d4324aa0a6d1ad8fc598a37 100644 (file)
  */
 
 
+#include "lib/audio_content.h"
 #include "lib/dcp_content_type.h"
 #include "lib/decoder.h"
-#include "lib/empty.h"
+#include "lib/empty_audio.h"
+#include "lib/empty_video.h"
 #include "lib/film.h"
 #include "lib/image_content.h"
 #include "lib/player.h"
@@ -46,16 +48,41 @@ using namespace boost::placeholders;
 using namespace dcpomatic;
 
 
-bool
-has_video (shared_ptr<const Content> content)
+BOOST_AUTO_TEST_CASE (empty_video_test1)
 {
-        return static_cast<bool>(content->video);
+       auto film = new_test_film2 ("empty_video_test1");
+       film->set_sequence (false);
+       auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+       auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+
+       film->examine_and_add_content (contentA);
+       film->examine_and_add_content (contentB);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       int const vfr = film->video_frame_rate ();
+
+       /* 0 1 2 3 4 5 6 7
+        *     A A A     B
+        */
+       contentA->video->set_length (3);
+       contentA->set_position (film, DCPTime::from_frames(2, vfr));
+       contentB->video->set_length (1);
+       contentB->set_position (film, DCPTime::from_frames(7, vfr));
+
+       EmptyVideo black (film, film->playlist(), film->playlist()->length(film));
+       BOOST_REQUIRE_EQUAL (black._periods.size(), 2U);
+       auto i = black._periods.begin();
+       BOOST_CHECK (i->from == DCPTime::from_frames(0, vfr));
+       BOOST_CHECK (i->to ==   DCPTime::from_frames(2, vfr));
+       ++i;
+       BOOST_CHECK (i->from == DCPTime::from_frames(5, vfr));
+       BOOST_CHECK (i->to ==   DCPTime::from_frames(7, vfr));
 }
 
 
-BOOST_AUTO_TEST_CASE (empty_test1)
+BOOST_AUTO_TEST_CASE (empty_audio_test1)
 {
-       auto film = new_test_film2 ("empty_test1");
+       auto film = new_test_film2 ("empty_audio_test1");
        film->set_sequence (false);
        auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
        auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
@@ -64,6 +91,10 @@ BOOST_AUTO_TEST_CASE (empty_test1)
        film->examine_and_add_content (contentB);
        BOOST_REQUIRE (!wait_for_jobs());
 
+       /* Make this content look like it has audio so we can test the EmptyAudio class */
+       contentA->audio = make_shared<AudioContent>(contentA.get());
+       contentB->audio = make_shared<AudioContent>(contentB.get());
+
        int const vfr = film->video_frame_rate ();
 
        /* 0 1 2 3 4 5 6 7
@@ -74,9 +105,9 @@ BOOST_AUTO_TEST_CASE (empty_test1)
        contentB->video->set_length (1);
        contentB->set_position (film, DCPTime::from_frames(7, vfr));
 
-       Empty black (film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film));
-       BOOST_REQUIRE_EQUAL (black._periods.size(), 2U);
-       auto i = black._periods.begin();
+       EmptyAudio silent (film, film->playlist(), film->playlist()->length(film));
+       BOOST_REQUIRE_EQUAL (silent._periods.size(), 2U);
+       auto i = silent._periods.begin();
        BOOST_CHECK (i->from == DCPTime::from_frames(0, vfr));
        BOOST_CHECK (i->to ==   DCPTime::from_frames(2, vfr));
        ++i;
@@ -86,9 +117,9 @@ BOOST_AUTO_TEST_CASE (empty_test1)
 
 
 /** Some tests where the first empty period is not at time 0 */
-BOOST_AUTO_TEST_CASE (empty_test2)
+BOOST_AUTO_TEST_CASE (empty_video_test2)
 {
-       auto film = new_test_film2 ("empty_test2");
+       auto film = new_test_film2 ("empty_video_test2");
        film->set_sequence (false);
        auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
        auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
@@ -107,7 +138,7 @@ BOOST_AUTO_TEST_CASE (empty_test2)
        contentB->video->set_length (1);
        contentB->set_position (film, DCPTime::from_frames(7, vfr));
 
-       Empty black (film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film));
+       EmptyVideo black (film, film->playlist(), film->playlist()->length(film));
        BOOST_REQUIRE_EQUAL (black._periods.size(), 1U);
        BOOST_CHECK (black._periods.front().from == DCPTime::from_frames(3, vfr));
        BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(7, vfr));
@@ -124,10 +155,53 @@ BOOST_AUTO_TEST_CASE (empty_test2)
 }
 
 
+/** Some tests where the first empty period is not at time 0 */
+BOOST_AUTO_TEST_CASE (empty_audio_test2)
+{
+       auto film = new_test_film2 ("empty_audio_test2");
+       film->set_sequence (false);
+       auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+       auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+
+       film->examine_and_add_content (contentA);
+       film->examine_and_add_content (contentB);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       /* Make this content look like it has audio so we can test the EmptyAudio class */
+       contentA->audio = make_shared<AudioContent>(contentA.get());
+       contentB->audio = make_shared<AudioContent>(contentB.get());
+
+       int const vfr = film->video_frame_rate ();
+
+       /* 0 1 2 3 4 5 6 7
+        * A A A         B
+        */
+       contentA->video->set_length (3);
+       contentA->set_position (film, DCPTime(0));
+       contentB->video->set_length (1);
+       contentB->set_position (film, DCPTime::from_frames(7, vfr));
+
+       EmptyAudio silent (film, film->playlist(), film->playlist()->length(film));
+       BOOST_REQUIRE_EQUAL (silent._periods.size(), 1U);
+       BOOST_CHECK (silent._periods.front().from == DCPTime::from_frames(3, vfr));
+       BOOST_CHECK (silent._periods.front().to == DCPTime::from_frames(7, vfr));
+
+       /* position should initially be the start of the first empty period */
+       BOOST_CHECK (silent.position() == DCPTime::from_frames(3, vfr));
+
+       /* check that done() works */
+       BOOST_CHECK (!silent.done ());
+       silent.set_position (DCPTime::from_frames (4, vfr));
+       BOOST_CHECK (!silent.done ());
+       silent.set_position (DCPTime::from_frames (7, vfr));
+       BOOST_CHECK (silent.done ());
+}
+
+
 /** Test for when the film's playlist is not the same as the one passed into Empty */
-BOOST_AUTO_TEST_CASE (empty_test3)
+BOOST_AUTO_TEST_CASE (empty_video_test3)
 {
-       auto film = new_test_film2 ("empty_test3");
+       auto film = new_test_film2 ("empty_video_test3");
        film->set_sequence (false);
        auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
        auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
@@ -148,7 +222,7 @@ BOOST_AUTO_TEST_CASE (empty_test3)
 
        auto playlist = make_shared<Playlist>();
        playlist->add (film, contentB);
-       Empty black (film, playlist, bind(&has_video, _1), playlist->length(film));
+       EmptyVideo black (film, playlist, playlist->length(film));
        BOOST_REQUIRE_EQUAL (black._periods.size(), 1U);
        BOOST_CHECK (black._periods.front().from == DCPTime::from_frames(0, vfr));
        BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(7, vfr));
@@ -158,9 +232,47 @@ BOOST_AUTO_TEST_CASE (empty_test3)
 }
 
 
-BOOST_AUTO_TEST_CASE (empty_test_with_overlapping_content)
+/** Test for when the film's playlist is not the same as the one passed into Empty */
+BOOST_AUTO_TEST_CASE (empty_audio_test3)
+{
+       auto film = new_test_film2 ("empty_audio_test3");
+       film->set_sequence (false);
+       auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+       auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+
+       film->examine_and_add_content (contentA);
+       film->examine_and_add_content (contentB);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       /* Make this content look like it has audio so we can test the EmptyAudio class */
+       contentA->audio = make_shared<AudioContent>(contentA.get());
+       contentB->audio = make_shared<AudioContent>(contentB.get());
+
+       int const vfr = film->video_frame_rate ();
+
+       /* 0 1 2 3 4 5 6 7
+        * A A A         B
+        */
+       contentA->video->set_length (3);
+       contentA->set_position (film, DCPTime(0));
+       contentB->video->set_length (1);
+       contentB->set_position (film, DCPTime::from_frames(7, vfr));
+
+       auto playlist = make_shared<Playlist>();
+       playlist->add (film, contentB);
+       EmptyAudio silent (film, playlist, playlist->length(film));
+       BOOST_REQUIRE_EQUAL (silent._periods.size(), 1U);
+       BOOST_CHECK (silent._periods.front().from == DCPTime::from_frames(0, vfr));
+       BOOST_CHECK (silent._periods.front().to == DCPTime::from_frames(7, vfr));
+
+       /* position should initially be the start of the first empty period */
+       BOOST_CHECK (silent.position() == DCPTime::from_frames(0, vfr));
+}
+
+
+BOOST_AUTO_TEST_CASE (empty_video_test_with_overlapping_content)
 {
-       auto film = new_test_film2 ("empty_test_with_overlapping_content");
+       auto film = new_test_film2 ("empty_video_test_with_overlapping_content");
        film->set_sequence (false);
        auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
        auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
@@ -176,8 +288,36 @@ BOOST_AUTO_TEST_CASE (empty_test_with_overlapping_content)
        contentB->video->set_length (vfr * 1);
        contentB->set_position (film, DCPTime::from_seconds(1));
 
-       Empty black(film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film));
+       EmptyVideo black(film, film->playlist(), film->playlist()->length(film));
 
        BOOST_REQUIRE (black._periods.empty());
 }
 
+
+BOOST_AUTO_TEST_CASE (empty_audio_test_with_overlapping_content)
+{
+       auto film = new_test_film2 ("empty_audio_test_with_overlapping_content");
+       film->set_sequence (false);
+       auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+       auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+
+       film->examine_and_add_content (contentA);
+       film->examine_and_add_content (contentB);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       /* Make this content look like it has audio so we can test the EmptyAudio class */
+       contentA->audio = make_shared<AudioContent>(contentA.get());
+       contentB->audio = make_shared<AudioContent>(contentB.get());
+
+       int const vfr = film->video_frame_rate ();
+
+       contentA->video->set_length (vfr * 3);
+       contentA->set_position (film, DCPTime());
+       contentB->video->set_length (vfr * 1);
+       contentB->set_position (film, DCPTime::from_seconds(1));
+
+       EmptyAudio silent(film, film->playlist(), film->playlist()->length(film));
+
+       BOOST_REQUIRE (silent._periods.empty());
+}
+