summaryrefslogtreecommitdiff
path: root/src/fruits/cmv
diff options
context:
space:
mode:
Diffstat (limited to 'src/fruits/cmv')
-rw-r--r--src/fruits/cmv/cmv.c38
-rw-r--r--src/fruits/cmv/meson.build13
2 files changed, 38 insertions, 13 deletions
diff --git a/src/fruits/cmv/cmv.c b/src/fruits/cmv/cmv.c
index 58c8e32..74e3555 100644
--- a/src/fruits/cmv/cmv.c
+++ b/src/fruits/cmv/cmv.c
@@ -53,6 +53,10 @@ static nn_thread_result NNWT_THREADCALL event_loop_thread(void *userdata)
static bool decode_addr(str *addr, str *enc)
{
+ if (al_str_find(enc, '.') != AL_STR_NO_POS) {
+ al_str_clone(addr, enc);
+ return true;
+ }
char value[4]; // max = 255.
for (u32 i = 0; i < 8; i += 2) {
str sub = al_str_substr(enc, i, i + 2);
@@ -75,40 +79,39 @@ static bool parse_exe_name(str *exe_name, str *addr)
u32 index = al_str_rfind(exe_name, '/');
if (index == AL_STR_NO_POS) {
if ((index = al_str_rfind(exe_name, '\\')) == AL_STR_NO_POS) {
- goto def;
+ return false;
}
}
str sub = al_str_substr(exe_name, index + 1, exe_name->length);
if (al_str_cmp(&sub, &al_str_c("sink-"), 0, 5) != 0) {
- goto def;
+ return false;
}
sub = al_str_substr(&sub, 5, sub.length);
// Skip version.
if ((index = al_str_find(&sub, '-')) == AL_STR_NO_POS) {
- goto def;
+ return false;
}
sub = al_str_substr(&sub, index + 1, sub.length);
if ((index = al_str_find(&sub, '.')) != AL_STR_NO_POS) {
sub = al_str_substr(&sub, 0, index);
}
- al_str_from(addr, "");
decode_addr(addr, &sub);
log_debug("Parsed address %.*s from exe filename.", al_str_x(addr));
return true;
-def:
- return false;
}
static struct cmv c = { 0 };
+#ifdef STELA_USE_PLATFORM_MAIN
+s32 stl_platform_main(u32 argc, str *argv, void *extra)
+#else
s32 window_system_main(u32 argc, str *argv, void *extra)
+#endif
{
- (void)extra;
-
bool local;
#ifdef CAMU_SINK_ONLY
local = argc > 1;
@@ -134,9 +137,9 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
nn_event_loop_init(&c.loop);
u8 type;
- str addr = al_str_null();
+ str addr = AL_STR_EMPTY;
if (local) {
-#ifdef NAUNET_ON_WINDOWS
+#if defined NAUNET_ON_WINDOWS || defined NAUNET_ON_ANDROID
type = NNWT_SOCKET_TCP;
al_str_clone(&addr, &al_str_c("127.0.0.1"));
#else
@@ -151,8 +154,8 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
} else {
type = NNWT_SOCKET_TCP;
char *SINK_IP = getenv("SINK_IP");
- al_str_from(&addr, "");
if (!SINK_IP || !decode_addr(&addr, &al_str_cr(SINK_IP))) {
+ local = true; // If no IP, default back to local.
al_str_cat(&addr, &al_str_c("127.0.0.1"));
}
}
@@ -228,11 +231,22 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
#endif
nn_packet_free(packet);
}
+ if (extra) {
+ u32 start_index = *(u32 *)extra;
+ if (start_index != 0) {
+ camu_server_local_set_index(&c.server, start_index);
+ }
+ }
}
struct nn_thread thread;
nn_thread_create(&thread, event_loop_thread, &c);
+#ifdef STELA_USE_PLATFORM_MAIN
+ al_str_free(&addr);
+ return 0;
+#endif
+
while (camu_desktop_tick(&c.desktop)) {}
camu_desktop_stop(&c.desktop);
@@ -251,6 +265,7 @@ out:
return ret;
}
+#ifndef STELA_USE_PLATFORM_MAIN
static bool sigint_force = false;
static void sigint_handler(s32 signum)
{
@@ -314,3 +329,4 @@ s32 main(s32 argc, char *argv[])
return ret;
}
+#endif
diff --git a/src/fruits/cmv/meson.build b/src/fruits/cmv/meson.build
index ec27c81..301fa58 100644
--- a/src/fruits/cmv/meson.build
+++ b/src/fruits/cmv/meson.build
@@ -14,7 +14,10 @@ if use_tui
endif
cmv_link_args = []
-if is_windows
+if is_android
+ # https://github.com/google/ExoPlayer/issues/9933#issuecomment-1029775358
+ cmv_link_args += ['-Wl,-Bsymbolic', '-static-libstdc++']
+elif is_windows
windows = import('windows')
cmv_src += [windows.compile_resources('icon.rc')]
if not is_msvc
@@ -22,4 +25,10 @@ if is_windows
endif
endif
-executable('cmv', cmv_src, dependencies: cmv_deps, c_args: cmv_args, link_args: cmv_link_args, install: true)
+if is_android
+ cmv_args += ['-DAPPLICATION_NAME="CTV"']
+ shared_library('ctv', cmv_src, dependencies: cmv_deps, c_args: cmv_args, link_args: cmv_link_args)
+else
+ cmv_args += ['-DAPPLICATION_NAME="CMV"']
+ executable('cmv', cmv_src, dependencies: cmv_deps, c_args: cmv_args, link_args: cmv_link_args, install: true)
+endif