temp commit
This commit is contained in:
parent
064c16d9e7
commit
574c6f039e
7 changed files with 99 additions and 11 deletions
|
|
@ -37,6 +37,22 @@ HRESULT EndpointNewSessionCallback::QueryInterface(REFIID riid, VOID **ppvInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT EndpointNewSessionCallback::OnSessionCreated(IAudioSessionControl *NewSession) {
|
HRESULT EndpointNewSessionCallback::OnSessionCreated(IAudioSessionControl *NewSession) {
|
||||||
|
if (eph->getFlow() == Flows::FLOW_CAPTURE) return S_OK;
|
||||||
|
|
||||||
|
HRESULT result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
|
IAudioSessionControl2* sessionControl;
|
||||||
|
//ISimmpleAudioVolume* sessionVolume;
|
||||||
|
if (FAILED(NewSession->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&sessionControl))) { log_wdebugcpp(L"no nueva sesion......"); };
|
||||||
|
if (sessionControl) {
|
||||||
|
sessionControl->AddRef();
|
||||||
|
//sessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (void**)&sessionVolume);
|
||||||
|
Session* newSession = new Session(this->eph->getEndpoint(), sessionControl);
|
||||||
|
eph->addSession(newSession);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == S_OK)
|
||||||
|
CoUninitialize();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,6 +315,11 @@ void Endpoint::activateEndpointSessions() {
|
||||||
sessionEnumerator->Release();
|
sessionEnumerator->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Endpoint::addSession(Session* session) {
|
||||||
|
session->setIndex(this->getSessionCount());
|
||||||
|
endpointSessions.push_back(session);
|
||||||
|
}
|
||||||
|
|
||||||
void Endpoint::activateEndpointVolume() {
|
void Endpoint::activateEndpointVolume() {
|
||||||
//bool extraThread = false;
|
//bool extraThread = false;
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class Endpoint {
|
||||||
/* sessions */
|
/* sessions */
|
||||||
std::vector<Session*> getSessions();
|
std::vector<Session*> getSessions();
|
||||||
size_t getSessionCount();
|
size_t getSessionCount();
|
||||||
|
void addSession(Session* session);
|
||||||
|
|
||||||
~Endpoint();
|
~Endpoint();
|
||||||
|
|
||||||
|
|
@ -135,7 +136,6 @@ class Overseer {
|
||||||
|
|
||||||
class EndpointNewSessionCallback : public IAudioSessionNotification {
|
class EndpointNewSessionCallback : public IAudioSessionNotification {
|
||||||
public:
|
public:
|
||||||
//EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices);
|
|
||||||
EndpointNewSessionCallback(EndpointHandler *eph);
|
EndpointNewSessionCallback(EndpointHandler *eph);
|
||||||
ULONG AddRef();
|
ULONG AddRef();
|
||||||
ULONG Release();
|
ULONG Release();
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,11 @@ HRESULT SessionStateCallback::OnGroupingParamChanged(LPCGUID NewGroupingParam, L
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT SessionStateCallback::OnStateChanged(AudioSessionState NewState) {
|
HRESULT SessionStateCallback::OnStateChanged(AudioSessionState NewState) {
|
||||||
|
/* enum _AudioSessionState {
|
||||||
|
* AudioSessionStateInactive,
|
||||||
|
* AudioSessionStateActive,
|
||||||
|
* AudioSessionStateExpired
|
||||||
|
* } AudioSessionState; */
|
||||||
/*
|
/*
|
||||||
* char *pszState = "?????";
|
* char *pszState = "?????";
|
||||||
*
|
*
|
||||||
|
|
@ -85,7 +90,6 @@ HRESULT SessionStateCallback::OnStateChanged(AudioSessionState NewState) {
|
||||||
* }
|
* }
|
||||||
* printf("New session state = %s\n", pszState);
|
* printf("New session state = %s\n", pszState);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,6 +130,20 @@ Session::Session(Endpoint* ep, IAudioSessionControl2* sessionControl, size_t idx
|
||||||
this->sessionControl = sessionControl;
|
this->sessionControl = sessionControl;
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
|
|
||||||
|
AudioSessionState msState;
|
||||||
|
sessionControl->GetState(&msState);
|
||||||
|
switch (msState) {
|
||||||
|
case AudioSessionState::AudioSessionStateActive:
|
||||||
|
this->sessionState = SessionState::ACTIVE;
|
||||||
|
break;
|
||||||
|
case AudioSessionState::AudioSessionStateInactive:
|
||||||
|
this->sessionState = SessionState::INACTIVE;
|
||||||
|
break;
|
||||||
|
case AudioSessionState::AudioSessionStateExpired:
|
||||||
|
this->sessionState = SessionState::EXPIRED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
sessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (void**)&sessionVolume);
|
sessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (void**)&sessionVolume);
|
||||||
DWORD pid;
|
DWORD pid;
|
||||||
sessionControl->GetProcessId(&pid);
|
sessionControl->GetProcessId(&pid);
|
||||||
|
|
@ -180,6 +198,10 @@ void Session::setVolume(NGuid guid, int channel, float volume) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::setIndex(size_t idx) {
|
||||||
|
this->idx = idx;
|
||||||
|
}
|
||||||
|
|
||||||
void Session::setMute(NGuid guid, bool muted) {
|
void Session::setMute(NGuid guid, bool muted) {
|
||||||
GUID tempMsGuid = NGuidToGUID(guid);
|
GUID tempMsGuid = NGuidToGUID(guid);
|
||||||
if(FAILED(sessionVolume->SetMute(muted, &tempMsGuid))) { log_wdebugcpp(std::wstring(L"SessionVolume null?")); };
|
if(FAILED(sessionVolume->SetMute(muted, &tempMsGuid))) { log_wdebugcpp(std::wstring(L"SessionVolume null?")); };
|
||||||
|
|
@ -268,6 +290,15 @@ wchar_t* fileDescription = NULL;
|
||||||
return exePath;
|
return exePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo: conflicting names. change callback name
|
||||||
|
void Session::setState(SessionState state) {
|
||||||
|
sessionState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionState Session::getState() {
|
||||||
|
return sessionState;
|
||||||
|
}
|
||||||
|
|
||||||
void Session::setStateCallback(SessionStateCallback *ssc){
|
void Session::setStateCallback(SessionStateCallback *ssc){
|
||||||
sessionControl->RegisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
sessionControl->RegisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
||||||
}
|
}
|
||||||
|
|
@ -275,3 +306,8 @@ void Session::setStateCallback(SessionStateCallback *ssc){
|
||||||
void Session::removeStateCallback(SessionStateCallback *ssc){
|
void Session::removeStateCallback(SessionStateCallback *ssc){
|
||||||
sessionControl->UnregisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
sessionControl->UnregisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Session::~Session() {
|
||||||
|
sessionControl->Release();
|
||||||
|
sessionVolume->Release();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,25 @@ class Session {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Session(Endpoint* ep, IAudioSessionControl2* sessionControl, size_t idx);
|
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);
|
void setVolume(NGuid guid, int channel, float volume);
|
||||||
float getVolume(int channel);
|
float getVolume(int channel);
|
||||||
void setMute(NGuid guid, bool muted);
|
void setMute(NGuid guid, bool muted);
|
||||||
bool getMute();
|
bool getMute();
|
||||||
|
SessionState getState();
|
||||||
|
void setState(SessionState state);
|
||||||
|
void setIndex(size_t idx);
|
||||||
std::wstring getName();
|
std::wstring getName();
|
||||||
|
|
||||||
void setStateCallback(SessionStateCallback *ssc);
|
void setStateCallback(SessionStateCallback *ssc);
|
||||||
void removeStateCallback(SessionStateCallback *ssc);
|
void removeStateCallback(SessionStateCallback *ssc);
|
||||||
|
~Session();
|
||||||
//uint32_t getChannelCount();
|
//uint32_t getChannelCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::wstring fetchProcessName(DWORD pid);
|
std::wstring fetchProcessName(DWORD pid);
|
||||||
std::wstring sessionName;
|
std::wstring sessionName;
|
||||||
|
SessionState sessionState;
|
||||||
Endpoint* ep;
|
Endpoint* ep;
|
||||||
IAudioSessionControl2* sessionControl = nullptr;
|
IAudioSessionControl2* sessionControl = nullptr;
|
||||||
ISimpleAudioVolume* sessionVolume = nullptr;
|
ISimpleAudioVolume* sessionVolume = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,19 @@ std::vector<SessionHandler*> EndpointHandler::getSessionHandlers(){
|
||||||
return this->sessionHandlers;
|
return this->sessionHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Endpoint* EndpointHandler::getEndpoint() {
|
||||||
|
return this->ep;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointHandler::addSession(Session* session) {
|
||||||
|
ep->addSession(session);
|
||||||
|
|
||||||
|
if (this->getState() == EndpointState::ENDPOINT_ACTIVE) {
|
||||||
|
SessionHandler* sessionHandler = new SessionHandler(this, session, (getSessionCount() - 1));
|
||||||
|
sessionHandlers.push_back(sessionHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EndpointHandler::~EndpointHandler() {
|
EndpointHandler::~EndpointHandler() {
|
||||||
ep->removeVolumeCallback(epc);
|
ep->removeVolumeCallback(epc);
|
||||||
epc->Release();
|
epc->Release();
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,11 @@ public:
|
||||||
/* sessions */
|
/* sessions */
|
||||||
size_t getSessionCount();
|
size_t getSessionCount();
|
||||||
std::vector<SessionHandler*> getSessionHandlers();
|
std::vector<SessionHandler*> getSessionHandlers();
|
||||||
|
void createNewSession();
|
||||||
|
Endpoint* getEndpoint();
|
||||||
|
|
||||||
|
/*Session*/
|
||||||
|
void addSession(Session* session);
|
||||||
|
|
||||||
~EndpointHandler();
|
~EndpointHandler();
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
25
src/global.h
25
src/global.h
|
|
@ -31,24 +31,31 @@ enum AudioChannel {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EndpointState {
|
enum EndpointState {
|
||||||
ENDPOINT_ACTIVE = (1 << 0),
|
ENDPOINT_ACTIVE = (1 << 0),
|
||||||
ENDPOINT_DISABLED = (1 << 1),
|
ENDPOINT_DISABLED = (1 << 1),
|
||||||
ENDPOINT_NOTPRESENT = (1 << 2),
|
ENDPOINT_NOTPRESENT = (1 << 2),
|
||||||
ENDPOINT_UNPLUGGED = (1 << 3),
|
ENDPOINT_UNPLUGGED = (1 << 3),
|
||||||
ENDPOINT_ALL = 0x0F
|
ENDPOINT_ALL = 0x0F
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SessionState {
|
||||||
|
ACTIVE = (1 << 0),
|
||||||
|
INACTIVE = (1 << 1),
|
||||||
|
EXPIRED = (1 << 2),
|
||||||
|
ALL = 0x07
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Flows {
|
enum Flows {
|
||||||
FLOW_PLAYBACK = (1 << 0),
|
FLOW_PLAYBACK = (1 << 0),
|
||||||
FLOW_CAPTURE = (1 << 1),
|
FLOW_CAPTURE = (1 << 1),
|
||||||
FLOW_BOTH = (1 << 2),
|
FLOW_BOTH = (1 << 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
ROLE_CONSOLE = (1 << 0),
|
ROLE_CONSOLE = (1 << 0),
|
||||||
ROLE_MULTIMEDIA = (1 << 1),
|
ROLE_MULTIMEDIA = (1 << 1),
|
||||||
ROLE_COMMUNICATIONS = (1 << 2),
|
ROLE_COMMUNICATIONS = (1 << 2),
|
||||||
ROLE_ALL = 0x07,
|
ROLE_ALL = 0x07,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NGuid {
|
struct NGuid {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue