diff --git a/encoder.cpp b/encoder.cpp index de9d102..1b4ad2b 100644 --- a/encoder.cpp +++ b/encoder.cpp @@ -130,7 +130,7 @@ obs_encoder_t* create_and_configure_video_encoder(bool hwAccel, bool lowCpuMode, obs_encoder_t* encVideo = nullptr; if (hwAccel) { - auto adjustedCrf = CalcCRF(outputSize.Width, outputSize.Height, crf, false); + auto adjustedCrf = CalcCRF((int)outputSize.Width, (int)outputSize.Height, crf, false); cout << "Actual CRF: " << adjustedCrf << std::endl; if (encoders.find("jim_nvenc") != encoders.end()) { @@ -148,7 +148,7 @@ obs_encoder_t* create_and_configure_video_encoder(bool hwAccel, bool lowCpuMode, } if (encVideo == nullptr) { - auto adjustedCrfForCpu = CalcCRF(outputSize.Width, outputSize.Height, crf, lowCpuMode); + auto adjustedCrfForCpu = CalcCRF((int)outputSize.Width, (int)outputSize.Height, crf, lowCpuMode); cout << "Actual CRF: " << adjustedCrfForCpu << std::endl; encVideo = obs_video_encoder_create("obs_x264", "enc_obs_x264", nullptr, nullptr); diff --git a/getscreens.cpp b/getscreens.cpp index d5a3ec1..29b8cb2 100644 --- a/getscreens.cpp +++ b/getscreens.cpp @@ -1,5 +1,5 @@ #include "getscreens.h" -#include "windows.h"; +#include "windows.h" #include "shellscalingapi.h" using namespace std; diff --git a/main.cpp b/main.cpp index 7e17e28..eb1adf8 100644 --- a/main.cpp +++ b/main.cpp @@ -46,9 +46,8 @@ obs_sceneitem_t* mouseSceneItem = 0; uint64_t lastMouseClick; mouse_info lastMouseClickPosition; bool mouseVisible; -#define ANIMATION_DURATION ((double)400) // ms * ns -void update_mouse_tracker_state(uint32_t x, uint32_t y, float opacity, float scale) +void update_mouse_tracker_state(float x, float y, float opacity, float scale) { if (mouseFilter == nullptr || mouseSceneItem == nullptr) { return; @@ -69,20 +68,22 @@ void tick_obs_frame_processing(void* priv, float seconds) { auto time = util_obs_get_time_ms(); auto mouseData = get_mouse_info(); + const float duration = 400; + if (mouseData.pressed) { lastMouseClickPosition = mouseData; lastMouseClick = time; } - auto lastClickAgo = time - lastMouseClick; - if (lastClickAgo < ANIMATION_DURATION) { + uint64_t lastClickAgo = time - lastMouseClick; + if (lastClickAgo < duration) { mouseVisible = true; // max 85% opacity - float opacity = (1 - (lastClickAgo / ANIMATION_DURATION)) * 85; - float mouseZoom = lastMouseClickPosition.dpi / 96; + float opacity = (float)((1 - (lastClickAgo / duration)) * 85); + float mouseZoom = (float)lastMouseClickPosition.dpi / 96; // radius: min 15, will grow +35 to max of 50 (*dpi) - float radius = (10 + ((lastClickAgo / ANIMATION_DURATION) * 30)) * mouseZoom; + float radius = (10 + ((lastClickAgo / duration) * 30)) * mouseZoom; // scale: intendedRenderedSize/actualImageSize - the tracker.png is 100x100 float scale = radius / 50; @@ -134,7 +135,7 @@ void handle_signal_started_recording(void* data, calldata_t* cd) void handle_signal_stopped_recording(void* data, calldata_t* cd) { obs_output_t* output = (obs_output_t*)calldata_ptr(cd, "output"); - int code = calldata_int(cd, "code"); + uint32_t code = (uint32_t)calldata_int(cd, "code"); const char* output_error = obs_output_get_last_error(output); json rec_stop; @@ -493,7 +494,7 @@ void run(vector arguments) obs_data_release(opt); obs_sceneitem_t* sceneItem = obs_scene_add(scene, source); - vec2 pos{ displayBounds.X - captureRegion.X , displayBounds.Y - captureRegion.Y }; + vec2 pos{ (float)(displayBounds.X - captureRegion.X) , (float)(displayBounds.Y - captureRegion.Y) }; obs_sceneitem_set_pos(sceneItem, &pos); } } diff --git a/pack-release.ps1 b/pack-release.ps1 index 6113d57..214cf7f 100644 --- a/pack-release.ps1 +++ b/pack-release.ps1 @@ -14,7 +14,7 @@ $version = $verHeader.Substring($verStart, $verEnd - $verStart) Write-Host "Creating release for obs-express v$version" -msbuild ObsExpressCpp.sln -p:Configuration=Release -p:Platform=x64 +msbuild ObsExpressCpp.sln -t:Rebuild -p:Configuration=Release -p:Platform=x64 $ReleaseDir = Resolve-Path -Path "build64/rundir/MinSizeRel" $BinDir = Resolve-Path -Path "$ReleaseDir/bin/64bit" diff --git a/util.cpp b/util.cpp index b017da1..32eac88 100644 --- a/util.cpp +++ b/util.cpp @@ -81,7 +81,7 @@ Color util_parse_color(const string& input) return r; } -string get_obs_output_errorcode_string(int code) +string get_obs_output_errorcode_string(uint32_t code) { switch (code) { case OBS_OUTPUT_SUCCESS: @@ -103,6 +103,8 @@ string get_obs_output_errorcode_string(int code) case OBS_OUTPUT_ENCODE_ERROR: return "Encoder error"; } + + return "Unknown error: " + to_string(code); } std::string util_string_utf8_encode(const std::wstring& wstr) diff --git a/util.h b/util.h index b5aeae2..526fa90 100644 --- a/util.h +++ b/util.h @@ -13,5 +13,5 @@ void util_obs_cpu_usage_info_start(); vector util_string_split(const string& input, char delimiter); Gdiplus::Rect util_parse_rect(const string& input); Gdiplus::Color util_parse_color(const string& input); -string get_obs_output_errorcode_string(int code); +string get_obs_output_errorcode_string(uint32_t code); std::string util_string_utf8_encode(const std::wstring& wstr);