From d4d26c954f4e61b1b1a526c56d88dfd51b6fab48 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 26 Oct 2025 15:38:46 +0100 Subject: wip: hacks. --- src/lib/cross.h | 2 ++ src/lib/cross_linux.cc | 9 +++++++++ src/lib/player.cc | 3 +++ src/lib/signal.h | 15 ++++++++++++++- src/lib/video_decoder.cc | 2 ++ src/lib/video_decoder.h | 4 ++-- 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/lib/cross.h b/src/lib/cross.h index 8b1ffccca..34061e3c8 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -32,6 +32,7 @@ #include /* windows.h defines this but we want to use it */ #undef ERROR +#include #include #include @@ -60,6 +61,7 @@ extern boost::filesystem::path libdcp_resources_path(); extern void start_batch_converter(); extern void start_player(); extern uint64_t thread_id(); +extern std::string thread_name(); extern int avio_open_boost(AVIOContext** s, boost::filesystem::path file, int flags); extern boost::filesystem::path home_directory(); extern bool running_32_on_64(); diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index c9d1322fe..aaf78c923 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -348,3 +348,12 @@ show_in_file_manager (boost::filesystem::path dir, boost::filesystem::path) return true; } + +string +thread_name() +{ + char buffer[16]; + pthread_getname_np(pthread_self(), buffer, sizeof(buffer)); + return buffer; +} + diff --git a/src/lib/player.cc b/src/lib/player.cc index 985bd3a9c..f52d40da8 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -27,6 +27,7 @@ #include "config.h" #include "content_audio.h" #include "content_video.h" +#include "cross.h" #include "dcp_content.h" #include "dcp_decoder.h" #include "dcpomatic_log.h" @@ -1031,6 +1032,8 @@ Player::emit_video_until(DCPTime time) void Player::video(weak_ptr weak_piece, ContentVideo video) { + std::cout << "Player receive video in " << thread_name() << "\n"; + if (_suspended) { return; } diff --git a/src/lib/signal.h b/src/lib/signal.h index a2ea1cf98..80c6811d5 100644 --- a/src/lib/signal.h +++ b/src/lib/signal.h @@ -23,6 +23,7 @@ #define DCPOMATIC_SIGNAL_H +#include "cross.h" #include #include @@ -132,6 +133,8 @@ private: { int id; boost::thread::id thread; + /* XXX */ + std::string thread_name; std::function function; }; @@ -141,7 +144,7 @@ public: boost::mutex::scoped_lock lm(_mutex); auto const id = _id++; auto const thread_id = boost::this_thread::get_id(); - _callbacks.push_back(Callback{id, thread_id, callback}); + _callbacks.push_back(Callback{id, thread_id, thread_name(), callback}); return Connection(*this, id); } @@ -154,18 +157,28 @@ public: } } + template + void operator()(Args...args) + { + emit(args...); + } + template void emit(Args... args) { boost::mutex::scoped_lock lm(_mutex); auto thread_id = boost::this_thread::get_id(); + std::cout << "emit with " << _callbacks.size() << "\n"; for (auto const& callback: _callbacks) { if (thread_id == callback.thread) { + std::cout << "simple emit.\n"; callback.function(args...); } else { + std::cout << "x-thread emit from " << thread_name() << " to " << callback.thread_name << "\n"; boost::mutex::scoped_lock lm2(pending::mutex); pending::callbacks[callback.thread].push_back(boost::bind(callback.function, args...)); if (thread_waker) { + std::cout << "x-thread emit wakes shit.\n"; thread_waker->wake(); } } diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 6aa638cea..036307208 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -19,6 +19,7 @@ */ +#include "cross.h" #include "frame_interval_checker.h" #include "image.h" #include "j2k_image_proxy.h" @@ -81,6 +82,7 @@ VideoDecoder::emit(shared_ptr film, shared_ptr ima switch (vft) { case VideoFrameType::TWO_D: + std::cout << "Data emit from " << thread_name() << "\n"; Data(ContentVideo(image, time, Eyes::BOTH, Part::WHOLE)); break; case VideoFrameType::THREE_D: diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index b609404c4..c4b91d9c4 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -31,8 +31,8 @@ #include "content_video.h" #include "decoder.h" #include "decoder_part.h" +#include "signal.h" #include "video_content.h" -#include class VideoContent; @@ -62,7 +62,7 @@ public: void seek () override; void emit(std::shared_ptr film, std::shared_ptr, dcpomatic::ContentTime time); - boost::signals2::signal Data; + Signal Data; private: std::shared_ptr _content; -- cgit v1.2.3