1 #include "cpu_player_video_preparer.h"
3 #include "dcpomatic_log.h"
4 #include "player_video.h"
6 #include <boost/thread.hpp>
10 using boost::shared_ptr;
11 using boost::weak_ptr;
14 CPUPlayerVideoPreparer::CPUPlayerVideoPreparer (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast)
15 : _work (new boost::asio::io_service::work(_service))
16 , _pixel_format (pixel_format)
20 LOG_TIMING("start-prepare-threads %1", boost::thread::hardware_concurrency() * 2);
22 for (size_t i = 0; i < boost::thread::hardware_concurrency() * 2; ++i) {
23 _pool.create_thread (bind (&boost::asio::io_service::run, &_service));
28 CPUPlayerVideoPreparer::~CPUPlayerVideoPreparer ()
37 CPUPlayerVideoPreparer::prepare (weak_ptr<PlayerVideo> weak_video)
40 shared_ptr<PlayerVideo> video = weak_video.lock ();
41 /* If the weak_ptr cannot be locked the video obviously no longer requires any work */
43 LOG_TIMING("start-prepare in %1", thread_id());
44 video->prepare (_pixel_format, _aligned, _fast);
45 LOG_TIMING("finish-prepare in %1", thread_id());
46 timestamped_printf("cpu finishes %d\n", video->time.frames_round(24));
56 CPUPlayerVideoPreparer::request (shared_ptr<PlayerVideo> pv)
58 _service.post (bind(&CPUPlayerVideoPreparer::prepare, this, weak_ptr<PlayerVideo>(pv)));