summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buffer/audio.c24
-rw-r--r--src/buffer/video.c20
-rw-r--r--src/cache/handle.c14
-rw-r--r--src/cache/handlers/cdio.c22
-rw-r--r--src/cache/handlers/http.c10
-rw-r--r--src/codec/ffmpeg/avio.h2
-rw-r--r--src/codec/ffmpeg/common.c9
-rw-r--r--src/codec/ffmpeg/common.h1
-rw-r--r--src/codec/ffmpeg/decoder.c26
-rw-r--r--src/codec/ffmpeg/decoder.h1
-rw-r--r--src/codec/ffmpeg/demuxer.c18
-rw-r--r--src/codec/ffmpeg/demuxer.h3
-rw-r--r--src/codec/ffmpeg/encoder.c21
-rw-r--r--src/codec/ffmpeg/encoder.h2
-rw-r--r--src/codec/ffmpeg/resampler.c17
-rw-r--r--src/codec/ffmpeg/resampler.h1
-rw-r--r--src/codec/ffmpeg/scaler.c14
-rw-r--r--src/codec/ffmpeg/scaler.h1
-rw-r--r--src/fruits/cmc/ui/ui.c2
-rw-r--r--src/fruits/cmv/cmv.c2
-rw-r--r--src/liana/client.c3
-rw-r--r--src/liana/handlers/cdio_server.c3
-rw-r--r--src/liana/vcr.c16
-rw-r--r--src/mixer/audio_miniaudio.c15
-rw-r--r--src/portal/cpy/lib.pxd8
-rw-r--r--src/portal/cpy/portal.pyx8
-rw-r--r--src/portal/cpy/setup.py2
-rw-r--r--src/portal/src/search.c16
-rw-r--r--src/render/queue_libplacebo.c19
-rw-r--r--src/render/renderer_libplacebo.c33
-rw-r--r--src/render/renderer_tiger.c11
-rw-r--r--src/screen/screen.c1
-rw-r--r--src/server/db.c5
-rw-r--r--src/util/color_palette.c14
34 files changed, 175 insertions, 189 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;
diff --git a/src/cache/handle.c b/src/cache/handle.c
index b6bbea0..dc974d3 100644
--- a/src/cache/handle.c
+++ b/src/cache/handle.c
@@ -12,7 +12,7 @@ static off_t wait_for_size(struct cch_handle *handle, struct cch_handler *handle
{
handle->wait.end = -1;
if (!handler->wait_for_range(handler, &handle->wait)) {
- trace("Wait for size failed.");
+ log_trace("Wait for size failed.");
return -1;
}
return cch_entry_get_size(handler->entry);
@@ -36,7 +36,7 @@ s32 cch_handle_read(struct cch_handle *handle, u8 *buf, s32 size)
handle->wait.start = handle->pointer;
handle->wait.end = handle->pointer + size;
if (!handler->wait_for_range(handler, &handle->wait)) {
- trace("Wait for range (%zd-%zd) failed.", handle->wait.start, handle->wait.end);
+ log_trace("Wait for range (%zd-%zd) failed.", handle->wait.start, handle->wait.end);
return CAMU_ERR_EOF;
}
struct cch_backing *backing = handle->entry->backing;
@@ -52,7 +52,7 @@ s32 cch_handle_read(struct cch_handle *handle, u8 *buf, s32 size)
backing->read(backing, buf, handle->pointer, &available);
}
handle->pointer += available;
- trace("read(%u), pointer: %zd.", size, handle->pointer);
+ log_trace("read(%u), pointer: %zd.", size, handle->pointer);
return (available > 0) ? (s32)available : CAMU_ERR_EOF;
}
@@ -63,26 +63,26 @@ off_t cch_handle_seek(struct cch_handle *handle, off_t offset, s32 whence)
if (filesize < 0) filesize = wait_for_size(handle, handler);
if (filesize <= 0) return -1;
if (whence == CAMU_SEEK_SIZE) {
- trace("SEEK_SIZE(), pointer: %zd, filesize: %zd.", handle->pointer, filesize);
+ log_trace("SEEK_SIZE(), pointer: %zd, filesize: %zd.", handle->pointer, filesize);
return filesize;
}
switch (whence) {
case SEEK_SET:
- trace("SEEK_SET(%zd, %d), pointer: %zd.", offset, whence, handle->pointer);
+ log_trace("SEEK_SET(%zd, %d), pointer: %zd.", offset, whence, handle->pointer);
if (offset > filesize || offset < 0) {
return -1;
}
handle->pointer = offset;
break;
case SEEK_CUR:
- trace("SEEK_CUR(%zd, %d), pointer: %zd.", offset, whence, handle->pointer);
+ log_trace("SEEK_CUR(%zd, %d), pointer: %zd.", offset, whence, handle->pointer);
if (handle->pointer + offset > filesize || handle->pointer + offset < 0) {
return -1;
}
handle->pointer += offset;
break;
case SEEK_END:
- trace("SEEK_END(%zd, %d), pointer: %zd.", offset, whence, handle->pointer);
+ log_trace("SEEK_END(%zd, %d), pointer: %zd.", offset, whence, handle->pointer);
handle->pointer = filesize + offset;
break;
default:
diff --git a/src/cache/handlers/cdio.c b/src/cache/handlers/cdio.c
index 3eae813..e978343 100644
--- a/src/cache/handlers/cdio.c
+++ b/src/cache/handlers/cdio.c
@@ -16,13 +16,13 @@ static void cdio_log_messages(struct cch_handler_cdio *cdio)
{
char *error_messages = cdio_cddap_errors(cdio->drive);
if (error_messages) {
- error("\n%s", error_messages);
+ log_error("\n%s", error_messages);
cdio_cddap_free_messages(error_messages);
}
char *messages = cdio_cddap_messages(cdio->drive);
if (messages) {
- info("\n%s", messages);
+ log_info("\n%s", messages);
cdio_cddap_free_messages(messages);
}
}
@@ -51,18 +51,18 @@ static nn_thread_result NNWT_THREADCALL cd_read_thread(void *userdata)
size_t size;
u8 *ptr = cdio->backing->get_ptr(cdio->backing, pointer, &size);
if (size < BYTES_PER_STEP) {
- error("Tried to write over expected size during normal operation.");
+ log_error("Tried to write over expected size during normal operation.");
cdio->backing->unlock(cdio->backing);
break;
}
if (ret == SECTORS_PER_STEP) {
al_memcpy(ptr, nn_buffer_get_ptr(&cdio->buffer, 0), BYTES_PER_STEP);
} else if (ret == -10) {
- error("I/O error, skipping sector.");
+ log_error("I/O error, skipping sector.");
al_memset(ptr, 0, BYTES_PER_STEP);
ret = SECTORS_PER_STEP;
} else if (ret < 0) {
- error("Fatal error (%d).", ret);
+ log_error("Fatal error (%d).", ret);
cdio->backing->unlock(cdio->backing);
break;
}
@@ -71,13 +71,13 @@ static nn_thread_result NNWT_THREADCALL cd_read_thread(void *userdata)
cdio->backing->unlock(cdio->backing);
cch_threaded_waits_evaluate(&cdio->waits, cdio->backing);
if (ret < SECTORS_PER_STEP || cdio->sector > cdio->end) {
- debug("Normal CD EOF.");
+ log_debug("Normal CD EOF.");
break;
}
}
if (cdio->sector <= cdio->end) {
- warn("Disc read cut short (sectors: %zd, end: %zd).", cdio->sector, cdio->end);
+ log_warn("Disc read cut short (sectors: %zd, end: %zd).", cdio->sector, cdio->end);
// We didn't read the full disc, disable waiters.
cch_threaded_waits_disable_all(&cdio->waits);
}
@@ -135,7 +135,7 @@ static bool open_cd_drive(struct cch_handler_cdio *cdio)
cdio_handle = cdio_open(*cd_drives, DRIVER_UNKNOWN);
drive = cdio_cddap_identify_cdio(cdio_handle, CDDA_MESSAGE_LOGIT, NULL);
} else {
- error("No compatible disc found.");
+ log_error("No compatible disc found.");
return false;
}
cdio_free_device_list(cd_drives);
@@ -144,19 +144,19 @@ static bool open_cd_drive(struct cch_handler_cdio *cdio)
s32 ret = cdio_cddap_open(drive);
if (ret != 0) {
- error("Unable to open disc (%d).", ret);
+ log_error("Unable to open disc (%d).", ret);
return false;
}
ret = cdio_cddap_speed_set(drive, 4);
if (ret != 0) {
- warn("Failed to set drive speed (%d).", ret);
+ log_warn("Failed to set drive speed (%d).", ret);
}
track_t tracks = cdio_cddap_tracks(drive);
track_t first_track = cdio_get_first_track_num(drive->p_cdio);
track_t last_track = cdio_get_last_track_num(drive->p_cdio);
- info("CD with %d tracks loaded (%d-%d).", tracks, first_track, last_track);
+ log_info("CD with %d tracks loaded (%d-%d).", tracks, first_track, last_track);
al_array_reserve(cdio->handler.entry->chapters, tracks);
lsn_t start = cdio_cddap_disc_firstsector(drive);
diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c
index 6ff5a3c..08bd165 100644
--- a/src/cache/handlers/http.c
+++ b/src/cache/handlers/http.c
@@ -36,23 +36,23 @@ static void http_callback(void *userdata, u8 op, u8 *buf, void *opaque)
}
case NNWT_HTTP_RESPONSE_CODE: {
long response_code = *(long *)opaque;
- debug("HTTP %ld.", response_code);
+ log_debug("HTTP %ld.", response_code);
break;
}
case NNWT_HTTP_CONTENT_LENGTH: {
curl_off_t length = *(curl_off_t *)opaque;
- debug("Content-Length: %"CURL_FORMAT_CURL_OFF_T".", length);
+ log_debug("Content-Length: %"CURL_FORMAT_CURL_OFF_T".", length);
cch_entry_set_size(http->handler.entry, length);
cch_threaded_waits_signal_any(&http->waits);
break;
}
case NNWT_HTTP_REDIRECT: {
long response_code = *(long *)opaque;
- debug("Redirect %ld.", response_code);
+ log_debug("Redirect %ld.", response_code);
break;
}
case NNWT_HTTP_FINISHED:
- debug("Transfer finished.");
+ log_debug("Transfer finished.");
break;
case NNWT_HTTP_ERROR:
cch_threaded_waits_disable_all(&http->waits);
@@ -72,7 +72,7 @@ static void handler_http_maybe_spawn_worker(struct cch_handler *handler, size_t
nn_http_set_url(request, &http->url);
nn_http_set_user_agent(request, &USER_AGENT);
nn_http_request_stream(request, NNWT_HTTP_GET, http->loop, http_callback, http);
- debug("Spawning worker for %.*s.", al_str_x(&http->url));
+ log_debug("Spawning worker for %.*s.", al_str_x(&http->url));
}
static bool handler_http_wait_for_range(struct cch_handler *handler, struct cch_handler_wait *wait)
diff --git a/src/codec/ffmpeg/avio.h b/src/codec/ffmpeg/avio.h
index b57cbcf..04aeeb4 100644
--- a/src/codec/ffmpeg/avio.h
+++ b/src/codec/ffmpeg/avio.h
@@ -1,8 +1,6 @@
#pragma once
#include <al/types.h>
-#include <libavutil/error.h>
-#include <libavformat/avio.h>
s32 camu_avio_read(void *data, u8 *buf, s32 buf_size);
s64 camu_avio_seek(void *data, s64 offset, s32 whence);
diff --git a/src/codec/ffmpeg/common.c b/src/codec/ffmpeg/common.c
index 044908c..d96dc76 100644
--- a/src/codec/ffmpeg/common.c
+++ b/src/codec/ffmpeg/common.c
@@ -1,5 +1,6 @@
-#include <al/lib.h>
+#define AL_LOG_SECTION "ff"
#include <al/log.h>
+#include <al/lib.h>
#include <libavutil/log.h>
#include "common.h"
@@ -38,9 +39,9 @@ static void av_log_callback(void *userdata, s32 level, const char *fmt, va_list
if ((log_context.pos > 0 && *(offset - 1) == '\n') || log_context.pos >= AV_LOG_MAX_CHUNK) {
if (level <= AV_LOG_INFO) {
- al_log_info("ff", log_context.buf);
+ log_info(log_context.buf);
} else {
- al_log_debug("ff", log_context.buf);
+ log_debug(log_context.buf);
}
log_context.pos = 0;
}
@@ -53,6 +54,6 @@ void camu_ff_set_log_callback(void (*callback)(void *, s32, const char *, va_lis
void camu_ff_common_init(void)
{
- al_log_info("ff", "Using FFmpeg version "FFMPEG_VERSION".");
+ log_info("Using FFmpeg version "FFMPEG_VERSION".");
camu_ff_set_log_callback(av_log_callback);
}
diff --git a/src/codec/ffmpeg/common.h b/src/codec/ffmpeg/common.h
index 944f915..639ca38 100644
--- a/src/codec/ffmpeg/common.h
+++ b/src/codec/ffmpeg/common.h
@@ -1,7 +1,6 @@
#pragma once
#include <al/types.h>
-#include <al/log.h>
#include <libavutil/frame.h>
s64 camu_ff_frame_duration(AVFrame *frame);
diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c
index 17be6cc..1675433 100644
--- a/src/codec/ffmpeg/decoder.c
+++ b/src/codec/ffmpeg/decoder.c
@@ -31,7 +31,7 @@ static s32 init_hwframe_context(struct camu_ff_decoder *av, AVCodecContext *cont
{
AVBufferRef *hw_frames_ref;
if (!(hw_frames_ref = av_hwframe_ctx_alloc(hw_device_context))) {
- error("Failed to create hardware frame context.");
+ log_error("Failed to create hardware frame context.");
return -1;
}
@@ -45,7 +45,7 @@ static s32 init_hwframe_context(struct camu_ff_decoder *av, AVCodecContext *cont
s32 ret = av_hwframe_ctx_init(hw_frames_ref);
if (ret < 0) {
- error("Failed to initialize hardware frame context (%s).", av_err2str(ret));
+ log_error("Failed to initialize hardware frame context (%s).", av_err2str(ret));
av_buffer_unref(&hw_frames_ref);
return ret;
}
@@ -71,7 +71,7 @@ static enum AVPixelFormat get_hw_format(AVCodecContext *context, const enum AVPi
}
}
- error("Failed to get HW surface format.");
+ log_error("Failed to get HW surface format.");
return avcodec_default_get_format(context, pix_fmts);
}
@@ -82,7 +82,7 @@ static s32 init_hwdevice_context(struct camu_ff_decoder *av, AVCodecContext *con
s32 ret = av_hwdevice_ctx_create(&av->hw_context, av->hw_device_type, NULL, NULL, 0);
if (ret < 0) {
- error("Failed to create specified HW device.");
+ log_error("Failed to create specified HW device.");
return ret;
}
@@ -90,7 +90,7 @@ static s32 init_hwdevice_context(struct camu_ff_decoder *av, AVCodecContext *con
// Note that context->extra_hw_frames has the ability to cause corruption.
context->extra_hw_frames = 18;
- info("Using %s hardware decoding.", av_hwdevice_get_type_name(av->hw_device_type));
+ log_info("Using %s hardware decoding.", av_hwdevice_get_type_name(av->hw_device_type));
return ret;
}
@@ -182,7 +182,7 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
AVCodecParameters *codecpar = stream->av.stream->codecpar;
const AVCodec *codec = avcodec_find_decoder(codecpar->codec_id);
if (!codec) {
- error("Failed to find decoder.");
+ log_error("Failed to find decoder.");
goto err;
}
@@ -216,19 +216,19 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
}
if (av->hw_device_type == AV_HWDEVICE_TYPE_NONE) {
- warn("Hardware accelerated video decoding of %s not supported.", codec->name);
+ log_warn("Hardware accelerated video decoding of %s not supported.", codec->name);
}
}
#endif
av->codec_context = avcodec_alloc_context3(codec);
if (!av->codec_context) {
- error("Failed to alloc codec context.");
+ log_error("Failed to alloc codec context.");
goto err;
}
if (avcodec_parameters_to_context(av->codec_context, codecpar) < 0) {
- error("Failed to copy codec parameters.");
+ log_error("Failed to copy codec parameters.");
goto err;
}
@@ -262,20 +262,20 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
av->codec_context->thread_count = cpus;
// FF_THREAD_FRAME or FF_THREAD_SLICE.
av->codec_context->thread_type = FF_THREAD_FRAME;
- info("Using %i threads for decoder.", cpus);
+ log_info("Using %i threads for decoder.", cpus);
}
}
AVDictionary *opts = NULL;
s32 ret = avcodec_open2(av->codec_context, codec, &opts);
if (ret < 0) {
- error("Failed to open codec %s (%s).", codec->name, av_err2str(ret));
+ log_error("Failed to open codec %s (%s).", codec->name, av_err2str(ret));
goto err;
}
const char *long_name = codec->long_name ? codec->long_name : codec->name;
s64 kbps = (codecpar->bit_rate > 0) ? codecpar->bit_rate / 1000 : 0;
- info("Codec: %s (%s) %lldkbps.", codec->name, long_name, kbps);
+ log_info("Codec: %s (%s) %lldkbps.", codec->name, long_name, kbps);
av->callback = callback;
av->userdata = userdata;
@@ -290,7 +290,7 @@ static s32 send_packet(struct camu_ff_decoder *av, AVPacket *pkt)
{
s32 ret = avcodec_send_packet(av->codec_context, pkt);
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
- error("Error sending packet to the decoder (%s).", av_err2str(ret));
+ log_error("Error sending packet to the decoder (%s).", av_err2str(ret));
}
return ret;
}
diff --git a/src/codec/ffmpeg/decoder.h b/src/codec/ffmpeg/decoder.h
index c6fb5fc..ab60ef3 100644
--- a/src/codec/ffmpeg/decoder.h
+++ b/src/codec/ffmpeg/decoder.h
@@ -1,6 +1,5 @@
#pragma once
-#include <al/types.h>
#include <libavcodec/avcodec.h>
#include "../codec.h"
diff --git a/src/codec/ffmpeg/demuxer.c b/src/codec/ffmpeg/demuxer.c
index b612b2d..cb2ed91 100644
--- a/src/codec/ffmpeg/demuxer.c
+++ b/src/codec/ffmpeg/demuxer.c
@@ -1,4 +1,6 @@
+#define AL_LOG_SECTION "ff_demuxer"
#include <al/log.h>
+#include <al/lib.h>
#include "demuxer.h"
#include "avio.h"
@@ -24,14 +26,14 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl
av->format_context = avformat_alloc_context();
if (!av->format_context) {
- al_log_error("ff_demuxer", "Failed to create format context.");
+ log_error("Failed to create format context.");
goto err;
}
u8 *buf = (u8 *)av_malloc(DEMUX_BUFFER_SIZE);
av->io_context = avio_alloc_context(buf, DEMUX_BUFFER_SIZE, 0, handle, camu_avio_read, NULL, camu_avio_seek);
if (!av->io_context) {
- al_log_error("ff_demuxer", "Failed to create custom io context.");
+ log_error("Failed to create custom io context.");
goto err;
}
@@ -56,7 +58,7 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl
// network streams sounds like something we want.
s32 ret = avformat_open_input(&av->format_context, "file:", NULL, &opts);
if (ret < 0) {
- al_log_error("ff_demuxer", "Failed to open input (%s).", av_err2str(ret));
+ log_error("Failed to open input (%s).", av_err2str(ret));
av_dict_free(&opts);
goto err;
}
@@ -64,12 +66,12 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl
av_dict_free(&opts);
if (avformat_find_stream_info(av->format_context, NULL) < 0) {
- al_log_error("ff_demuxer", "Failed to find stream info.");
+ log_error("Failed to find stream info.");
goto err;
}
if (!av->format_context->nb_streams) {
- al_log_error("ff_demuxer", "No streams found.");
+ log_error("No streams found.");
goto err;
}
@@ -86,12 +88,12 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl
if (type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_SUBTITLE) {
// Try to detect attached images.
if (type == AVMEDIA_TYPE_VIDEO && GUESS_STREAM_IS_IMAGE(stream)) {
- al_log_info("ff_demuxer", "Assuming stream #%u is an image.", i);
+ log_info("Assuming stream #%u is an image.", i);
} else {
if (stream->duration < 0) {
stream->duration = av_rescale_q(default_duration, AV_TIME_BASE_Q, stream->time_base);
al_assert(stream->duration >= 0);
- al_log_info("ff_demuxer", "Stream #%u has an invalid duration, defaulting to %.3fs.",
+ log_info("Stream #%u has an invalid duration, defaulting to %.3fs.",
i, stream->duration * av_q2d(stream->time_base));
}
duration = (u64)av_rescale_q(stream->duration, stream->time_base, AV_TIME_BASE_Q);
@@ -140,7 +142,7 @@ static s32 ff_demuxer_get_packet(struct camu_demuxer *demux, struct camu_codec_p
break;
}
if (ret < 0) {
- al_log_error("ff_demuxer", "Failed to read frame (%s).", av_err2str(ret));
+ log_error("Failed to read frame (%s).", av_err2str(ret));
break;
}
if (!subscribed_to_index(demux, pkt->stream_index)) {
diff --git a/src/codec/ffmpeg/demuxer.h b/src/codec/ffmpeg/demuxer.h
index 8066513..378c5bb 100644
--- a/src/codec/ffmpeg/demuxer.h
+++ b/src/codec/ffmpeg/demuxer.h
@@ -1,8 +1,5 @@
#pragma once
-#include <al/types.h>
-#include <al/lib.h>
-#include <al/array.h>
#include <libavformat/avformat.h>
#include "../codec.h"
diff --git a/src/codec/ffmpeg/encoder.c b/src/codec/ffmpeg/encoder.c
index 0577ae9..50e80e4 100644
--- a/src/codec/ffmpeg/encoder.c
+++ b/src/codec/ffmpeg/encoder.c
@@ -1,13 +1,6 @@
-#include <al/lib.h>
+#define AL_LOG_SECTION "ff_encoder"
#include <al/log.h>
-#include <libavcodec/avcodec.h>
-#include <libavcodec/codec.h>
-#include <libavformat/avformat.h>
-#include <libavutil/audio_fifo.h>
-#include <libavutil/channel_layout.h>
-#include <libavutil/error.h>
-#include <libavutil/frame.h>
-#include <libavutil/samplefmt.h>
+#include <al/lib.h>
#include "encoder.h"
@@ -27,14 +20,14 @@ bool camu_ff_encoder_init(struct camu_ff_encoder *enc, char *encoder_name, char
const AVCodec *codec = avcodec_find_encoder_by_name(encoder_name);
if (!codec) {
- al_log_error("ff_encoder", "Failed to find codec by name %s.", encoder_name);
+ log_error("Failed to find codec by name %s.", encoder_name);
goto err;
}
enc->codec_context = avcodec_alloc_context3(codec);
if (!enc->codec_context) {
- al_log_error("ff_encoder", "Failed to alloc codec context.");
+ log_error("Failed to alloc codec context.");
goto err;
}
@@ -61,7 +54,7 @@ bool camu_ff_encoder_init(struct camu_ff_encoder *enc, char *encoder_name, char
av_dict_set(&opts, "application", "audio", 0);
if (avcodec_open2(enc->codec_context, codec, &opts) < 0) {
- al_log_error("ff_encoder", "Failed to open codec.");
+ log_error("Failed to open codec.");
av_dict_free(&opts);
goto err;
}
@@ -95,7 +88,7 @@ void camu_ff_encoder_push(struct camu_ff_encoder *enc, u8 **data, s32 sample_cou
enc->frame->data[0] = data[0];
s32 ret = avcodec_send_frame(enc->codec_context, enc->frame);
if (ret < 0 && ret != AVERROR_EOF) {
- al_log_error("ff_encoder", "Error sending frame to the encoder (%s).", av_err2str(ret));
+ log_error("Error sending frame to the encoder (%s).", av_err2str(ret));
return;
}
AVPacket pkt = { 0 };
@@ -103,7 +96,7 @@ void camu_ff_encoder_push(struct camu_ff_encoder *enc, u8 **data, s32 sample_cou
ret = avcodec_receive_packet(enc->codec_context, &pkt);
if (ret < 0) {
if (!(ret = AVERROR_EOF || ret == AVERROR(EAGAIN))) {
- al_log_error("ff_encoder", "Error receiving packet from the encoder (%s).", av_err2str(ret));
+ log_error("Error receiving packet from the encoder (%s).", av_err2str(ret));
}
return;
}
diff --git a/src/codec/ffmpeg/encoder.h b/src/codec/ffmpeg/encoder.h
index 238403f..5f7d06f 100644
--- a/src/codec/ffmpeg/encoder.h
+++ b/src/codec/ffmpeg/encoder.h
@@ -2,8 +2,6 @@
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
-#include <libavutil/audio_fifo.h>
-#include <libavutil/rational.h>
#include "../codec.h"
diff --git a/src/codec/ffmpeg/resampler.c b/src/codec/ffmpeg/resampler.c
index 61e8c9e..eacc75b 100644
--- a/src/codec/ffmpeg/resampler.c
+++ b/src/codec/ffmpeg/resampler.c
@@ -1,10 +1,7 @@
-#include <al/lib.h>
+#define AL_LOG_SECTION "ff_resampler"
#include <al/log.h>
-#include <libavutil/channel_layout.h>
-#include <libavutil/frame.h>
-#include <libavutil/samplefmt.h>
+#include <al/lib.h>
#include <libavutil/opt.h>
-#include <libswresample/swresample.h>
#include "resampler.h"
@@ -19,19 +16,19 @@ static bool ff_resampler_init(struct camu_resampler *resamp, struct camu_resampl
&fmt->req.channel_layout, fmt->req.format, fmt->req.sample_rate,
&fmt->in.channel_layout, fmt->in.format, fmt->in.sample_rate, 0, NULL);
if (ret != 0) {
- al_log_error("ff_resampler", "Failed to configure resampler context.");
+ log_error("Failed to configure resampler context.");
return false;
}
#ifdef CAMU_HAVE_SOXR
// Slower but more accurate resampler.
av_opt_set_int(av->resample_context, "resampler", SWR_ENGINE_SOXR, 0);
- al_log_info("ff_resampler", "Using SoX resampler.");
+ log_info("Using SoX resampler.");
#endif
if (swr_init(av->resample_context) != 0) {
swr_free(&av->resample_context);
- al_log_error("ff_resampler", "Failed to init resampler context.");
+ log_error("Failed to init resampler context.");
return false;
}
@@ -61,7 +58,7 @@ static s32 ff_resampler_convert(struct camu_resampler *resamp, const u8 **in_dat
s32 resample_count = swr_convert(av->resample_context, av->data,
out_resample_count, in_data, in_samples);
if (resample_count < 0) {
- al_log_error("ff_resampler", "Failed to convert samples (%d).", resample_count);
+ log_error("Failed to convert samples (%d).", resample_count);
}
return resample_count;
}
@@ -73,7 +70,7 @@ static s32 ff_resampler_flush(struct camu_resampler *resamp)
av->sample_count, NULL, 0);
if (swr_init(av->resample_context) != 0) {
swr_free(&av->resample_context);
- al_log_error("ff_resampler", "Failed to re-init resampler context after flush.");
+ log_error("Failed to re-init resampler context after flush.");
return -1;
}
return resample_count;
diff --git a/src/codec/ffmpeg/resampler.h b/src/codec/ffmpeg/resampler.h
index 35e1158..fc89cb4 100644
--- a/src/codec/ffmpeg/resampler.h
+++ b/src/codec/ffmpeg/resampler.h
@@ -1,6 +1,5 @@
#pragma once
-#include <al/types.h>
#include <libswresample/swresample.h>
#include "../codec.h"
diff --git a/src/codec/ffmpeg/scaler.c b/src/codec/ffmpeg/scaler.c
index a76c0a5..93bbac6 100644
--- a/src/codec/ffmpeg/scaler.c
+++ b/src/codec/ffmpeg/scaler.c
@@ -1,7 +1,7 @@
-#include <al/lib.h>
+#define AL_LOG_SECTION "ff_scaler"
#include <al/log.h>
+#include <al/lib.h>
#include <libavutil/imgutils.h>
-#include <libavcodec/avcodec.h>
#include "scaler.h"
@@ -11,7 +11,7 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, s32 width, s32 height)
if (!frame) return NULL;
s32 ret = av_image_alloc(frame->data, frame->linesize, width, height, pix_fmt, 32);
if (ret < 0) {
- al_log_error("ff_scaler", "Failed to allocate picture buffer (%s).", av_err2str(ret));
+ log_error("Failed to allocate picture buffer (%s).", av_err2str(ret));
return NULL;
}
/*
@@ -23,7 +23,7 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, s32 width, s32 height)
}
s32 ret = av_image_fill_arrays(frame->data, frame->linesize, buffer, pix_fmt, width, height, 1);
if (ret < 0) {
- al_log_error("ff_scaler", "Failed to allocate picture buffer (%s).", av_err2str(ret));
+ log_error("Failed to allocate picture buffer (%s).", av_err2str(ret));
av_free(frame);
return NULL;
}
@@ -45,14 +45,14 @@ static bool ff_scaler_init(struct camu_scaler *scale, struct camu_scaler_format
av->scaler_context = sws_getContext(fmt->in.width, fmt->in.height, fmt->in.format,
fmt->req.width, fmt->req.height, fmt->req.format, flags, NULL, NULL, NULL);
if (!av->scaler_context) {
- al_log_error("ff_scaler", "Failed to create scaler context.");
+ log_error("Failed to create scaler context.");
return false;
}
struct camu_codec_frame *frame = &av->frame;
frame->av.frame = alloc_picture(fmt->req.format, fmt->req.width, fmt->req.height);
if (!frame->av.frame) {
- al_log_error("ff_scaler", "Failed to allocate frame.");
+ log_error("Failed to allocate frame.");
return false;
}
@@ -68,7 +68,7 @@ static bool ff_scaler_scale(struct camu_scaler *scale, const u8 **in_slice, s32
s32 ret = sws_scale(av->scaler_context, in_slice, in_strides, 0,
slice_height, frame->data, frame->linesize);
if (ret != (s32)fmt->req.height) {
- al_log_error("ff_scaler", "Failed to scale frame (%s).", av_err2str(ret));
+ log_error("Failed to scale frame (%s).", av_err2str(ret));
return false;
}
return true;
diff --git a/src/codec/ffmpeg/scaler.h b/src/codec/ffmpeg/scaler.h
index f01f3fd..afd6aaf 100644
--- a/src/codec/ffmpeg/scaler.h
+++ b/src/codec/ffmpeg/scaler.h
@@ -1,6 +1,5 @@
#pragma once
-#include <al/types.h>
#include <libswscale/swscale.h>
#include "../codec.h"
diff --git a/src/fruits/cmc/ui/ui.c b/src/fruits/cmc/ui/ui.c
index b830042..88c9c5d 100644
--- a/src/fruits/cmc/ui/ui.c
+++ b/src/fruits/cmc/ui/ui.c
@@ -1,5 +1,5 @@
-#include <al/lib.h>
#include <al/log.h>
+#include <al/lib.h>
#include "ui.h"
#include "ext.h"
diff --git a/src/fruits/cmv/cmv.c b/src/fruits/cmv/cmv.c
index 834e95a..7fc6baa 100644
--- a/src/fruits/cmv/cmv.c
+++ b/src/fruits/cmv/cmv.c
@@ -251,7 +251,7 @@ s32 main(s32 argc, char *argv[])
str arg;
#ifdef NAUNET_ON_WINDOWS
if (!al_str_from_wstr(&arg, &al_wstr_cr(argv[i]))) {
- error("Failed to convert argument #%i from a wide string.", i);
+ log_error("Failed to convert argument #%i from a wide string.", i);
continue;
}
#else
diff --git a/src/liana/client.c b/src/liana/client.c
index 0aec3e5..d926f9e 100644
--- a/src/liana/client.c
+++ b/src/liana/client.c
@@ -1,3 +1,4 @@
+#define AL_LOG_SECTION "liana"
#include <al/log.h>
#include <nnwt/multiplex.h>
@@ -185,7 +186,7 @@ static bool connection_callback(void *userdata, struct nn_packet_stream *stream)
};
if (rec.unconfigured) {
al_assert(client->connection_id == 0);
- al_log_warn("liana", "Handling reconnect on unconfigured client.");
+ log_warn("Handling reconnect on unconfigured client.");
}
client->callback(client->userdata, LIANA_CLIENT_RECONNECTED, NULL, &rec);
} else {
diff --git a/src/liana/handlers/cdio_server.c b/src/liana/handlers/cdio_server.c
index 6ea1422..e1d574d 100644
--- a/src/liana/handlers/cdio_server.c
+++ b/src/liana/handlers/cdio_server.c
@@ -1,3 +1,4 @@
+#define AL_LOG_SECTION "cdio"
#include <al/log.h>
#include "../../cache/entry.h"
@@ -51,7 +52,7 @@ static u64 cdio_server_get_duration(struct lia_server_handler *handler)
struct cch_chapter *first = &al_array_at(cdio->handle->entry->chapters, 0);
struct cch_chapter *last = &al_array_last(cdio->handle->entry->chapters);
u64 length = camu_audio_format_bytes_to_usec(&cdio->fmt, (last->end - first->start) * CDIO_CD_FRAMESIZE_RAW);
- al_log_info("cdio", "Length: %.2fs.", length / 1000000.0);
+ log_info("Length: %.2fs.", length / 1000000.0);
return length;
}
diff --git a/src/liana/vcr.c b/src/liana/vcr.c
index ef2406c..c3adddf 100644
--- a/src/liana/vcr.c
+++ b/src/liana/vcr.c
@@ -104,7 +104,7 @@ static nn_thread_result NNWT_THREADCALL vcr_track_thread(void *userdata)
// NULL packet means flush.
bool success = track->client->handle_packet(track->client, packet);
if (!success) {
- error("Error handling packet, exiting track thread.");
+ log_error("Error handling packet, exiting track thread.");
return_entire_cache(track);
track->cache.disabled = true;
nn_packet_cache_unlock(&track->cache);
@@ -220,7 +220,7 @@ static void cork_if_buffered(struct lia_vcr *vcr, u64 buffer)
if (vcr->expand == VCR_EXPAND_UNTOUCHED) {
vcr->mark.buffered = buffer * 2;
vcr->expand = VCR_EXPAND_GROWN;
- info("Expanded buffer to size %.2fMB.", vcr->mark.buffered / (f32)MB(1));
+ log_info("Expanded buffer to size %.2fMB.", vcr->mark.buffered / (f32)MB(1));
return;
} else if (vcr->expand == VCR_EXPAND_GROWN) {
vcr->mark.low = vcr->mark.buffered - MB(2);
@@ -253,7 +253,7 @@ static void update_metrics(struct lia_vcr *vcr, u32 size)
f32 kbps = (frame / 125.f) / (diff / 1000000.f);
f32 capacity = vcr->mark.buffered / (f32)MB(1);
f32 buffered = al_atomic_load(u64)(&vcr->count, AL_ATOMIC_RELAXED) / (f32)MB(1);
- info("Receiving packets at %.2fkbps (%.2f/%.2fMB).", kbps, buffered, capacity);
+ log_info("Receiving packets at %.2fkbps (%.2f/%.2fMB).", kbps, buffered, capacity);
}
}
@@ -267,7 +267,7 @@ void lia_vcr_push_packet(struct lia_vcr *vcr, struct nn_packet *packet)
update_metrics(vcr, size);
track = get_track_from_index(vcr, nn_packet_read_s32(packet));
if (!track) {
- debug("Received data from errored or unknown track.");
+ log_debug("Received data from errored or unknown track.");
break;
}
if (VCR_TRACK_THREADED(track)) {
@@ -284,7 +284,7 @@ void lia_vcr_push_packet(struct lia_vcr *vcr, struct nn_packet *packet)
return;
} else {
if (!track->client->handle_packet(track->client, packet)) {
- warn("Error handling non-buffered packet.");
+ log_warn("Error handling non-buffered packet.");
}
}
break;
@@ -296,13 +296,13 @@ void lia_vcr_push_packet(struct lia_vcr *vcr, struct nn_packet *packet)
#ifndef CAMU_DIRECT_MODE
nn_signal_stop(&vcr->signal);
#endif
- debug("Received EOF.");
+ log_debug("Received EOF.");
break;
case LIANA_PACKET_ERROR:
- warn("Unhandled error packet.");
+ log_warn("Unhandled error packet.");
break;
default:
- warn("Erroneous packet.");
+ log_warn("Erroneous packet.");
break;
}
nn_packet_stream_return_packet(vcr->data, packet);
diff --git a/src/mixer/audio_miniaudio.c b/src/mixer/audio_miniaudio.c
index 30a5b6b..7e31abf 100644
--- a/src/mixer/audio_miniaudio.c
+++ b/src/mixer/audio_miniaudio.c
@@ -1,3 +1,4 @@
+#define AL_LOG_SECTION "audio_miniaudio"
#include <al/log.h>
#if defined(__clang__) || defined(__GNUC__)
_Pragma("GCC diagnostic push") \
@@ -60,11 +61,11 @@ static void miniaudio_log_callback(void *userdata, u32 level, const char *messag
{
(void)userdata;
if (level == MA_LOG_LEVEL_ERROR) {
- al_log_error("audio_miniaudio", message);
+ log_error(message);
} else if (level == MA_LOG_LEVEL_WARNING) {
- al_log_warn("audio_miniaudio", message);
+ log_warn(message);
} else {
- al_log_debug("audio_miniaudio", message);
+ log_debug(message);
}
}
@@ -87,7 +88,7 @@ static bool audio_miniaudio_init(struct camu_audio *audio, str *name)
#endif
s32 ret = ma_context_init(backends, ARRAY_SIZE(backends), &ma->context_config, &ma->context);
if (ret != MA_SUCCESS) {
- al_log_error("audio_miniaudio", "Failed to initialize context (%d).", ret);
+ log_error("Failed to initialize context (%d).", ret);
return false;
}
ma->selected_device = NULL;
@@ -209,12 +210,12 @@ static bool audio_miniaudio_configure_stream(struct camu_audio *audio, void *opa
#endif
s32 ret = ma_device_init(&ma->context, &ma->config, &ma->device);
if (ret != MA_SUCCESS) {
- al_log_error("audio_miniaudio", "Failed to initialize device (%d).", ret);
+ log_error("Failed to initialize device (%d).", ret);
return false;
}
s32 format = camu_sample_format_from_miniaudio(ma->device.playback.internalFormat);
const char *format_name = camu_audio_format_name(format);
- al_log_info("audio_miniaudio", "Output: %s (%dch) %dHz.", format_name,
+ log_info("Output: %s (%dch) %dHz.", format_name,
ma->device.playback.internalChannels, ma->device.playback.internalSampleRate);
return true;
}
@@ -222,7 +223,7 @@ static bool audio_miniaudio_configure_stream(struct camu_audio *audio, void *opa
static u64 audio_miniaudio_get_latency(struct camu_audio *audio)
{
struct camu_audio_miniaudio *ma = (struct camu_audio_miniaudio *)audio;
- al_log_debug("audio_miniaudio", "periods: %u, period_size_in_frames: %u, sample_rate: %u.",
+ log_debug("periods: %u, period_size_in_frames: %u, sample_rate: %u.",
ma->device.playback.internalPeriods,
ma->device.playback.internalPeriodSizeInFrames,
ma->device.playback.internalSampleRate);
diff --git a/src/portal/cpy/lib.pxd b/src/portal/cpy/lib.pxd
index 5749141..6a5b69c 100644
--- a/src/portal/cpy/lib.pxd
+++ b/src/portal/cpy/lib.pxd
@@ -7,7 +7,7 @@ cdef extern from "<al/lib.h>":
void al_bzero(void *s, size_t n)
cdef extern from "<al/log.h>":
- s32 al_log_info(const char *ns, const char *, ...)
- s32 al_log_warn(const char *ns, const char *, ...)
- s32 al_log_error(const char *ns, const char *, ...)
- s32 al_log_debug(const char *ns, const char *, ...)
+ s32 log_info(const char *, ...)
+ s32 log_warn(const char *, ...)
+ s32 log_error(const char *, ...)
+ s32 log_debug(const char *, ...)
diff --git a/src/portal/cpy/portal.pyx b/src/portal/cpy/portal.pyx
index 22d2ef9..b9b6e8d 100644
--- a/src/portal/cpy/portal.pyx
+++ b/src/portal/cpy/portal.pyx
@@ -7,16 +7,16 @@ import sys
sys.path.append('./py')
cdef int log_info(char *message) except -1:
- return lib.al_log_info("portal", "%s", message)
+ return lib.log_info("%s", message)
cdef int log_warn(char *message) except -1:
- return lib.al_log_warn("portal", "%s", message)
+ return lib.log_warn("%s", message)
cdef int log_error(char *message) except -1:
- return lib.al_log_error("portal", "%s", message)
+ return lib.log_error("%s", message)
cdef int log_debug(char *message) except -1:
- return lib.al_log_debug("portal", "%s", message)
+ return lib.log_debug("%s", message)
def encode_str(str):
return str.encode('UTF-8')
diff --git a/src/portal/cpy/setup.py b/src/portal/cpy/setup.py
index 7267bff..d14068f 100644
--- a/src/portal/cpy/setup.py
+++ b/src/portal/cpy/setup.py
@@ -3,4 +3,4 @@ from Cython.Build import cythonize
from Cython.Compiler import Options
Options.embed = True
alabaster_inc = "../../../subprojects/libalabaster/include"
-cythonize([Extension("portal", ["./portal.pyx"], include_dirs=[alabaster_inc], extra_link_args=[])], language_level=3)
+cythonize([Extension("portal", ["./portal.pyx"], include_dirs=[alabaster_inc], extra_link_args=[], define_macros=[("AL_LOG_SECTION", "portal")])], language_level=3)
diff --git a/src/portal/src/search.c b/src/portal/src/search.c
index c66e7a8..81d1e72 100644
--- a/src/portal/src/search.c
+++ b/src/portal/src/search.c
@@ -20,12 +20,12 @@ bool camu_python_init(void)
PyStatus status = Py_PreInitialize(&pre_config);
if (PyStatus_Exception(status)) {
- error("Preinitialization failed.");
+ log_error("Preinitialization failed.");
return false;
}
if (PyImport_AppendInittab("portal", PyInit_portal) == -1) {
- error("Could not extend in-built modules table.");
+ log_error("Could not extend in-built modules table.");
return false;
}
@@ -34,7 +34,7 @@ bool camu_python_init(void)
PyObject *module = PyImport_ImportModule("portal");
if (!module) {
PyErr_Print();
- error("Could not import module.");
+ log_error("Could not import module.");
goto err;
}
@@ -73,7 +73,7 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
if (!have_python) {
// Defer python init.
if (!(have_python = camu_python_init())) {
- error("Failed to initialize python.");
+ log_error("Failed to initialize python.");
break;
}
}
@@ -96,9 +96,9 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
al_array_init(search->pages);
search->bridge = bridge;
al_array_push(bridge->searches, search);
- info("New search %x (%.*s).", result.id, al_str_x(&cmd->query));
+ log_info("New search %x (%.*s).", result.id, al_str_x(&cmd->query));
} else {
- info("Failed to create search (%.*s).", al_str_x(&cmd->query));
+ log_info("Failed to create search (%.*s).", al_str_x(&cmd->query));
}
al_str_free(&cmd->module);
al_str_free(&cmd->query);
@@ -112,7 +112,7 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
al_array_foreach_ptr(search->pages, j, page) {
if (page->num == cmd->num) break;
}
- info("Loading page %i (%.*s).", cmd->num, al_str_x(&search->query));
+ log_info("Loading page %i (%.*s).", cmd->num, al_str_x(&search->query));
if (portal_bridge_get_page(search, search->id, cmd->num) == -1) {
break;
}
@@ -124,7 +124,7 @@ static nn_thread_result NNWT_THREADCALL queue_thread(void *userdata)
}
}
} else {
- info("Requested search doesn't exist (id: %d).", search->id);
+ log_info("Requested search doesn't exist (id: %d).", search->id);
result.id = -1;
}
break;
diff --git a/src/render/queue_libplacebo.c b/src/render/queue_libplacebo.c
index 65a713e..dd62975 100644
--- a/src/render/queue_libplacebo.c
+++ b/src/render/queue_libplacebo.c
@@ -1,3 +1,4 @@
+#define AL_LOG_SECTION "frame_queue_libplacebo"
#include <al/lib.h>
#include <al/log.h>
#ifdef CAMU_HAVE_FFMPEG
@@ -17,12 +18,12 @@ static bool queue_lp_configure_subtitiles(struct camu_frame_queue *queue, u32 wi
if (!lq->ass) return false;
lq->ass_renderer = ass_renderer_init(lq->ass);
if (!lq->ass_renderer) {
- al_log_error("frame_queue_libplacebo", "Failed to initialize ass renderer.");
+ log_error("Failed to initialize ass renderer.");
return false;
}
lq->ass_track = ass_new_track(lq->ass);
if (!lq->ass_track) {
- al_log_error("frame_queue_libplacebo", "Failed to create ass track.");
+ log_error("Failed to create ass track.");
return false;
}
ass_set_frame_size(lq->ass_renderer, width, height);
@@ -67,7 +68,7 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src
pixel_stride = 1;
break;
default:
- al_log_error("frame_queue_libplacebo", "Unsuppored pixel format.");
+ log_error("Unsuppored pixel format.");
al_assert_and_return(false);
}
@@ -94,7 +95,7 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src
camu_codec_frame_discard(frame);
if (!ok) {
- al_log_error("frame_queue_libplacebo", "Failed to upload texture.");
+ log_error("Failed to upload texture.");
return false;
}
@@ -147,7 +148,7 @@ static struct camu_overlay_lp *create_subtitle_overlay(pl_gpu gpu, ASS_Image *as
.ptr = ass_frame->bitmap
));
if (!ok) {
- al_log_error("frame_queue_libplacebo", "Failed to upload subtitle bitmap.");
+ log_error("Failed to upload subtitle bitmap.");
continue;
}
@@ -222,7 +223,7 @@ static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *
// https://github.com/streetpea/chiaki-ng/blob/dd145ec2c802814e98fb833d3a9692169aa67315/gui/src/qmlbackend.cpp#L786
if (!ok && frame->hw_frames_ctx) {
if (!lq->copy_frame_fallback) {
- al_log_warn("frame_queue_libplacebo", "Falling back to software copy.");
+ log_warn("Falling back to software copy.");
lq->copy_frame_fallback = true;
lq->swframe = av_frame_alloc();
enum AVPixelFormat *fmts;
@@ -240,7 +241,7 @@ static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *
));
av_frame_unref(lq->swframe);
} else {
- al_log_error("frame_queue_libplacebo", "Failed to transfer hwframe from the device (%s).", av_err2str(ret));
+ log_error("Failed to transfer hwframe from the device (%s).", av_err2str(ret));
}
}
@@ -270,7 +271,7 @@ static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *
av_frame_free(&frame);
if (!ok) {
- al_log_error("frame_queue_libplacebo", "Failed to map AVFrame.");
+ log_error("Failed to map AVFrame.");
return false;
}
@@ -304,7 +305,7 @@ static void discard_av_frame(const struct pl_source_frame *src)
{
AVFrame *frame = src->frame_data;
av_frame_free(&frame);
- al_log_warn("frame_queue_libplacebo", "Dropped frame with PTS %.3f.", src->pts);
+ log_warn("Dropped frame with PTS %.3f.", src->pts);
}
static void queue_lp_push_av_frame(struct camu_frame_queue *queue, AVFrame *frame, f64 pts)
diff --git a/src/render/renderer_libplacebo.c b/src/render/renderer_libplacebo.c
index bd9a981..71b156a 100644
--- a/src/render/renderer_libplacebo.c
+++ b/src/render/renderer_libplacebo.c
@@ -1,5 +1,6 @@
-#include <al/lib.h>
+#define AL_LOG_SECTION "renderer_libplacebo"
#include <al/log.h>
+#include <al/lib.h>
#include <nnwt/file.h>
#ifdef CAMU_HAVE_FFMPEG
#include <libplacebo/utils/libav.h>
@@ -55,9 +56,9 @@ static void log_callback(void *userdata, enum pl_log_level level, const char *me
{
(void)userdata;
if (level < PL_LOG_INFO) {
- al_log_info("render_libplacebo", message);
+ log_info(message);
} else {
- al_log_debug("render_libplacebo", message);
+ log_debug(message);
}
}
@@ -105,13 +106,13 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
.num_extensions = num,
));
if (!lr->vk_inst) {
- al_log_error("render_libplacebo", "Failed to create vulkan instance.");
+ log_error("Failed to create vulkan instance.");
goto err;
}
err = vk_create_surface(priv, lr->vk_inst->instance, &lr->surface);
if (err != VK_SUCCESS) {
- al_log_error("render_libplacebo", "Failed to create vulkan surface.");
+ log_error("Failed to create vulkan surface.");
goto err;
}
@@ -122,7 +123,7 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
.surface = lr->surface
));
if (!lr->vk) {
- al_log_error("render_libplacebo", "Failed to create vulkan device.");
+ log_error("Failed to create vulkan device.");
goto err;
}
@@ -131,20 +132,20 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
.present_mode = VK_PRESENT_MODE_FIFO_KHR
));
if (!lr->swapchain) {
- al_log_error("render_libplacebo", "Failed to create vulkan swapchain.");
+ log_error("Failed to create vulkan swapchain.");
goto err;
}
lr->gpu = lr->vk->gpu;
- al_log_info("render_libplacebo", "Using Vulkan.");
+ log_info("Using Vulkan.");
#elif defined CAMU_RENDERER_DX11
(void)priv;
lr->d3d11 = pl_d3d11_create(lr->logger, pl_d3d11_params(
.debug = false
));
if (!lr->d3d11) {
- al_log_error("render_libplacebo", "Failed to create D3D11 device.");
+ log_error("Failed to create D3D11 device.");
goto err;
}
@@ -152,13 +153,13 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
.window = win32_window,
));
if (!lr->swapchain) {
- al_log_error("render_libplacebo", "Failed to create D3D11 swapchain.");
+ log_error("Failed to create D3D11 swapchain.");
goto err;
}
lr->gpu = lr->d3d11->gpu;
- al_log_info("render_libplacebo", "Using DirectX 11.");
+ log_info("Using DirectX 11.");
#elif defined CAMU_RENDERER_OPENGL
(void)gl_load_loader;
lr->gl = pl_opengl_create(lr->logger, pl_opengl_params(
@@ -175,7 +176,7 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
.priv = priv,
));
if (!lr->gl) {
- al_log_error("render_libplacebo", "Failed to create GL device.");
+ log_error("Failed to create GL device.");
goto err;
}
@@ -185,13 +186,13 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
.priv = priv
));
if (!lr->swapchain) {
- al_log_error("render_libplacebo", "Failed to create GL swapchain.");
+ log_error("Failed to create GL swapchain.");
goto err;
}
lr->gpu = lr->gl->gpu;
- al_log_info("render_libplacebo", "Using OpenGL.");
+ log_info("Using OpenGL.");
#endif
lr->renderer = pl_renderer_create(lr->logger, lr->gpu);
@@ -357,7 +358,7 @@ static void renderer_lp_render(struct camu_renderer *renderer, struct camu_scree
}
if (!pl_swapchain_submit_frame(lr->swapchain)) {
- al_log_error("render_libplacebo", "Failed to submit frame, likely fatal.");
+ log_error("Failed to submit frame, likely fatal.");
}
lr->have_frame = false;
@@ -372,7 +373,7 @@ static void renderer_lp_render(struct camu_renderer *renderer, struct camu_scree
f64 tick = nn_get_tick();
f64 frame_time = tick - lr->last_render_tick;
if (frame_time > (1.0 / 24.0)) { // 24fps is totally arbitrary.
- al_log_info("render_libplacebo", "FRAME_TIME: %fs (%.2ffps)", frame_time, 1.0 / frame_time);
+ log_info("FRAME_TIME: %fs (%.2ffps)", frame_time, 1.0 / frame_time);
}
lr->last_render_tick = tick;
#endif
diff --git a/src/render/renderer_tiger.c b/src/render/renderer_tiger.c
index ab6e85b..eb99e0c 100644
--- a/src/render/renderer_tiger.c
+++ b/src/render/renderer_tiger.c
@@ -1,5 +1,6 @@
-#include <al/lib.h>
+#define AL_LOG_SECTION "renderer_tiger"
#include <al/log.h>
+#include <al/lib.h>
#include <linmath.h>
#include "../screen/view.h"
@@ -66,15 +67,13 @@ static bool compile_shaders(struct camu_renderer_tiger *tr)
GLuint vs_shader = glCreateShader(GL_VERTEX_SHADER);
if (!compile(vs_shader, default_vs, error)) {
- al_log_error("render_tiger", "Failed to compile vertex shader (%.*s)",
- sizeof(error), error);
+ log_error("Failed to compile vertex shader (%.*s)", sizeof(error), error);
return false;
}
GLuint fs_shader = glCreateShader(GL_FRAGMENT_SHADER);
if (!compile(fs_shader, default_fs, error)) {
- al_log_error("render_tiger", "Failed to compile fragment shader (%.*s)",
- sizeof(error), error);
+ log_error("Failed to compile fragment shader (%.*s)", sizeof(error), error);
return false;
}
@@ -152,7 +151,7 @@ static bool renderer_tiger_create_renderer(struct camu_renderer *renderer, u32 *
GLint pos = glGetAttribLocation(tr->program, "a_Position");
glVertexAttribPointer(pos, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (void *)0);
if (stl_gl_check_error()) {
- al_log_error("render_tiger", "glVertexAttribPointer returned error, use GLES context.");
+ log_error("glVertexAttribPointer returned error, use GLES context.");
al_assert_and_return(false);
}
glEnableVertexAttribArray(pos);
diff --git a/src/screen/screen.c b/src/screen/screen.c
index 4d5aee5..155668e 100644
--- a/src/screen/screen.c
+++ b/src/screen/screen.c
@@ -1,4 +1,3 @@
-#include <al/log.h>
#include <nnwt/thread.h>
#include <math.h>
diff --git a/src/server/db.c b/src/server/db.c
index fa768e2..162d127 100644
--- a/src/server/db.c
+++ b/src/server/db.c
@@ -22,18 +22,19 @@ static void open_user(struct camu_server *server, struct nn_dir *camu_db, struct
json_t *root = json_loadb(buffer.data, buffer.length, 0, &error);
al_str_free(&buffer);
if (!root) {
- error("Failed to parse %.*s:%d:%d (%s).", al_str_x(&path), error.line, error.column, error.text);
+ log_error("Failed to parse %.*s:%d:%d (%s).", al_str_x(&path), error.line, error.column, error.text);
goto out;
}
struct camu_user *user = al_alloc_object(struct camu_user);
al_str_from(&user->name, json_string_value(json_object_get(root, "username")));
- info("Loaded user \"%.*s\"", al_str_x(&user->name));
+ log_info("Loaded user \"%.*s\"", al_str_x(&user->name));
al_array_push(server->users, user);
json_decref(root);
out:
al_str_free(&path);
}
#endif
+
static void open_user(struct camu_server *server, struct nn_dir *camu_db, struct nn_dir_entry *dir)
{
(void)server;
diff --git a/src/util/color_palette.c b/src/util/color_palette.c
index d386858..fc26a10 100644
--- a/src/util/color_palette.c
+++ b/src/util/color_palette.c
@@ -49,7 +49,7 @@ bool camu_color_palette_init(str *path)
json_t *root = json_loadb(buffer.data, buffer.length, 0, &error);
al_str_free(&buffer);
if (!root) {
- error("Failed to load %.*s as a json (%s).", al_str_x(path), error.text);
+ log_error("Failed to load %.*s as a json (%s).", al_str_x(path), error.text);
return false;
}
@@ -57,14 +57,14 @@ bool camu_color_palette_init(str *path)
json_t *special = json_object_get(root, "special");
if (!special) {
- error("\"special\" field missing from the color palette.");
+ log_error("\"special\" field missing from the color palette.");
parsed = false;
goto out;
}
json_t *colors = json_object_get(root, "colors");
if (!colors) {
- error("\"colors\" field missing from the color palette.");
+ log_error("\"colors\" field missing from the color palette.");
parsed = false;
goto out;
}
@@ -78,7 +78,7 @@ bool camu_color_palette_init(str *path)
for (u32 i = 0; i < ARRAY_SIZE(special_colors); i++) {
object = json_object_get(special, special_colors[i]);
if (!object) {
- error("Couldn't find special color: %s.", special_colors[i]);
+ log_error("Couldn't find special color: %s.", special_colors[i]);
return false;
}
color = json_string_value(object);
@@ -87,14 +87,14 @@ bool camu_color_palette_init(str *path)
if (!to_long_error) {
global_color_palette.colors[i] = value;
} else {
- warn("%s is not a valid hex color.", normal_colors[i]);
+ log_warn("%s is not a valid hex color.", normal_colors[i]);
}
}
for (u32 i = 0; i < ARRAY_SIZE(normal_colors); i++) {
object = json_object_get(colors, normal_colors[i]);
if (!object) {
- error("Couldn't find color: %s.", normal_colors[i]);
+ log_error("Couldn't find color: %s.", normal_colors[i]);
return false;
}
color = json_string_value(object);
@@ -103,7 +103,7 @@ bool camu_color_palette_init(str *path)
if (!to_long_error) {
global_color_palette.colors[i + 2] = value;
} else {
- warn("%s is not a valid hex color.", normal_colors[i]);
+ log_warn("%s is not a valid hex color.", normal_colors[i]);
}
}