shared_ptr<Piece> earliest;
for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
- if ((*i)->content->end() < _position) {
+// cout << "check " << (*i)->decoder->next() << " cf " << (*i)->content->end() << "\n";
+ if (((*i)->decoder->next() + (*i)->content->start()) >= (*i)->content->end()) {
continue;
}
return true;
}
- earliest->decoder->pass ();
-
- /* Move position to earliest active next emission */
-
- for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
- if ((*i)->content->end() < _position) {
- continue;
- }
-
- Time const t = (*i)->content->start() + (*i)->decoder->next();
-
- if (t < _position) {
- _position = t;
- }
+#if 0
+ cout << "PASS:\n";
+ cout << "\tpass ";
+ if (dynamic_pointer_cast<FFmpegContent> (earliest->content)) {
+ cout << " FFmpeg.\n";
+ } else if (dynamic_pointer_cast<ImageMagickContent> (earliest->content)) {
+ cout << " ImageMagickContent.\n";
+ } else if (dynamic_pointer_cast<SndfileContent> (earliest->content)) {
+ cout << " SndfileContent.\n";
+ } else if (dynamic_pointer_cast<BlackDecoder> (earliest->decoder)) {
+ cout << " Black.\n";
+ } else if (dynamic_pointer_cast<SilenceDecoder> (earliest->decoder)) {
+ cout << " Silence.\n";
}
+#endif
+
+ earliest->decoder->pass ();
+ _position = earliest->content->start() + earliest->decoder->next ();
return false;
}
(*i)->decoder->seek (t - (*i)->content->start());
}
- _position = t;
-
/* XXX: don't seek audio because we don't need to... */
}
void
Player::setup_pieces ()
{
+// cout << "----- Player SETUP PIECES.\n";
+
list<shared_ptr<Piece> > old_pieces = _pieces;
_pieces.clear ();
fd->Audio.connect (bind (&Player::process_audio, this, *i, _1, _2));
decoder = fd;
+// cout << "\tFFmpeg @ " << fc->start() << " -- " << fc->end() << "\n";
}
shared_ptr<const ImageMagickContent> ic = dynamic_pointer_cast<const ImageMagickContent> (*i);
}
decoder = id;
+// cout << "\tImageMagick @ " << ic->start() << " -- " << ic->end() << "\n";
}
shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (*i);
sd->Audio.connect (bind (&Player::process_audio, this, *i, _1, _2));
decoder = sd;
+// cout << "\tSndfile @ " << sc->start() << " -- " << sc->end() << "\n";
}
_pieces.push_back (shared_ptr<Piece> (new Piece (*i, decoder)));
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();
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();
}
}
-
- _position = 0;
}
void