Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD: Rewrite OSS backend, introduce sosso library #943

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

0EVSG
Copy link
Contributor

@0EVSG 0EVSG commented Jul 6, 2023

This is a complete rewrite of the OSS backend for FreeBSD - none of this
affects other systems or touches code outside of the freebsd directory.
Main motivation was to make better use of my RME RayDAT PCIe sound
card and its low-latency capabilities. This endeavor quickly escalated into
separate testing programs and then a C++ header-only library to manage
OSS channels. The result of which is hereby used to implement the
FreeBSD OSS backend of JACK, bringing some substantial improvements
over the old code.

The synced OSS operation (sosso) library

As a header-only C++ library, synced OSS operation (sosso) is used to
clean up and separate the low-level handling of FreeBSD OSS devices
in JACK. Features include:

  • Supports both read() / write() and mmap() IO operation.
  • Adaptive polling, better suited for low-latency requirements.
  • Internal double buffer to avoid troubles with OSS buffer resize.
  • Closely monitors progress and drift for each channel (+/- 1ms).
  • Facilitates drift correction through buffer offsets.
  • Depends on C++ standard library and system headers, nothing else.

Although the sosso library is somewhat tailored to the needs of JACK,
it was developed separately and will eventually be published and / or
used in other projects. Therefore the headers follow a different
formatting style and are more liberally licensed (ISC).

Rewrite the OSS backend using the sosso library

Make use of the sosso library to handle the low-level operation of
OSS devices on FreeBSD. Further separate this part into the
JackOSSChannel class, which should make it easier to reuse the code
for JackOSSAdapter (not planned yet).
JackOSSChannel features an additional assist thread which helps to
process the OSS device when the driver thread is busy with the JACK
dependency graph.
Combined with the improvements of the sosso library, these changes
bring JACK into the realm of real-time audio processing on FreeBSD,
for select PCI sound cards (4-6ms round trip latency).

@0EVSG 0EVSG added backend Related to a specific backend FreeBSD Bug or feature related to using JACK on FreeBSD labels Jul 6, 2023
@0EVSG 0EVSG requested a review from falkTX July 6, 2023 19:39
@0EVSG 0EVSG self-assigned this Jul 6, 2023
@0EVSG
Copy link
Contributor Author

0EVSG commented Dec 9, 2023

Ping! @falkTX, should I just merge this if you don't have time for a review? It's only relevant to FreeBSD.

@falkTX
Copy link
Member

falkTX commented Dec 9, 2023

it has been on my mind for a while, reviewing this before a release. give me a bit more time please, the changeset is not that small

@0EVSG
Copy link
Contributor Author

0EVSG commented Dec 9, 2023

That's fine with me, take your time and thanks for looking into it - would be nice though to have a small window before release to fix any issues, like a week in advance.

It's quite a lot of changes and I'd appreciate your review. Maybe you want to concentrate on the second commit with all the JackOSS* sources and treat the sosso headers more like an external library. I'm particularly interested in your opinion on the additional assist thread: It takes over OSS buffer handling while the maln driver thread is busy working on the process graph. Working on the process graph seems to take quite some time (up to 1ms) even with undemanding workloads, so the assist thread became necessary to prevent underruns on small OSS buffers.
If you have better ideas, please let me know.

@0EVSG
Copy link
Contributor Author

0EVSG commented Jan 26, 2024

Force push added some missing mutex unlocks, fixes a hangup after IO errors.

@0EVSG
Copy link
Contributor Author

0EVSG commented Jul 28, 2024

Hey, I missed the anniversary on this PR - happy birthday! ;-)

@falkTX: Any realistic chance of a release in the near future? I don't want to put pressure on you, just a statement so I can adjust my plans. This has to go into FreeBSD ports some way or the other, and I'll temporarily switch port sources to my own repo to include it, if needed.

As a header-only C++ library, synced OSS operation (sosso) is used to
clean up and separate the low-level handling of FreeBSD OSS devices
in JACK. Features include:

 * Supports both read() / write() and mmap() IO operation.
 * Adaptive polling, better suited for low-latency requirements.
 * Internal double buffer to avoid troubles with OSS buffer resize.
 * Closely monitors progress and drift for each channel (+/- 1ms).
 * Facilitates drift correction through buffer offsets.
 * Depends on C++ standard library and system headers, nothing else.

Although the sosso library is somewhat tailored to the needs of JACK,
it was developed separately and will eventually be published and / or
used in other projects. Therefore the headers follow a different
formatting style and are more liberally licensed (ISC).
Make use of the sosso library to handle the low-level operation of
OSS devices on FreeBSD. Further separate this part into the
JackOSSChannel class, which should make it easier to reuse the code
for JackOSSAdapter (not planned yet).
JackOSSChannel features an additional assist thread which helps to
process the OSS device when the driver thread is busy with the JACK
dependency graph.
Combined with the improvements of the sosso library, these changes
bring JACK into the realm of real-time audio processing on FreeBSD,
for select PCI sound cards (4-6ms round trip latency).
@falkTX
Copy link
Member

falkTX commented Jul 28, 2024

realistically september, finally got a home of my own but was in the middle of 2 other trips so a lot of stuff stopped while I focus on more personal / life things.
I want to give some attention to carla before jack2 (as carla is reaching a breaking point where new distros require qt6 and will drop qt5) so need to give that priority once I get free time.

@0EVSG
Copy link
Contributor Author

0EVSG commented Jul 28, 2024

Just did a rebase on the HEAD of current develop branch, no changes to my commits.

September is fine, I may try to offer this as a build option in FreeBSD ports. Congrats to you for your own home, enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to a specific backend FreeBSD Bug or feature related to using JACK on FreeBSD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants