Permalink
Browse files

AudioCommon: Implement WASAPI

  • Loading branch information...
spycrab committed Feb 10, 2018
1 parent 92ec97f commit a196dfe50d1d8a2fcd2ffbe5c8eea10687f1698f
@@ -10,6 +10,7 @@
#include "AudioCommon/OpenALStream.h"
#include "AudioCommon/OpenSLESStream.h"
#include "AudioCommon/PulseAudioStream.h"
#include "AudioCommon/WASAPIStream.h"
#include "AudioCommon/XAudio2Stream.h"
#include "AudioCommon/XAudio2_7Stream.h"
#include "Common/Common.h"
@@ -50,6 +51,8 @@ void InitSoundStream()
g_sound_stream = std::make_unique<PulseAudio>();
else if (backend == BACKEND_OPENSLES && OpenSLESStream::isValid())
g_sound_stream = std::make_unique<OpenSLESStream>();
else if (backend == BACKEND_WASAPI && WASAPIStream::isValid())
g_sound_stream = std::make_unique<WASAPIStream>();
if (!g_sound_stream || !g_sound_stream->Init())
{
@@ -110,6 +113,9 @@ std::vector<std::string> GetSoundBackends()
backends.push_back(BACKEND_OPENAL);
if (OpenSLESStream::isValid())
backends.push_back(BACKEND_OPENSLES);
if (WASAPIStream::isValid())
backends.push_back(BACKEND_WASAPI);
return backends;
}
@@ -128,15 +134,16 @@ bool SupportsDPL2Decoder(const std::string& backend)
bool SupportsLatencyControl(const std::string& backend)
{
return backend == BACKEND_OPENAL;
return backend == BACKEND_OPENAL || backend == BACKEND_WASAPI;
}
bool SupportsVolumeChanges(const std::string& backend)
{
// FIXME: this one should ask the backend whether it supports it.
// but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider...
return backend == BACKEND_CUBEB || backend == BACKEND_OPENAL || backend == BACKEND_XAUDIO2;
return backend == BACKEND_CUBEB || backend == BACKEND_OPENAL || backend == BACKEND_XAUDIO2 ||
backend == BACKEND_WASAPI;
}
void UpdateSoundStream()
@@ -231,4 +238,4 @@ void ToggleMuteVolume()
isMuted = !isMuted;
UpdateSoundStream();
}
}
} // namespace AudioCommon
@@ -44,6 +44,7 @@
<ClCompile Include="Mixer.cpp" />
<ClCompile Include="NullSoundStream.cpp" />
<ClCompile Include="OpenALStream.cpp" />
<ClCompile Include="WASAPIStream.cpp" />
<ClCompile Include="WaveFile.cpp" />
<ClCompile Include="XAudio2Stream.cpp" />
<ClCompile Include="XAudio2_7Stream.cpp">
@@ -63,6 +64,7 @@
<ClInclude Include="OpenSLESStream.h" />
<ClInclude Include="PulseAudioStream.h" />
<ClInclude Include="SoundStream.h" />
<ClInclude Include="WASAPIStream.h" />
<ClInclude Include="WaveFile.h" />
<ClInclude Include="XAudio2Stream.h" />
<ClInclude Include="XAudio2_7Stream.h" />
@@ -81,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
@@ -27,6 +27,9 @@
<ClCompile Include="CubebStream.cpp">
<Filter>SoundStreams</Filter>
</ClCompile>
<ClCompile Include="WASAPIStream.cpp">
<Filter>SoundStreams</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AudioCommon.h" />
@@ -62,8 +65,11 @@
<ClInclude Include="CubebStream.h">
<Filter>SoundStreams</Filter>
</ClInclude>
<ClInclude Include="WASAPIStream.h">
<Filter>SoundStreams</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>
@@ -47,6 +47,7 @@ else()
endif()
if(WIN32)
target_sources(audiocommon PRIVATE WASAPIStream.cpp)
target_sources(audiocommon PRIVATE XAudio2Stream.cpp)
add_library(audiocommon_xaudio27 "XAudio2_7Stream.cpp")
Oops, something went wrong.

0 comments on commit a196dfe

Please sign in to comment.