Skip to content

Commit

Permalink
Review build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Sep 25, 2023
1 parent 5f055e8 commit e41501a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion getscreens.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "getscreens.h"
#include "windows.h";
#include "windows.h"
#include "shellscalingapi.h"

using namespace std;
Expand Down
19 changes: 10 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -493,7 +494,7 @@ void run(vector<string> 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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pack-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion util.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ void util_obs_cpu_usage_info_start();
vector<string> 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);

0 comments on commit e41501a

Please sign in to comment.