Skip to content

Commit 1d04b4e

Browse files
authored
Fix Sndio backend & cleanup compilation on OpenBSD (#8407)
- Resolves #8406 by fixing a sndio backend regression introduced in #7568 - Sets `Qt[5-6]_DIR` and `Qt[5-6]Test_DIR` automatically for OpenBSD, similar to how this is handled for macOS - Add `$LOCALBASE` and `$X11BASE` to include and link paths when compiling for OpenBSD - Explicitly disable several features by default when compiling for OpenBSD, as is done in the ports tree
1 parent 948bbf9 commit 1d04b4e

5 files changed

Lines changed: 53 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,32 @@ ELSE(LMMS_BUILD_WIN32)
150150
SET(STATUS_WINMM "<not supported on this platform>")
151151
ENDIF(LMMS_BUILD_WIN32)
152152

153+
IF(LMMS_BUILD_OPENBSD)
154+
# “don't link deprecated ossaudio on OpenBSD”
155+
# https://cvsweb.openbsd.org/checkout/ports/audio/lmms/patches/patch-CMakeLists_txt?rev=1.3
156+
SET(WANT_OSS OFF)
157+
SET(STATUS_OSS "<not supported on this platform>")
158+
# LMMS finds SDL and compiles fine with it enabled, but it doesn't
159+
# appear as an option when choosing an audio backend in settings for
160+
# some reason. This might be fixable, but the OpenBSD ports
161+
# maintainers have also explicitly disabled SDL since 2010-10-28.
162+
# https://cvsweb.openbsd.org/checkout/ports/audio/lmms/Makefile?rev=1.1
163+
SET(WANT_SDL OFF)
164+
SET(STATUS_SDL "<not supported on this platform>")
165+
# “explicitly disable pulseaudio in these ports so they won't pick
166+
# it up when it becomes available.”
167+
# https://cvsweb.openbsd.org/checkout/ports/audio/lmms/Makefile?rev=1.5
168+
SET(WANT_PULSEAUDIO OFF)
169+
SET(STATUS_PULSEAUDIO "<not supported on this platform>")
170+
# OpenBSD does not and never will have WINE, which is necessary for
171+
# Windows VST support.
172+
# TODO: Is Linux VST support on OpenBSD possible?
173+
SET(WANT_VST OFF)
174+
SET(STATUS_VST "<not supported on this platform>")
175+
SET(STATUS_VST_32 "<not supported on this platform>")
176+
SET(STATUS_VST_64 "<not supported on this platform>")
177+
ENDIF()
178+
153179
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
154180

155181
CHECK_INCLUDE_FILES(pthread.h LMMS_HAVE_PTHREAD_H)
@@ -165,8 +191,6 @@ CHECK_INCLUDE_FILES(sys/soundcard.h LMMS_HAVE_SYS_SOUNDCARD_H)
165191
CHECK_INCLUDE_FILES(soundcard.h LMMS_HAVE_SOUNDCARD_H)
166192
CHECK_INCLUDE_FILES(fcntl.h LMMS_HAVE_FCNTL_H)
167193
CHECK_INCLUDE_FILES(sys/ioctl.h LMMS_HAVE_SYS_IOCTL_H)
168-
CHECK_INCLUDE_FILES(ctype.h LMMS_HAVE_CTYPE_H)
169-
CHECK_INCLUDE_FILES(string.h LMMS_HAVE_STRING_H)
170194
CHECK_INCLUDE_FILES(process.h LMMS_HAVE_PROCESS_H)
171195
CHECK_INCLUDE_FILES(locale.h LMMS_HAVE_LOCALE_H)
172196

cmake/modules/DetectMachine.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,12 @@ IF(LMMS_BUILD_APPLE)
192192
STRING(REGEX REPLACE "\\.[0-9]*$" "" APPLE_OS_VER "${APPLE_OS_VER}")
193193
SET(CMAKE_MACOSX_RPATH 1)
194194
ENDIF()
195+
196+
IF(LMMS_BUILD_OPENBSD)
197+
SET(Qt5_DIR "${OPENBSD_LOCALBASE}/lib/qt5/cmake/Qt5/")
198+
SET(Qt5Test_DIR "${OPENBSD_LOCALBASE}/lib/qt5/cmake/Qt5Test/")
199+
SET(Qt6_DIR "${OPENBSD_LOCALBASE}/lib/qt6/cmake/Qt6/")
200+
SET(Qt6Test_DIR "${OPENBSD_LOCALBASE}/lib/qt6/cmake/Qt6Test/")
201+
INCLUDE_DIRECTORIES("${OPENBSD_LOCALBASE}/include/" "${OPENBSD_X11BASE}/include/")
202+
LINK_DIRECTORIES("${OPENBSD_LOCALBASE}/lib/" "${OPENBSD_X11BASE}/lib/")
203+
ENDIF()

doc/Doxyfile.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,8 +1981,6 @@ PREDEFINED = "LMMS_BUILD_LINUX=" \
19811981
"LMMS_HAVE_SOUNDCARD_H=" \
19821982
"LMMS_HAVE_FCNTL_H=" \
19831983
"LMMS_HAVE_SYS_IOCTL_H=" \
1984-
"LMMS_HAVE_CTYPE_H=" \
1985-
"LMMS_HAVE_STRING_H=" \
19861984
"LMMS_HAVE_PROCESS_H=" \
19871985
"LMMS_HAVE_LOCALE_H=" \
19881986

src/core/audio/AudioSndio.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ AudioSndio::AudioSndio(bool& _success_ful, AudioEngine* _audioEngine)
6868
sio_initpar(&m_par);
6969

7070
m_par.pchan = channels();
71-
m_par.bits = 16;
71+
m_par.bits = sizeof(int_sample_t) * 8;
72+
m_par.sig = 1; // int_sample_t must be signed
7273
m_par.le = SIO_LE_NATIVE;
7374
m_par.rate = sampleRate();
7475
m_par.round = audioEngine()->framesPerAudioBuffer();
@@ -130,12 +131,25 @@ void AudioSndio::stopProcessingImpl()
130131
void AudioSndio::run()
131132
{
132133
const auto framesPerAudioBuffer = audioEngine()->framesPerAudioBuffer();
133-
auto buf = std::vector<float>(framesPerAudioBuffer * channels());
134+
const auto samplesPerAudioBuffer = framesPerAudioBuffer * channels();
135+
auto fbuf = std::vector<sample_t>(samplesPerAudioBuffer);
136+
auto ibuf = std::vector<int_sample_t>(samplesPerAudioBuffer);
134137

135138
while (AudioDevice::isRunning())
136139
{
137-
audioEngine()->renderNextBuffer({buf.data(), channels(), framesPerAudioBuffer});
138-
sio_write(m_hdl, buf.data(), buf.size() * sizeof(float));
140+
audioEngine()->renderNextBuffer({fbuf.data(), channels(), framesPerAudioBuffer});
141+
142+
// Sndio doesn't speak float, so convert samples to signed int.
143+
// While convertToS16() exists, it is intentionally not used
144+
// here. There is no need to convert endian-ness since sndio was
145+
// initialized with SIO_LE_NATIVE, and there's no reason to
146+
// also convert to SampleFrame.
147+
for (auto i = 0u; i < samplesPerAudioBuffer; ++i)
148+
{
149+
ibuf[i] = static_cast<int_sample_t>(AudioEngine::clip(fbuf[i]) * OUTPUT_SAMPLE_MULTIPLIER);
150+
}
151+
152+
sio_write(m_hdl, ibuf.data(), ibuf.size() * sizeof(int_sample_t));
139153
}
140154
}
141155

src/lmmsconfig.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,5 @@
5252
#cmakedefine LMMS_HAVE_SOUNDCARD_H
5353
#cmakedefine LMMS_HAVE_FCNTL_H
5454
#cmakedefine LMMS_HAVE_SYS_IOCTL_H
55-
#cmakedefine LMMS_HAVE_CTYPE_H
56-
#cmakedefine LMMS_HAVE_STRING_H
5755
#cmakedefine LMMS_HAVE_PROCESS_H
5856
#cmakedefine LMMS_HAVE_LOCALE_H

0 commit comments

Comments
 (0)