From 72801def1480905af53fb12927b3f122d53d5313 Mon Sep 17 00:00:00 2001 From: "jonathan.reichardt" Date: Wed, 10 Jun 2026 23:48:07 +0200 Subject: [PATCH 1/2] Migrate engine + io_sim to oals::rt shim --- .github/workflows/ci.yaml | 34 +++++++++++++++++++++++++++ .gitignore | 1 + OpenAudioNetwork | 2 +- engine/main.cpp | 48 ++++++++------------------------------- io_sim/main.cpp | 23 ++++--------------- 5 files changed, 51 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .gitignore diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..c385975 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: ['**'] + pull_request: + branches: ['**'] + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install deps (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends cmake ninja-build + + - name: Install deps (macOS) + if: runner.os == 'macOS' + run: brew install cmake ninja + + - name: Configure + run: cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Debug + + - name: Build + run: cmake --build build \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e864704 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/build/ \ No newline at end of file diff --git a/OpenAudioNetwork b/OpenAudioNetwork index 3295bc0..a967774 160000 --- a/OpenAudioNetwork +++ b/OpenAudioNetwork @@ -1 +1 @@ -Subproject commit 3295bc0ec7bdfe16822798379a17b1df95504891 +Subproject commit a967774f496c6b2b6a74cc0c1d9f2bb211c6a65d diff --git a/engine/main.cpp b/engine/main.cpp index 6af85a5..e78bee7 100644 --- a/engine/main.cpp +++ b/engine/main.cpp @@ -18,27 +18,7 @@ #include "OpenAudioNetwork/common/AudioRouter.h" #include "OpenAudioNetwork/common/ClockMaster.h" - -#include "linux/sched.h" - -void set_thread_realtime(uint8_t prio) { - sched_param sparams{}; - sparams.sched_priority = prio; - - if (sched_setscheduler(0, SCHED_FIFO, &sparams) == -1) { - std::cerr << "Failed to set thread realtime..." << std::endl; - } -} - -void set_running_cpu(int cpu_id) { - cpu_set_t cs{}; - CPU_ZERO(&cs); - CPU_SET(cpu_id, &cs); - - if (sched_setaffinity(0, sizeof(cpu_set_t), &cs) != 0) { - std::cerr << "Failed to set affinity..." << std::endl; - } -} +#include int main(int argc, char* argv[]) { @@ -121,8 +101,8 @@ int main(int argc, char* argv[]) { load_plugins(ploader, &plumber, &router, nman.get_net_mapper()); std::thread audiopoll_thread = std::thread([&router]() { - set_thread_realtime(25); - set_running_cpu(1); + oals::rt::set_thread_realtime(25); + oals::rt::set_running_cpu(1); while (true) { router.poll_audio_data(false); @@ -130,8 +110,8 @@ int main(int argc, char* argv[]) { }); std::thread controlpoll_thread = std::thread([&router]() { - set_thread_realtime(20); - set_running_cpu(1); + oals::rt::set_thread_realtime(20); + oals::rt::set_running_cpu(1); while (true) { router.poll_control_packets(false); @@ -139,12 +119,8 @@ int main(int argc, char* argv[]) { }); std::thread pipe_updater = std::thread([&audio_engine, &router]() { - set_thread_realtime(80); - set_running_cpu(2); - - timespec thread_wait_time{}; - thread_wait_time.tv_sec = 0; - thread_wait_time.tv_nsec = 100; + oals::rt::set_thread_realtime(80); + oals::rt::set_running_cpu(2); while (true) { router.poll_local_audio_buffer(); @@ -153,20 +129,16 @@ int main(int argc, char* argv[]) { // This process is a high-priority realtime process // It is a blocking task, to let the other threads run // I must add a small wait here - clock_nanosleep(CLOCK_MONOTONIC, 0, &thread_wait_time, nullptr); + oals::rt::precise_sleep(100); } }); std::thread clock_syncer = std::thread([&nman]() { - set_running_cpu(3); - - timespec thread_wait_time{}; - thread_wait_time.tv_sec = 0; - thread_wait_time.tv_nsec = 10000; + oals::rt::set_running_cpu(3); while (true) { nman.clock_master_process(); - clock_nanosleep(CLOCK_MONOTONIC, 0, &thread_wait_time, nullptr); + oals::rt::precise_sleep(10000); } }); diff --git a/io_sim/main.cpp b/io_sim/main.cpp index 1ebdbc2..b1e1289 100644 --- a/io_sim/main.cpp +++ b/io_sim/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -15,17 +16,7 @@ #include #include #include - -#include - -void set_thread_realtime(uint8_t prio) { - sched_param sparams{}; - sparams.sched_priority = prio; - - if (sched_setscheduler(0, SCHED_FIFO, &sparams) != 0) { - std::cerr << "Failed to set thread realtime..." << std::endl; - } -} +#include float sig_gen(float f, float gain, int n) { constexpr float T = 1.0f / 96000.0f; @@ -237,11 +228,7 @@ int main(int argc, char* argv[]) { playback_thread.detach(); */ - sched_param params{}; - params.sched_priority = 99; - if (sched_setscheduler(0, SCHED_RR, ¶ms) != 0) { - std::cerr << "FAILED TO SET SCHED" << std::endl; - } + oals::rt::set_process_scheduler_rr(99); auto wait_base = (long)((AUDIO_DATA_SAMPLES_PER_PACKETS * (1.0f / 96000.0f)) * 1e9); @@ -277,7 +264,7 @@ int main(int argc, char* argv[]) { chann++; } - set_thread_realtime(50); + oals::rt::set_thread_realtime(50); std::cout << "START" << std::endl; @@ -301,7 +288,7 @@ int main(int argc, char* argv[]) { //last_stamp = now; - clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, nullptr); + oals::rt::precise_sleep(ts.tv_nsec); ts.tv_nsec = wait_base; } From 471fcad96c20be4b035b4b8524d78ad137f0b13a Mon Sep 17 00:00:00 2001 From: Jonathan Darius Reichardt <31374296+jonathan-reichardt@users.noreply.github.com> Date: Wed, 10 Jun 2026 23:54:05 +0200 Subject: [PATCH 2/2] Install additional dependencies in CI --- .github/workflows/ci.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c385975..5cc3441 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,6 +8,7 @@ on: jobs: build: + name: ${{ matrix.os }} strategy: fail-fast: false matrix: @@ -16,19 +17,28 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: recursive - name: Install deps (Linux) if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y --no-install-recommends cmake ninja-build + sudo apt-get install -y --no-install-recommends \ + cmake ninja-build pkg-config \ + qt6-base-dev libsndfile1-dev - name: Install deps (macOS) if: runner.os == 'macOS' - run: brew install cmake ninja + run: | + brew update + brew install cmake ninja qt6 libsndfile - name: Configure - run: cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Debug + run: | + cmake -G Ninja -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_PREFIX_PATH="$(brew --prefix qt6 2>/dev/null || echo /usr)" - name: Build - run: cmake --build build \ No newline at end of file + run: cmake --build build