-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/oals rt shim #4
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['**'] | ||
| pull_request: | ||
| branches: ['**'] | ||
|
|
||
| jobs: | ||
| build: | ||
| name: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| 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 pkg-config \ | ||
| qt6-base-dev libsndfile1-dev | ||
|
|
||
| - name: Install deps (macOS) | ||
| if: runner.os == 'macOS' | ||
| run: | | ||
| brew update | ||
| brew install cmake ninja qt6 libsndfile | ||
|
|
||
| - name: Configure | ||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| **/build/ |
| +32 −0 | .github/workflows/ci.yaml | |
| +1 −0 | .gitignore | |
| +2 −0 | netutils/CMakeLists.txt | |
| +71 −0 | netutils/rt.cpp | |
| +20 −0 | netutils/rt.h |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,24 +8,15 @@ | |
| #include <cmath> | ||
| #include <chrono> | ||
| #include <queue> | ||
| #include <ctime> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I missed the line, but I can't see where this header is used. |
||
|
|
||
| #include <alsa/asoundlib.h> | ||
| #include <sndfile.h> | ||
|
|
||
| #include <OpenAudioNetwork/common/NetworkMapper.h> | ||
| #include <OpenAudioNetwork/common/packet_structs.h> | ||
| #include <OpenAudioNetwork/common/ClockSlave.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) != 0) { | ||
| std::cerr << "Failed to set thread realtime..." << std::endl; | ||
| } | ||
| } | ||
| #include <OpenAudioNetwork/netutils/rt.h> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as in engine/main.cpp |
||
|
|
||
| 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; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: OAN is a "local" library, not a system one, so it should use quotes instead of brackets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, understood. Is this a project preference or a general C++ thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More a general cpp thing. But it is just styling, it doesn't change anything regarding functionality