diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-10-26 15:38:46 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-10-26 15:38:46 +0100 |
| commit | d4d26c954f4e61b1b1a526c56d88dfd51b6fab48 (patch) | |
| tree | 8d1fca74ff1be621887a8ac39e91d947f84f9d31 /src/lib | |
| parent | cee4765caf903bf4b60e0e7539eaa2dae2bfa952 (diff) | |
wip: hacks.new-signals
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/cross.h | 2 | ||||
| -rw-r--r-- | src/lib/cross_linux.cc | 9 | ||||
| -rw-r--r-- | src/lib/player.cc | 3 | ||||
| -rw-r--r-- | src/lib/signal.h | 15 | ||||
| -rw-r--r-- | src/lib/video_decoder.cc | 2 | ||||
| -rw-r--r-- | 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 <boost/filesystem.hpp> /* windows.h defines this but we want to use it */ #undef ERROR +#include <boost/thread.hpp> #include <boost/thread/mutex.hpp> #include <boost/optional.hpp> @@ -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<Piece> 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 <boost/thread.hpp> #include <iostream> @@ -132,6 +133,8 @@ private: { int id; boost::thread::id thread; + /* XXX */ + std::string thread_name; std::function<Parameters> 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); } @@ -155,17 +158,27 @@ public: } template <typename... Args> + void operator()(Args...args) + { + emit(args...); + } + + template <typename... Args> 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<const Film> film, shared_ptr<const ImageProxy> 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 <boost/signals2.hpp> class VideoContent; @@ -62,7 +62,7 @@ public: void seek () override; void emit(std::shared_ptr<const Film> film, std::shared_ptr<const ImageProxy>, dcpomatic::ContentTime time); - boost::signals2::signal<void (ContentVideo)> Data; + Signal<void (ContentVideo)> Data; private: std::shared_ptr<const Content> _content; |
