double next_clip_fade_time = -1.0;
for ( ;; ) {
+ bool clip_ready;
+ steady_clock::time_point before_sleep = steady_clock::now();
+
// Wait until we're supposed to play something.
{
unique_lock<mutex> lock(queue_state_mu);
- new_clip_changed.wait(lock, [this]{
+ clip_ready = new_clip_changed.wait_for(lock, milliseconds(100), [this]{
return new_clip_ready && current_clip.pts_in != -1;
});
new_clip_ready = false;
playing = true;
}
+ steady_clock::duration time_slept = steady_clock::now() - before_sleep;
+ pts += duration_cast<duration<size_t, TimebaseRatio>>(time_slept).count();
+
+ if (!clip_ready) {
+ if (video_stream != nullptr) {
+ video_stream->schedule_refresh_frame(pts);
+ }
+ continue;
+ }
+
Clip clip;
unsigned stream_idx;
{
double duration_next_clip = (next_clip.pts_out - next_clip.pts_in) / TIMEBASE / speed;
next_clip_fade_time = std::min(time_left_this_clip, duration_next_clip);
- fprintf(stderr, "decided on %.3f seconds fade time [%f %f]\n", next_clip_fade_time, time_left_this_clip, duration_next_clip);
}
}