[fix] fix unused variables and type conversions

This commit is contained in:
dijunkun
2024-11-26 17:31:37 +08:00
parent 1e58abdfdd
commit 0caa243006
4 changed files with 13 additions and 8 deletions

View File

@@ -88,7 +88,8 @@ int Render::ControlBar() {
RemoteAction remote_action; RemoteAction remote_action;
remote_action.type = ControlType::audio_capture; remote_action.type = ControlType::audio_capture;
remote_action.a = audio_capture_button_pressed_; remote_action.a = audio_capture_button_pressed_;
SendData(peer_, (const char*)&remote_action, sizeof(remote_action)); SendDataFrame(peer_, (const char*)&remote_action,
sizeof(remote_action));
} }
} }
if (!audio_capture_button_pressed_) { if (!audio_capture_button_pressed_) {

View File

@@ -62,7 +62,7 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
if (control_bar_hovered_) { if (control_bar_hovered_) {
remote_action.m.flag = MouseFlag::move; remote_action.m.flag = MouseFlag::move;
} }
SendData(peer_, (const char *)&remote_action, sizeof(remote_action)); SendDataFrame(peer_, (const char *)&remote_action, sizeof(remote_action));
} else if (SDL_MOUSEBUTTONUP == event.type) { } else if (SDL_MOUSEBUTTONUP == event.type) {
remote_action.type = ControlType::mouse; remote_action.type = ControlType::mouse;
if (SDL_BUTTON_LEFT == event.button.button) { if (SDL_BUTTON_LEFT == event.button.button) {
@@ -73,11 +73,11 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
if (control_bar_hovered_) { if (control_bar_hovered_) {
remote_action.m.flag = MouseFlag::move; remote_action.m.flag = MouseFlag::move;
} }
SendData(peer_, (const char *)&remote_action, sizeof(remote_action)); SendDataFrame(peer_, (const char *)&remote_action, sizeof(remote_action));
} else if (SDL_MOUSEMOTION == event.type) { } else if (SDL_MOUSEMOTION == event.type) {
remote_action.type = ControlType::mouse; remote_action.type = ControlType::mouse;
remote_action.m.flag = MouseFlag::move; remote_action.m.flag = MouseFlag::move;
SendData(peer_, (const char *)&remote_action, sizeof(remote_action)); SendDataFrame(peer_, (const char *)&remote_action, sizeof(remote_action));
} }
return 0; return 0;
@@ -93,7 +93,7 @@ int Render::SendKeyEvent(int key_code, bool is_down) {
} }
remote_action.k.key_value = key_code; remote_action.k.key_value = key_code;
SendData(peer_, (const char *)&remote_action, sizeof(remote_action)); SendDataFrame(peer_, (const char *)&remote_action, sizeof(remote_action));
return 0; return 0;
} }
@@ -282,8 +282,8 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
remote_action.type = ControlType::host_infomation; remote_action.type = ControlType::host_infomation;
memcpy(&remote_action.i.host_name, host_name.data(), host_name.size()); memcpy(&remote_action.i.host_name, host_name.data(), host_name.size());
remote_action.i.host_name_size = host_name.size(); remote_action.i.host_name_size = host_name.size();
int ret = SendData(render->peer_, (const char *)&remote_action, int ret = SendDataFrame(render->peer_, (const char *)&remote_action,
sizeof(remote_action)); sizeof(remote_action));
if (0 == ret) { if (0 == ret) {
render->hostname_sent_ = true; render->hostname_sent_ = true;
} }

View File

@@ -26,6 +26,8 @@ if is_os("windows") then
add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32", add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32",
"SDL2-static", "SDL2main", "gdi32", "winmm", "setupapi", "version", "SDL2-static", "SDL2main", "gdi32", "winmm", "setupapi", "version",
"Imm32", "iphlpapi") "Imm32", "iphlpapi")
-- add_cxflags("/W4", "/WX")
add_cxflags("/W4")
elseif is_os("linux") then elseif is_os("linux") then
add_requires("ffmpeg 5.1.2", {system = false}) add_requires("ffmpeg 5.1.2", {system = false})
add_syslinks("pthread", "dl") add_syslinks("pthread", "dl")
@@ -36,12 +38,14 @@ elseif is_os("linux") then
"-lasound", "-lxcb-shape", "-lxcb-xfixes", "-lsndio", "-lxcb", "-lasound", "-lxcb-shape", "-lxcb-xfixes", "-lsndio", "-lxcb",
"-lxcb-shm", "-lXext", "-lX11", "-lXv", "-ldl", "-lpthread", "-lxcb-shm", "-lXext", "-lX11", "-lXv", "-ldl", "-lpthread",
{force = true}) {force = true})
add_cxflags("-Wno-unused-variable")
elseif is_os("macosx") then elseif is_os("macosx") then
add_requires("ffmpeg 5.1.2", {system = false}) add_requires("ffmpeg 5.1.2", {system = false})
add_requires("libxcb", {system = false}) add_requires("libxcb", {system = false})
add_packages("libxcb") add_packages("libxcb")
add_links("SDL2", "SDL2main") add_links("SDL2", "SDL2main")
add_ldflags("-Wl,-ld_classic") add_ldflags("-Wl,-ld_classic")
add_cxflags("-Wno-unused-variable")
add_frameworks("OpenGL", "IOSurface", "ScreenCaptureKit") add_frameworks("OpenGL", "IOSurface", "ScreenCaptureKit")
end end