summaryrefslogtreecommitdiff
path: root/src/buffer/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer/video.c')
-rw-r--r--src/buffer/video.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/buffer/video.c b/src/buffer/video.c
index 19d7aa7..9125dab 100644
--- a/src/buffer/video.c
+++ b/src/buffer/video.c
@@ -178,7 +178,8 @@ void camu_video_buffer_push(struct camu_video_buffer *buf, struct camu_codec_fra
if (flow != FLOWING) {
// A static buffer will be FLUSHED after any push().
if (buf->is_static) {
- log_error("Unexpected duplicate frame received.");
+ log_error("Expected a single frame, but received another.");
+ atomic_store(u32)(&buf->flow, FLUSHED_ERROR, AL_ATOMIC_RELEASE);
}
camu_codec_frame_discard(frame);
return;
@@ -214,7 +215,7 @@ void camu_video_buffer_push(struct camu_video_buffer *buf, struct camu_codec_fra
}
buf->buffered = true;
buf->buffered_with_one_frame = count == 1;
- log_debug("Buffered (mark: %.2fs).", count * buf->avg_frame_duration);
+ log_debug("Buffered (%.2fs).", count * buf->avg_frame_duration);
buf->callback(buf->userdata, CAMU_BUFFER_BUFFERED);
} else if (count >= BUFFER_MARK_HIGH) {
buf->callback(buf->userdata, CAMU_BUFFER_CORK);
@@ -234,14 +235,16 @@ void camu_video_buffer_push_subtitle(struct camu_video_buffer *buf, struct camu_
void camu_video_buffer_flush(struct camu_video_buffer *buf, bool error)
{
log_debug("Flush requested.");
- u8 flow = error ? FLUSHED_ERROR : FLUSHED;
- atomic_store(u32)(&buf->flow, flow, AL_ATOMIC_RELAXED);
+ u8 flow = atomic_load(u32)(&buf->flow, AL_ATOMIC_ACQUIRE);
+ error |= flow == FLUSHED_ERROR;
+ flow = error ? FLUSHED_ERROR : FLUSHED;
+ atomic_store(u32)(&buf->flow, flow, AL_ATOMIC_RELEASE);
u32 count;
buf->queue->flush(buf->queue, &count);
if (!buf->buffered) {
buf->buffered = true;
buf->buffered_with_one_frame = count == 1;
- log_debug("Buffered (mark: %.2fs).", count * buf->avg_frame_duration);
+ log_debug("Buffered (%.2fs).", count * buf->avg_frame_duration);
buf->callback(buf->userdata, CAMU_BUFFER_BUFFERED);
}
}
@@ -266,8 +269,7 @@ bool camu_video_buffer_read(struct camu_video_buffer *buf, void *out, bool *weig
f64 base_pts = atomic_load(f64)(&buf->pts, AL_ATOMIC_ACQUIRE);
if (!buf->is_static) {
bool allow_set = !buf->weighted_first_read;
- bool armed_for_pause = false;
- f64 pts = camu_clock_get_pts(buf->clock, buf->latency, allow_set, &armed_for_pause);
+ f64 pts = camu_clock_get_pts(buf->clock, buf->latency, allow_set, NULL);
if (!CAMU_PTS_CONSIDER_PAUSED(pts) && pts > base_pts) {
base_pts = pts;
}