2 Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/config.h"
23 #include "lib/cross.h"
24 #include "lib/image.h"
25 #include "lib/j2k_encoder.h"
26 #include "lib/player_video.h"
27 #include "lib/raw_image_proxy.h"
28 #include "lib/writer.h"
31 #include <libavutil/pixfmt.h>
33 #include <boost/test/unit_test.hpp>
36 using std::make_shared;
38 using boost::optional;
41 BOOST_AUTO_TEST_CASE(j2k_encoder_deadlock_test)
45 auto film = new_test_film2("j2k_encoder_deadlock_test");
47 /* Don't call ::start() on this Writer, so it can never write anything */
48 Writer writer(film, {}, {});
49 writer.set_encoder_threads(4);
51 /* We want to test the case where the writer queue fills, and this can't happen unless there
52 * are enough encoding threads (each of which will end up waiting for the writer to empty,
53 * which will never happen).
55 Config::instance()->set_master_encoding_threads(4);
56 J2KEncoder encoder(film, writer);
59 for (int i = 0; i < 26; ++i) {
60 auto image = make_shared<Image>(AV_PIX_FMT_RGB24, dcp::Size(1998, 1080), Image::Alignment::PADDED);
61 auto image_proxy = make_shared<RawImageProxy>(image);
63 std::make_shared<PlayerVideo>(
67 dcp::Size(1998, 1080),
68 dcp::Size(1998, 1080),
71 optional<ColourConversion>(),
74 optional<dcpomatic::ContentTime>(),
81 dcpomatic_sleep_seconds(10);