1
0
Fork 0

Compare commits

..

1 commit

Author SHA1 Message Date
Alex Janka a54abb48e7 raw-window-handle 0.6.0 2024-02-08 15:20:59 +11:00
27 changed files with 184 additions and 435 deletions

View file

@ -54,9 +54,8 @@ jobs:
uses: dtolnay/rust-toolchain@nightly uses: dtolnay/rust-toolchain@nightly
- name: Run the tests - name: Run the tests
# Don't use --all-features as that will enable a whole bunch of # Don't use --all-features as that will enable a whole bunch of
# conflicting iced features. `--locked` ensures that the lockfile is up # conflicting iced features
# to date. We only really need this in one of the builds. run: cargo test --workspace --features "simd,standalone,zstd"
run: cargo test --locked --workspace --features "simd,standalone,zstd"
# This makes sure that NIH-plug can be compiled without VST3 support # This makes sure that NIH-plug can be compiled without VST3 support
build-without-vst3: build-without-vst3:

View file

@ -10,62 +10,6 @@ Since there is no stable release yet, the changes are organized per day in
reverse chronological order. The main purpose of this document in its current reverse chronological order. The main purpose of this document in its current
state is to list breaking changes. state is to list breaking changes.
## [2024-05-05]
### Breaking changes
- `nih_plug_egui` has been updated from egui 0.26.1 to egui 0.27.2.
- `nih_plug_vizia` has been updated to the latest version with some a additional
patches. This includes a workaround for the problem where opening multiple
instances of a plugin's GUI on Windows or macOS would result in crashes.
### Changed
- Two byte slices are now accepted in `NoteEvent::from_midi()` if the event
doesn't use the third byte.
### Fixed
- Fixed a race condition in the VST3 GUI event loop on Linux. This could cause
panics with certain versions of Carla.
- The CPAL backend now correctly handles situations where it receives fewer
samples than configured.
- Fixed the handling of multichannel audio in the CPAL backend.
## [2024-05-04]
### Fixed
- Fixed a soundness issue in the buffer management where in-place input/output
buffers may not have been recognized properly before.
## [2024-03-23]
### Added
- `nih_plug_xtask` now detects and uses non-standard `target` directory
locations if overridden through Cargo's settings.
## [2024-03-18]
### Changed
- (Keyboard) input events sent by the host through VST3's `IPlugView` interface
are now explicitly ignored. This may allow a couple more keyboard events to
reach through to plugin windows in hosts that use these.
## [2024-02-23]
### Fixed
- Fixed `nih_plug_egui` panicking due to cursor icons not yet being implemented in baseview for MacOS and Windows.
## [2024-02-22]
### Breaking changes
- `nih_plug_egui` has been updated from egui 0.22.0 to using egui 0.26.1.
## [2023-12-30] ## [2023-12-30]
### Breaking changes ### Breaking changes

288
Cargo.lock generated
View file

