diff options
| author | 2025-04-17 10:03:43 -0400 | |
|---|---|---|
| committer | 2025-04-17 10:03:43 -0400 | |
| commit | eccba12e1fe3c1b9510e274cd8ddfa94bba6f489 (patch) | |
| tree | 43cef769c453fcb3854f80cb5f1831d512098167 /src/buffer | |
| parent | ae8822ec0327c4d5674f1dc79de926b230f27f1f (diff) | |
| download | camu-eccba12e1fe3c1b9510e274cd8ddfa94bba6f489.tar.gz camu-eccba12e1fe3c1b9510e274cd8ddfa94bba6f489.tar.bz2 camu-eccba12e1fe3c1b9510e274cd8ddfa94bba6f489.zip | |
Implement logging changes and cleanup
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/buffer')
| -rw-r--r-- | src/buffer/audio.c | 24 | ||||
| -rw-r--r-- | src/buffer/video.c | 20 |
2 files changed, 22 insertions, 22 deletions
diff --git a/src/buffer/audio.c b/src/buffer/audio.c index d6041e4..28209d7 100644 --- a/src/buffer/audio.c +++ b/src/buffer/audio.c @@ -64,7 +64,7 @@ bool camu_audio_buffer_configure(struct camu_audio_buffer *buf, struct camu_code struct camu_audio_format *fmt = &stream->audio.fmt; const char *format_name = camu_audio_format_name(fmt->format); - info("Stream: %s (%dch) %dHz.", format_name, fmt->channel_count, fmt->sample_rate); + log_info("Stream: %s (%dch) %dHz.", format_name, fmt->channel_count, fmt->sample_rate); struct camu_audio_format *in = &buf->fmt.in; struct camu_audio_format *req = &buf->fmt.req; @@ -82,7 +82,7 @@ bool camu_audio_buffer_configure(struct camu_audio_buffer *buf, struct camu_code return false; #endif const char *req_format_name = camu_audio_format_name(req->format); - info("Resampling to: %s (%dch) %dHz.", req_format_name, req->channel_count, req->sample_rate); + log_info("Resampling to: %s (%dch) %dHz.", req_format_name, req->channel_count, req->sample_rate); } buf->size = (ptrdiff_t)camu_audio_format_sec_to_bytes(req, BUFFER_SIZE); @@ -151,7 +151,7 @@ static bool push_internal(struct camu_audio_buffer *buf, f64 pts, u8 **data, s32 // The maximum space is buf->size - 1. ptrdiff_t space = al_ring_buffer_space(&buf->rb); if (!buf->buffered && (buf->size - 1) - space >= buf->mark.buffered) { - debug("Buffered (mark: %.1fKB).", buf->mark.buffered / 1024.0); + log_debug("Buffered (mark: %.1fKB).", buf->mark.buffered / 1024.0); buf->callback(buf->userdata, CAMU_BUFFER_BUFFERED); buf->buffered = true; } @@ -164,7 +164,7 @@ static bool push_internal(struct camu_audio_buffer *buf, f64 pts, u8 **data, s32 peak += have; if (peak >= buf->mark.min) { // If this happens the writer of this buffer is taking way too long to stop. - warn("Overrun likely, discarding peak buffer (audio will be desynced)."); + log_warn("Overrun likely, discarding peak buffer (audio will be desynced)."); camu_peak_buffer_flush(&buf->peak); peak = 0; } @@ -220,12 +220,12 @@ void camu_audio_buffer_push(struct camu_audio_buffer *buf, struct camu_codec_fra // flush() always comes from the same thread as push(). void camu_audio_buffer_flush(struct camu_audio_buffer *buf) { - debug("Flush requested."); + log_debug("Flush requested."); if (!push_internal(buf, 0.0, NULL, 0)) { - debug("Buffer filled by flush."); + log_debug("Buffer filled by flush."); } if (!buf->buffered) { - debug("Buffered (flush)."); + log_debug("Buffered (flush)."); buf->callback(buf->userdata, CAMU_BUFFER_BUFFERED); buf->buffered = true; } @@ -307,7 +307,7 @@ ptrdiff_t camu_audio_buffer_read(struct camu_audio_buffer *buf, u8 *data, ptrdif if (!buf->ignore_desync && al_atomic_load(u32)(&buf->unpause, AL_ATOMIC_ACQUIRE) > 0) { // Queuing multiple resyncs before resuming the stream will cause pops! - info("Forcing resync."); + log_info("Forcing resync."); buf->pause = PAUSE_PAUSED; al_atomic_sub(u32)(&buf->unpause, 1, AL_ATOMIC_RELEASE); } @@ -329,7 +329,7 @@ ptrdiff_t camu_audio_buffer_read(struct camu_audio_buffer *buf, u8 *data, ptrdif pts -= base_pts; if (pts > 0.0) { // Skip. ret = MIN((ptrdiff_t)camu_audio_format_sec_to_bytes(fmt, pts), have); - info("Skipping %fs of audio (%zd bytes).", pts, ret); + log_info("Skipping %fs of audio (%zd bytes).", pts, ret); ret = al_ring_buffer_discard(&buf->rb, ret); have -= ret; base_pts += camu_audio_format_bytes_to_sec(fmt, ret); @@ -338,7 +338,7 @@ ptrdiff_t camu_audio_buffer_read(struct camu_audio_buffer *buf, u8 *data, ptrdif pts = -pts; ret = MIN((ptrdiff_t)camu_audio_format_sec_to_bytes(fmt, pts), req); if (!buf->logged_delay) { - info("Delaying audio by %fs.", pts); + log_info("Delaying audio by %fs.", pts); buf->logged_delay = true; } al_memset(data, 0, ret); @@ -367,7 +367,7 @@ ptrdiff_t camu_audio_buffer_read(struct camu_audio_buffer *buf, u8 *data, ptrdif // enough for this request. if (have < req) { signal = have; - debug("Flushed (signal: %zd).", signal); + log_debug("Flushed (signal: %zd).", signal); buf->callback(buf->userdata, CAMU_BUFFER_EOF); al_atomic_store(u8)(&buf->flow, SIGNALED, AL_ATOMIC_RELEASE); } @@ -378,7 +378,7 @@ ptrdiff_t camu_audio_buffer_read(struct camu_audio_buffer *buf, u8 *data, ptrdif // We hit an underrun because data wasn't coming in fast enough. // An underrun can also happen in the audio output if read() (this function) // takes too long. That isn't checked here. - warn("Underrun (req: %zd, have: %zd).", req, have); + log_warn("Underrun (req: %zd, have: %zd).", req, have); // If we have data by the next read(), try to skip ahead to maintain sync. // This might exacerbate the underrun issue but an underrun is already // unexpected behavior, trying to stay in sync comes first. diff --git a/src/buffer/video.c b/src/buffer/video.c index 486a93d..783fea0 100644 --- a/src/buffer/video.c +++ b/src/buffer/video.c @@ -51,7 +51,7 @@ bool camu_video_buffer_configure(struct camu_video_buffer *buf, struct camu_code switch (stream->mode) { case CAMU_NORMAL: { buf->single_frame = true; - info("Stream: %s (%ux%u) IMAGE.", format_name, fmt->width, fmt->height); + log_info("Stream: %s (%ux%u) IMAGE.", format_name, fmt->width, fmt->height); break; } #ifdef CAMU_HAVE_FFMPEG @@ -59,10 +59,10 @@ bool camu_video_buffer_configure(struct camu_video_buffer *buf, struct camu_code AVRational frame_rate = stream->av.stream->avg_frame_rate; buf->single_frame = stream->duration == 0 || frame_rate.den == 0; if (buf->single_frame) { - info("Stream: %s (%ux%u) IMAGE.", format_name, fmt->width, fmt->height); + log_info("Stream: %s (%ux%u) IMAGE.", format_name, fmt->width, fmt->height); } else { buf->avg_frame_duration = (frame_rate.den > 0) ? av_q2d(av_inv_q(frame_rate)) : 0.0; - info("Stream: %s (%ux%u) VIDEO %.3ffps.", format_name, fmt->width, fmt->height, av_q2d(frame_rate)); + log_info("Stream: %s (%ux%u) VIDEO %.3ffps.", format_name, fmt->width, fmt->height, av_q2d(frame_rate)); } break; } @@ -90,7 +90,7 @@ bool camu_video_buffer_configure(struct camu_video_buffer *buf, struct camu_code return false; #endif const char *req_format_name = camu_pixel_format_name(req->format); - info("Scaling to: %s (%ux%u).", req_format_name, req->width, req->height); + log_info("Scaling to: %s (%ux%u).", req_format_name, req->width, req->height); } else { buf->fmt.scaler_needed = false; camu_video_format_copy(req, in); @@ -123,10 +123,10 @@ static void after_push_internal(struct camu_video_buffer *buf) } buf->buffered = true; buf->buffered_with_one_frame = count == 1; - debug("Buffered (mark: %.2fs).", have); + log_debug("Buffered (mark: %.2fs).", have); buf->callback(buf->userdata, CAMU_BUFFER_BUFFERED); } else if (have >= BUFFER_MARK_RESET) { - warn("Buffer overflow, resetting."); + log_warn("Buffer overflow, resetting."); buf->queue->reset(buf->queue); } else if (have >= BUFFER_MARK_HIGH) { buf->callback(buf->userdata, CAMU_BUFFER_CORK); @@ -196,7 +196,7 @@ void camu_video_buffer_push_subtitle(struct camu_video_buffer *buf, struct camu_ // flush() always comes from the same thread as push(). void camu_video_buffer_flush(struct camu_video_buffer *buf) { - debug("Flush requested."); + log_debug("Flush requested."); al_atomic_store(u8)(&buf->flow, FLUSHED, AL_ATOMIC_RELAXED); buf->queue->flush(buf->queue); if (!buf->buffered) { @@ -204,7 +204,7 @@ void camu_video_buffer_flush(struct camu_video_buffer *buf) f64 have = count * buf->avg_frame_duration; buf->buffered = true; buf->buffered_with_one_frame = count == 1; - debug("Buffered (mark: %.2fs).", have); + log_debug("Buffered (mark: %.2fs).", have); buf->callback(buf->userdata, CAMU_BUFFER_BUFFERED); } } @@ -243,7 +243,7 @@ bool camu_video_buffer_read(struct camu_video_buffer *buf, void *out, bool *weig // In our code that 1 frame buffer might be a video, in which case that behavior is erroneous. bool eof = ret == CAMU_QUEUE_EOF || (buf->buffered_with_one_frame && ret == CAMU_QUEUE_OK); if (flow == FLUSHED && eof) { - debug("Flushed."); + log_debug("Flushed."); buf->callback(buf->userdata, CAMU_BUFFER_EOF); al_atomic_store(u8)(&buf->flow, SIGNALED, AL_ATOMIC_RELEASE); } else if (flow == FLOWING) { @@ -258,7 +258,7 @@ bool camu_video_buffer_read(struct camu_video_buffer *buf, void *out, bool *weig *weighted = buf->weighted_read; buf->weighted_read = false; } else if (ret == CAMU_QUEUE_MORE) { - trace("Underrun."); + log_trace("Underrun."); } return ret == CAMU_QUEUE_OK || ret == CAMU_QUEUE_MORE; |