summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-04-28 14:11:28 -0400
committerAndrew Opalach <andrew@akon.city> 2025-04-28 14:11:28 -0400
commitc8c0af300dde117a839f2d5d6b777694d7f118e9 (patch)
tree3297f1ba256da0b837fbaa9c581d7f420ce98a4a /src
parent61492af23ecc5dd9ab4956a84a7c0451deb8b84b (diff)
downloadcamu-c8c0af300dde117a839f2d5d6b777694d7f118e9.tar.gz
camu-c8c0af300dde117a839f2d5d6b777694d7f118e9.tar.bz2
camu-c8c0af300dde117a839f2d5d6b777694d7f118e9.zip
Minor restructure and dependency updates
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src')
-rw-r--r--src/codec/ffmpeg/decoder.c2
-rw-r--r--src/codec/ffmpeg/demuxer.c12
-rw-r--r--src/fruits/cmc/ui/widgets/now_playing.c2
-rw-r--r--src/fruits/cmv/cmv.c9
-rw-r--r--src/fruits/ctv/ctv.c6
-rw-r--r--src/libsink/desktop.c (renamed from src/sink/desktop.c)23
-rw-r--r--src/libsink/desktop.h (renamed from src/sink/desktop.h)4
-rw-r--r--src/libsink/input_simulator.c (renamed from src/sink/input_simulator.c)0
-rw-r--r--src/libsink/input_simulator.h (renamed from src/sink/input_simulator.h)0
-rw-r--r--src/libsink/meson.build5
-rw-r--r--src/server/server.c2
-rw-r--r--src/sink/meson.build4
-rw-r--r--src/util/print_time.h (renamed from src/sink/util.h)0
13 files changed, 36 insertions, 33 deletions
diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c
index cae56d1..80b1d12 100644
--- a/src/codec/ffmpeg/decoder.c
+++ b/src/codec/ffmpeg/decoder.c
@@ -262,7 +262,7 @@ 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.
// SLICE seems to work better based on videos that got completely choked
- // in THREAD_FRAME mode (4k60 hevc, FFMpeg 7.1.1, AMD 3900x).
+ // in THREAD_FRAME mode (4k60 HEVC, FFmpeg 7.1.1, AMD 3900x).
av->codec_context->thread_type = FF_THREAD_SLICE;
log_info("Using %i threads for decoder.", cpus);
}
diff --git a/src/codec/ffmpeg/demuxer.c b/src/codec/ffmpeg/demuxer.c
index cb2ed91..d45a970 100644
--- a/src/codec/ffmpeg/demuxer.c
+++ b/src/codec/ffmpeg/demuxer.c
@@ -75,12 +75,14 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl
goto err;
}
-#define GUESS_STREAM_IS_IMAGE(stream) \
- (stream->duration >= 0 && stream->nb_frames <= 1 && (stream->avg_frame_rate.den == 0 && stream->r_frame_rate.den > 0))
-
s64 default_duration = (av->format_context->duration < 0) ? 0 : av->format_context->duration;
av->duration = 0;
+#define GUESS_STREAM_IS_IMAGE(stream) \
+ ((stream->duration >= 0 && stream->nb_frames <= 1 && \
+ (stream->avg_frame_rate.den == 0 && stream->r_frame_rate.den > 0)) || \
+ (stream->duration < 0 && default_duration == 0))
+
for (u32 i = 0; i < av->format_context->nb_streams; i++) {
AVStream *stream = av->format_context->streams[i];
enum AVMediaType type = stream->codecpar->codec_type;
@@ -88,12 +90,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)) {
- log_info("Assuming stream #%u is an image.", i);
+ log_debug("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);
- log_info("Stream #%u has an invalid duration, defaulting to %.3fs.",
+ log_warn("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);
diff --git a/src/fruits/cmc/ui/widgets/now_playing.c b/src/fruits/cmc/ui/widgets/now_playing.c
index d30590c..845a572 100644
--- a/src/fruits/cmc/ui/widgets/now_playing.c
+++ b/src/fruits/cmc/ui/widgets/now_playing.c
@@ -1,7 +1,7 @@
#include <math.h>
#include "../../../../liana/list.h"
-#include "../../../../sink/util.h"
+#include "../../../../util/print_time.h"
#include "../../cmc.h"
diff --git a/src/fruits/cmv/cmv.c b/src/fruits/cmv/cmv.c
index 7fc6baa..2dda139 100644
--- a/src/fruits/cmv/cmv.c
+++ b/src/fruits/cmv/cmv.c
@@ -4,9 +4,9 @@
#include <nnwt/thread.h>
#include "../../util/color_palette.h"
-#include "../../sink/desktop.h"
-#include "../../server/common.h"
#include "../../codec/ffmpeg/common.h"
+#include "../../libsink/desktop.h"
+#include "../../server/common.h"
#ifndef CAMU_SINK_ONLY
#include "../../server/server.h"
#endif
@@ -167,7 +167,7 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
}
#endif
- if (!camu_desktop_init(&c.desktop, "cmv")) {
+ if (!camu_desktop_open(&c.desktop, "cmv")) {
return EXIT_FAILURE;
}
#ifndef CAMU_SINK_ONLY
@@ -176,7 +176,8 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
c.desktop.userdata = &c;
}
#endif
- if (!camu_desktop_connect(&c.desktop, &c.loop, type, &addr, CAMU_PORT)) {
+ str *name = local ? &al_str_c("local") : &al_str_c("desktop");
+ if (!camu_desktop_connect(&c.desktop, name, &c.loop, type, &addr, CAMU_PORT)) {
return EXIT_FAILURE;
}
diff --git a/src/fruits/ctv/ctv.c b/src/fruits/ctv/ctv.c
index 804cbed..5becb88 100644
--- a/src/fruits/ctv/ctv.c
+++ b/src/fruits/ctv/ctv.c
@@ -2,7 +2,7 @@
#include <android/log.h>
#include "../../libsink/sink.h"
-#include "../../sink/desktop.h"
+#include "../../libsink/desktop.h"
#ifdef CAMU_HAVE_FFMPEG
#include "../../codec/ffmpeg/common.h"
#endif
@@ -26,7 +26,7 @@ static nn_thread_result NNWT_THREADCALL event_loop_thread(void *userdata)
prefs->audio_lang = CAMU_LANG_ENGLISH;
prefs->subtitle_lang = CAMU_LANG_ENGLISH;
- if (!camu_desktop_connect(&c->desktop, &c->loop, CAMU_TEST_TYPE, &CAMU_TEST_ADDR, CAMU_PORT)) {
+ if (!camu_desktop_connect(&c->desktop, &al_str_c("ctv"), &c->loop, CAMU_TEST_TYPE, &CAMU_TEST_ADDR, CAMU_PORT)) {
return 0;
}
@@ -56,7 +56,7 @@ s32 stl_platform_main(u32 argc, str *argv)
camu_ff_common_init();
#endif
- if (!camu_desktop_init(&c.desktop, "ctv")) {
+ if (!camu_desktop_open(&c.desktop, "ctv")) {
return 0;
}
diff --git a/src/sink/desktop.c b/src/libsink/desktop.c
index fcb7cf1..2bbe906 100644
--- a/src/sink/desktop.c
+++ b/src/libsink/desktop.c
@@ -13,9 +13,9 @@
#elif defined CAMU_RENDERER_LIBPLACEBO
#include "../render/renderer_libplacebo.h"
#endif
+#include "../util/print_time.h"
#include "desktop.h"
-#include "util.h"
#ifdef CAMU_SCREEN_DEBUG_KEY
#include "input_simulator.h"
#endif
@@ -31,13 +31,13 @@ static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque)
case CAMU_SINK_AUDIO: {
struct camu_audio_buffer *buf = (struct camu_audio_buffer *)opaque;
camu_mixer_add_buffer(mixer, buf);
- log_info("Audio buffer added.");
+ log_debug("Audio buffer added.");
break;
}
case CAMU_SINK_VIDEO: {
struct camu_video_buffer *buf = (struct camu_video_buffer *)opaque;
camu_screen_add_buffer(scr, buf);
- log_info("Video buffer added.");
+ log_debug("Video buffer added.");
break;
}
}
@@ -47,13 +47,13 @@ static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque)
case CAMU_SINK_AUDIO: {
struct camu_audio_buffer *buf = (struct camu_audio_buffer *)opaque;
camu_mixer_remove_buffer(mixer, buf);
- log_info("Audio buffer removed.");
+ log_debug("Audio buffer removed.");
break;
}
case CAMU_SINK_VIDEO: {
struct camu_video_buffer *buf = (struct camu_video_buffer *)opaque;
camu_screen_remove_buffer(scr, buf);
- log_info("Video buffer removed.");
+ log_debug("Video buffer removed.");
break;
}
}
@@ -111,8 +111,7 @@ static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque)
}
static char status[64];
-
-static void print_status(struct camu_sink *sink)
+static void log_playback_pos(struct camu_sink *sink)
{
struct camu_sink_entry *current = camu_sink_get_current(sink);
if (!current) {
@@ -176,7 +175,7 @@ static void screen_callback(void *userdata, u8 op, void *opaque)
camu_sink_shuffle(&c->sink);
break;
case CAMU_SCREEN_STATUS:
- print_status(&c->sink);
+ log_playback_pos(&c->sink);
break;
#ifdef CAMU_SCREEN_DEBUG_KEY
case CAMU_SCREEN_DEBUG:
@@ -193,11 +192,11 @@ static void screen_callback(void *userdata, u8 op, void *opaque)
}
}
-bool camu_desktop_init(struct camu_desktop *c, const char *name)
+bool camu_desktop_open(struct camu_desktop *c, const char *window_name)
{
c->scr.callback = screen_callback;
c->scr.userdata = c;
- if (!camu_screen_init(&c->scr) || !camu_screen_create_window(&c->scr, name)) {
+ if (!camu_screen_init(&c->scr) || !camu_screen_create_window(&c->scr, window_name)) {
return false;
}
#if defined CAMU_RENDERER_TIGER
@@ -226,14 +225,14 @@ bool camu_desktop_init(struct camu_desktop *c, const char *name)
return true;
}
-bool camu_desktop_connect(struct camu_desktop *c, struct nn_event_loop *loop, u8 type, str *addr, u16 port)
+bool camu_desktop_connect(struct camu_desktop *c, str *name, struct nn_event_loop *loop, u8 type, str *addr, u16 port)
{
c->loop = loop;
camu_sink_init(&c->sink, c->loop, &c->mixer, c->renderer);
al_str_from(&c->sink.default_list, "default");
c->sink.callback = sink_callback;
c->sink.userdata = c;
- return camu_sink_connect(&c->sink, &al_str_c("desktop"), type, addr, port);
+ return camu_sink_connect(&c->sink, name, type, addr, port);
}
bool camu_desktop_tick(struct camu_desktop *c)
diff --git a/src/sink/desktop.h b/src/libsink/desktop.h
index 65fcfe0..279fd7b 100644
--- a/src/sink/desktop.h
+++ b/src/libsink/desktop.h
@@ -19,8 +19,8 @@ struct camu_desktop {
void *userdata;
};
-bool camu_desktop_init(struct camu_desktop *c, const char *name);
-bool camu_desktop_connect(struct camu_desktop *c, struct nn_event_loop *loop, u8 type, str *addr, u16 port);
+bool camu_desktop_open(struct camu_desktop *c, const char *window_name);
+bool camu_desktop_connect(struct camu_desktop *c, str *name, struct nn_event_loop *loop, u8 type, str *addr, u16 port);
bool camu_desktop_tick(struct camu_desktop *c);
void camu_desktop_stop(struct camu_desktop *c);
void camu_desktop_free(struct camu_desktop *c);
diff --git a/src/sink/input_simulator.c b/src/libsink/input_simulator.c
index 80fde02..80fde02 100644
--- a/src/sink/input_simulator.c
+++ b/src/libsink/input_simulator.c
diff --git a/src/sink/input_simulator.h b/src/libsink/input_simulator.h
index e05b03e..e05b03e 100644
--- a/src/sink/input_simulator.h
+++ b/src/libsink/input_simulator.h
diff --git a/src/libsink/meson.build b/src/libsink/meson.build
index a0805af..153e371 100644
--- a/src/libsink/meson.build
+++ b/src/libsink/meson.build
@@ -9,3 +9,8 @@ else
endif
libsink = declare_dependency(sources: libsink_src, dependencies: libsink_deps, compile_args: libsink_args)
+
+desktop_src = ['desktop.c', 'input_simulator.c']
+desktop_deps = [libsink]
+desktop_args = ['-DCAMU_MIXER_THREADED', '-DCAMU_SCREEN_THREADED']
+desktop = declare_dependency(sources: desktop_src, dependencies: desktop_deps, compile_args: desktop_args)
diff --git a/src/server/server.c b/src/server/server.c
index dfeee78..0275147 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -151,7 +151,7 @@ static bool identify_callback(void *userdata, struct nn_rpc_connection *conn,
sink->server = server;
al_array_push(server->sinks, sink);
handle_toggle_sink(server, &al_str_c("default"), sink, true);
- log_info("New sink.");
+ log_info("Sink \"%.*s\" connected.", al_str_x(&name));
break;
}
}
diff --git a/src/sink/meson.build b/src/sink/meson.build
deleted file mode 100644
index 8d13b26..0000000
--- a/src/sink/meson.build
+++ /dev/null
@@ -1,4 +0,0 @@
-desktop_src = ['desktop.c', 'input_simulator.c']
-desktop_deps = [libsink]
-desktop_args = ['-DCAMU_MIXER_THREADED', '-DCAMU_SCREEN_THREADED']
-desktop = declare_dependency(sources: desktop_src, dependencies: desktop_deps, compile_args: desktop_args)
diff --git a/src/sink/util.h b/src/util/print_time.h
index d9dd4cc..d9dd4cc 100644
--- a/src/sink/util.h
+++ b/src/util/print_time.h