Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/sine-table-le…
Browse files Browse the repository at this point in the history
…ngth
  • Loading branch information
orottier committed Oct 20, 2023
2 parents 029dc04 + 2796013 commit f309e39
Show file tree
Hide file tree
Showing 85 changed files with 1,339 additions and 1,066 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: Post benchmark results
name: benchmark post results

# read-write repo token
# access to secrets
Expand All @@ -9,42 +9,39 @@ name: Post benchmark results
# see https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
on:
workflow_run:
branches-ignore:
- "main"
workflows: ["Build"]
workflows: ["benchmark"]
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- name: "Download artifact"
uses: actions/github-script@v3.1.0
uses: actions/github-script@v6
with:
script: |
const artifacts = await github.actions.listWorkflowRunArtifacts({
const fs = require('fs');
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
const matchArtifact = artifacts.data.artifacts.find((artifact) => {
return artifact.name == "pr"
})[0];
const download = await github.actions.downloadArtifact({
});
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: "Write result in PR"
uses: actions/github-script@v3
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -54,7 +51,7 @@ jobs:
const message = '```\nBenchmark result:\n\n' + iai_feature + '\n```\n';
await github.issues.createComment({
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
Expand Down
70 changes: 25 additions & 45 deletions .github/workflows/rust.yaml → .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -1,75 +1,51 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: Build
name: benchmark

# read-only repo token, no access to secrets
permissions:
contents: read

# no access to secrets
on:
push:
branches: [main]
pull_request:
issue_comment:
types: [created, edited]

env:
CARGO_TERM_COLOR: always

jobs:
verify-build:
benchmark:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '/bench')

steps:
- name: Install ALSA and Jack dependencies
run: |
sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-jackd2-dev cmake
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Check out repository
# the workflow is triggered from main branch
# cf. https://github.com/actions/checkout/issues/331
# need this first step to init the git repo
- name: Checkout
uses: actions/checkout@v3

- name: Generate Cargo.lock
run: cargo generate-lockfile

# restore cargo cache from previous runs
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
# Distinguished by the action name to avoid sharing!
shared-key: "rust"

# check it builds
- name: Build
run: cargo build --verbose --all-targets --all-features

# run tests
- name: Run tests
run: cargo test --verbose --all-features
- name: Install valgrind and hub
run: sudo apt-get update && sudo apt-get install hub valgrind

benchmark:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'

steps:
# checkout repo, install dependencies
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout Pull Request
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# install dependencies
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

# restore cargo cache from previous runs
- name: Rust Cache
uses: Swatinem/rust-cache@v2.0.0
uses: Swatinem/rust-cache@v2
with:
# The cache should not be shared between different workflows and jobs.
shared-key: ${{ github.workflow }}-${{ github.job }}

## Benchmarks
- name: install valgrind for benchmarks
run: sudo apt-get install valgrind
- name: Checkout main branch
run: git checkout main
- name: Copy over benchmarks from PR branch
Expand All @@ -83,12 +59,16 @@ jobs:
- name: Run bench against baseline
run: cargo bench --no-default-features | sed '0,/^test result:/d' | tee bench.txt

# for testing
# - name: create mock results
# run: echo "my bench results" > bench.txt

## Save results
## see https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- name: Save PR number and bench results
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/pr_number.txt
echo ${{ github.event.issue.number }} > ./pr/pr_number.txt
mv bench.txt ./pr/bench.txt
- uses: actions/upload-artifact@v2
with:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: build

# read-only repo token, no access to secrets
permissions:
contents: read

# no access to secrets
on:
push:
branches: [main]
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
verify-build:
runs-on: ubuntu-latest

steps:
- name: Install ALSA and Jack dependencies
run: |
sudo apt-get update && sudo apt-get install -y libasound2-dev libjack-jackd2-dev cmake
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Check out repository
uses: actions/checkout@v3

- name: Generate Cargo.lock
run: cargo generate-lockfile

# restore cargo cache from previous runs
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
# The cache should not be shared between different workflows and jobs.
shared-key: ${{ github.workflow }}-${{ github.job }}

# check it builds
- name: Build
run: cargo build --verbose --all-targets --all-features

# run tests
- name: Run tests
run: cargo test --verbose --all-features
4 changes: 2 additions & 2 deletions .github/workflows/msrv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- name: Cache Rust toolchain and build artifacts
uses: Swatinem/rust-cache@v2
with:
# Distinguished by the action name to avoid sharing!
shared-key: "msrv"
# The cache should not be shared between different workflows and jobs.
shared-key: ${{ github.workflow }}-${{ github.job }}

- name: Check workspace
run: cargo check --locked --workspace --verbose --all-targets --all-features
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
- name: Cache Rust toolchain and build artifacts
uses: Swatinem/rust-cache@v2
with:
# Distinguished by the action name to avoid sharing across different actions!
shared-key: "pre-commit"
# The cache should not be shared between different workflows and jobs.
shared-key: ${{ github.workflow }}-${{ github.job }}

- name: Detect code style issues (push)
uses: pre-commit/action@v3.0.0
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_stages:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -28,26 +28,26 @@ repos:
stages:
- commit-msg
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.8.1
rev: v0.10.0
hooks:
- id: markdownlint-cli2
exclude: ^LICENSE\.md$
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.5
rev: v0.9.0.6
hooks:
- id: shellcheck
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
args: [--ignore-words=.codespellignore]
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.23.3
rev: 0.27.0
hooks:
- id: check-github-actions
- id: check-github-workflows
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0
rev: v3.0.3
hooks:
- id: prettier
types_or:
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Version History

## Version 0.35.0 (2023-10-18)

- Fix: panic when creating and dropping PannerNodes
- Improved performance of setting panning mode to HRTF

## Version 0.34.0 (2023-10-12)

- Breaking: many AudioNode setter methods now require `&mut self` instead of `&self`
- Fix: all audio node settings are now applied in order in the audio graph
- Fix: render thread would crash when a PannerNode is removed
- Fixed and improved device ids for audio input/output devices
- Added current playhead position for AudioBufferSourceNode

## Version 0.33.0 (2023-07-27)

- Fix: clamp to number of output channels to 32 even if the hardware supports more to prevent runtime panics
- Fix: prevent a render thread panic if the audio graph is not fully initialized yet
- Fix: rename AudioDestination max_channels_count to max_channel_count
- Fix: AudioBufferSourceNode is now Send + Sync
- Change AudioProcessor::onmessage signature to prevent deallocations
- Add garbage collector thread as sidecar of the render thread to handle some deallocations

## Version 0.32.0 (2023-07-16)

- Fix for some audio node settings being applied out of order
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "web-audio-api"
version = "0.32.0"
version = "0.35.0"
authors = ["Otto <otto@ot-to.nl>"]
edition = "2021"
description = "A pure Rust implementation of the Web Audio API, for use in non-browser contexts"
Expand All @@ -22,7 +22,7 @@ cubeb = { version = "0.10", optional = true }
dasp_sample = "0.11"
float_eq = "1.0"
hound = "3.5"
hrtf = "0.8"
hrtf = "0.8.1"
llq = "0.1.1"
log = "0.4"
num-complex = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let file = std::fs::File::open("samples/major-scale.ogg").unwrap();
let buffer = context.decode_audio_data_sync(file).unwrap();

// setup an AudioBufferSourceNode
let src = context.create_buffer_source();
let mut src = context.create_buffer_source();
src.set_buffer(buffer);
src.set_loop(true);

Expand Down
Loading

0 comments on commit f309e39

Please sign in to comment.