+ /* Fill in visual gaps with black and audio gaps with silence */
+
+ Time video_pos = 0;
+ Time audio_pos = 0;
+ list<shared_ptr<Piece> > pieces_copy = _pieces;
+ for (list<shared_ptr<Piece> >::iterator i = pieces_copy.begin(); i != pieces_copy.end(); ++i) {
+ if (dynamic_pointer_cast<VideoContent> ((*i)->content)) {
+ Time const diff = (*i)->content->start() - video_pos;
+ if (diff > 0) {
+ shared_ptr<NullContent> nc (new NullContent (_film, video_pos, diff));
+ shared_ptr<BlackDecoder> bd (new BlackDecoder (_film, nc));
+ bd->Video.connect (bind (&Player::process_video, this, nc, _1, _2, _3, _4));
+ _pieces.push_back (shared_ptr<Piece> (new Piece (nc, bd)));
+// cout << "\tblack @ " << video_pos << " -- " << (video_pos + diff) << "\n";
+ }
+
+ video_pos = (*i)->content->end();
+ } else {
+ Time const diff = (*i)->content->start() - audio_pos;
+ if (diff > 0) {
+ shared_ptr<NullContent> nc (new NullContent (_film, audio_pos, diff));
+ shared_ptr<SilenceDecoder> sd (new SilenceDecoder (_film, nc));
+ sd->Audio.connect (bind (&Player::process_audio, this, nc, _1, _2));
+ _pieces.push_back (shared_ptr<Piece> (new Piece (nc, sd)));
+// cout << "\tsilence @ " << audio_pos << " -- " << (audio_pos + diff) << "\n";
+ }
+ audio_pos = (*i)->content->end();
+ }
+ }