Skip to content

Commit

Permalink
enable jack for win too
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrra committed Sep 15, 2023
1 parent d890977 commit 77c9dbe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/framework/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ set(MODULE audio)

include(GetPlatformInfo)

if (MUE_ENABLE_AUDIO_JACK)
set(DRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.h
)

else (MUE_ENABLE_AUDIO_JACK)

if (OS_IS_WIN)
set(DRIVER_SRC
#${CMAKE_CURRENT_LIST_DIR}/internal/platform/win/winmmdriver.cpp
Expand All @@ -37,21 +49,13 @@ if (OS_IS_WIN)
${CMAKE_CURRENT_LIST_DIR}/internal/platform/win/audiodeviceslistener.h
)
elseif(OS_IS_LIN OR OS_IS_FBSD)
set(JACK_SRC "")
if (MUE_ENABLE_AUDIO_JACK)
set(JACK_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/jack/jackaudiodriver.h
)
endif()
set(DRIVER_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/linuxaudiodriver.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/lin/audiodeviceslistener.h
${CMAKE_CURRENT_LIST_DIR}/internal/platform/alsa/alsaaudiodriver.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/platform/alsa/alsaaudiodriver.h
${JACK_SRC}
)
elseif(OS_IS_MAC)
set(DRIVER_SRC
Expand All @@ -72,6 +76,8 @@ elseif(OS_IS_WASM)
)
endif()

endif (MUE_ENABLE_AUDIO_JACK)

add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/fluidsynth fluidsynth)

set(MODULE_SRC
Expand Down
15 changes: 15 additions & 0 deletions src/framework/audio/internal/platform/lin/linuxaudiodriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
#include "../jack/jackaudiodriver.h" //FIX: relative path, set path in CMakeLists
#endif

#if defined(JACK_AUDIO) && !defined(OS_IS_LIN)
#define ALSA_PCM_NEW_HW_PARAMS_API
#include <alsa/asoundlib.h>
#endif

#include <fcntl.h>
#include <unistd.h>
Expand Down Expand Up @@ -95,11 +97,16 @@ AudioDeviceID LinuxAudioDriver::outputDevice() const

bool LinuxAudioDriver::makeDevice(const AudioDeviceID& deviceId)
{
#if defined(JACK_AUDIO) && !defined(OS_IS_LIN)
if (deviceId == "jack") {
m_current_audioDriverState = std::make_unique<JackDriverState>();
#else
if (deviceId == "alsa") {
m_current_audioDriverState = std::make_unique<AlsaDriverState>();
#if JACK_AUDIO
} else if (deviceId == "jack") {
m_current_audioDriverState = std::make_unique<JackDriverState>();
#endif
#endif
} else {
LOGE() << "Unknown device name: " << deviceId;
Expand Down Expand Up @@ -148,7 +155,11 @@ bool LinuxAudioDriver::selectOutputDevice(const AudioDeviceID& deviceId)

bool LinuxAudioDriver::resetToDefaultOutputDevice()
{
#if defined(JACK_AUDIO) && !defined(OS_IS_LIN)
return selectOutputDevice("jack"); // FIX:
#else
return selectOutputDevice("alsa"); // FIX:
#endif
}

mu::async::Notification LinuxAudioDriver::outputDeviceChanged() const
Expand All @@ -159,8 +170,12 @@ mu::async::Notification LinuxAudioDriver::outputDeviceChanged() const
AudioDeviceList LinuxAudioDriver::availableOutputDevices() const
{
AudioDeviceList devices;
#if defined(JACK_AUDIO) && !defined(OS_IS_LIN)
devices.push_back({ "jack", trc("audio", "JACK") });
#else
devices.push_back({ "alsa", trc("audio", "ALSA") });
devices.push_back({ "jack", trc("audio", "JACK") });
#endif

return devices;
}
Expand Down

0 comments on commit 77c9dbe

Please sign in to comment.