From 1c425bc9849ea1653e18b43b353a7d81a6ddb524 Mon Sep 17 00:00:00 2001 From: Sverre Skodje Date: Fri, 3 Feb 2023 21:42:33 +0100 Subject: [PATCH] Fixed some type conversion and other warnings --- ScreenRecorderLibNative/AudioManager.cpp | 2 +- ScreenRecorderLibNative/AudioManager.h | 2 +- ScreenRecorderLibNative/LoopbackCapture.cpp | 10 +++++----- ScreenRecorderLibNative/LoopbackCapture.h | 2 +- ScreenRecorderLibNative/RecordingManager.cpp | 12 ++++++------ ScreenRecorderLibNative/util.h | 2 -- TestConsoleAppCpp/TestConsoleAppCpp.vcxproj | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/ScreenRecorderLibNative/AudioManager.cpp b/ScreenRecorderLibNative/AudioManager.cpp index fd2accb..8f8f6c0 100644 --- a/ScreenRecorderLibNative/AudioManager.cpp +++ b/ScreenRecorderLibNative/AudioManager.cpp @@ -72,7 +72,7 @@ HRESULT AudioManager::InitializeAudioCapture() return hr; } -std::vector AudioManager::GrabAudioFrame(_In_ int durationHundredNanos) +std::vector AudioManager::GrabAudioFrame(_In_ UINT64 durationHundredNanos) { EnterCriticalSection(&m_CriticalSection); LeaveCriticalSectionOnExit leaveOnExit(&m_CriticalSection); diff --git a/ScreenRecorderLibNative/AudioManager.h b/ScreenRecorderLibNative/AudioManager.h index 71899fb..b8275aa 100644 --- a/ScreenRecorderLibNative/AudioManager.h +++ b/ScreenRecorderLibNative/AudioManager.h @@ -9,7 +9,7 @@ class AudioManager ~AudioManager(); HRESULT Initialize(_In_ std::shared_ptr &audioOptions); void ClearRecordedBytes(); - std::vector GrabAudioFrame(_In_ int durationHundredNanos); + std::vector GrabAudioFrame(_In_ UINT64 durationHundredNanos); private: CRITICAL_SECTION m_CriticalSection; std::shared_ptr m_AudioOptions; diff --git a/ScreenRecorderLibNative/LoopbackCapture.cpp b/ScreenRecorderLibNative/LoopbackCapture.cpp index aea3458..ad304e7 100644 --- a/ScreenRecorderLibNative/LoopbackCapture.cpp +++ b/ScreenRecorderLibNative/LoopbackCapture.cpp @@ -39,7 +39,7 @@ HRESULT LoopbackCapture::StartLoopbackCapture( return E_FAIL; } // activate an IAudioClient - IAudioClient *pAudioClient; + IAudioClient *pAudioClient = nullptr; hr = pMMDevice->Activate( __uuidof(IAudioClient), CLSCTX_ALL, NULL, @@ -182,7 +182,7 @@ HRESULT LoopbackCapture::StartLoopbackCapture( } // activate an IAudioCaptureClient - IAudioCaptureClient *pAudioCaptureClient; + IAudioCaptureClient *pAudioCaptureClient = nullptr; hr = pAudioClient->GetService( __uuidof(IAudioCaptureClient), (void **)&pAudioCaptureClient @@ -204,7 +204,7 @@ HRESULT LoopbackCapture::StartLoopbackCapture( AvRevertMmThreadCharacteristicsOnExit unregisterMmcss(hTask); // set the waitable timer - LARGE_INTEGER liFirstFire; + LARGE_INTEGER liFirstFire{}; liFirstFire.QuadPart = -hnsDefaultDevicePeriod / 2; // negative means relative time LONG lTimeBetweenFires = (LONG)hnsDefaultDevicePeriod / 2 / (10 * 1000); // convert to milliseconds BOOL bOK = SetWaitableTimer( @@ -351,10 +351,10 @@ std::vector LoopbackCapture::PeakRecordedBytes() return m_RecordedBytes; } -std::vector LoopbackCapture::GetRecordedBytes(int duration100Nanos) +std::vector LoopbackCapture::GetRecordedBytes(UINT64 duration100Nanos) { int frameCount = int(ceil(m_InputFormat.sampleRate * HundredNanosToSeconds(duration100Nanos))); - int byteCount = min((frameCount * m_InputFormat.FrameBytes()), m_RecordedBytes.size()); + size_t byteCount = min((frameCount * m_InputFormat.FrameBytes()), m_RecordedBytes.size()); m_TaskWrapperImpl->m_Mutex.lock(); std::vector newvector(m_RecordedBytes.begin(), m_RecordedBytes.begin() + byteCount); // convert audio diff --git a/ScreenRecorderLibNative/LoopbackCapture.h b/ScreenRecorderLibNative/LoopbackCapture.h index ff9d990..e0bb1c3 100644 --- a/ScreenRecorderLibNative/LoopbackCapture.h +++ b/ScreenRecorderLibNative/LoopbackCapture.h @@ -32,7 +32,7 @@ class LoopbackCapture UINT32 channels ); std::vector PeakRecordedBytes(); - std::vector GetRecordedBytes(int duration100Nanos); + std::vector GetRecordedBytes(UINT64 duration100Nanos); HRESULT StartCapture(UINT32 audioChannels, std::wstring device, EDataFlow flow) { return StartCapture(0, audioChannels, device, flow); } HRESULT StartCapture(UINT32 sampleRate, UINT32 audioChannels, std::wstring device, EDataFlow flow); HRESULT StopCapture(); diff --git a/ScreenRecorderLibNative/RecordingManager.cpp b/ScreenRecorderLibNative/RecordingManager.cpp index dd5d274..58c6355 100644 --- a/ScreenRecorderLibNative/RecordingManager.cpp +++ b/ScreenRecorderLibNative/RecordingManager.cpp @@ -437,7 +437,7 @@ REC_RESULT RecordingManager::StartRecorderLoop(_In_ const std::vectorGetVideoFps(); } else if (recorderMode == RecorderModeInternal::Slideshow) { - videoFrameDurationMillis = GetSnapshotOptions()->GetSnapshotsInterval().count(); + videoFrameDurationMillis = (double)GetSnapshotOptions()->GetSnapshotsInterval().count(); } INT64 videoFrameDuration100Nanos = MillisToHundredNanos(videoFrameDurationMillis); @@ -446,9 +446,9 @@ REC_RESULT RecordingManager::StartRecorderLoop(_In_ const std::vectorm_RecordTaskCts.get_token(); INT64 minimumTimeForDelay100Nanons = 5000;//0.5ms - INT64 maxFrameLengthMillis = HundredNanosToMillis(m_MaxFrameLength100Nanos); + DWORD maxFrameLengthMillis = (DWORD)HundredNanosToMillis(m_MaxFrameLength100Nanos); DynamicWait DynamicWait; - int totalDiff = 0; + INT64 totalDiff = 0; auto IsTimeToTakeSnapshot([&]() { @@ -506,10 +506,10 @@ REC_RESULT RecordingManager::StartRecorderLoop(_In_ const std::vectorGrabAudioFrame(duration100Nanos); if (audioBytes.size() > 0) { - INT64 frameCount = audioBytes.size() / ((GetAudioOptions()->GetAudioBitsPerSample() / 8) * GetAudioOptions()->GetAudioChannels()); + INT64 frameCount = audioBytes.size() / (INT64)((GetAudioOptions()->GetAudioBitsPerSample() / 8) * GetAudioOptions()->GetAudioChannels()); INT64 newDuration = (frameCount * 10 * 1000 * 1000) / GetAudioOptions()->GetAudioSamplesPerSecond(); diff = newDuration - duration100Nanos; } @@ -808,7 +808,7 @@ HRESULT RecordingManager::ProcessTextureTransforms(_In_ ID3D11Texture2D *pTextur int leftMargin = (int)max(0, round(((double)videoOutputFrameSize.cx - (double)RectWidth(contentRect))) / 2); int topMargin = (int)max(0, round(((double)videoOutputFrameSize.cy - (double)RectHeight(contentRect))) / 2); - D3D11_BOX Box; + D3D11_BOX Box{}; Box.front = 0; Box.back = 1; Box.left = 0; diff --git a/ScreenRecorderLibNative/util.h b/ScreenRecorderLibNative/util.h index 208528d..69f41f9 100644 --- a/ScreenRecorderLibNative/util.h +++ b/ScreenRecorderLibNative/util.h @@ -159,7 +159,6 @@ inline double HundredNanosToSeconds(INT64 hundredNanos) { /// /// Forces the dimensions of rect to be even by adding 1*modifier pixel if odd. /// -/// inline RECT MakeRectEven(_In_ RECT &rect, _In_ int modifier = -1) { if ((rect.right - rect.left) % 2 != 0) @@ -171,7 +170,6 @@ inline RECT MakeRectEven(_In_ RECT &rect, _In_ int modifier = -1) /// /// Forces the dimensions of n to be even by adding 1*modifier pixel if odd. /// -/// inline LONG MakeEven(_In_ LONG n, _In_ int modifier = -1) { return n + (1 * modifier) * n % 2; } diff --git a/TestConsoleAppCpp/TestConsoleAppCpp.vcxproj b/TestConsoleAppCpp/TestConsoleAppCpp.vcxproj index a5c729a..c4cec01 100644 --- a/TestConsoleAppCpp/TestConsoleAppCpp.vcxproj +++ b/TestConsoleAppCpp/TestConsoleAppCpp.vcxproj @@ -25,7 +25,7 @@ TestConsoleAppCpp 10.0 4.8 - TestConsoleAppManagedCpp + TestConsoleAppCpp