Skip to content

Commit

Permalink
Fix C6214, rein in OP tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
riverar committed Jul 17, 2015
1 parent 6bee563 commit 36d3396
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions EarTrumpet.Interop/AudioSessionService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ HRESULT AudioSessionService::CreateEtAudioSessionFromAudioSession(CComPtr<IAudio
FAST_FAIL(audioSessionControl->QueryInterface(IID_PPV_ARGS(&simpleAudioVolume)));
FAST_FAIL(simpleAudioVolume->GetMasterVolume(&etAudioSession->Volume));

if (IsImmersiveProcess(pid))
HRESULT hr = IsImmersiveProcess(pid);
if (hr == S_OK)
{
PWSTR appUserModelId;
FAST_FAIL(GetAppUserModelIdFromPid(pid, &appUserModelId));
Expand All @@ -99,7 +100,7 @@ HRESULT AudioSessionService::CreateEtAudioSessionFromAudioSession(CComPtr<IAudio

etAudioSession->IsDesktopApp = false;
}
else
else if (hr == S_FALSE)
{
bool isSystemSoundsSession = (S_OK == audioSessionControl2->IsSystemSoundsSession());

Expand Down Expand Up @@ -163,12 +164,19 @@ HRESULT AudioSessionService::GetAudioSessions(void** audioSessions)
return S_OK;
}

BOOL AudioSessionService::IsImmersiveProcess(DWORD pid)
HRESULT AudioSessionService::IsImmersiveProcess(DWORD pid)
{
shared_ptr<void> processHandle(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid), CloseHandle);
shared_ptr<void> processHandle(OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid), CloseHandle);
FAST_FAIL_HANDLE(processHandle.get());

return ::IsImmersiveProcess(processHandle.get());
if (::IsImmersiveProcess(processHandle.get()))
{
return S_OK;
}
else
{
return S_FALSE;
}
}

HRESULT AudioSessionService::GetAppUserModelIdFromPid(DWORD pid, LPWSTR* applicationUserModelIdPtr)
Expand Down
2 changes: 1 addition & 1 deletion EarTrumpet.Interop/AudioSessionService.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace EarTrumpet
HRESULT CreateEtAudioSessionFromAudioSession(CComPtr<IAudioSessionEnumerator> sessionEnumerator, int sessionCount, EarTrumpetAudioSession* etAudioSession);
HRESULT GetAppProperties(PCWSTR pszAppId, PWSTR* ppszName, PWSTR* ppszIcon, ULONG *background);
HRESULT GetAppUserModelIdFromPid(DWORD pid, LPWSTR* applicationUserModelIdPtr);
BOOL IsImmersiveProcess(DWORD pid);
HRESULT IsImmersiveProcess(DWORD pid);

std::vector<EarTrumpetAudioSession> _sessions;
std::map<int, CComPtr<IAudioSessionControl2>> _sessionMap;
Expand Down

0 comments on commit 36d3396

Please sign in to comment.