57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
#pragma once
|
|
#include "msinclude.h"
|
|
|
|
#include "global.h"
|
|
#include "contclasses.h"
|
|
|
|
class Endpoint;
|
|
|
|
class SessionStateCallback : public IAudioSessionEvents {
|
|
public:
|
|
SessionStateCallback(SessionHandler *sh);
|
|
ULONG AddRef();
|
|
ULONG Release();
|
|
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
|
HRESULT OnSessionCreated(IAudioSessionControl *NewSession);
|
|
HRESULT OnChannelVolumeChanged(DWORD ChannelCount, float NewChannelVolumeArray[], DWORD ChangedChannel, LPCGUID EventContext);
|
|
HRESULT OnDisplayNameChanged(LPCWSTR NewDisplayName, LPCGUID EventContext);
|
|
HRESULT OnGroupingParamChanged( LPCGUID NewGroupingParam, LPCGUID EventContext);
|
|
HRESULT OnIconPathChanged(LPCWSTR NewIconPath, LPCGUID EventContext);
|
|
HRESULT OnSessionDisconnected(AudioSessionDisconnectReason DisconnectReason);
|
|
HRESULT OnSimpleVolumeChanged(float NewVolume, BOOL NewMute, LPCGUID EventContext);
|
|
HRESULT OnStateChanged(AudioSessionState NewState);
|
|
|
|
private:
|
|
ULONG ref = 1;
|
|
SessionHandler *sh;
|
|
};
|
|
|
|
class Session {
|
|
|
|
public:
|
|
Session(Endpoint* ep, IAudioSessionControl2* sessionControl, size_t idx);
|
|
Session(Endpoint* ep, IAudioSessionControl2* sessionControl) : Session(ep, sessionControl, SIZE_MAX) {};
|
|
void setVolume(NGuid guid, int channel, float volume);
|
|
float getVolume(int channel);
|
|
void setMute(NGuid guid, bool muted);
|
|
bool getMute();
|
|
SessionState getState();
|
|
void setState(SessionState state);
|
|
void setIndex(size_t idx);
|
|
std::wstring getName();
|
|
|
|
void setStateCallback(SessionStateCallback *ssc);
|
|
void removeStateCallback(SessionStateCallback *ssc);
|
|
~Session();
|
|
//uint32_t getChannelCount();
|
|
|
|
private:
|
|
std::wstring fetchProcessName(DWORD pid);
|
|
std::wstring sessionName;
|
|
SessionState sessionState;
|
|
Endpoint* ep;
|
|
IAudioSessionControl2* sessionControl = nullptr;
|
|
ISimpleAudioVolume* sessionVolume = nullptr;
|
|
size_t idx;
|
|
};
|
|
|