diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-11-09 22:24:18 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-02 00:31:28 +0200 |
| commit | 925d97b8e51421bf509c5ffbe4abe8f77a6ca95e (patch) | |
| tree | 9a1641342821c5896a00c28cf083fc5c79b880af | |
| parent | 266e3f1b80d1263ff3cc8b3afaecd6ca1f88983b (diff) | |
It doesn't seem necessary to use shared_ptr for the DCPVideo queue in J2KEncoder.v2.16.x-old
| -rw-r--r-- | src/lib/dcp_video.h | 4 | ||||
| -rw-r--r-- | src/lib/j2k_encoder.cc | 28 | ||||
| -rw-r--r-- | src/lib/j2k_encoder.h | 2 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h index 862b787d2..3bd516ccd 100644 --- a/src/lib/dcp_video.h +++ b/src/lib/dcp_video.h @@ -45,8 +45,8 @@ public: DCPVideo (std::shared_ptr<const PlayerVideo>, int index, int dcp_fps, int bandwidth, Resolution r); DCPVideo (std::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr); - DCPVideo (DCPVideo const&) = delete; - DCPVideo& operator= (DCPVideo const&) = delete; + DCPVideo (DCPVideo const&) = default; + DCPVideo& operator= (DCPVideo const&) = default; dcp::ArrayData encode_locally () const; dcp::ArrayData encode_remotely (EncodeServerDescription, int timeout = 30) const; diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 55961fc6b..985708f05 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -135,13 +135,13 @@ J2KEncoder::end () So just mop up anything left in the queue here. */ - for (auto i: _queue) { - LOG_GENERAL(N_("Encode left-over frame %1"), i->index()); + for (auto const& i: _queue) { + LOG_GENERAL(N_("Encode left-over frame %1"), i.index()); try { _writer->write ( - make_shared<dcp::ArrayData>(i->encode_locally()), - i->index(), - i->eyes() + make_shared<dcp::ArrayData>(i.encode_locally()), + i.index(), + i.eyes() ); frame_done (); } catch (std::exception& e) { @@ -237,7 +237,7 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time) LOG_DEBUG_ENCODE("Frame @ %1 ENCODE", to_string(time)); /* Queue this new frame for encoding */ LOG_TIMING ("add-frame-to-queue queue=%1", _queue.size ()); - _queue.push_back (make_shared<DCPVideo>( + _queue.push_back (DCPVideo( pv, position, _film->video_frame_rate(), @@ -315,7 +315,7 @@ try { boost::this_thread::disable_interruption dis; - LOG_TIMING ("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), vf->index(), (int) vf->eyes ()); + LOG_TIMING ("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), vf.index(), static_cast<int>(vf.eyes())); _queue.pop_front (); lock.unlock (); @@ -325,7 +325,7 @@ try /* We need to encode this input */ if (server) { try { - encoded = make_shared<dcp::ArrayData>(vf->encode_remotely(server.get())); + encoded = make_shared<dcp::ArrayData>(vf.encode_remotely(server.get())); if (remote_backoff > 0) { LOG_GENERAL ("%1 was lost, but now she is found; removing backoff", server->host_name ()); @@ -341,15 +341,15 @@ try } LOG_ERROR ( N_("Remote encode of %1 on %2 failed (%3); thread sleeping for %4s"), - vf->index(), server->host_name(), e.what(), remote_backoff + vf.index(), server->host_name(), e.what(), remote_backoff ); } } else { try { - LOG_TIMING ("start-local-encode thread=%1 frame=%2", thread_id(), vf->index()); - encoded = make_shared<dcp::ArrayData>(vf->encode_locally()); - LOG_TIMING ("finish-local-encode thread=%1 frame=%2", thread_id(), vf->index()); + LOG_TIMING ("start-local-encode thread=%1 frame=%2", thread_id(), vf.index()); + encoded = make_shared<dcp::ArrayData>(vf.encode_locally()); + LOG_TIMING ("finish-local-encode thread=%1 frame=%2", thread_id(), vf.index()); } catch (std::exception& e) { /* This is very bad, so don't cope with it, just pass it on */ LOG_ERROR (N_("Local encode failed (%1)"), e.what ()); @@ -358,11 +358,11 @@ try } if (encoded) { - _writer->write (encoded, vf->index(), vf->eyes()); + _writer->write (encoded, vf.index(), vf.eyes()); frame_done (); } else { lock.lock (); - LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), vf->index()); + LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), vf.index()); _queue.push_front (vf); lock.unlock (); } diff --git a/src/lib/j2k_encoder.h b/src/lib/j2k_encoder.h index cea965309..ea0a2bef8 100644 --- a/src/lib/j2k_encoder.h +++ b/src/lib/j2k_encoder.h @@ -96,7 +96,7 @@ private: std::shared_ptr<boost::thread_group> _threads; mutable boost::mutex _queue_mutex; - std::list<std::shared_ptr<DCPVideo>> _queue; + std::list<DCPVideo> _queue; /** condition to manage thread wakeups when we have nothing to do */ boost::condition _empty_condition; /** condition to manage thread wakeups when we have too much to do */ |
