break;
}
- // If the queue is full (which is really the state we'd like to be in),
- // wait until there's room for one more frame (ie., one was output from
- // VideoStream), or until or until there's a new clip we're supposed to play.
{
unique_lock<mutex> lock(queue_state_mu);
- new_clip_changed.wait(lock, [this]{
- if (video_stream != nullptr && num_queued_frames < max_queued_frames) {
- return true;
- }
- return new_clip_ready || override_stream_idx != -1;
- });
+ if (video_stream == nullptr) {
+ // No queue, just wait until the right time and then show the frame.
+ new_clip_changed.wait_until(lock, next_frame_start, [this]{
+ return new_clip_ready || override_stream_idx != -1;
+ });
+ } else {
+ // If the queue is full (which is really the state we'd like to be in),
+ // wait until there's room for one more frame (ie., one was output from
+ // VideoStream), or until or until there's a new clip we're supposed to play.
+ //
+ // In this case, we don't sleep until next_frame_start; the displaying is
+ // done by the queue.
+ new_clip_changed.wait(lock, [this]{
+ if (num_queued_frames < max_queued_frames) {
+ return true;
+ }
+ return new_clip_ready || override_stream_idx != -1;
+ });
+ }
if (new_clip_ready) {
if (video_stream != nullptr) {
lock.unlock(); // Urg.
video_stream->clear_queue();
lock.lock();
}
+ got_next_clip = false;
goto wait_for_clip;
}
if (override_stream_idx != -1) {
if (in_pts_lower == in_pts_upper) {
auto display_func = [this, primary_stream_idx, in_pts_lower, secondary_stream_idx, secondary_pts, fade_alpha]{
- destination->setFrame(primary_stream_idx, in_pts_lower, /*interpolated=*/false, secondary_stream_idx, secondary_pts, fade_alpha);
+ destination->setFrame(primary_stream_idx, in_pts_lower, secondary_stream_idx, secondary_pts, fade_alpha);
};
if (video_stream == nullptr) {
display_func();
next_frame_start, pts, display_func, QueueSpotHolder(this),
primary_stream_idx, in_pts_lower);
} else {
+ assert(secondary_pts != -1);
video_stream->schedule_faded_frame(next_frame_start, pts, display_func,
QueueSpotHolder(this), primary_stream_idx, in_pts_lower,
secondary_stream_idx, secondary_pts, fade_alpha);
double snap_pts_as_frameno = (snap_pts - in_pts_origin) * output_framerate / TIMEBASE / speed;
if (fabs(snap_pts_as_frameno - frameno) < 0.01) {
auto display_func = [this, primary_stream_idx, snap_pts, secondary_stream_idx, secondary_pts, fade_alpha]{
- destination->setFrame(primary_stream_idx, snap_pts, /*interpolated=*/false, secondary_stream_idx, secondary_pts, fade_alpha);
+ destination->setFrame(primary_stream_idx, snap_pts, secondary_stream_idx, secondary_pts, fade_alpha);
};
if (video_stream == nullptr) {
display_func();
next_frame_start, pts, display_func,
QueueSpotHolder(this), primary_stream_idx, snap_pts);
} else {
+ assert(secondary_pts != -1);
video_stream->schedule_faded_frame(
next_frame_start, pts, display_func, QueueSpotHolder(this),
primary_stream_idx, snap_pts, secondary_stream_idx, secondary_pts, fade_alpha);
if (video_stream == nullptr) {
// Previews don't do any interpolation.
assert(secondary_stream_idx == -1);
- destination->setFrame(primary_stream_idx, in_pts_lower, /*interpolated=*/false);
+ destination->setFrame(primary_stream_idx, in_pts_lower);
} else {
- auto display_func = [this, primary_stream_idx, pts, secondary_stream_idx, secondary_pts, fade_alpha]{
- destination->setFrame(primary_stream_idx, pts, /*interpolated=*/true, secondary_stream_idx, secondary_pts, fade_alpha);
+ auto display_func = [this](shared_ptr<Frame> frame) {
+ destination->setFrame(frame);
};
video_stream->schedule_interpolated_frame(
next_frame_start, pts, display_func, QueueSpotHolder(this),
if (it == frames[stream_idx].end()) {
return;
}
- destination->setFrame(stream_idx, *it, /*interpolated=*/false);
+ destination->setFrame(stream_idx, *it);
}
void Player::take_queue_spot()