Skip to content

Commit

Permalink
Audio: don’t build ALSA, PulseAudio or FAudio backends when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
linkmauve authored and Nekotekina committed Oct 31, 2019
1 parent 63bbf11 commit fdc834d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 25 deletions.
8 changes: 8 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ if(USE_ALSA)
target_link_libraries(3rdparty_alsa INTERFACE ${ALSA_LIBRARIES})

set(ALSA_TARGET 3rdparty_alsa)
else()
unset(USE_ALSA)
#set(USE_ALSA FALSE)
endif()
endif()

Expand All @@ -279,6 +282,9 @@ if(USE_PULSE)
target_link_libraries(3rdparty_pulse INTERFACE ${PULSE_LDFLAGS})

set(PULSE_TARGET 3rdparty_pulse)
else()
unset(USE_PULSE)
#set(USE_PULSE FALSE)
endif()
endif()

Expand Down Expand Up @@ -344,6 +350,8 @@ if(USE_FAUDIO)
pkg_check_modules(SDL2 sdl2)
if (NOT SDL2_FOUND OR SDL2_VERSION VERSION_LESS 2.0.9)
message("-- RPCS3: FAudio requires SDL 2.0.9 or newer.")
unset(USE_FAUDIO)
#set(USE_FAUDIO FALSE)
else()
add_subdirectory(FAudio EXCLUDE_FROM_ALL)
target_compile_definitions(FAudio INTERFACE -DHAVE_FAUDIO)
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/Audio/ALSA/ALSABackend.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef HAVE_ALSA
#error "ALSA support disabled but still being built."
#endif

#include "stdafx.h"
#include "Emu/System.h"

#include "ALSABackend.h"

#ifdef HAVE_ALSA


static void error(int err, const char* reason)
{
Expand Down Expand Up @@ -160,5 +162,3 @@ bool ALSABackend::AddData(const void* src, u32 num_samples)

return true;
}

#endif
6 changes: 3 additions & 3 deletions rpcs3/Emu/Audio/ALSA/ALSABackend.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#ifdef HAVE_ALSA
#ifndef HAVE_ALSA
#error "ALSA support disabled but still being built."
#endif

#include "Emu/Audio/AudioBackend.h"

Expand All @@ -26,5 +28,3 @@ class ALSABackend : public AudioBackend

virtual bool AddData(const void* src, u32 num_samples) override;
};

#endif
8 changes: 4 additions & 4 deletions rpcs3/Emu/Audio/FAudio/FAudioBackend.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "FAudioBackend.h"
#ifndef HAVE_FAUDIO
#error "FAudio support disabled but still being built."
#endif

#ifdef HAVE_FAUDIO
#include "FAudioBackend.h"

FAudioBackend::FAudioBackend()
{
Expand Down Expand Up @@ -175,5 +177,3 @@ f32 FAudioBackend::SetFrequencyRatio(f32 new_ratio)

return new_ratio;
}

#endif
6 changes: 3 additions & 3 deletions rpcs3/Emu/Audio/FAudio/FAudioBackend.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#ifdef HAVE_FAUDIO
#ifndef HAVE_FAUDIO
#error "FAudio support disabled but still being built."
#endif

#include "Emu/Audio/AudioBackend.h"
#include "3rdparty/FAudio/include/FAudio.h"
Expand Down Expand Up @@ -40,5 +42,3 @@ class FAudioBackend : public AudioBackend
virtual u64 GetNumEnqueuedSamples() override;
virtual f32 SetFrequencyRatio(f32 new_ratio) override;
};

#endif
8 changes: 4 additions & 4 deletions rpcs3/Emu/Audio/Pulse/PulseBackend.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef HAVE_PULSE
#error "PulseAudio support disabled but still being built."
#endif

#include "Emu/System.h"
#include "PulseBackend.h"

#ifdef HAVE_PULSE

#include <pulse/simple.h>
#include <pulse/error.h>

Expand Down Expand Up @@ -70,5 +72,3 @@ bool PulseBackend::AddData(const void* src, u32 num_samples)

return true;
}

#endif
7 changes: 4 additions & 3 deletions rpcs3/Emu/Audio/Pulse/PulseBackend.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once

#ifdef HAVE_PULSE
#ifndef HAVE_PULSE
#error "PulseAudio support disabled but still being built."
#endif

#include <pulse/simple.h>
#include "Emu/Audio/AudioBackend.h"

Expand All @@ -23,5 +26,3 @@ class PulseBackend : public AudioBackend
private:
pa_simple *connection = nullptr;
};

#endif
20 changes: 16 additions & 4 deletions rpcs3/Emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,23 @@ target_sources(rpcs3_emu PRIVATE
target_sources(rpcs3_emu PRIVATE
Audio/AudioDumper.cpp
Audio/AL/OpenALBackend.cpp
Audio/ALSA/ALSABackend.cpp
Audio/Pulse/PulseBackend.cpp
Audio/FAudio/FAudioBackend.cpp
)

if(HAVE_ALSA)
target_sources(rpcs3_emu PRIVATE Audio/ALSA/ALSABackend.cpp)
target_link_libraries(rpcs3_emu PUBLIC 3rdparty::alsa)
endif()

if(HAVE_PULSE)
target_sources(rpcs3_emu PRIVATE Audio/Pulse/PulseBackend.cpp)
target_link_libraries(rpcs3_emu PUBLIC 3rdparty::pulse)
endif()

if(HAVE_FAUDIO)
target_sources(rpcs3_emu PRIVATE Audio/FAudio/FAudioBackend.cpp)
target_link_libraries(rpcs3_emu PUBLIC 3rdparty::faudio)
endif()

if(WIN32)
target_sources(rpcs3_emu PRIVATE
Audio/XAudio2/XAudio27Backend.cpp
Expand All @@ -105,7 +117,7 @@ endif()

target_link_libraries(rpcs3_emu
PUBLIC
3rdparty::alsa 3rdparty::pulse 3rdparty::openal 3rdparty::faudio)
3rdparty::openal)


# Cell
Expand Down

0 comments on commit fdc834d

Please sign in to comment.