+ if (c->can_be_played()) {
+ if (c->video) {
+ video = make_shared<VideoDecoder>(this, c);
+ }
+ if (c->audio) {
+ audio = make_shared<AudioDecoder>(this, c->audio, fast);
+ }
+ for (auto i: c->text) {
+ /* XXX: this time here should be the time of the first subtitle, not 0 */
+ text.push_back (make_shared<TextDecoder>(this, i, ContentTime()));
+ }
+ if (c->atmos) {
+ atmos = make_shared<AtmosDecoder>(this, c);
+ }
+ }
+
+ /* We try to avoid re-scanning the DCP's files every time we make a new DCPDecoder; we do this
+ by re-using the _reels list. Before we do this we need to check that nothing too serious
+ has changed in the DCPContent.
+
+ We do this by storing a digest of the important bits of the DCPContent and then checking that's
+ the same before we re-use _reels.
+ */
+
+ _lazy_digest = calculate_lazy_digest (c);
+
+ if (old && old->lazy_digest() == _lazy_digest) {
+ _reels = old->_reels;
+ } else {
+
+ auto cpl_list = cpls ();
+
+ if (cpl_list.empty()) {
+ throw DCPError (_("No CPLs found in DCP."));
+ }
+
+ shared_ptr<dcp::CPL> cpl;
+ for (auto i: cpl_list) {
+ if (_dcp_content->cpl() && i->id() == _dcp_content->cpl().get()) {
+ cpl = i;
+ }
+ }
+
+ if (!cpl) {
+ /* No CPL found; probably an old file that doesn't specify it;
+ just use the first one.
+ */
+ cpl = cpls().front ();
+ }
+
+ _reels = cpl->reels ();