Created
November 24, 2016 19:22
-
-
Save Belphemur/58d45c5b9d123a82c8f2f983f32ceff0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // AudioEndTester.cpp : Defines the entry point for the console application. | |
| // | |
| #include "stdafx.h" | |
| #include "AudioEndPointLibrary.h" | |
| #include <iostream> | |
| #include <string> | |
| void do_work(AudioEndPoint::AudioDeviceList playbackDevices, AudioEndPoint::AudioDeviceList recordingDevices) | |
| { | |
| for (AudioEndPoint::AudioDeviceList::iterator i = playbackDevices.begin(); i != playbackDevices.end(); ++i) | |
| { | |
| auto audioDevice = std::move(*i); | |
| std::wcout << audioDevice->FriendlyName << L" : " << audioDevice->ID <<L" isDefault: "<<(audioDevice->IsDefault(eConsole)?L"True":L"False")<<std::endl; | |
| if(std::wstring(audioDevice->FriendlyName).find(std::wstring(L"Logitech")) != std::wstring::npos) | |
| { | |
| //audioDevice->SetDefault(eMultimedia); | |
| } | |
| } | |
| std::wcout << std::endl << std::endl; | |
| for (AudioEndPoint::AudioDeviceList::iterator i = recordingDevices.begin(); i != recordingDevices.end(); ++i) | |
| { | |
| auto audioDevice = std::move(*i); | |
| std::wcout << audioDevice->FriendlyName << L" : " << audioDevice->ID << std::endl; | |
| if (std::wstring(audioDevice->FriendlyName).find(std::wstring(L"Logitech")) != std::wstring::npos) | |
| { | |
| //audioDevice->SetDefault(eMultimedia); | |
| } | |
| } | |
| } | |
| void SetLists(AudioEndPoint::AudioDeviceList& playbackDevices, AudioEndPoint::AudioDeviceList& recordingDevices) | |
| { | |
| playbackDevices = AudioEndPoint::CAudioEndPointLibrary::GetInstance().GetPlaybackDevices(DefSound::Active); | |
| recordingDevices = AudioEndPoint::CAudioEndPointLibrary::GetInstance().GetRecordingDevices(DefSound::Active); | |
| } | |
| int main() | |
| { | |
| AudioEndPoint::AudioDeviceList playbackDevices; | |
| AudioEndPoint::AudioDeviceList recordingDevices; | |
| SetLists(playbackDevices, recordingDevices); | |
| AudioEndPoint::CAudioEndPointLibrary::GetInstance().Signals->DeviceStateChanged.Register([](AudioEndPoint::AudioDevicePtr device, DefSound::EDeviceState newState){ | |
| std::wcout << std::endl << device->FriendlyName <<L" : State (" << device->DeviceState << L")" << std::endl; | |
| }); | |
| auto signInfo = &AudioEndPoint::CAudioEndPointLibrary::GetInstance().Signals->DeviceDefaultChanged.Register([](AudioEndPoint::AudioDevicePtr device, ERole role) { | |
| std::wcout << std::endl << device->FriendlyName << L" : ROLE (" << role << L", "<<device->IsDefault(role) << L")" << std::endl; | |
| }); | |
| AudioEndPoint::CAudioEndPointLibrary::GetInstance().Signals->DeviceRemoved.Register([](AudioEndPoint::AudioDevicePtr device) { | |
| std::wcout << std::endl << device->ID << L" : REMOVED" << std::endl; | |
| }); | |
| std::wcout << L"Enter the letter Q + Enter to stop the application" << std::endl << "When a device change state or is disconnected you'll be notified" << std::endl << std::endl; | |
| auto test = 'a'; | |
| while (test != 'q') { | |
| do_work(playbackDevices, recordingDevices); | |
| std::cin >> test; | |
| if(test == 'r') | |
| { | |
| signInfo->m_signal->Unregister(*signInfo); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment