New upstream version 19.0.3+dfsg1
This commit is contained in:
parent
3708b8e092
commit
1f1bbb3518
534 changed files with 13862 additions and 2459 deletions
|
|
@ -30,6 +30,13 @@ using namespace std;
|
|||
#include <shellapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <Dwmapi.h>
|
||||
#include <psapi.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <audiopolicy.h>
|
||||
|
||||
#include <util/windows/WinHandle.hpp>
|
||||
#include <util/windows/HRError.hpp>
|
||||
#include <util/windows/ComPtr.hpp>
|
||||
|
||||
static inline bool check_path(const char* data, const char *path,
|
||||
string &output)
|
||||
|
|
@ -216,3 +223,114 @@ void SetWin32DropStyle(QWidget *window)
|
|||
ex_style |= WS_EX_ACCEPTFILES;
|
||||
SetWindowLongPtr(hwnd, GWL_EXSTYLE, ex_style);
|
||||
}
|
||||
|
||||
bool DisableAudioDucking(bool disable)
|
||||
{
|
||||
ComPtr<IMMDeviceEnumerator> devEmum;
|
||||
ComPtr<IMMDevice> device;
|
||||
ComPtr<IAudioSessionManager2> sessionManager2;
|
||||
ComPtr<IAudioSessionControl> sessionControl;
|
||||
ComPtr<IAudioSessionControl2> sessionControl2;
|
||||
|
||||
HRESULT result = CoCreateInstance(__uuidof(MMDeviceEnumerator),
|
||||
nullptr, CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IMMDeviceEnumerator),
|
||||
(void **)&devEmum);
|
||||
if (FAILED(result))
|
||||
return false;
|
||||
|
||||
result = devEmum->GetDefaultAudioEndpoint(eRender, eConsole, &device);
|
||||
if (FAILED(result))
|
||||
return false;
|
||||
|
||||
result = device->Activate(__uuidof(IAudioSessionManager2),
|
||||
CLSCTX_INPROC_SERVER, nullptr,
|
||||
(void **)&sessionManager2);
|
||||
if (FAILED(result))
|
||||
return false;
|
||||
|
||||
result = sessionManager2->GetAudioSessionControl(nullptr, 0,
|
||||
&sessionControl);
|
||||
if (FAILED(result))
|
||||
return false;
|
||||
|
||||
result = sessionControl->QueryInterface(&sessionControl2);
|
||||
if (FAILED(result))
|
||||
return false;
|
||||
|
||||
result = sessionControl2->SetDuckingPreference(disable);
|
||||
return SUCCEEDED(result);
|
||||
}
|
||||
|
||||
uint64_t CurrentMemoryUsage()
|
||||
{
|
||||
PROCESS_MEMORY_COUNTERS pmc = {};
|
||||
pmc.cb = sizeof(pmc);
|
||||
|
||||
if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
|
||||
return 0;
|
||||
|
||||
return (uint64_t)pmc.WorkingSetSize;
|
||||
}
|
||||
|
||||
struct RunOnceMutexData {
|
||||
WinHandle handle;
|
||||
|
||||
inline RunOnceMutexData(HANDLE h) : handle(h) {}
|
||||
};
|
||||
|
||||
RunOnceMutex::RunOnceMutex(RunOnceMutex &&rom)
|
||||
{
|
||||
delete data;
|
||||
data = rom.data;
|
||||
rom.data = nullptr;
|
||||
}
|
||||
|
||||
RunOnceMutex::~RunOnceMutex()
|
||||
{
|
||||
delete data;
|
||||
}
|
||||
|
||||
RunOnceMutex &RunOnceMutex::operator=(RunOnceMutex &&rom)
|
||||
{
|
||||
delete data;
|
||||
data = rom.data;
|
||||
rom.data = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
RunOnceMutex GetRunOnceMutex(bool &already_running)
|
||||
{
|
||||
string name;
|
||||
|
||||
if (!portable_mode) {
|
||||
name = "OBSStudioCore";
|
||||
} else {
|
||||
char path[500];
|
||||
*path = 0;
|
||||
GetConfigPath(path, sizeof(path), "");
|
||||
name = "OBSStudioPortable";
|
||||
name += path;
|
||||
}
|
||||
|
||||
BPtr<wchar_t> wname;
|
||||
os_utf8_to_wcs_ptr(name.c_str(), name.size(), &wname);
|
||||
|
||||
if (wname) {
|
||||
wchar_t *temp = wname;
|
||||
while (*temp) {
|
||||
if (!iswalnum(*temp))
|
||||
*temp = L'_';
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE h = OpenMutexW(SYNCHRONIZE, false, wname.Get());
|
||||
already_running = !!h;
|
||||
|
||||
if (!already_running)
|
||||
h = CreateMutexW(nullptr, false, wname.Get());
|
||||
|
||||
RunOnceMutex rom(h ? new RunOnceMutexData(h) : nullptr);
|
||||
return rom;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue