<p>I decided to release a little tool that I created to test the C++ part of my Default Audio Device Switcher that I built using DefSOUND for SoundSwitch.</p>
<p>The tester only uses the lib to list all the audio device found (that are active) and then when a device change state, it will display the change.</p>
<h2 class="release-downloads-header">Update tooling for VS 2017</h2><div class="release-description"><p>Same testing tool, with the possibility to switch audio device.</p>
<p>Used only for testing purpose.</p>
<h1>Usage</h1>
<ul>
<li>s : toggle the default audio device</li>
<li>q : quit the application</li>
</ul></div><ul class="release-downloads"><li><a href="https://github.com/Belphemur/AudioEndPointLibrary/releases/download/v4.7.1/AudioTester_x64.zip" rel="nofollow"><strong class="release-name">AudioTester_x64.zip</strong> <small class="release-size">2.04 MB</small> <small class="release-download-count">157 downloads</small></a></li><li><a href="https://github.com/Belphemur/AudioEndPointLibrary/releases/download/v4.7.1/AudioTester_x86.zip" rel="nofollow"><strong class="release-name">AudioTester_x86.zip</strong> <small class="release-size">1.85 MB</small> <small class="release-download-count">54 downloads</small></a></li><li><a href="https://github.com/Belphemur/AudioEndPointLibrary/archive/v4.7.1.zip" rel="nofollow"><strong class="release-source">Source code</strong></a></li></ul>
<p>You can find enclosed the code used to create the tester:</p>
<script src="https://gist.github.com/58d45c5b9d123a82c8f2f983f32ceff0.js"></script><noscript><pre><code class="language-c++ c++">// 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&#039;ll be notified"; <;<; std::endl <;<; std::endl;
 auto test = &#039;a&#039;;
 while (test != &#039;q&#039;) {
 do_work(playbackDevices, recordingDevices);
 std::cin >;>; test;
 if(test == &#039;r&#039;)
 {
 signInfo->;m_signal->;Unregister(*signInfo);
 }
 }
}

</code></pre></noscript>
<p> ;</p>

Leave a Reply Cancel reply