@ -280,12 +280,6 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "as-raw-xcb-connection"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
[[package]] [[package]]
name = "assert_no_alloc" name = "assert_no_alloc"
version = "1.1.2" version = "1.1.2"
@ -465,7 +459,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -527,7 +521,7 @@ checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -646,7 +640,7 @@ dependencies = [
[[package]] [[package]]
name = "baseview" name = "baseview"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/RustAudio/baseview.git?rev=45465c5f46abed6c6ce370fffde5edc8e4cd5aa3#45465c5f46abed6c6ce370fffde5edc8e4cd5aa3" source = "git+https://github.com/RustAudio/baseview.git#2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"core-foundation", "core-foundation",
@ -657,24 +651,8 @@ dependencies = [
"uuid", "uuid",
"winapi", "winapi",
"x11", "x11",
"x11rb 0.13.0", "xcb 0.9.0",
] "xcb-util",
[[package]]
name = "baseview"
version = "0.1.0"
source = "git+https://github.com/RustAudio/baseview.git#579130ecb4f9f315ae52190af42f0ea46aeaa4a2"
dependencies = [
"cocoa",
"core-foundation",
"keyboard-types",
"nix 0.22.3",
"objc",
"raw-window-handle 0.5.2",
"uuid",
"winapi",
"x11",
"x11rb 0.13.0",
] ]
[[package]] [[package]]
@ -694,7 +672,7 @@ dependencies = [
"regex", "regex",
"rustc-hash", "rustc-hash",
"shlex", "shlex",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -789,7 +767,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -810,15 +788,6 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21" checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21"
[[package]]
name = "camino"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "cargo-nih-plug" name = "cargo-nih-plug"
version = "0.1.0" version = "0.1.0"
@ -826,29 +795,6 @@ dependencies = [
"nih_plug_xtask", "nih_plug_xtask",
] ]
[[package]]
name = "cargo-platform"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc"
dependencies = [
"serde",
]
[[package]]
name = "cargo_metadata"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
dependencies = [
"camino",
"cargo-platform",
"semver",
"serde",
"serde_json",
"thiserror",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.83" version = "1.0.83"
@ -963,7 +909,7 @@ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -1092,22 +1038,10 @@ dependencies = [
"objc", "objc",
"objc-foundation", "objc-foundation",
"objc_id", "objc_id",
"smithay-clipboard",
"x11-clipboard 0.7.1", "x11-clipboard 0.7.1",
] ]
[[package]]
name = "copypasta"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d35364349bf9e9e1c3a035ddcb00d188d23a3c40c50244c03c27a99fc6a65ae"
dependencies = [
"clipboard-win",
"objc",
"objc-foundation",
"objc_id",
"x11-clipboard 0.8.1",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.9.4"
@ -1377,7 +1311,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -1483,7 +1417,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -1530,18 +1464,18 @@ dependencies = [
[[package]] [[package]]
name = "ecolor" name = "ecolor"
version = "0.27.2" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20930a432bbd57a6d55e07976089708d4893f3d556cf42a0d79e9e321fa73b10" checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
] ]
[[package]] [[package]]
name = "egui" name = "egui"
version = "0.27.2" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "584c5d1bf9a67b25778a3323af222dbe1a1feb532190e103901187f92c7fe29a" checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7"
dependencies = [ dependencies = [
"ahash", "ahash",
"epaint", "epaint",
@ -1550,29 +1484,28 @@ dependencies = [
[[package]] [[package]]
name = "egui-baseview" name = "egui-baseview"
version = "0.2.0" version = "0.1.0"
source = "git+https://github.com/BillyDM/egui-baseview.git?rev=68c4d0e8e5c1c702a888a245f4ac50eddfdfcaed#68c4d0e8e5c1c702a888a245f4ac50eddfdfcaed" source = "git+https://github.com/BillyDM/egui-baseview.git?rev=27c027c22a83d2eb214074f922ba4115f712e483#27c027c22a83d2eb214074f922ba4115f712e483"
dependencies = [ dependencies = [
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=45465c5f46abed6c6ce370fffde5edc8e4cd5aa3)", "baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=1d9806d5bd92275d0d8142d9c9c90198757b9b25)",
"copypasta 0.10.0", "copypasta 0.8.2",
"egui", "egui",
"egui_glow", "egui_glow",
"keyboard-types", "keyboard-types",
"log", "raw-window-handle 0.4.3",
"raw-window-handle 0.5.2",
] ]
[[package]] [[package]]
name = "egui_glow" name = "egui_glow"
version = "0.27.2" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0e5d975f3c86edc3d35b1db88bb27c15dde7c55d3b5af164968ab5ede3f44ca" checksum = "1f8c2752cdf1b0ef5fcda59a898cacabad974d4f5880e92a420b2c917022da64"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"egui", "egui",
"glow 0.13.1", "glow 0.12.3",
"log", "log",
"memoffset 0.9.0", "memoffset 0.6.5",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
] ]
@ -1585,9 +1518,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]] [[package]]
name = "emath" name = "emath"
version = "0.27.2" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4c3a552cfca14630702449d35f41c84a0d15963273771c6059175a803620f3f" checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
] ]
@ -1610,23 +1543,23 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
name = "epaint" name = "epaint"
version = "0.27.2" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b381f8b149657a4acf837095351839f32cd5c4aec1817fc4df84e18d76334176" checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b"
dependencies = [ dependencies = [
"ab_glyph", "ab_glyph",
"ahash", "ahash",
"atomic_refcell",
"bytemuck", "bytemuck",
"ecolor", "ecolor",
"emath", "emath",
"nohash-hasher", "nohash-hasher",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"rayon",
] ]
[[package]] [[package]]
@ -1971,7 +1904,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -2077,26 +2010,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "gethostname"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "gethostname"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818"
dependencies = [
"libc",
"windows-targets 0.48.5",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.1.16" version = "0.1.16"
@ -2187,18 +2100,6 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "glow"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1"
dependencies = [
"js-sys",
"slotmap",
"wasm-bindgen",
"web-sys",
]
[[package]] [[package]]
name = "glow_glyph" name = "glow_glyph"
version = "0.5.1" version = "0.5.1"
@ -3066,13 +2967,14 @@ dependencies = [
name = "nih_plug_egui" name = "nih_plug_egui"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=45465c5f46abed6c6ce370fffde5edc8e4cd5aa3)", "baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=1d9806d5bd92275d0d8142d9c9c90198757b9b25)",
"crossbeam", "crossbeam",
"egui",
"egui-baseview", "egui-baseview",
"lazy_static", "lazy_static",
"nih_plug", "nih_plug",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"raw-window-handle 0.5.2", "raw-window-handle 0.4.3",
"serde", "serde",
] ]
@ -3107,7 +3009,6 @@ name = "nih_plug_xtask"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_metadata",
"goblin", "goblin",
"reflink", "reflink",
"serde", "serde",
@ -3266,7 +3167,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -3753,9 +3654,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.79" version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -3788,9 +3689,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.35" version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -4166,13 +4067,13 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
name = "selectors" name = "selectors"
version = "0.23.0" version = "0.23.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"cssparser", "cssparser",
@ -4205,28 +4106,25 @@ name = "semver"
version = "1.0.20" version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.197" version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.197" version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -4248,7 +4146,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -4485,9 +4383,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.53" version = "2.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -4559,7 +4457,7 @@ checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -4681,7 +4579,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]
@ -4806,7 +4704,7 @@ checksum = "fea2a4c80deb4fb3ca51f66b5e2dd91e3642bbce52234bcf22e41668281208e4"
dependencies = [ dependencies = [
"proc-macro-hack", "proc-macro-hack",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
"unic-langid-impl", "unic-langid-impl",
] ]
@ -4888,7 +4786,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "vizia" name = "vizia"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"vizia_baseview", "vizia_baseview",
"vizia_core", "vizia_core",
@ -4898,7 +4796,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_baseview" name = "vizia_baseview"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4)", "baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4)",
"femtovg", "femtovg",
@ -4912,7 +4810,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_core" name = "vizia_core"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"bitflags 2.4.1", "bitflags 2.4.1",
@ -4943,7 +4841,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_derive" name = "vizia_derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -4953,12 +4851,12 @@ dependencies = [
[[package]] [[package]]
name = "vizia_id" name = "vizia_id"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
[[package]] [[package]]
name = "vizia_input" name = "vizia_input"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"keyboard-types", "keyboard-types",
@ -4968,7 +4866,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_storage" name = "vizia_storage"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"morphorm", "morphorm",
"vizia_id", "vizia_id",
@ -4977,7 +4875,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_style" name = "vizia_style"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"cssparser", "cssparser",
@ -4990,7 +4888,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_window" name = "vizia_window"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"morphorm", "morphorm",
@ -5001,7 +4899,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_winit" name = "vizia_winit"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2024-05-06#e3fab5530cda9cb90f679508d9f058bd62189d36" source = "git+https://github.com/robbert-vdh/vizia.git?tag=patched-2023-12-30#0a4af1999d24f866d8e274a7810c4b61eea95a91"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"accesskit_winit", "accesskit_winit",
@ -5107,7 +5005,7 @@ dependencies = [
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -5141,7 +5039,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -5657,16 +5555,7 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "980b9aa9226c3b7de8e2adb11bf20124327c054e0e5812d2aac0b5b5a87e7464" checksum = "980b9aa9226c3b7de8e2adb11bf20124327c054e0e5812d2aac0b5b5a87e7464"
dependencies = [ dependencies = [
"x11rb 0.10.1", "x11rb",
]
[[package]]
name = "x11-clipboard"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b41aca1115b1f195f21c541c5efb423470848d48143127d0f07f8b90c27440df"
dependencies = [
"x11rb 0.12.0",
] ]
[[package]] [[package]]
@ -5686,37 +5575,11 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507"
dependencies = [ dependencies = [
"gethostname 0.2.3", "gethostname",
"nix 0.24.3", "nix 0.24.3",
"winapi", "winapi",
"winapi-wsapoll", "winapi-wsapoll",
"x11rb-protocol 0.10.0", "x11rb-protocol",
]
[[package]]
name = "x11rb"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a"
dependencies = [
"gethostname 0.3.0",
"nix 0.26.4",
"winapi",
"winapi-wsapoll",
"x11rb-protocol 0.12.0",
]
[[package]]
name = "x11rb"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a"
dependencies = [
"as-raw-xcb-connection",
"gethostname 0.4.3",
"libc",
"rustix 0.38.28",
"x11rb-protocol 0.13.0",
] ]
[[package]] [[package]]
@ -5728,21 +5591,6 @@ dependencies = [
"nix 0.24.3", "nix 0.24.3",
] ]
[[package]]
name = "x11rb-protocol"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc"
dependencies = [
"nix 0.26.4",
]
[[package]]
name = "x11rb-protocol"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34"
[[package]] [[package]]
name = "xcb" name = "xcb"
version = "0.9.0" version = "0.9.0"
@ -5905,7 +5753,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.53", "syn 2.0.43",
] ]
[[package]] [[package]]

View file

@ -11,7 +11,6 @@ description = "A simple but modern API-agnostic audio plugin framework"
repository = "https://github.com/robbert-vdh/nih-plug" repository = "https://github.com/robbert-vdh/nih-plug"
[workspace] [workspace]
resolver = "2"
members = [ members = [
"nih_plug_derive", "nih_plug_derive",
"nih_plug_egui", "nih_plug_egui",

View file

@ -11,8 +11,9 @@ keeping the amount of magic to minimum and making it easy to experiment with
different approaches to things. See the [current features](#current-features) different approaches to things. See the [current features](#current-features)
section for more information on the project's current status. section for more information on the project's current status.
Check out the [documentation](https://nih-plug.robbertvanderhelm.nl/), or use Come join us on the [Rust Audio Discord](https://discord.gg/ykxU3rt4Cb), check
the [cookiecutter template](https://github.com/robbert-vdh/nih-plug-template) to out the [documentation](https://nih-plug.robbertvanderhelm.nl/), or use the
[cookiecutter template](https://github.com/robbert-vdh/nih-plug-template) to
quickly get started with NIH-plug. quickly get started with NIH-plug.
### Table of contents ### Table of contents

View file

@ -14,4 +14,4 @@ quote = "1.0"
proc-macro2 = "1.0" proc-macro2 = "1.0"
[dev-dependencies] [dev-dependencies]
nih_plug = { path = "..", default-features = false } nih_plug = { path = ".." }

View file

@ -8,19 +8,27 @@ license = "ISC"
description = "An adapter to use egui GUIs with NIH-plug" description = "An adapter to use egui GUIs with NIH-plug"
[features] [features]
default = ["opengl", "default_fonts"] default = ["egui-default-features", "opengl"]
# Use egui's default features
egui-default-features = ["egui/default"]
# `nih_plug_egui` always uses OpenGL since egui's wgpu backend is still unstable # `nih_plug_egui` always uses OpenGL since egui's wgpu backend is still unstable
# depending on the platform # depending on the platform
opengl = ["egui-baseview/opengl"] opengl = []
default_fonts = ["egui-baseview/default_fonts"]
rayon = ["egui-baseview/rayon"]
[dependencies] [dependencies]
nih_plug = { path = "..", default-features = false } nih_plug = { path = ".." }
raw-window-handle = "0.5"
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "45465c5f46abed6c6ce370fffde5edc8e4cd5aa3" } # The currently targeted version of baseview uses a different version of
# `raw_window_handle` than NIH-plug, so we need to manually convert between them
raw-window-handle = "0.4"
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "1d9806d5bd92275d0d8142d9c9c90198757b9b25" }
crossbeam = "0.8" crossbeam = "0.8"
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "68c4d0e8e5c1c702a888a245f4ac50eddfdfcaed", default-features = false } # The `egui-default-features` feature enables the default features. This makes
# it possible to opt out of this if needed.
egui = { version = "0.22", default-features = false }
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "27c027c22a83d2eb214074f922ba4115f712e483" }
lazy_static = "1.4" lazy_static = "1.4"
parking_lot = "0.12" parking_lot = "0.12"
# To make the state persistable # To make the state persistable

View file

@ -3,7 +3,7 @@
use baseview::gl::GlConfig; use baseview::gl::GlConfig;
use baseview::{Size, WindowHandle, WindowOpenOptions, WindowScalePolicy}; use baseview::{Size, WindowHandle, WindowOpenOptions, WindowScalePolicy};
use crossbeam::atomic::AtomicCell; use crossbeam::atomic::AtomicCell;
use egui_baseview::egui::Context; use egui::Context;
use egui_baseview::EguiWindow; use egui_baseview::EguiWindow;
use nih_plug::prelude::{Editor, GuiContext, ParamSetter, ParentWindowHandle}; use nih_plug::prelude::{Editor, GuiContext, ParamSetter, ParentWindowHandle};
use parking_lot::RwLock; use parking_lot::RwLock;
@ -37,17 +37,17 @@ unsafe impl HasRawWindowHandle for ParentWindowHandleAdapter {
fn raw_window_handle(&self) -> RawWindowHandle { fn raw_window_handle(&self) -> RawWindowHandle {
match self.0 { match self.0 {
ParentWindowHandle::X11Window(window) => { ParentWindowHandle::X11Window(window) => {
let mut handle = raw_window_handle::XcbWindowHandle::empty(); let mut handle = raw_window_handle::XcbHandle::empty();
handle.window = window; handle.window = window;
RawWindowHandle::Xcb(handle) RawWindowHandle::Xcb(handle)
} }
ParentWindowHandle::AppKitNsView(ns_view) => { ParentWindowHandle::AppKitNsView(ns_view) => {
let mut handle = raw_window_handle::AppKitWindowHandle::empty(); let mut handle = raw_window_handle::AppKitHandle::empty();
handle.ns_view = ns_view; handle.ns_view = ns_view;
RawWindowHandle::AppKit(handle) RawWindowHandle::AppKit(handle)
} }
ParentWindowHandle::Win32Hwnd(hwnd) => { ParentWindowHandle::Win32Hwnd(hwnd) => {
let mut handle = raw_window_handle::Win32WindowHandle::empty(); let mut handle = raw_window_handle::Win32Handle::empty();
handle.hwnd = hwnd; handle.hwnd = hwnd;
RawWindowHandle::Win32(handle) RawWindowHandle::Win32(handle)
} }

View file

@ -18,7 +18,7 @@ use std::sync::Arc;
compile_error!("There's currently no software rendering support for egui"); compile_error!("There's currently no software rendering support for egui");
/// Re-export for convenience. /// Re-export for convenience.
pub use egui_baseview::egui; pub use egui;
mod editor; mod editor;
pub mod widgets; pub mod widgets;

View file

@ -3,7 +3,7 @@
use std::sync::Arc; use std::sync::Arc;
use egui_baseview::egui::{self, TextStyle, Ui, Vec2}; use egui::{TextStyle, Ui, Vec2};
use nih_plug::prelude::{Param, ParamFlags, ParamPtr, ParamSetter, Params}; use nih_plug::prelude::{Param, ParamFlags, ParamPtr, ParamSetter, Params};
use super::ParamSlider; use super::ParamSlider;

View file

@ -1,9 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use egui_baseview::egui::{ use egui::{vec2, Key, Response, Sense, Stroke, TextEdit, TextStyle, Ui, Vec2, Widget, WidgetText};
self, emath, vec2, Key, Response, Sense, Stroke, TextEdit, TextStyle, Ui, Vec2, Widget,
WidgetText,
};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use nih_plug::prelude::{Param, ParamSetter}; use nih_plug::prelude::{Param, ParamSetter};
use parking_lot::Mutex; use parking_lot::Mutex;
@ -202,7 +199,8 @@ impl<'a, P: Param> ParamSlider<'a, P> {
response.mark_changed(); response.mark_changed();
} else { } else {
let proportion = let proportion =
emath::remap_clamp(click_pos.x, response.rect.x_range(), 0.0..=1.0) as f64; egui::emath::remap_clamp(click_pos.x, response.rect.x_range(), 0.0..=1.0)
as f64;
self.set_normalized_value(proportion as f32); self.set_normalized_value(proportion as f32);
response.mark_changed(); response.mark_changed();
Self::set_drag_amount_memory(ui, 0.0); Self::set_drag_amount_memory(ui, 0.0);
@ -303,12 +301,7 @@ impl<'a, P: Param> ParamSlider<'a, P> {
.layout() .layout()
.align_size_within_rect(text.size(), response.rect.shrink2(padding)) .align_size_within_rect(text.size(), response.rect.shrink2(padding))
.min; .min;
text.paint_with_visuals(ui.painter(), text_pos, &visuals);
ui.painter().add(egui::epaint::TextShape::new(
text_pos,
text,
visuals.fg_stroke.color,
));
} }
} }
} }

View file

@ -1,6 +1,6 @@
//! Utilities for creating these widgets. //! Utilities for creating these widgets.
use egui_baseview::egui::{self, Color32}; use egui::Color32;
/// Additively modify the hue, saturation, and lightness [0, 1] values of a color. /// Additively modify the hue, saturation, and lightness [0, 1] values of a color.
pub fn add_hsv(color: Color32, h: f32, s: f32, v: f32) -> Color32 { pub fn add_hsv(color: Color32, h: f32, s: f32, v: f32) -> Color32 {

View file

@ -56,7 +56,7 @@ async-std = ["iced_baseview/async-std"]
smol = ["iced_baseview/smol"] smol = ["iced_baseview/smol"]
[dependencies] [dependencies]
nih_plug = { path = "..", default-features = false } nih_plug = { path = ".." }
nih_plug_assets = { git = "https://github.com/robbert-vdh/nih_plug_assets.git" } nih_plug_assets = { git = "https://github.com/robbert-vdh/nih_plug_assets.git" }
# The currently targeted version of baseview uses a different version of # The currently targeted version of baseview uses a different version of
@ -67,6 +67,6 @@ atomic_refcell = "0.1"
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "1d9806d5bd92275d0d8142d9c9c90198757b9b25" } baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "1d9806d5bd92275d0d8142d9c9c90198757b9b25" }
crossbeam = "0.8" crossbeam = "0.8"
# This targets iced 0.4 # This targets iced 0.4
iced_baseview = { git = "https://github.com/robbert-vdh/iced_baseview.git", branch = "feature/update-baseview", default-features = false } iced_baseview = { git = "https://github.com/robbert-vdh/iced_baseview.git", branch = "feature/update-baseview", default_features = false }
# To make the state persistable # To make the state persistable
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }

View file

@ -9,7 +9,7 @@ configurations. To use wgpu instead, include the crate with the following
options: options:
```toml ```toml
nih_plug_iced = { git = "https://github.com/robbert-vdh/nih-plug.git", default-features = false, features = ["wgpu"] } nih_plug_iced = { git = "https://github.com/robbert-vdh/nih-plug.git", default_features = false, features = ["wgpu"] }
``` ```
Iced has many more optional features. Check the `Cargo.toml` file for more Iced has many more optional features. Check the `Cargo.toml` file for more

View file

@ -8,13 +8,13 @@ license = "ISC"
description = "An adapter to use VIZIA GUIs with NIH-plug" description = "An adapter to use VIZIA GUIs with NIH-plug"
[dependencies] [dependencies]
nih_plug = { path = "..", default-features = false } nih_plug = { path = ".." }
nih_plug_assets = { git = "https://github.com/robbert-vdh/nih_plug_assets.git" } nih_plug_assets = { git = "https://github.com/robbert-vdh/nih_plug_assets.git" }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4" } baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4" }
# This contains an as of writing not yet merged patch for rounding errors when # This contains an as of writing not yet merged patch for rounding errors when
# resizing, and a workaround for certain events not firing when resizing # resizing, and a workaround for certain events not firing when resizing
vizia = { git = "https://github.com/robbert-vdh/vizia.git", tag = "patched-2024-05-06", default-features = false, features = ["baseview", "clipboard", "x11"] } vizia = { git = "https://github.com/robbert-vdh/vizia.git", tag = "patched-2023-12-30", default_features = false, features = ["baseview", "clipboard", "x11"] }
crossbeam = "0.8" crossbeam = "0.8"
# To make the state persistable # To make the state persistable

View file

@ -8,7 +8,6 @@ license = "ISC"
[dependencies] [dependencies]
anyhow = "1.0" anyhow = "1.0"
cargo_metadata = "0.18.1"
goblin = "0.6.1" goblin = "0.6.1"
# Version 0.1.3 from crates.io assumes a 64-bit toolchain # Version 0.1.3 from crates.io assumes a 64-bit toolchain
reflink = { git = "https://github.com/nicokoch/reflink.git", rev = "e8d93b465f5d9ad340cd052b64bbc77b8ee107e2" } reflink = { git = "https://github.com/nicokoch/reflink.git", rev = "e8d93b465f5d9ad340cd052b64bbc77b8ee107e2" }

View file

@ -14,6 +14,9 @@ mod util;
/// Re-export for the main function. /// Re-export for the main function.
pub use anyhow::Result; pub use anyhow::Result;
/// The base directory for the bundler's output.
const BUNDLE_HOME: &str = "target/bundled";
fn build_usage_string(command_name: &str) -> String { fn build_usage_string(command_name: &str) -> String {
format!( format!(
"Usage: "Usage:
@ -76,11 +79,6 @@ pub fn main() -> Result<()> {
/// `std::env::args()` before passing it to this function. /// `std::env::args()` before passing it to this function.
pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>) -> Result<()> { pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>) -> Result<()> {
chdir_workspace_root()?; chdir_workspace_root()?;
let cargo_metadata = cargo_metadata::MetadataCommand::new()
.manifest_path("./Cargo.toml")
.exec()
.context("Could not parse `cargo-metadata`")?;
let target_dir = cargo_metadata.target_directory.as_std_path();
let mut args = args.into_iter(); let mut args = args.into_iter();
let usage_string = build_usage_string(command_name); let usage_string = build_usage_string(command_name);
@ -98,9 +96,9 @@ pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>
// As explained above, for efficiency's sake this is a two step process // As explained above, for efficiency's sake this is a two step process
build(&packages, &other_args)?; build(&packages, &other_args)?;
bundle(target_dir, &packages[0], &other_args, false)?; bundle(&packages[0], &other_args, false)?;
for package in packages.into_iter().skip(1) { for package in packages.into_iter().skip(1) {
bundle(target_dir, &package, &other_args, false)?; bundle(&package, &other_args, false)?;
} }
Ok(()) Ok(())
@ -136,9 +134,9 @@ pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>
// This `true` indicates a universal build. This will cause the two sets of built // This `true` indicates a universal build. This will cause the two sets of built
// binaries to beq lipo'd together into universal binaries before bundling // binaries to beq lipo'd together into universal binaries before bundling
bundle(target_dir, &packages[0], &other_args, true)?; bundle(&packages[0], &other_args, true)?;
for package in packages.into_iter().skip(1) { for package in packages.into_iter().skip(1) {
bundle(target_dir, &package, &other_args, true)?; bundle(&package, &other_args, true)?;
} }
Ok(()) Ok(())
@ -216,7 +214,7 @@ pub fn build(packages: &[String], args: &[String]) -> Result<()> {
/// Normally this respects the `--target` option for cross compilation. If the `universal` option is /// Normally this respects the `--target` option for cross compilation. If the `universal` option is
/// specified instead, then this will assume both `x86_64-apple-darwin` and `aarch64-apple-darwin` /// specified instead, then this will assume both `x86_64-apple-darwin` and `aarch64-apple-darwin`
/// have been built and it will try to lipo those together instead. /// have been built and it will try to lipo those together instead.
pub fn bundle(target_dir: &Path, package: &str, args: &[String], universal: bool) -> Result<()> { pub fn bundle(package: &str, args: &[String], universal: bool) -> Result<()> {
let mut build_type_dir = "debug"; let mut build_type_dir = "debug";
let mut cross_compile_target: Option<String> = None; let mut cross_compile_target: Option<String> = None;
for arg_idx in (0..args.len()).rev() { for arg_idx in (0..args.len()).rev() {
@ -254,8 +252,7 @@ pub fn bundle(target_dir: &Path, package: &str, args: &[String], universal: bool
// We can bundle both library targets (for plugins) and binary targets (for standalone // We can bundle both library targets (for plugins) and binary targets (for standalone
// applications) // applications)
if universal { if universal {
let x86_64_target_base = let x86_64_target_base = target_base(Some("x86_64-apple-darwin"))?.join(build_type_dir);
target_base(target_dir, Some("x86_64-apple-darwin"))?.join(build_type_dir);
let x86_64_bin_path = x86_64_target_base.join(binary_basename( let x86_64_bin_path = x86_64_target_base.join(binary_basename(
package, package,
CompilationTarget::MacOS(Architecture::X86_64), CompilationTarget::MacOS(Architecture::X86_64),
@ -265,8 +262,7 @@ pub fn bundle(target_dir: &Path, package: &str, args: &[String], universal: bool
CompilationTarget::MacOS(Architecture::X86_64), CompilationTarget::MacOS(Architecture::X86_64),
)); ));
let aarch64_target_base = let aarch64_target_base = target_base(Some("aarch64-apple-darwin"))?.join(build_type_dir);
target_base(target_dir, Some("aarch64-apple-darwin"))?.join(build_type_dir);
let aarch64_bin_path = aarch64_target_base.join(binary_basename( let aarch64_bin_path = aarch64_target_base.join(binary_basename(
package, package,
CompilationTarget::MacOS(Architecture::AArch64), CompilationTarget::MacOS(Architecture::AArch64),
@ -285,7 +281,6 @@ pub fn bundle(target_dir: &Path, package: &str, args: &[String], universal: bool
eprintln!(); eprintln!();
if build_bin { if build_bin {
bundle_binary( bundle_binary(
target_dir,
package, package,
&[&x86_64_bin_path, &aarch64_bin_path], &[&x86_64_bin_path, &aarch64_bin_path],
CompilationTarget::MacOSUniversal, CompilationTarget::MacOSUniversal,
@ -293,7 +288,6 @@ pub fn bundle(target_dir: &Path, package: &str, args: &[String], universal: bool
} }
if build_lib { if build_lib {
bundle_plugin( bundle_plugin(
target_dir,
package, package,
&[&x86_64_lib_path, &aarch64_lib_path], &[&x86_64_lib_path, &aarch64_lib_path],
CompilationTarget::MacOSUniversal, CompilationTarget::MacOSUniversal,
@ -301,8 +295,7 @@ pub fn bundle(target_dir: &Path, package: &str, args: &[String], universal: bool
} }
} else { } else {
let compilation_target = compilation_target(cross_compile_target.as_deref())?; let compilation_target = compilation_target(cross_compile_target.as_deref())?;
let target_base = let target_base = target_base(cross_compile_target.as_deref())?.join(build_type_dir);
target_base(target_dir, cross_compile_target.as_deref())?.join(build_type_dir);
let bin_path = target_base.join(binary_basename(package, compilation_target)); let bin_path = target_base.join(binary_basename(package, compilation_target));
let lib_path = target_base.join(library_basename(package, compilation_target)); let lib_path = target_base.join(library_basename(package, compilation_target));
if !bin_path.exists() && !lib_path.exists() { if !bin_path.exists() && !lib_path.exists() {
@ -321,10 +314,10 @@ to your Cargo.toml file?"#,
eprintln!(); eprintln!();
if bin_path.exists() { if bin_path.exists() {
bundle_binary(target_dir, package, &[&bin_path], compilation_target)?; bundle_binary(package, &[&bin_path], compilation_target)?;
} }
if lib_path.exists() { if lib_path.exists() {
bundle_plugin(target_dir, package, &[&lib_path], compilation_target)?; bundle_plugin(package, &[&lib_path], compilation_target)?;
} }
} }
@ -335,12 +328,10 @@ to your Cargo.toml file?"#,
/// combined into a single binary using a method that depends on the compilation target. For /// combined into a single binary using a method that depends on the compilation target. For
/// universal macOS builds this uses lipo. /// universal macOS builds this uses lipo.
fn bundle_binary( fn bundle_binary(
target_dir: &Path,
package: &str, package: &str,
bin_paths: &[&Path], bin_paths: &[&Path],
compilation_target: CompilationTarget, compilation_target: CompilationTarget,
) -> Result<()> { ) -> Result<()> {
let bundle_home_dir = bundle_home(target_dir);
let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) { let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) {
Some(PackageConfig { name: Some(name) }) => name, Some(PackageConfig { name: Some(name) }) => name,
_ => package.to_string(), _ => package.to_string(),
@ -349,7 +340,7 @@ fn bundle_binary(
// On MacOS the standalone target needs to be in a bundle // On MacOS the standalone target needs to be in a bundle
let standalone_bundle_binary_name = let standalone_bundle_binary_name =
standalone_bundle_binary_name(&bundle_name, compilation_target); standalone_bundle_binary_name(&bundle_name, compilation_target);
let standalone_binary_path = bundle_home_dir.join(&standalone_bundle_binary_name); let standalone_binary_path = Path::new(BUNDLE_HOME).join(&standalone_bundle_binary_name);
fs::create_dir_all(standalone_binary_path.parent().unwrap()) fs::create_dir_all(standalone_binary_path.parent().unwrap())
.context("Could not create standalone bundle directory")?; .context("Could not create standalone bundle directory")?;
@ -372,7 +363,7 @@ fn bundle_binary(
})?; })?;
} }
let standalone_bundle_home = bundle_home_dir.join( let standalone_bundle_home = Path::new(BUNDLE_HOME).join(
Path::new(&standalone_bundle_binary_name) Path::new(&standalone_bundle_binary_name)
.components() .components()
.next() .next()
@ -399,12 +390,10 @@ fn bundle_binary(
/// the libraries will be combined into a single library using a method that depends on the /// the libraries will be combined into a single library using a method that depends on the
/// compilation target. For universal macOS builds this uses lipo. /// compilation target. For universal macOS builds this uses lipo.
fn bundle_plugin( fn bundle_plugin(
target_dir: &Path,
package: &str, package: &str,
lib_paths: &[&Path], lib_paths: &[&Path],
compilation_target: CompilationTarget, compilation_target: CompilationTarget,
) -> Result<()> { ) -> Result<()> {
let bundle_home_dir = bundle_home(target_dir);
let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) { let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) {
Some(PackageConfig { name: Some(name) }) => name, Some(PackageConfig { name: Some(name) }) => name,
_ => package.to_string(), _ => package.to_string(),
@ -430,7 +419,7 @@ fn bundle_plugin(
if bundle_clap { if bundle_clap {
let clap_bundle_library_name = clap_bundle_library_name(&bundle_name, compilation_target); let clap_bundle_library_name = clap_bundle_library_name(&bundle_name, compilation_target);
let clap_lib_path = bundle_home_dir.join(&clap_bundle_library_name); let clap_lib_path = Path::new(BUNDLE_HOME).join(&clap_bundle_library_name);
fs::create_dir_all(clap_lib_path.parent().unwrap()) fs::create_dir_all(clap_lib_path.parent().unwrap())
.context("Could not create CLAP bundle directory")?; .context("Could not create CLAP bundle directory")?;
@ -439,7 +428,7 @@ fn bundle_plugin(
// In contrast to VST3, CLAP only uses bundles on macOS, so we'll just take the first // In contrast to VST3, CLAP only uses bundles on macOS, so we'll just take the first
// component of the library name instead // component of the library name instead
let clap_bundle_home = bundle_home_dir.join( let clap_bundle_home = Path::new(BUNDLE_HOME).join(
Path::new(&clap_bundle_library_name) Path::new(&clap_bundle_library_name)
.components() .components()
.next() .next()
@ -458,7 +447,7 @@ fn bundle_plugin(
} }
if bundle_vst2 { if bundle_vst2 {
let vst2_bundle_library_name = vst2_bundle_library_name(&bundle_name, compilation_target); let vst2_bundle_library_name = vst2_bundle_library_name(&bundle_name, compilation_target);
let vst2_lib_path = bundle_home_dir.join(&vst2_bundle_library_name); let vst2_lib_path = Path::new(BUNDLE_HOME).join(&vst2_bundle_library_name);
fs::create_dir_all(vst2_lib_path.parent().unwrap()) fs::create_dir_all(vst2_lib_path.parent().unwrap())
.context("Could not create VST2 bundle directory")?; .context("Could not create VST2 bundle directory")?;
@ -467,7 +456,7 @@ fn bundle_plugin(
// VST2 only uses bundles on macOS, so we'll just take the first component of the library // VST2 only uses bundles on macOS, so we'll just take the first component of the library
// name instead // name instead
let vst2_bundle_home = bundle_home_dir.join( let vst2_bundle_home = Path::new(BUNDLE_HOME).join(
Path::new(&vst2_bundle_library_name) Path::new(&vst2_bundle_library_name)
.components() .components()
.next() .next()
@ -486,7 +475,7 @@ fn bundle_plugin(
} }
if bundle_vst3 { if bundle_vst3 {
let vst3_lib_path = let vst3_lib_path =
bundle_home_dir.join(vst3_bundle_library_name(&bundle_name, compilation_target)); Path::new(BUNDLE_HOME).join(vst3_bundle_library_name(&bundle_name, compilation_target));
fs::create_dir_all(vst3_lib_path.parent().unwrap()) fs::create_dir_all(vst3_lib_path.parent().unwrap())
.context("Could not create VST3 bundle directory")?; .context("Could not create VST3 bundle directory")?;
@ -615,18 +604,13 @@ fn compilation_target(cross_compile_target: Option<&str>) -> Result<CompilationT
} }
} }
/// The directory bundled plugins should be written to.
fn bundle_home(target_directory: &Path) -> PathBuf {
target_directory.join("bundled")
}
/// The base directory for the compiled binaries. This does not use [`CompilationTarget`] as we need /// The base directory for the compiled binaries. This does not use [`CompilationTarget`] as we need
/// to be able to differentiate between native and cross-compilation. /// to be able to differentiate between native and cross-compilation.
fn target_base(target_directory: &Path, cross_compile_target: Option<&str>) -> Result<PathBuf> { fn target_base(cross_compile_target: Option<&str>) -> Result<PathBuf> {
match cross_compile_target { match cross_compile_target {
// Unhandled targets will already be handled in `compilation_target` // Unhandled targets will already be handled in `compilation_target`
Some(target) => Ok(target_directory.join(target)), Some(target) => Ok(Path::new("target").join(target)),
None => Ok(target_directory.to_owned()), None => Ok(PathBuf::from("target")),
} }
} }

View file

@ -101,7 +101,7 @@ fn top_bar(cx: &mut Context) {
// Try to open the Diopser plugin's page when clicking on the title. If this // Try to open the Diopser plugin's page when clicking on the title. If this
// fails then that's not a problem // fails then that's not a problem
let result = open::that(Diopser::URL); let result = open::that(Diopser::URL);
if cfg!(debug_assertions) && result.is_err() { if cfg!(debug) && result.is_err() {
nih_debug_assert_failure!("Failed to open web browser: {:?}", result); nih_debug_assert_failure!("Failed to open web browser: {:?}", result);
} }
} }

View file

@ -1,3 +1,4 @@
use atomic_float::AtomicF32;
use nih_plug::prelude::*; use nih_plug::prelude::*;
use nih_plug_egui::{create_egui_editor, egui, widgets, EguiState}; use nih_plug_egui::{create_egui_editor, egui, widgets, EguiState};
use std::sync::Arc; use std::sync::Arc;

View file

@ -12,7 +12,7 @@ description = "A simple gain plugin with an vizia GUI"
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]
[dependencies] [dependencies]
nih_plug = { path = "../../../", features = ["standalone"] } nih_plug = { path = "../../../", features = ["assert_process_allocs", "standalone"] }
nih_plug_vizia = { path = "../../../nih_plug_vizia" } nih_plug_vizia = { path = "../../../nih_plug_vizia" }
atomic_float = "0.1" atomic_float = "0.1"

View file

@ -4,7 +4,7 @@ use std::sync::Arc;
/// A test tone generator that can either generate a sine wave based on the plugin's parameters or /// A test tone generator that can either generate a sine wave based on the plugin's parameters or
/// based on the current MIDI input. /// based on the current MIDI input.
pub struct Sine { struct Sine {
params: Arc<SineParams>, params: Arc<SineParams>,
sample_rate: f32, sample_rate: f32,

View file

@ -126,7 +126,7 @@ fn main_column(cx: &mut Context) {
// Try to open the plugin's page when clicking on the title. If this // Try to open the plugin's page when clicking on the title. If this
// fails then that's not a problem // fails then that's not a problem
let result = open::that(SpectralCompressor::URL); let result = open::that(SpectralCompressor::URL);
if cfg!(debug_assertions) && result.is_err() { if cfg!(debug) && result.is_err() {
nih_debug_assert_failure!( nih_debug_assert_failure!(
"Failed to open web browser: {:?}", "Failed to open web browser: {:?}",
result result

View file

@ -419,11 +419,11 @@ impl<S: SysExMessage> NoteEvent<S> {
pub fn from_midi(timing: u32, midi_data: &[u8]) -> Result<Self, u8> { pub fn from_midi(timing: u32, midi_data: &[u8]) -> Result<Self, u8> {
let status_byte = midi_data.first().copied().unwrap_or_default(); let status_byte = midi_data.first().copied().unwrap_or_default();
let event_type = status_byte & midi::EVENT_TYPE_MASK; let event_type = status_byte & midi::EVENT_TYPE_MASK;
let channel = status_byte & midi::MIDI_CHANNEL_MASK;
if midi_data.len() >= 3 { if midi_data.len() >= 3 {
// TODO: Maybe add special handling for 14-bit CCs and RPN messages at some // TODO: Maybe add special handling for 14-bit CCs and RPN messages at some
// point, right now the plugin has to figure it out for itself // point, right now the plugin has to figure it out for itself
let channel = status_byte & midi::MIDI_CHANNEL_MASK;
match event_type { match event_type {
// You thought this was a note on? Think again! This is a cleverly disguised note off // You thought this was a note on? Think again! This is a cleverly disguised note off
// event straight from the 80s when Baud rate was still a limiting factor! // event straight from the 80s when Baud rate was still a limiting factor!
@ -464,6 +464,13 @@ impl<S: SysExMessage> NoteEvent<S> {
pressure: midi_data[2] as f32 / 127.0, pressure: midi_data[2] as f32 / 127.0,
}); });
} }
midi::CHANNEL_KEY_PRESSURE => {
return Ok(NoteEvent::MidiChannelPressure {
timing,
channel,
pressure: midi_data[1] as f32 / 127.0,
});
}
midi::PITCH_BEND_CHANGE => { midi::PITCH_BEND_CHANGE => {
return Ok(NoteEvent::MidiPitchBend { return Ok(NoteEvent::MidiPitchBend {
timing, timing,
@ -480,18 +487,6 @@ impl<S: SysExMessage> NoteEvent<S> {
value: midi_data[2] as f32 / 127.0, value: midi_data[2] as f32 / 127.0,
}); });
} }
_ => (),
}
}
if midi_data.len() >= 2 {
match event_type {
midi::CHANNEL_KEY_PRESSURE => {
return Ok(NoteEvent::MidiChannelPressure {
timing,
channel,
pressure: midi_data[1] as f32 / 127.0,
});
}
midi::PROGRAM_CHANGE => { midi::PROGRAM_CHANGE => {
return Ok(NoteEvent::MidiProgramChange { return Ok(NoteEvent::MidiProgramChange {
timing, timing,

View file

@ -702,8 +702,6 @@ impl CpalMidir {
.main_input_channels .main_input_channels
.map(NonZeroU32::get) .map(NonZeroU32::get)
.unwrap_or(0) as usize; .unwrap_or(0) as usize;
// This may contain excess unused space at the end if we get fewer samples than configured
// from CPAL
let mut main_io_storage = vec![vec![0.0f32; buffer_size]; num_output_channels]; let mut main_io_storage = vec![vec![0.0f32; buffer_size]; num_output_channels];
// This backend does not support auxiliary inputs and outputs, so in order to have the same // This backend does not support auxiliary inputs and outputs, so in order to have the same
@ -826,16 +824,8 @@ impl CpalMidir {
} }
{ {
// Even though we told CPAL that we wanted `buffer_size` samples, it may still give
// us fewer. If we receive more than what we configured, then this will panic.
let actual_sample_count = data.len() / num_output_channels;
assert!(
actual_sample_count <= buffer_size,
"Received {actual_sample_count} samples, while the configured buffer size is \
{buffer_size}"
);
let buffers = unsafe { let buffers = unsafe {
buffer_manager.create_buffers(0, actual_sample_count, |buffer_sources| { buffer_manager.create_buffers(0, buffer_size, |buffer_sources| {
*buffer_sources.main_output_channel_pointers = Some(ChannelPointers { *buffer_sources.main_output_channel_pointers = Some(ChannelPointers {
ptrs: NonNull::new(main_io_channel_pointers.get().as_mut_ptr()) ptrs: NonNull::new(main_io_channel_pointers.get().as_mut_ptr())
.unwrap(), .unwrap(),
@ -903,10 +893,11 @@ impl CpalMidir {
// The buffer's samples need to be written to `data` in an interlaced format // The buffer's samples need to be written to `data` in an interlaced format
// SAFETY: Dropping `buffers` allows us to borrow `main_io_storage` again // SAFETY: Dropping `buffers` allows us to borrow `main_io_storage` again
for (i, output_sample) in data.iter_mut().enumerate() { for (output_sample, buffer_sample) in data
let ch = i % num_output_channels; .iter_mut()
let n = i / num_output_channels; .zip(main_io_storage.iter().flat_map(|channels| channels.iter()))
*output_sample = T::from_sample(main_io_storage[ch][n]); {
*output_sample = T::from_sample(*buffer_sample);
} }
if let Some(output_event_rb_producer) = &mut output_event_rb_producer { if let Some(output_event_rb_producer) = &mut output_event_rb_producer {

View file

@ -51,7 +51,6 @@ unsafe impl Sync for BufferManager {}
/// Host data that the plugin's [`Buffer`]s should be created from. Leave these fields as `None` /// Host data that the plugin's [`Buffer`]s should be created from. Leave these fields as `None`
/// values /// values
#[derive(Debug)]
pub struct BufferSource<'a> { pub struct BufferSource<'a> {
pub main_input_channel_pointers: &'a mut Option<ChannelPointers>, pub main_input_channel_pointers: &'a mut Option<ChannelPointers>,
pub main_output_channel_pointers: &'a mut Option<ChannelPointers>, pub main_output_channel_pointers: &'a mut Option<ChannelPointers>,
@ -220,28 +219,25 @@ impl BufferManager {
self.main_input_channel_pointers, self.main_input_channel_pointers,
self.main_output_channel_pointers, self.main_output_channel_pointers,
) { ) {
self.main_buffer.set_slices(num_samples, |output_slices| { // If the host processes the main IO out of place then the inputs need to be copied to
for (channel_idx, output_slice) in output_slices // the output buffers. Otherwise the input should already be there.
.iter_mut() if input_channel_pointers.ptrs != output_channel_pointers.ptrs {
.enumerate() self.main_buffer.set_slices(num_samples, |output_slices| {
.take(input_channel_pointers.num_channels) for (channel_idx, output_slice) in output_slices
{ .iter_mut()
let input_channel_pointer = .enumerate()
*input_channel_pointers.ptrs.as_ptr().add(channel_idx); .take(input_channel_pointers.num_channels)
debug_assert!(channel_idx < output_channel_pointers.num_channels); {
let output_channel_pointer = let input_channel_pointer =
*output_channel_pointers.ptrs.as_ptr().add(channel_idx); input_channel_pointers.ptrs.as_ptr().add(channel_idx);
// If the host processes the main IO out of place then the inputs need to be
// copied to the output buffers. Otherwise the input should already be there.
if input_channel_pointer != output_channel_pointer {
output_slice.copy_from_slice(std::slice::from_raw_parts_mut( output_slice.copy_from_slice(std::slice::from_raw_parts_mut(
input_channel_pointer.add(sample_offset), (*input_channel_pointer).add(sample_offset),
num_samples, num_samples,
)) ))
} }
} });
}); }
// Any excess channels will need to be filled with zeroes since they'd otherwise point // Any excess channels will need to be filled with zeroes since they'd otherwise point
// to whatever was left in the buffer // to whatever was left in the buffer

View file

@ -5,7 +5,7 @@ use std::ffi::{c_void, CStr};
use std::mem; use std::mem;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::sync::Arc; use std::sync::Arc;
use vst3_sys::base::{kInvalidArgument, kNotImplemented, kResultFalse, kResultOk, tresult, TBool}; use vst3_sys::base::{kInvalidArgument, kResultFalse, kResultOk, tresult, TBool};
use vst3_sys::gui::{IPlugFrame, IPlugView, IPlugViewContentScaleSupport, ViewRect}; use vst3_sys::gui::{IPlugFrame, IPlugView, IPlugViewContentScaleSupport, ViewRect};
use vst3_sys::utils::SharedVstPtr; use vst3_sys::utils::SharedVstPtr;
use vst3_sys::VST3; use vst3_sys::VST3;
@ -225,8 +225,12 @@ impl<P: Vst3Plugin> RunLoopEventHandler<P> {
self.tasks.push(task)?; self.tasks.push(task)?;
// We need to use a Unix domain socket to let the host know to call our event handler. In // We need to use a Unix domain socket to let the host know to call our event handler. In
// theory eventfd would be more suitable here, but Ardour does not support that. This is // theory eventfd would be more suitable here, but Ardour does not support that.
// read again in `Self::on_fd_is_set()`. // XXX: This can technically lead to a race condition if the host is currently calling
// `on_fd_is_set()` on another thread and the task has already been popped and executed
// and this value has not yet been written to the socket. Doing it the other way around
// gets you the other situation where the event handler could be run without the task
// being posted yet. In practice this won't cause any issues however.
let notify_value = 1i8; let notify_value = 1i8;
const NOTIFY_VALUE_SIZE: usize = std::mem::size_of::<i8>(); const NOTIFY_VALUE_SIZE: usize = std::mem::size_of::<i8>();
assert_eq!( assert_eq!(
@ -333,7 +337,7 @@ impl<P: Vst3Plugin> IPlugView for WrapperView<P> {
unsafe fn on_wheel(&self, _distance: f32) -> tresult { unsafe fn on_wheel(&self, _distance: f32) -> tresult {
// We'll let the plugin use the OS' input mechanisms because not all DAWs (or very few // We'll let the plugin use the OS' input mechanisms because not all DAWs (or very few
// actually) implement these functions // actually) implement these functions
kNotImplemented kResultOk
} }
unsafe fn on_key_down( unsafe fn on_key_down(
@ -342,7 +346,7 @@ impl<P: Vst3Plugin> IPlugView for WrapperView<P> {
_key_code: i16, _key_code: i16,
_modifiers: i16, _modifiers: i16,
) -> tresult { ) -> tresult {
kNotImplemented kResultOk
} }
unsafe fn on_key_up( unsafe fn on_key_up(
@ -351,7 +355,7 @@ impl<P: Vst3Plugin> IPlugView for WrapperView<P> {
_key_code: i16, _key_code: i16,
_modifiers: i16, _modifiers: i16,
) -> tresult { ) -> tresult {
kNotImplemented kResultOk
} }
unsafe fn get_size(&self, size: *mut ViewRect) -> tresult { unsafe fn get_size(&self, size: *mut ViewRect) -> tresult {
@ -394,7 +398,7 @@ impl<P: Vst3Plugin> IPlugView for WrapperView<P> {
} }
unsafe fn on_focus(&self, _state: TBool) -> tresult { unsafe fn on_focus(&self, _state: TBool) -> tresult {
kNotImplemented kResultOk
} }
unsafe fn set_frame(&self, frame: *mut c_void) -> tresult { unsafe fn set_frame(&self, frame: *mut c_void) -> tresult {
@ -468,34 +472,21 @@ impl<P: Vst3Plugin> IPlugViewContentScaleSupport for WrapperView<P> {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
impl<P: Vst3Plugin> IEventHandler for RunLoopEventHandler<P> { impl<P: Vst3Plugin> IEventHandler for RunLoopEventHandler<P> {
unsafe fn on_fd_is_set(&self, _fd: FileDescriptor) { unsafe fn on_fd_is_set(&self, _fd: FileDescriptor) {
// There should be a one-to-one correlation to bytes being written to `self.socket_read_fd`
// and events being pushed to `self.tasks`, but because the process of pushing a task and
// notifying this thread through the socket is not atomic we can't reliably just read a byte
// from this socket for every task we process. For instance, if `Self::post_task()` gets
// called while this loop is already running, it could happen that we pop and execute the
// task before the byte gets written to the socket. To avoid this, we'll clear the socket
// upfront, and then execute the tasks afterwards. If this situation does happen, then the
// worst thing that can happen is that this function is called a second time while
// `self.tasks()` is already empty.
let mut notify_value = [0; 32];
loop {
let read_result = libc::read(
self.socket_read_fd,
&mut notify_value as *mut _ as *mut c_void,
std::mem::size_of_val(&notify_value),
);
// If after the first loop the socket contains no more data, then the `read()` call will
// return -1 and `errno` will have been set to `EAGAIN`
if read_result <= 0 {
break;
}
}
// This gets called from the host's UI thread because we wrote some bytes to the Unix domain // This gets called from the host's UI thread because we wrote some bytes to the Unix domain
// socket. We'll read that data from the socket again just to make REAPER happy. // socket. We'll read that data from the socket again just to make REAPER happy.
while let Some(task) = self.tasks.pop() { while let Some(task) = self.tasks.pop() {
self.inner.execute(task, true); self.inner.execute(task, true);
let mut notify_value = 1i8;
const NOTIFY_VALUE_SIZE: usize = std::mem::size_of::<i8>();
assert_eq!(
libc::read(
self.socket_read_fd,
&mut notify_value as *mut _ as *mut c_void,
NOTIFY_VALUE_SIZE
),
NOTIFY_VALUE_SIZE as isize
);
} }
} }
} }