fixed IAudioSessionControl2 invocation, modified README
This commit is contained in:
parent
f931d2bfa4
commit
9806f046bd
4 changed files with 182 additions and 177 deletions
93
README.md
93
README.md
|
|
@ -1,89 +1,18 @@
|
|||
# Atonsio
|
||||
|
||||
**enberda filipas con esta mierda**, eh. Increible que esto lo haya hecho alguien digno de ser big techie.
|
||||
**Small prototype showing how to register as a COM application and reaching endpoint and session manipulation**.
|
||||
|
||||
Anyway, al caso:
|
||||
# Class graph
|
||||
|
||||
```
|
||||
IMMDeviceEnumerator
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
IMMDeviceCollection
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
IMMDevice--------------------------------------|
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
| \ |
|
||||
IMMEndpoint IAudioEndpointVolume IAudioSessionManager2
|
||||
(No demostrado) (Columen endpoint) (Manager de sesiones)
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
IAudioSessionEnumerator
|
||||
(Handle de sesiones)
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
IAudioSessionControl2
|
||||
(Cast a padre, 1 x sesion)
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
ISimpleAudioVolume
|
||||
(Via QueryInterface(), 1 x sesion ofc)
|
||||
```
|
||||

|
||||
|
||||
Ezpz microsoft comeme los cojones
|
||||
# Notes
|
||||
|
||||
- Name might appear blank. This is not a bug, but rather an inconvenience due to the fact that many programs create unnamed sessions. Mixers, such as `SndVol` or mine, overcome this fact by fetching its parent process' name.
|
||||
|
||||
# Build
|
||||
llvm-mingw 06 2022:
|
||||
|
||||
clang++ testmain.cpp -o si.exe -Wall -Wextra -Wpedantic -std=c++11 -g -gcodeview -L D:/Contenido/Capybara/llvm-mingw/x86_64-w64-mingw32/bin -L C:\capybara\libclang\x86_64-w64-mingw32\lib -l Ole32 -static -lc++ -lunwind --verbose
|
||||
- Built using `clang` using [**llvm-mingw UCRT 20220906**](https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906).
|
||||
|
||||
```
|
||||
clang++ testmain.cpp -o test.exe -Wall -Wextra -Wpedantic -std=c++11 -l Ole32 -static -lc++ -lunwind --verbose
|
||||
```
|
||||
26
graph.gv
Normal file
26
graph.gv
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
digraph coreaudiodemo {
|
||||
fontname="Helvetica,Arial,sans-serif"
|
||||
node [color=black, style=bold, fontname="Helvetica,Arial,sans-serif",shape="record"]
|
||||
edge [color=blue, style=bold, fontname="Helvetica,Arial,sans-serif"]
|
||||
|
||||
de [label="<p0> class IMMDeviceEnumerator\n(Retrieves current endpoints)",labelloc=b];
|
||||
dc [label="<p0> class IMMDeviceCollection\n(Endpoint collection)",labelloc=b];
|
||||
ie [label="<p0> class IMMDevice (Deceitful name, actual endpoint)",labelloc=b];
|
||||
ieroutes [label="<p0> class IMMEndpoint \n(Just Playback/Capture flag)
|
||||
| <p1> class IAudioEndpointVolume \n(Endpoint volume/balance)
|
||||
| <p2> class IAudioSessionManager \n(Entry point to endpoint's session management)",labelloc=b];
|
||||
iase [label="<p0> class IAudioSessionEnumerator \n(Retrieves endpoint's current sessions)",labelloc=b];
|
||||
iasc [label="<p0> class IAudioSessionControl \n(Used to call derived class)",labelloc=b];
|
||||
iasc2 [label="<p0> class IAudioSessionControl2 \n(Session management. Called via `QueryInterface())",labelloc=b];
|
||||
isav [label="<p0> class ISimpleAudioVolume \n(Session volume controls. Called via `QueryInterface())`",labelloc=b];
|
||||
|
||||
de -> dc;
|
||||
dc -> ie;
|
||||
ie -> ieroutes:p0 [label=""];
|
||||
ie -> ieroutes:p1;
|
||||
ie -> ieroutes:p2;
|
||||
ieroutes:p2 -> iase;
|
||||
iase -> iasc;
|
||||
iasc -> iasc2;
|
||||
iasc2 -> isav;
|
||||
}
|
||||
128
output.svg
Normal file
128
output.svg
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 9.0.0 (20230911.1827)
|
||||
-->
|
||||
<!-- Title: coreaudiodemo Pages: 1 -->
|
||||
<svg width="745pt" height="591pt"
|
||||
viewBox="0.00 0.00 744.62 591.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 587)">
|
||||
<title>coreaudiodemo</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-587 740.62,-587 740.62,4 -4,4"/>
|
||||
<!-- de -->
|
||||
<g id="node1" class="node">
|
||||
<title>de</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="194.38,-541.5 194.38,-582.5 393.38,-582.5 393.38,-541.5 194.38,-541.5"/>
|
||||
<text text-anchor="middle" x="293.88" y="-565.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IMMDeviceEnumerator</text>
|
||||
<text text-anchor="middle" x="293.88" y="-548.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Retrieves current endpoints)</text>
|
||||
</g>
|
||||
<!-- dc -->
|
||||
<g id="node2" class="node">
|
||||
<title>dc</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="200.38,-463.5 200.38,-504.5 387.38,-504.5 387.38,-463.5 200.38,-463.5"/>
|
||||
<text text-anchor="middle" x="293.88" y="-487.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IMMDeviceCollection</text>
|
||||
<text text-anchor="middle" x="293.88" y="-470.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Endpoint collection)</text>
|
||||
</g>
|
||||
<!-- de->dc -->
|
||||
<g id="edge1" class="edge">
|
||||
<title>de->dc</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M293.88,-541.03C293.88,-533.44 293.88,-524.6 293.88,-516.21"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="297.38,-517.86 293.88,-507.86 290.38,-517.86 297.38,-517.86"/>
|
||||
</g>
|
||||
<!-- ie -->
|
||||
<g id="node3" class="node">
|
||||
<title>ie</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="126.5,-390.5 126.5,-426.5 461.25,-426.5 461.25,-390.5 126.5,-390.5"/>
|
||||
<text text-anchor="middle" x="293.88" y="-403.45" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IMMDevice (Deceitful name, actual endpoint)</text>
|
||||
</g>
|
||||
<!-- dc->ie -->
|
||||
<g id="edge2" class="edge">
|
||||
<title>dc->ie</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M293.88,-463.3C293.88,-455.56 293.88,-446.51 293.88,-438.07"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="297.38,-439.77 293.88,-429.77 290.38,-439.77 297.38,-439.77"/>
|
||||
</g>
|
||||
<!-- ieroutes -->
|
||||
<g id="node4" class="node">
|
||||
<title>ieroutes</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="0,-312.5 0,-353.5 711.75,-353.5 711.75,-312.5 0,-312.5"/>
|
||||
<text text-anchor="middle" x="96.5" y="-336.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IMMEndpoint </text>
|
||||
<text text-anchor="middle" x="96.5" y="-319.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Just Playback/Capture flag)</text>
|
||||
<polyline fill="none" stroke="black" stroke-width="2" points="193,-312.5 193,-353.5"/>
|
||||
<text text-anchor="middle" x="294.38" y="-336.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IAudioEndpointVolume </text>
|
||||
<text text-anchor="middle" x="294.38" y="-319.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Endpoint volume/balance)</text>
|
||||
<polyline fill="none" stroke="black" stroke-width="2" points="395.75,-312.5 395.75,-353.5"/>
|
||||
<text text-anchor="middle" x="553.75" y="-336.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IAudioSessionManager </text>
|
||||
<text text-anchor="middle" x="553.75" y="-319.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Entry point to endpoint's session management)</text>
|
||||
</g>
|
||||
<!-- ie->ieroutes -->
|
||||
<g id="edge3" class="edge">
|
||||
<title>ie->ieroutes:p0</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M155.71,-390.03C130.46,-383.87 109.39,-375.66 100.9,-364.77"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="104.71,-364.98 97.93,-356.84 98.15,-367.43 104.71,-364.98"/>
|
||||
</g>
|
||||
<!-- ie->ieroutes -->
|
||||
<g id="edge4" class="edge">
|
||||
<title>ie->ieroutes:p1</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M293.88,-390.15C293.88,-382.87 293.88,-374.08 293.88,-365.33"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="297.38,-367.03 293.88,-357.03 290.38,-367.03 297.38,-367.03"/>
|
||||
</g>
|
||||
<!-- ie->ieroutes -->
|
||||
<g id="edge5" class="edge">
|
||||
<title>ie->ieroutes:p2</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M461.48,-398.45C503.53,-392.25 539.84,-381.94 550.63,-364.86"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="553.49,-367.48 553.01,-356.9 546.79,-365.48 553.49,-367.48"/>
|
||||
</g>
|
||||
<!-- iase -->
|
||||
<g id="node5" class="node">
|
||||
<title>iase</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="422.5,-234.5 422.5,-275.5 685.25,-275.5 685.25,-234.5 422.5,-234.5"/>
|
||||
<text text-anchor="middle" x="553.88" y="-258.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IAudioSessionEnumerator </text>
|
||||
<text text-anchor="middle" x="553.88" y="-241.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Retrieves endpoint's current sessions)</text>
|
||||
</g>
|
||||
<!-- ieroutes->iase -->
|
||||
<g id="edge6" class="edge">
|
||||
<title>ieroutes:p2->iase</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M553.88,-312C553.88,-303.97 553.88,-295.28 553.88,-287.21"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="557.38,-288.98 553.88,-278.98 550.38,-288.98 557.38,-288.98"/>
|
||||
</g>
|
||||
<!-- iasc -->
|
||||
<g id="node6" class="node">
|
||||
<title>iasc</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="456.25,-156.5 456.25,-197.5 651.5,-197.5 651.5,-156.5 456.25,-156.5"/>
|
||||
<text text-anchor="middle" x="553.88" y="-180.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IAudioSessionControl </text>
|
||||
<text text-anchor="middle" x="553.88" y="-163.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Used to call derived class)</text>
|
||||
</g>
|
||||
<!-- iase->iasc -->
|
||||
<g id="edge7" class="edge">
|
||||
<title>iase->iasc</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M553.88,-234.03C553.88,-226.44 553.88,-217.6 553.88,-209.21"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="557.38,-210.86 553.88,-200.86 550.38,-210.86 557.38,-210.86"/>
|
||||
</g>
|
||||
<!-- iasc2 -->
|
||||
<g id="node7" class="node">
|
||||
<title>iasc2</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="382,-78.5 382,-119.5 725.75,-119.5 725.75,-78.5 382,-78.5"/>
|
||||
<text text-anchor="middle" x="553.88" y="-102.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class IAudioSessionControl2 </text>
|
||||
<text text-anchor="middle" x="553.88" y="-85.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Session management. Called via `QueryInterface())</text>
|
||||
</g>
|
||||
<!-- iasc->iasc2 -->
|
||||
<g id="edge8" class="edge">
|
||||
<title>iasc->iasc2</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M553.88,-156.03C553.88,-148.44 553.88,-139.6 553.88,-131.21"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="557.38,-132.86 553.88,-122.86 550.38,-132.86 557.38,-132.86"/>
|
||||
</g>
|
||||
<!-- isav -->
|
||||
<g id="node8" class="node">
|
||||
<title>isav</title>
|
||||
<polygon fill="none" stroke="black" stroke-width="2" points="371.12,-0.5 371.12,-41.5 736.62,-41.5 736.62,-0.5 371.12,-0.5"/>
|
||||
<text text-anchor="middle" x="553.88" y="-24.2" font-family="Helvetica,Arial,sans-serif" font-size="14.00">class ISimpleAudioVolume </text>
|
||||
<text text-anchor="middle" x="553.88" y="-7.7" font-family="Helvetica,Arial,sans-serif" font-size="14.00">(Session volume controls. Called via `QueryInterface())`</text>
|
||||
</g>
|
||||
<!-- iasc2->isav -->
|
||||
<g id="edge9" class="edge">
|
||||
<title>iasc2->isav</title>
|
||||
<path fill="none" stroke="blue" stroke-width="2" d="M553.88,-78.03C553.88,-70.44 553.88,-61.6 553.88,-53.21"/>
|
||||
<polygon fill="blue" stroke="blue" stroke-width="2" points="557.38,-54.86 553.88,-44.86 550.38,-54.86 557.38,-54.86"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8 KiB |
114
testmain.cpp
114
testmain.cpp
|
|
@ -1,29 +1,17 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <combaseapi.h>
|
||||
#include <initguid.h>
|
||||
#include <functiondiscoverykeys_devpkey.h>
|
||||
|
||||
#include <endpointvolume.h>
|
||||
#include <audiopolicy.h>
|
||||
#include <audioclient.h>
|
||||
//#include <comdef.h>
|
||||
//#include <comip.h>
|
||||
#include <Winerror.h>
|
||||
|
||||
|
||||
//#define EXIT_ON_ERROR(hres, className) \
|
||||
if (FAILED(hres)) { printf("%s\n", #className); goto Exit; }
|
||||
|
||||
|
||||
#define EXIT_ON_ERROR(hres) \
|
||||
if (FAILED(hres)) { printf("%s - %d\n", __FILE__, __LINE__); goto Exit; }
|
||||
|
||||
|
|
@ -32,15 +20,6 @@
|
|||
if ((punk) != NULL) \
|
||||
{ (punk)->Release(); (punk) = NULL; }
|
||||
|
||||
//#pragma once
|
||||
|
||||
/*
|
||||
* Comentarios patrocinados por David
|
||||
* Enviar mensaje a @Phireh
|
||||
*/
|
||||
|
||||
// const IID IntID_IAudioEndpointVolume = __uuidof(IAudioEndpointVolume);
|
||||
|
||||
IMMDeviceEnumerator *deviceEnumeratorPtr = NULL;
|
||||
IMMDeviceCollection *deviceCollectionPtr = NULL;
|
||||
IMMDevice *endpointPtr = NULL;
|
||||
|
|
@ -49,6 +28,7 @@ IAudioEndpointVolume *endpointVolumePtr = NULL;
|
|||
IAudioSessionManager2 *sessionManagerPtr = NULL;
|
||||
|
||||
IAudioSessionEnumerator *sessionEnumeratorPtr = NULL;
|
||||
IAudioSessionControl* sessionControlPtr = NULL;
|
||||
IAudioSessionControl2 *sessionControl2Ptr = NULL;
|
||||
ISimpleAudioVolume *sessionVolumePtr = NULL;
|
||||
|
||||
|
|
@ -68,22 +48,11 @@ void PrintEndpointNames() {
|
|||
(void**)&deviceEnumeratorPtr);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
||||
//hr = deviceEnumeratorPtr->EnumAudioEndpoints(eRender, DEVICE_STATE_&deviceCollectionPtr);
|
||||
//hr = deviceEnumeratorPtr->EnumAudioEndpoints(eRender, DEVICE_STATE_&deviceCollectionPtr); << Elegimos a mano para ahorrar código de iteración
|
||||
//Llamar a dispositivo por defecto. 2o param no importa lmao
|
||||
hr = deviceEnumeratorPtr->GetDefaultAudioEndpoint(eRender, eConsole, &endpointPtr);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
||||
// UINT count;
|
||||
// hr = deviceCollectionPtr->GetCount(&count);
|
||||
// EXIT_ON_ERROR(hr)
|
||||
|
||||
// if (count == 0) {
|
||||
// printf("No endpoints found.\n");
|
||||
// }
|
||||
|
||||
// hr = deviceCollectionPtr->Item(i, &endpointPtr);
|
||||
// EXIT_ON_ERROR(hr)
|
||||
|
||||
//RECUPERAR ENDPOINT ID
|
||||
hr = endpointPtr->GetId(&endpointID);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
|
@ -94,10 +63,10 @@ void PrintEndpointNames() {
|
|||
|
||||
|
||||
PROPVARIANT varName;
|
||||
// Initialize container for property value.
|
||||
// Inicializar el struct para poder extraer la información.
|
||||
PropVariantInit(&varName);
|
||||
|
||||
// Get the endpoint's friendly-name property.
|
||||
// Cogemos el nombre humano
|
||||
hr = deviceEndpointPropertiesPtr->GetValue(PKEY_Device_FriendlyName , &varName);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
||||
|
|
@ -113,37 +82,35 @@ void PrintEndpointNames() {
|
|||
EXIT_ON_ERROR(hr);
|
||||
|
||||
//Registramos el gestor de sesiones para conseguir el handle que da el handle de sesiones a nivel informativo
|
||||
//Y justo despues, el que da control a nivel sonoro xdddddddddddddddddddddddddddddddddddddddddddddd
|
||||
//Y justo despues, el que da control a nivel sonoro
|
||||
hr = endpointPtr->Activate(__uuidof(IAudioSessionManager2), CLSCTX_ALL, NULL, (void**) &sessionManagerPtr);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
|
||||
//Ahora si viene el handle de las sesiones xdddddddddd
|
||||
//Ahora si viene el handle de las sesiones
|
||||
hr = sessionManagerPtr->GetSessionEnumerator(&sessionEnumeratorPtr);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
//Cogemos el numero de sesiones y recorremos para coger cada una
|
||||
//Luego tho, que soy una puta vaga y hay que probar cositas
|
||||
//Cogemos el numero de sesiones y recorreríamos para coger cada una. Aquí, se elige la 0 para, una vez más, no enmarañar el código.
|
||||
INT sessionCount;
|
||||
hr = sessionEnumeratorPtr->GetCount(&sessionCount);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
hr = sessionEnumeratorPtr->GetSession(2, (IAudioSessionControl**)&sessionControl2Ptr);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
LPWSTR sessionDisplayName;
|
||||
hr = sessionControl2Ptr->GetDisplayName(&sessionDisplayName);
|
||||
hr = sessionEnumeratorPtr->GetSession(0, (IAudioSessionControl**)&sessionControlPtr);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
hr = sessionControlPtr->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&sessionControl2Ptr);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
//Puede que el nombre no se rellene. Esto se debe a que no todos los programas registran su sesión con un nombre humano. SndVol.exe se toma la libertad de pesquisar el nombre a través de los metadatos del ejecutable que la ha creado si es una aplicación Win32, y otro campo si es una aplicación .appx.
|
||||
LPWSTR sessionDisplayName;
|
||||
hr = sessionControl2Ptr->IsSystemSoundsSession();
|
||||
if(hr)
|
||||
hr = sessionControl2Ptr->GetDisplayName(&sessionDisplayName);
|
||||
else
|
||||
sessionDisplayName = L"System Sounds";
|
||||
|
||||
printf("Sesion 0 de endpoint %S: \"%S\" \n Num sesiones: (%d)\n", varName.pwszVal, sessionDisplayName, sessionCount);
|
||||
|
||||
//hr = sessionControlPtr->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&sessionControl2Ptr);
|
||||
//EXIT_ON_ERROR(hr);
|
||||
|
||||
//hr = sessionControl2Ptr->GetProcessId(&foundProcessId);
|
||||
//EXIT_ON_ERROR(hr);
|
||||
|
||||
hr = sessionControl2Ptr->QueryInterface(__uuidof(ISimpleAudioVolume), (void**)&sessionVolumePtr);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
|
|
@ -162,42 +129,7 @@ void PrintEndpointNames() {
|
|||
//SAFE_RELEASE(sessionControlPtr);
|
||||
SAFE_RELEASE(sessionControl2Ptr);
|
||||
SAFE_RELEASE(sessionVolumePtr);
|
||||
/*
|
||||
// Each loop prints the name of an endpoint device.
|
||||
for (ULONG i = 0; i < count; i++) {
|
||||
// Get pointer to endpoint number i.
|
||||
hr = deviceCollectionPtr->Item(i, &endpointPtr);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
||||
// Get the endpoint ID string.
|
||||
hr = endpointPtr->GetId(&endpointID);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
||||
hr = endpointPtr->OpenPropertyStore(STGM_READ, &deviceEndpointPropertiesPtr);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
||||
PROPVARIANT varName;
|
||||
// Initialize container for property value.
|
||||
PropVariantInit(&varName);
|
||||
|
||||
// Get the endpoint's friendly-name property.2
|
||||
hr = deviceEndpointPropertiesPtr->GetValue(PKEY_Device_FriendlyName , &varName);
|
||||
EXIT_ON_ERROR(hr)
|
||||
|
||||
// Print endpoint friendly name and endpoint ID.
|
||||
printf("Endpoint %lu: \"%S\" (%S)\n", i, varName.pwszVal, endpointID);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CoTaskMemFree(endpointID);
|
||||
endpointID = NULL;
|
||||
PropVariantClear(&varName);
|
||||
SAFE_RELEASE(deviceEndpointPropertiesPtr)
|
||||
SAFE_RELEASE(endpointPtr)
|
||||
}
|
||||
*/
|
||||
SAFE_RELEASE(deviceEnumeratorPtr)
|
||||
SAFE_RELEASE(deviceCollectionPtr)
|
||||
return;
|
||||
|
|
@ -212,16 +144,6 @@ Exit:
|
|||
CoUninitialize();
|
||||
}
|
||||
|
||||
void onExit(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
PrintEndpointNames();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue