From e71ae3a83ff36994daeb23abee4670b3ee88bbb4 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Wed, 22 May 2024 20:43:23 +0000 Subject: [PATCH] Bug 1895787 - Update cubeb rust repos to support audio dumping and more. r=cubeb-reviewers,supply-chain-reviewers,padenot The "more" is mainly some fixes in the coreaudio backend, including: - serializing more audio operations onto the serial queue - using the correct audio unit scope when querying for its stream format - tightening up some potential races around reinit on certain errors Differential Revision: https://phabricator.services.mozilla.com/D211042 --- .cargo/config.toml.in | 12 +- Cargo.lock | 32 +- supply-chain/audits.toml | 20 ++ .../audioipc2-client/.cargo-checksum.json | 2 +- third_party/rust/audioipc2-client/Cargo.toml | 2 +- .../audioipc2-server/.cargo-checksum.json | 2 +- third_party/rust/audioipc2-server/Cargo.toml | 2 +- .../rust/audioipc2/.cargo-checksum.json | 2 +- third_party/rust/audioipc2/Cargo.toml | 2 +- .../rust/audioipc2/src/sys/unix/msg.rs | 4 +- .../rust/cubeb-backend/.cargo-checksum.json | 2 +- third_party/rust/cubeb-backend/Cargo.toml | 4 +- third_party/rust/cubeb-backend/src/traits.rs | 2 +- .../rust/cubeb-core/.cargo-checksum.json | 2 +- third_party/rust/cubeb-core/Cargo.toml | 4 +- third_party/rust/cubeb-core/src/builders.rs | 1 - third_party/rust/cubeb-core/src/context.rs | 2 +- .../rust/cubeb-coreaudio/.cargo-checksum.json | 2 +- .../.github/workflows/test.yml | 5 +- third_party/rust/cubeb-coreaudio/Cargo.toml | 2 +- .../src/backend/aggregate_device.rs | 43 ++- .../src/backend/device_property.rs | 16 + .../rust/cubeb-coreaudio/src/backend/mod.rs | 318 ++++++++++-------- .../src/backend/tests/aggregate_device.rs | 2 +- .../cubeb-coreaudio/src/backend/tests/api.rs | 62 ++-- .../src/backend/tests/interfaces.rs | 75 ++++- .../src/backend/tests/manual.rs | 4 +- .../src/backend/tests/utils.rs | 54 ++- .../rust/cubeb-pulse/.cargo-checksum.json | 2 +- third_party/rust/cubeb-pulse/Cargo.toml | 2 +- .../rust/cubeb-pulse/src/backend/context.rs | 2 +- .../rust/cubeb-pulse/src/backend/stream.rs | 16 +- .../rust/cubeb-sys/.cargo-checksum.json | 2 +- third_party/rust/cubeb-sys/Cargo.toml | 2 +- .../rust/cubeb-sys/libcubeb/CMakeLists.txt | 4 +- .../cubeb-sys/libcubeb/include/cubeb/cubeb.h | 2 +- .../rust/cubeb-sys/libcubeb/src/cubeb.c | 6 +- .../cubeb-sys/libcubeb/src/cubeb_aaudio.cpp | 21 +- .../libcubeb/src/cubeb_audio_dump.cpp | 231 +++++++++++++ .../cubeb-sys/libcubeb/src/cubeb_audio_dump.h | 108 ++++++ .../libcubeb/src/cubeb_audiounit.cpp | 26 +- .../cubeb-sys/libcubeb/src/cubeb_wasapi.cpp | 58 +++- .../libcubeb/test/test_audio_dump.cpp | 74 ++++ .../cubeb-sys/libcubeb/test/test_duplex.cpp | 2 + third_party/rust/cubeb-sys/src/audio_dump.rs | 35 ++ third_party/rust/cubeb-sys/src/lib.rs | 2 + third_party/rust/cubeb/.cargo-checksum.json | 2 +- third_party/rust/cubeb/Cargo.lock | 18 +- third_party/rust/cubeb/Cargo.toml | 4 +- third_party/rust/cubeb/src/sample.rs | 2 +- toolkit/library/rust/shared/Cargo.toml | 10 +- 51 files changed, 1030 insertions(+), 281 deletions(-) create mode 100644 third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.cpp create mode 100644 third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.h create mode 100644 third_party/rust/cubeb-sys/libcubeb/test/test_audio_dump.cpp create mode 100644 third_party/rust/cubeb-sys/src/audio_dump.rs diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in index 171ca31854e5..9d66224c8fe2 100644 --- a/.cargo/config.toml.in +++ b/.cargo/config.toml.in @@ -65,19 +65,19 @@ git = "https://github.com/mozilla/application-services" rev = "e0563d725f852f617878ecc13a03cdf50c85cd5a" replace-with = "vendored-sources" -[source."git+https://github.com/mozilla/audioipc?rev=409e11f8de6288e9ddfe269654523735302e59e6"] +[source."git+https://github.com/mozilla/audioipc?rev=3495905752a4263827f5d43737f9ca3ed0243ce0"] git = "https://github.com/mozilla/audioipc" -rev = "409e11f8de6288e9ddfe269654523735302e59e6" +rev = "3495905752a4263827f5d43737f9ca3ed0243ce0" replace-with = "vendored-sources" -[source."git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=4ca174cf83ebe32b3198478c2211d69678845bc7"] +[source."git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=0989726a1b9b640a30dfdf3ea005a12c73ab8155"] git = "https://github.com/mozilla/cubeb-coreaudio-rs" -rev = "4ca174cf83ebe32b3198478c2211d69678845bc7" +rev = "0989726a1b9b640a30dfdf3ea005a12c73ab8155" replace-with = "vendored-sources" -[source."git+https://github.com/mozilla/cubeb-pulse-rs?rev=8ff972c8e2ec1782ff262ac4071c0415e69b1367"] +[source."git+https://github.com/mozilla/cubeb-pulse-rs?rev=8678dcab1c287de79c4c184ccc2e065bc62b70e2"] git = "https://github.com/mozilla/cubeb-pulse-rs" -rev = "8ff972c8e2ec1782ff262ac4071c0415e69b1367" +rev = "8678dcab1c287de79c4c184ccc2e065bc62b70e2" replace-with = "vendored-sources" [source."git+https://github.com/mozilla/midir.git?rev=85156e360a37d851734118104619f86bd18e94c6"] diff --git a/Cargo.lock b/Cargo.lock index 74316e2199e3..f8a858c2d311 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,7 +260,7 @@ dependencies = [ [[package]] name = "audioipc2" version = "0.6.0" -source = "git+https://github.com/mozilla/audioipc?rev=409e11f8de6288e9ddfe269654523735302e59e6#409e11f8de6288e9ddfe269654523735302e59e6" +source = "git+https://github.com/mozilla/audioipc?rev=3495905752a4263827f5d43737f9ca3ed0243ce0#3495905752a4263827f5d43737f9ca3ed0243ce0" dependencies = [ "arrayvec", "ashmem", @@ -288,7 +288,7 @@ dependencies = [ [[package]] name = "audioipc2-client" version = "0.6.0" -source = "git+https://github.com/mozilla/audioipc?rev=409e11f8de6288e9ddfe269654523735302e59e6#409e11f8de6288e9ddfe269654523735302e59e6" +source = "git+https://github.com/mozilla/audioipc?rev=3495905752a4263827f5d43737f9ca3ed0243ce0#3495905752a4263827f5d43737f9ca3ed0243ce0" dependencies = [ "audio_thread_priority", "audioipc2", @@ -299,7 +299,7 @@ dependencies = [ [[package]] name = "audioipc2-server" version = "0.6.0" -source = "git+https://github.com/mozilla/audioipc?rev=409e11f8de6288e9ddfe269654523735302e59e6#409e11f8de6288e9ddfe269654523735302e59e6" +source = "git+https://github.com/mozilla/audioipc?rev=3495905752a4263827f5d43737f9ca3ed0243ce0#3495905752a4263827f5d43737f9ca3ed0243ce0" dependencies = [ "audio_thread_priority", "audioipc2", @@ -941,7 +941,7 @@ dependencies = [ [[package]] name = "coreaudio-sys-utils" version = "0.1.0" -source = "git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=4ca174cf83ebe32b3198478c2211d69678845bc7#4ca174cf83ebe32b3198478c2211d69678845bc7" +source = "git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=0989726a1b9b640a30dfdf3ea005a12c73ab8155#0989726a1b9b640a30dfdf3ea005a12c73ab8155" dependencies = [ "core-foundation-sys", "coreaudio-sys", @@ -1160,27 +1160,27 @@ dependencies = [ [[package]] name = "cubeb" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db57570f2617f0214c11721e8d2325816d9dc936c2c472661ac5d90a30fba98" +checksum = "3d105547cf8036cdb30e796ce0d06832af4766106a44574402fa2fd3c861a042" dependencies = [ "cubeb-core", ] [[package]] name = "cubeb-backend" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00b0f3b84e315571bd8c4e18794180633066267a413f2f05bca65001adc8410" +checksum = "67361fe9b49b4599e2a230ce322529b6ddd91df14897c872dcede716f8fbca81" dependencies = [ "cubeb-core", ] [[package]] name = "cubeb-core" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380c03a7df0ea3744f6a210d6340f423935e53cbf2fd68ada84b5e808e46ac7" +checksum = "ac08d314dd1ec6d41d9ccdeec70899c98ed3b89845367000dd6096099481bc73" dependencies = [ "bitflags 1.999.999", "cubeb-sys", @@ -1189,7 +1189,7 @@ dependencies = [ [[package]] name = "cubeb-coreaudio" version = "0.1.0" -source = "git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=4ca174cf83ebe32b3198478c2211d69678845bc7#4ca174cf83ebe32b3198478c2211d69678845bc7" +source = "git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=0989726a1b9b640a30dfdf3ea005a12c73ab8155#0989726a1b9b640a30dfdf3ea005a12c73ab8155" dependencies = [ "atomic", "audio-mixer", @@ -1208,7 +1208,7 @@ dependencies = [ [[package]] name = "cubeb-pulse" version = "0.5.0" -source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=8ff972c8e2ec1782ff262ac4071c0415e69b1367#8ff972c8e2ec1782ff262ac4071c0415e69b1367" +source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=8678dcab1c287de79c4c184ccc2e065bc62b70e2#8678dcab1c287de79c4c184ccc2e065bc62b70e2" dependencies = [ "cubeb-backend", "pulse", @@ -1219,9 +1219,9 @@ dependencies = [ [[package]] name = "cubeb-sys" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c20c457d7b34dad6e0c1a9c759c96b4420b9e9917a572998b81835799a07e1d" +checksum = "26073cd50c7b6ba4272204839f56921557609a0d67e092882cbb903df94cab39" dependencies = [ "cmake", "pkg-config", @@ -4649,7 +4649,7 @@ dependencies = [ [[package]] name = "pulse" version = "0.3.0" -source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=8ff972c8e2ec1782ff262ac4071c0415e69b1367#8ff972c8e2ec1782ff262ac4071c0415e69b1367" +source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=8678dcab1c287de79c4c184ccc2e065bc62b70e2#8678dcab1c287de79c4c184ccc2e065bc62b70e2" dependencies = [ "bitflags 2.5.0", "pulse-ffi", @@ -4658,7 +4658,7 @@ dependencies = [ [[package]] name = "pulse-ffi" version = "0.1.0" -source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=8ff972c8e2ec1782ff262ac4071c0415e69b1367#8ff972c8e2ec1782ff262ac4071c0415e69b1367" +source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=8678dcab1c287de79c4c184ccc2e065bc62b70e2#8678dcab1c287de79c4c184ccc2e065bc62b70e2" dependencies = [ "libc", ] diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 3d3fdbc86d2d..fb73507d73a1 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -1288,6 +1288,11 @@ who = "Andreas Pehrson " criteria = "safe-to-deploy" delta = "0.10.3 -> 0.12.0" +[[audits.cubeb]] +who = "Andreas Pehrson " +criteria = "safe-to-deploy" +delta = "0.12.0 -> 0.13.0" + [[audits.cubeb-backend]] who = "Matthew Gregan " criteria = "safe-to-deploy" @@ -1319,6 +1324,11 @@ who = "Andreas Pehrson " criteria = "safe-to-deploy" delta = "0.10.7 -> 0.12.0" +[[audits.cubeb-backend]] +who = "Andreas Pehrson " +criteria = "safe-to-deploy" +delta = "0.12.0 -> 0.13.0" + [[audits.cubeb-core]] who = "Matthew Gregan " criteria = "safe-to-deploy" @@ -1355,6 +1365,11 @@ who = "Andreas Pehrson " criteria = "safe-to-deploy" delta = "0.10.7 -> 0.12.0" +[[audits.cubeb-core]] +who = "Andreas Pehrson " +criteria = "safe-to-deploy" +delta = "0.12.0 -> 0.13.0" + [[audits.cubeb-sys]] who = "Matthew Gregan " criteria = "safe-to-deploy" @@ -1386,6 +1401,11 @@ who = "Andreas Pehrson " criteria = "safe-to-deploy" delta = "0.10.7 -> 0.12.0" +[[audits.cubeb-sys]] +who = "Andreas Pehrson " +criteria = "safe-to-deploy" +delta = "0.12.0 -> 0.13.0" + [[audits.d3d12]] who = "Jim Blandy " criteria = "safe-to-deploy" diff --git a/third_party/rust/audioipc2-client/.cargo-checksum.json b/third_party/rust/audioipc2-client/.cargo-checksum.json index c524aec67f34..713e1bfb259f 100644 --- a/third_party/rust/audioipc2-client/.cargo-checksum.json +++ b/third_party/rust/audioipc2-client/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"e94c46bbd290f02adccc7ae932285416d7e021bfde80abb2fb31a2c05426e732","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/context.rs":"a0559e92b554ef3156ab2bf2f1424555c8ef4a7977b9f43ac8500a9f399f8d99","src/lib.rs":"c87d9d57a16a9286cde730978db692df0fbc70cc69dd4f4677198d6843031fd8","src/send_recv.rs":"859abe75b521eb4297c84b30423814b5b87f3c7741ad16fe72189212e123e1ac","src/stream.rs":"90dc6a85552f3569ab1847de4247a46bcff2f5aef0c4d43fa2376589df015b25"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"b4fad65749eb0988ce4e6b6a2aae51e58ae22eca97cf61dfb011e951a0909f0e","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/context.rs":"a0559e92b554ef3156ab2bf2f1424555c8ef4a7977b9f43ac8500a9f399f8d99","src/lib.rs":"c87d9d57a16a9286cde730978db692df0fbc70cc69dd4f4677198d6843031fd8","src/send_recv.rs":"859abe75b521eb4297c84b30423814b5b87f3c7741ad16fe72189212e123e1ac","src/stream.rs":"90dc6a85552f3569ab1847de4247a46bcff2f5aef0c4d43fa2376589df015b25"},"package":null} \ No newline at end of file diff --git a/third_party/rust/audioipc2-client/Cargo.toml b/third_party/rust/audioipc2-client/Cargo.toml index b776fb47e0fb..ecafb31ad347 100644 --- a/third_party/rust/audioipc2-client/Cargo.toml +++ b/third_party/rust/audioipc2-client/Cargo.toml @@ -21,7 +21,7 @@ description = "Cubeb Backend for talking to remote cubeb server." license = "ISC" [dependencies] -cubeb-backend = "0.12" +cubeb-backend = "0.13" log = "0.4" [dependencies.audio_thread_priority] diff --git a/third_party/rust/audioipc2-server/.cargo-checksum.json b/third_party/rust/audioipc2-server/.cargo-checksum.json index 092d47fc8366..d7ba879e5030 100644 --- a/third_party/rust/audioipc2-server/.cargo-checksum.json +++ b/third_party/rust/audioipc2-server/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"77997660e305851d9c0e656aac7159b999452a36f3436d8b2f402edd36fef853","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/lib.rs":"d70079c66de72c3469504f1f0c9cf5e510644cac17f2d8300b8d12218740e07b","src/server.rs":"187e2236aa9f2fb6cc4a533d40714a71504afa5ef9d849ac28b7f26032859c29"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"62eab883f31c0c088ff865fe2e4305d987b7b534f6cdfe1e5812072a2ec13f8b","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/lib.rs":"d70079c66de72c3469504f1f0c9cf5e510644cac17f2d8300b8d12218740e07b","src/server.rs":"187e2236aa9f2fb6cc4a533d40714a71504afa5ef9d849ac28b7f26032859c29"},"package":null} \ No newline at end of file diff --git a/third_party/rust/audioipc2-server/Cargo.toml b/third_party/rust/audioipc2-server/Cargo.toml index e5436e4e6a20..0326e5e40353 100644 --- a/third_party/rust/audioipc2-server/Cargo.toml +++ b/third_party/rust/audioipc2-server/Cargo.toml @@ -21,7 +21,7 @@ description = "Remote cubeb server" license = "ISC" [dependencies] -cubeb-core = "0.12.0" +cubeb-core = "0.13" log = "0.4" once_cell = "1.2.0" slab = "0.4" diff --git a/third_party/rust/audioipc2/.cargo-checksum.json b/third_party/rust/audioipc2/.cargo-checksum.json index 92cc622efe03..de1fba76d462 100644 --- a/third_party/rust/audioipc2/.cargo-checksum.json +++ b/third_party/rust/audioipc2/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"dff67ba050be15275d357b7f001df6caa6ae1f93b2acd61ac7d6ee269a1f5960","benches/serialization.rs":"d56855d868dab6aa22c8b03a61084535351b76c94b68d8b1d20764e352fe473f","build.rs":"65df9a97c6cdaa3faf72581f04ac289197b0b1797d69d22c1796e957ff1089e2","src/codec.rs":"86068272e220696d8d7e369072326349e7598e5a24223d98179c3251bb7b3ff1","src/errors.rs":"67a4a994d0724397657581cde153bdfc05ce86e7efc467f23fafc8f64df80fa4","src/ipccore.rs":"db73e916468c54d3497d75ffcab3bf23067771ed7b2e1a23c714429f56f59ec3","src/lib.rs":"a6fcac8b44318435db60313d3ef32ff3fada390bea8978c8414c40744998b98b","src/messages.rs":"d4f6d4f41b7fd3cc7deae726657e1100f315f4cd10c5fe6ce8a57c03c8e26ca9","src/rpccore.rs":"025b6614f1c42b96b0a8e74fd7881032d338c66e0d67ec0af70f910a9e30ebe1","src/shm.rs":"c00d16f4af510d12e704ae865f7348ad64ddef180e42b18e7dd95c4be35a9c80","src/sys/mod.rs":"e6fa1d260abf093e1f7b50185195e2d3aee0eb8c9774c6f253953b5896d838f3","src/sys/unix/cmsg.rs":"9529e8f8429db86f7c5df132953d3054e603852270f3c6938cdb5f630b2711f1","src/sys/unix/cmsghdr.c":"d7344b3dc15cdce410c68669b848bb81f7fe36362cd3699668cb613fa05180f8","src/sys/unix/mod.rs":"59835f0d5509940078b1820a54f49fc5514adeb3e45e7d21e3ab917431da2e74","src/sys/unix/msg.rs":"0e297d73bae9414184f85c2209cca0a3fde6d999a3f1d3f42faa3f56b6d57233","src/sys/windows/mod.rs":"7eaabb76e62c6962b636320e2bbf79a78fce61659c799a798f7dd6d56b0be8a1"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"5dc7153bf7291eea52bdc5561440c1c646272f8c913e8782bc2c84b7ed2f8b76","benches/serialization.rs":"d56855d868dab6aa22c8b03a61084535351b76c94b68d8b1d20764e352fe473f","build.rs":"65df9a97c6cdaa3faf72581f04ac289197b0b1797d69d22c1796e957ff1089e2","src/codec.rs":"86068272e220696d8d7e369072326349e7598e5a24223d98179c3251bb7b3ff1","src/errors.rs":"67a4a994d0724397657581cde153bdfc05ce86e7efc467f23fafc8f64df80fa4","src/ipccore.rs":"db73e916468c54d3497d75ffcab3bf23067771ed7b2e1a23c714429f56f59ec3","src/lib.rs":"a6fcac8b44318435db60313d3ef32ff3fada390bea8978c8414c40744998b98b","src/messages.rs":"d4f6d4f41b7fd3cc7deae726657e1100f315f4cd10c5fe6ce8a57c03c8e26ca9","src/rpccore.rs":"025b6614f1c42b96b0a8e74fd7881032d338c66e0d67ec0af70f910a9e30ebe1","src/shm.rs":"c00d16f4af510d12e704ae865f7348ad64ddef180e42b18e7dd95c4be35a9c80","src/sys/mod.rs":"e6fa1d260abf093e1f7b50185195e2d3aee0eb8c9774c6f253953b5896d838f3","src/sys/unix/cmsg.rs":"9529e8f8429db86f7c5df132953d3054e603852270f3c6938cdb5f630b2711f1","src/sys/unix/cmsghdr.c":"d7344b3dc15cdce410c68669b848bb81f7fe36362cd3699668cb613fa05180f8","src/sys/unix/mod.rs":"59835f0d5509940078b1820a54f49fc5514adeb3e45e7d21e3ab917431da2e74","src/sys/unix/msg.rs":"25244de3eba920fa42e032f8fa4ea4913a9fdeb5124ade61e707f6cc6dd946b0","src/sys/windows/mod.rs":"7eaabb76e62c6962b636320e2bbf79a78fce61659c799a798f7dd6d56b0be8a1"},"package":null} \ No newline at end of file diff --git a/third_party/rust/audioipc2/Cargo.toml b/third_party/rust/audioipc2/Cargo.toml index 62be642df595..4b6b2b00cffa 100644 --- a/third_party/rust/audioipc2/Cargo.toml +++ b/third_party/rust/audioipc2/Cargo.toml @@ -29,7 +29,7 @@ bincode = "1.3" byteorder = "1" bytes = "1" crossbeam-queue = "0.3" -cubeb = "0.12" +cubeb = "0.13" log = "0.4" scopeguard = "1.1.0" serde = "1" diff --git a/third_party/rust/audioipc2/src/sys/unix/msg.rs b/third_party/rust/audioipc2/src/sys/unix/msg.rs index c2cd35328958..9f9d5880f974 100644 --- a/third_party/rust/audioipc2/src/sys/unix/msg.rs +++ b/third_party/rust/audioipc2/src/sys/unix/msg.rs @@ -34,7 +34,7 @@ pub(crate) fn recv_msg_with_flags( flags: libc::c_int, ) -> io::Result<(usize, usize, libc::c_int)> { let slice = unix::as_os_slice_mut(bufs); - let len = cmp::min(::max_value() as usize, slice.len()); + let len = cmp::min(::MAX as usize, slice.len()); let (control, controllen) = if cmsg.len() == 0 { (ptr::null_mut(), 0) } else { @@ -63,7 +63,7 @@ pub(crate) fn send_msg_with_flags( flags: libc::c_int, ) -> io::Result { let slice = unix::as_os_slice(bufs); - let len = cmp::min(::max_value() as usize, slice.len()); + let len = cmp::min(::MAX as usize, slice.len()); let (control, controllen) = if cmsg.is_empty() { (ptr::null_mut(), 0) } else { diff --git a/third_party/rust/cubeb-backend/.cargo-checksum.json b/third_party/rust/cubeb-backend/.cargo-checksum.json index b7957cac430c..2dc593c9a5d1 100644 --- a/third_party/rust/cubeb-backend/.cargo-checksum.json +++ b/third_party/rust/cubeb-backend/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"b3a6e03dbc48515bbca791eba64096ab43dddafa6c60eec2b824369e2afb31b8","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/capi.rs":"d9bc993ea8bb51220c5cdc54488bc795f74411fe688332bd80dbb062c41342bb","src/lib.rs":"4ce6db20f88487e99057ebeae0615fa1c99e82cfee0ab0825936da2e108fc73e","src/log.rs":"968b839a8a5a56fe42e372678fdd580e2777e1dba8c4f0bee6fbfe5e3f03b860","src/ops.rs":"e631eba0d1ef8c13287361be32c0806d7869f598f58266bab0a45642521fa07e","src/traits.rs":"45e3e58772dd0ff40bf36d56dd9f1fc682cc08cea570022fa50eae1c34d43a3a","tests/test_capi.rs":"783c8321dceb33a414168ae64e162f934015144f49118d868557009819a20e06"},"package":"b00b0f3b84e315571bd8c4e18794180633066267a413f2f05bca65001adc8410"} \ No newline at end of file +{"files":{"Cargo.toml":"ea3e08eb6e9fd52717bf756cf2a7063afeb3af617df0dee2f14591f45b9e6f62","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/capi.rs":"d9bc993ea8bb51220c5cdc54488bc795f74411fe688332bd80dbb062c41342bb","src/lib.rs":"4ce6db20f88487e99057ebeae0615fa1c99e82cfee0ab0825936da2e108fc73e","src/log.rs":"968b839a8a5a56fe42e372678fdd580e2777e1dba8c4f0bee6fbfe5e3f03b860","src/ops.rs":"e631eba0d1ef8c13287361be32c0806d7869f598f58266bab0a45642521fa07e","src/traits.rs":"876ea164c03d198c92a61d9b11d2839c3a257ae48042b9cd2d9ececcf00d373a","tests/test_capi.rs":"783c8321dceb33a414168ae64e162f934015144f49118d868557009819a20e06"},"package":"67361fe9b49b4599e2a230ce322529b6ddd91df14897c872dcede716f8fbca81"} \ No newline at end of file diff --git a/third_party/rust/cubeb-backend/Cargo.toml b/third_party/rust/cubeb-backend/Cargo.toml index 2f4d2dc05567..b5a26509b806 100644 --- a/third_party/rust/cubeb-backend/Cargo.toml +++ b/third_party/rust/cubeb-backend/Cargo.toml @@ -11,7 +11,7 @@ [package] name = "cubeb-backend" -version = "0.12.0" +version = "0.13.0" authors = ["Dan Glastonbury "] description = """ Bindings to libcubeb internals to facilitate implementing cubeb backends in rust. @@ -23,7 +23,7 @@ license = "ISC" repository = "https://github.com/mozilla/cubeb-rs" [dependencies.cubeb-core] -version = "0.12.0" +version = "0.13.0" [features] gecko-in-tree = ["cubeb-core/gecko-in-tree"] diff --git a/third_party/rust/cubeb-backend/src/traits.rs b/third_party/rust/cubeb-backend/src/traits.rs index 79488d57721d..d662342c731c 100644 --- a/third_party/rust/cubeb-backend/src/traits.rs +++ b/third_party/rust/cubeb-backend/src/traits.rs @@ -24,7 +24,7 @@ pub trait ContextOps { collection: &DeviceCollectionRef, ) -> Result<()>; fn device_collection_destroy(&mut self, collection: &mut DeviceCollectionRef) -> Result<()>; - #[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] + #[allow(clippy::too_many_arguments)] fn stream_init( &mut self, stream_name: Option<&CStr>, diff --git a/third_party/rust/cubeb-core/.cargo-checksum.json b/third_party/rust/cubeb-core/.cargo-checksum.json index ff85000f1ae6..f6ad33f7c6f2 100644 --- a/third_party/rust/cubeb-core/.cargo-checksum.json +++ b/third_party/rust/cubeb-core/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"9f1c5d546cc66c991eafd6369bb8799f6021e677217b86f092d08c6a1e6fee6a","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/builders.rs":"87adbbdd63fde848eeaae4a79a04859ed02ca982fb644f6b8b5fe7c158a8944c","src/call.rs":"cf8949c2cf53f5418d8e5222f570b9301a98a476a18c734fc2ebbc8b53ac0165","src/channel.rs":"c88b8846e53bbec6b125a4fa6a3787c48312be958bd08cc5ee773b218d93d683","src/context.rs":"ac5937037e69f32bb3ef5985d1921f53a2651d0068c12f90762eb0e18489e93e","src/device.rs":"86fd507bf1cd97b13b8cf3e92519b3be11904be68d4997658b276d5054162cd7","src/device_collection.rs":"f86535ffeee73b889bdbac1c5a3432b01cca86df819a7cc26eaa0c983d30cbbe","src/error.rs":"3693bf575e9504b9b1ab114de3e2ce7132039acf27ec68967dae66c2ce1581aa","src/ffi_types.rs":"71948d0949675df876e18c4340f4e693fc6a14c4de9d63a3885450c95577596b","src/format.rs":"7162c1550be53f5fe94b0bba4c71fea2f0304462108657c62a20ea47207ca413","src/lib.rs":"57ecf793ab1cc052c021ccbf9ad011ea52d1303e2dbc54adea90a95b5d7a36cf","src/log.rs":"4bef74d7a7fd9ffdf249be5ef95781969f00a7ecff2d3a190d5b1536d1635a73","src/stream.rs":"9fbfc65f77fb1009f8578c530744276828a6d6778f53b96decb698d937c2b098","src/util.rs":"308cfbaacd615ff600e74415c52daeef007fff34a4a0648a73c0042f6067f84f"},"package":"2380c03a7df0ea3744f6a210d6340f423935e53cbf2fd68ada84b5e808e46ac7"} \ No newline at end of file +{"files":{"Cargo.toml":"23878f9ab656986033932729656b52e131f3fc186be68fa7bbef288d6d7590d8","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/builders.rs":"584d3e911d55746ab6ff9aed4c5901a73a9518ac14fa2e589fe169541ec78e33","src/call.rs":"cf8949c2cf53f5418d8e5222f570b9301a98a476a18c734fc2ebbc8b53ac0165","src/channel.rs":"c88b8846e53bbec6b125a4fa6a3787c48312be958bd08cc5ee773b218d93d683","src/context.rs":"f58f8562599d27ab4a9bf76d429a5b7dc971449c20245803fc857ddb6e3090cc","src/device.rs":"86fd507bf1cd97b13b8cf3e92519b3be11904be68d4997658b276d5054162cd7","src/device_collection.rs":"f86535ffeee73b889bdbac1c5a3432b01cca86df819a7cc26eaa0c983d30cbbe","src/error.rs":"3693bf575e9504b9b1ab114de3e2ce7132039acf27ec68967dae66c2ce1581aa","src/ffi_types.rs":"71948d0949675df876e18c4340f4e693fc6a14c4de9d63a3885450c95577596b","src/format.rs":"7162c1550be53f5fe94b0bba4c71fea2f0304462108657c62a20ea47207ca413","src/lib.rs":"57ecf793ab1cc052c021ccbf9ad011ea52d1303e2dbc54adea90a95b5d7a36cf","src/log.rs":"4bef74d7a7fd9ffdf249be5ef95781969f00a7ecff2d3a190d5b1536d1635a73","src/stream.rs":"9fbfc65f77fb1009f8578c530744276828a6d6778f53b96decb698d937c2b098","src/util.rs":"308cfbaacd615ff600e74415c52daeef007fff34a4a0648a73c0042f6067f84f"},"package":"ac08d314dd1ec6d41d9ccdeec70899c98ed3b89845367000dd6096099481bc73"} \ No newline at end of file diff --git a/third_party/rust/cubeb-core/Cargo.toml b/third_party/rust/cubeb-core/Cargo.toml index 543cceabff79..7844793c6c88 100644 --- a/third_party/rust/cubeb-core/Cargo.toml +++ b/third_party/rust/cubeb-core/Cargo.toml @@ -11,7 +11,7 @@ [package] name = "cubeb-core" -version = "0.12.0" +version = "0.13.0" authors = ["Dan Glastonbury "] description = """ Common types and definitions for cubeb rust and C bindings. Not intended for direct use. @@ -26,7 +26,7 @@ repository = "https://github.com/mozilla/cubeb-rs" version = "1.2.0" [dependencies.cubeb-sys] -version = "0.12.0" +version = "0.13" [features] gecko-in-tree = ["cubeb-sys/gecko-in-tree"] diff --git a/third_party/rust/cubeb-core/src/builders.rs b/third_party/rust/cubeb-core/src/builders.rs index c79b83569f71..a37eb3a52472 100644 --- a/third_party/rust/cubeb-core/src/builders.rs +++ b/third_party/rust/cubeb-core/src/builders.rs @@ -6,7 +6,6 @@ use ffi; use {ChannelLayout, SampleFormat, StreamParams, StreamPrefs}; -/// #[derive(Debug)] pub struct StreamParamsBuilder(ffi::cubeb_stream_params); diff --git a/third_party/rust/cubeb-core/src/context.rs b/third_party/rust/cubeb-core/src/context.rs index 84c362789a72..a1941adbb71d 100644 --- a/third_party/rust/cubeb-core/src/context.rs +++ b/third_party/rust/cubeb-core/src/context.rs @@ -95,7 +95,7 @@ impl ContextRef { /// /// This function is unsafe because it dereferences the given `data_callback`, `state_callback`, and `user_ptr` pointers. /// The caller should ensure those pointers are valid. - #[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] + #[allow(clippy::too_many_arguments)] pub unsafe fn stream_init( &self, stream_name: Option<&CStr>, diff --git a/third_party/rust/cubeb-coreaudio/.cargo-checksum.json b/third_party/rust/cubeb-coreaudio/.cargo-checksum.json index b0c27f353e55..40bb89d27b65 100644 --- a/third_party/rust/cubeb-coreaudio/.cargo-checksum.json +++ b/third_party/rust/cubeb-coreaudio/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".circleci/config.yml":"7f3dc865105ca8f33965a7958b1fe2e627ae2d5a703f3b2a4ab6e2e796018597",".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".githooks/pre-push":"8b8b26544cd56f54c0c33812551f786bb25cb08c86dbfeb6bf3daad881c826a1",".github/workflows/test.yml":"ac8f4cf5b7631b5c738d50c0cf78113bd395940b9e76593904bbaf2d02d16a70",".travis.yml":"dc07bac53f70f16c9bdf52264bdc58500ae6018c1b4c567bc7642f6b4ca3cc35","Cargo.toml":"a16b883e4fb41bdbbe5f68158040f181aeeffb4573ab0d493e9452f7c6f00541","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"0007782a05a5330f739ad789c19c82562c82e32386b0447000fc72c0d48405bc","build-audiounit-rust-in-cubeb.sh":"d228a05985dcd02ec1ecac66a2b64dae5a530804a25a7054ccc95905aedfb7ef","install_git_hook.sh":"d38c8e51e636f6b90b489621ac34ccd1d1b1f40dccce3d178ed1da1c5068f16d","install_rustfmt_clippy.sh":"4ae90d8dcb9757cb3ae4ae142ef80e5377c0dde61c63f4a3c32418646e80ca7b","run_device_tests.sh":"90c2542fa3ff8a35fed894fae3a1aa0157117b7f0e28df14b8e6f7b1f1f43797","run_sanitizers.sh":"84e93a0da137803018f37403511e8c92760be730426bf6cea34419d93d1a7ff8","run_tests.sh":"bae82f66dd47a060b6fdcc238520084aec1079d5b1b1d66d103baa1ffaa8773d","src/backend/aggregate_device.rs":"db7d644358090b1d65ff2d53ad854369790ae4ad7dfa12b79888c0002c1b4950","src/backend/auto_release.rs":"050fdcee74cf46b9a8a85a877e166d72a853d33220f59cf734cbb6ea09daa441","src/backend/buffer_manager.rs":"e9bcf964347daa8952f98caa2746e34a31ea8908375204896593f56e4b6147ca","src/backend/device_property.rs":"a7622feaa41db1cd76fd35a85a022e44f4894e396a104a59008d5b8757d2ab4e","src/backend/mixer.rs":"c4d09291598cbffb2217b551770ec590f34b6dd6b461dd99b019d5bb70f0eef3","src/backend/mod.rs":"d75e116a58d63c6a7cb281d160066f48c8c449702dad58c762ad50d9512d7bd3","src/backend/resampler.rs":"48bf8f56ae8d60dbabca6417b768000619abee8731ac3902164b45651ac08a4d","src/backend/tests/aggregate_device.rs":"770cf90f32b5ab2203476031c1fbc8379b713baa97bec36f7fd0d77fef1efd60","src/backend/tests/api.rs":"773e88b506efccf0eacbf408d34dea1fb2c5a8500e7fe8a494a97f15f1ea41fc","src/backend/tests/backlog.rs":"3b189a7e036543c467cc242af0ed3332721179ee2b1c8847a6db563546f1ac52","src/backend/tests/device_change.rs":"babf50326fb38db24fe80f24f546e1b6ad04319ae8835bb372d893fc9b3038a2","src/backend/tests/device_property.rs":"73c25f579a995e8a59c9b7d391813afb75f739b5e2f825480cba04499a1d46e8","src/backend/tests/interfaces.rs":"654333cd6d6023e72ba392d98872d33bc55f8f052205a9f701aec72069449e24","src/backend/tests/manual.rs":"e550cc8bb7619bb80b68e49bf7f475c029e0f1b34323d1d30edcbe322cf4efc7","src/backend/tests/mod.rs":"8dba770023d7f9c4228f0e11915347f0e07da5fd818e3ee4478c4b197af9aa2a","src/backend/tests/parallel.rs":"a7ebd579339c40ca64c0757cc9da6baec641e670f226e1b2ec5049894700bd7a","src/backend/tests/tone.rs":"b028c67777b6453a26190b6a49785dfe28556adcbe179cb10862ce0d47ee8509","src/backend/tests/utils.rs":"80d7e4ebc06b23c63a4d2867e0c80e0bfe05449fa55edd21e785ed2c089bf7d5","src/backend/utils.rs":"6c3ffbcd602e6cc9f56deb9ecb07b2eef2e6f074ef924178e466f380aae5c595","src/capi.rs":"21b66b70545bf04ec719928004d1d9adb45b24ced51288f5b2993d79aaf78f5f","src/lib.rs":"5e586d45cd6b3722f0a6736d9252593299269817a153eef1930a5fb9bfbb56f5","todo.md":"efc1f012eb9a331a040cad4ac03aa79307f25885f71b6fb38f3ad7af8d7d515c"},"package":null} \ No newline at end of file +{"files":{".circleci/config.yml":"7f3dc865105ca8f33965a7958b1fe2e627ae2d5a703f3b2a4ab6e2e796018597",".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".githooks/pre-push":"8b8b26544cd56f54c0c33812551f786bb25cb08c86dbfeb6bf3daad881c826a1",".github/workflows/test.yml":"cf6ebe6d41b022897360866b526d19ba8843aa82ae99a1d28393985576b6a782",".travis.yml":"dc07bac53f70f16c9bdf52264bdc58500ae6018c1b4c567bc7642f6b4ca3cc35","Cargo.toml":"2698cf87581d8d551ed3ac5875564720ed23d7b788e8d145d4281c8026203cd2","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"0007782a05a5330f739ad789c19c82562c82e32386b0447000fc72c0d48405bc","build-audiounit-rust-in-cubeb.sh":"d228a05985dcd02ec1ecac66a2b64dae5a530804a25a7054ccc95905aedfb7ef","install_git_hook.sh":"d38c8e51e636f6b90b489621ac34ccd1d1b1f40dccce3d178ed1da1c5068f16d","install_rustfmt_clippy.sh":"4ae90d8dcb9757cb3ae4ae142ef80e5377c0dde61c63f4a3c32418646e80ca7b","run_device_tests.sh":"90c2542fa3ff8a35fed894fae3a1aa0157117b7f0e28df14b8e6f7b1f1f43797","run_sanitizers.sh":"84e93a0da137803018f37403511e8c92760be730426bf6cea34419d93d1a7ff8","run_tests.sh":"bae82f66dd47a060b6fdcc238520084aec1079d5b1b1d66d103baa1ffaa8773d","src/backend/aggregate_device.rs":"6e94c36c09081a728b1ab748b460fe8f538cf5f50bc62fd47171a393fe2d609a","src/backend/auto_release.rs":"050fdcee74cf46b9a8a85a877e166d72a853d33220f59cf734cbb6ea09daa441","src/backend/buffer_manager.rs":"e9bcf964347daa8952f98caa2746e34a31ea8908375204896593f56e4b6147ca","src/backend/device_property.rs":"0714b90c3187b0b1709f5e4b7757e1b434659276e00db48a3f3270fbfd429640","src/backend/mixer.rs":"c4d09291598cbffb2217b551770ec590f34b6dd6b461dd99b019d5bb70f0eef3","src/backend/mod.rs":"cfda5e4d5f7d3f6fda65fbcbf19bb114cdd2d9b6750c03967a4432bd1bfb788e","src/backend/resampler.rs":"48bf8f56ae8d60dbabca6417b768000619abee8731ac3902164b45651ac08a4d","src/backend/tests/aggregate_device.rs":"48e291b355a7c0c643fc58e9d238ed00234b4f1ac0f4c26737cc74862d4f2ac8","src/backend/tests/api.rs":"ef3babcd3410394b8d5bcdaf0ea526486b14d8e42f33211997aafe179430bf4a","src/backend/tests/backlog.rs":"3b189a7e036543c467cc242af0ed3332721179ee2b1c8847a6db563546f1ac52","src/backend/tests/device_change.rs":"babf50326fb38db24fe80f24f546e1b6ad04319ae8835bb372d893fc9b3038a2","src/backend/tests/device_property.rs":"73c25f579a995e8a59c9b7d391813afb75f739b5e2f825480cba04499a1d46e8","src/backend/tests/interfaces.rs":"cd58614435574444d8a1f039dc201cf371cccacd58efbae8ed8fbff919550d0a","src/backend/tests/manual.rs":"16dca201d7a7c6d37186aafdee277d437fc2ce5bbd215f33e660c6cb971395de","src/backend/tests/mod.rs":"8dba770023d7f9c4228f0e11915347f0e07da5fd818e3ee4478c4b197af9aa2a","src/backend/tests/parallel.rs":"a7ebd579339c40ca64c0757cc9da6baec641e670f226e1b2ec5049894700bd7a","src/backend/tests/tone.rs":"b028c67777b6453a26190b6a49785dfe28556adcbe179cb10862ce0d47ee8509","src/backend/tests/utils.rs":"21c8e7f6f18da0f8d33733ad0fc981041b43586db6a637c3f7aec7e7b3936aed","src/backend/utils.rs":"6c3ffbcd602e6cc9f56deb9ecb07b2eef2e6f074ef924178e466f380aae5c595","src/capi.rs":"21b66b70545bf04ec719928004d1d9adb45b24ced51288f5b2993d79aaf78f5f","src/lib.rs":"5e586d45cd6b3722f0a6736d9252593299269817a153eef1930a5fb9bfbb56f5","todo.md":"efc1f012eb9a331a040cad4ac03aa79307f25885f71b6fb38f3ad7af8d7d515c"},"package":null} \ No newline at end of file diff --git a/third_party/rust/cubeb-coreaudio/.github/workflows/test.yml b/third_party/rust/cubeb-coreaudio/.github/workflows/test.yml index 2bbb9eab5dde..8f80508876f4 100644 --- a/third_party/rust/cubeb-coreaudio/.github/workflows/test.yml +++ b/third_party/rust/cubeb-coreaudio/.github/workflows/test.yml @@ -33,10 +33,13 @@ jobs: rustc --version cargo --version - - name: Setup Audio + - name: Setup switchaudio if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' }} run: | brew install switchaudio-osx + + - name: Setup blackhole-2ch + run: | brew install blackhole-2ch SwitchAudioSource -s "BlackHole 2ch" -t input SwitchAudioSource -s "BlackHole 2ch" -t output diff --git a/third_party/rust/cubeb-coreaudio/Cargo.toml b/third_party/rust/cubeb-coreaudio/Cargo.toml index 02fb9832ac57..23276a307056 100644 --- a/third_party/rust/cubeb-coreaudio/Cargo.toml +++ b/third_party/rust/cubeb-coreaudio/Cargo.toml @@ -29,7 +29,7 @@ crate-type = [ atomic = "0.4" audio-mixer = "0.2" bitflags = "2" -cubeb-backend = "0.12.0" +cubeb-backend = "0.13" float-cmp = "0.6" lazy_static = "1.2" libc = "0.2" diff --git a/third_party/rust/cubeb-coreaudio/src/backend/aggregate_device.rs b/third_party/rust/cubeb-coreaudio/src/backend/aggregate_device.rs index 782e76de2fbe..d0f71a73a181 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/aggregate_device.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/aggregate_device.rs @@ -149,11 +149,12 @@ impl AggregateDevice { pub fn create_blank_device_sync( plugin_id: AudioObjectID, ) -> std::result::Result { + debug_assert_running_serially(); let waiting_time = Duration::new(5, 0); - let condvar_pair = Arc::new((Mutex::new(Vec::::new()), Condvar::new())); + let condvar_pair = Arc::new((Mutex::new(()), Condvar::new())); let mut cloned_condvar_pair = condvar_pair.clone(); - let data_ptr = &mut cloned_condvar_pair as *mut Arc<(Mutex>, Condvar)>; + let data_ptr = &mut cloned_condvar_pair as *mut Arc<(Mutex<()>, Condvar)>; let address = get_property_address( Property::HardwareDevices, @@ -182,18 +183,18 @@ impl AggregateDevice { // Wait until the aggregate is created. let (lock, cvar) = &*condvar_pair; - let devices = lock.lock().unwrap(); - if !devices.contains(&device) { - let (devs, timeout_res) = cvar.wait_timeout(devices, waiting_time).unwrap(); - if timeout_res.timed_out() { - cubeb_log!( - "Time out for waiting the creation of aggregate device {}!", - device - ); - } - if !devs.contains(&device) { - return Err(Error::from(waiting_time)); - } + let guard = lock.lock().unwrap(); + let (_guard, timeout_res) = cvar + .wait_timeout_while(guard, waiting_time, |()| { + !audiounit_get_devices().contains(&device) + }) + .unwrap(); + if timeout_res.timed_out() { + cubeb_log!( + "Time out for waiting the creation of aggregate device {}!", + device + ); + return Err(Error::from(waiting_time)); } extern "C" fn devices_changed_callback( @@ -203,10 +204,9 @@ impl AggregateDevice { data: *mut c_void, ) -> OSStatus { assert_eq!(id, kAudioObjectSystemObject); - let pair = unsafe { &mut *(data as *mut Arc<(Mutex>, Condvar)>) }; + let pair = unsafe { &mut *(data as *mut Arc<(Mutex<()>, Condvar)>) }; let (lock, cvar) = &**pair; - let mut devices = lock.lock().unwrap(); - *devices = audiounit_get_devices(); + let _guard = lock.lock().unwrap(); cvar.notify_one(); NO_ERR } @@ -218,6 +218,7 @@ impl AggregateDevice { plugin_id: AudioObjectID, ) -> std::result::Result { assert_ne!(plugin_id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = AudioObjectPropertyAddress { mSelector: kAudioPlugInCreateAggregateDevice, @@ -306,6 +307,7 @@ impl AggregateDevice { input_id: AudioDeviceID, output_id: AudioDeviceID, ) -> std::result::Result<(), Error> { + debug_assert_running_serially(); let address = AudioObjectPropertyAddress { mSelector: kAudioAggregateDevicePropertyFullSubDeviceList, mScope: kAudioObjectPropertyScopeGlobal, @@ -392,6 +394,7 @@ impl AggregateDevice { assert_ne!(input_id, kAudioObjectUnknown); assert_ne!(output_id, kAudioObjectUnknown); assert_ne!(input_id, output_id); + debug_assert_running_serially(); let output_sub_devices = Self::get_sub_devices(output_id)?; let input_sub_devices = Self::get_sub_devices(input_id)?; @@ -431,6 +434,7 @@ impl AggregateDevice { device_id: AudioDeviceID, ) -> std::result::Result, Error> { assert_ne!(device_id, kAudioObjectUnknown); + debug_assert_running_serially(); let mut sub_devices = Vec::new(); let address = AudioObjectPropertyAddress { @@ -468,6 +472,7 @@ impl AggregateDevice { } pub fn get_master_device_uid(device_id: AudioDeviceID) -> std::result::Result { + debug_assert_running_serially(); let address = AudioObjectPropertyAddress { mSelector: kAudioAggregateDevicePropertyMainSubDevice, mScope: kAudioObjectPropertyScopeGlobal, @@ -495,6 +500,7 @@ impl AggregateDevice { ) -> std::result::Result<(), Error> { assert_ne!(device_id, kAudioObjectUnknown); assert_ne!(primary_id, kAudioObjectUnknown); + debug_assert_running_serially(); cubeb_log!( "Set master device of the aggregate device {} to device {}", @@ -526,6 +532,7 @@ impl AggregateDevice { device_id: AudioObjectID, ) -> std::result::Result<(), Error> { assert_ne!(device_id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = AudioObjectPropertyAddress { mSelector: kAudioObjectPropertyOwnedObjects, mScope: kAudioObjectPropertyScopeGlobal, @@ -609,6 +616,7 @@ impl AggregateDevice { ) -> std::result::Result<(), Error> { assert_ne!(plugin_id, kAudioObjectUnknown); assert_ne!(device_id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = AudioObjectPropertyAddress { mSelector: kAudioPlugInDestroyAggregateDevice, @@ -640,6 +648,7 @@ impl AggregateDevice { assert_ne!(input_id, kAudioObjectUnknown); assert_ne!(output_id, kAudioObjectUnknown); assert_ne!(input_id, output_id); + debug_assert_running_serially(); let label = get_device_label(input_id, DeviceType::INPUT)?; let input_label = label.into_string(); diff --git a/third_party/rust/cubeb-coreaudio/src/backend/device_property.rs b/third_party/rust/cubeb-coreaudio/src/backend/device_property.rs index b9a50c6576d9..6a85f22359aa 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/device_property.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/device_property.rs @@ -5,6 +5,7 @@ pub fn get_device_uid( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceUID, devtype); let mut size = mem::size_of::(); @@ -22,6 +23,7 @@ pub fn get_device_model_uid( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::ModelUID, devtype); let mut size = mem::size_of::(); @@ -39,6 +41,7 @@ pub fn get_device_transport_type( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::TransportType, devtype); let mut size = mem::size_of::(); @@ -56,6 +59,7 @@ pub fn get_device_source( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceSource, devtype); let mut size = mem::size_of::(); @@ -73,6 +77,7 @@ pub fn get_device_source_name( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let mut source: u32 = get_device_source(id, devtype)?; let address = get_property_address(Property::DeviceSourceName, devtype); @@ -97,6 +102,7 @@ pub fn get_device_name( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceName, devtype); let mut size = mem::size_of::(); @@ -114,6 +120,7 @@ pub fn get_device_manufacturer( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceManufacturer, devtype); let mut size = mem::size_of::(); @@ -131,6 +138,7 @@ pub fn get_device_buffer_frame_size_range( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceBufferFrameSizeRange, devtype); let mut size = mem::size_of::(); @@ -148,6 +156,7 @@ pub fn get_device_latency( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceLatency, devtype); let mut size = mem::size_of::(); @@ -165,6 +174,7 @@ pub fn get_device_streams( devtype: DeviceType, ) -> std::result::Result, OSStatus> { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceStreams, devtype); @@ -188,6 +198,7 @@ pub fn get_device_sample_rate( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceSampleRate, devtype); let mut size = mem::size_of::(); @@ -205,6 +216,7 @@ pub fn get_ranges_of_device_sample_rate( devtype: DeviceType, ) -> std::result::Result, OSStatus> { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::DeviceSampleRates, devtype); @@ -225,6 +237,7 @@ pub fn get_ranges_of_device_sample_rate( pub fn get_stream_latency(id: AudioStreamID) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address( Property::StreamLatency, @@ -242,6 +255,7 @@ pub fn get_stream_latency(id: AudioStreamID) -> std::result::Result std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address( Property::StreamTerminalType, @@ -261,6 +275,7 @@ pub fn get_stream_virtual_format( id: AudioStreamID, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address( Property::StreamVirtualFormat, @@ -281,6 +296,7 @@ pub fn get_clock_domain( devtype: DeviceType, ) -> std::result::Result { assert_ne!(id, kAudioObjectUnknown); + debug_assert_running_serially(); let address = get_property_address(Property::ClockDomain, devtype); let mut size = mem::size_of::(); diff --git a/third_party/rust/cubeb-coreaudio/src/backend/mod.rs b/third_party/rust/cubeb-coreaudio/src/backend/mod.rs index 855c119b63f1..eda2eb76f8ec 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/mod.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/mod.rs @@ -33,7 +33,7 @@ use self::mixer::*; use self::resampler::*; use self::utils::*; use backend::ringbuf::RingBuffer; -#[cfg(feature = "audio_dump")] +#[cfg(feature = "audio-dump")] use cubeb_backend::ffi::cubeb_audio_dump_stream_t; use cubeb_backend::{ ffi, ChannelLayout, Context, ContextOps, DeviceCollectionRef, DeviceId, DeviceRef, DeviceType, @@ -116,7 +116,7 @@ lazy_static! { }; } -#[cfg(feature = "audio_dump")] +#[cfg(feature = "audio-dump")] fn dump_audio(stream: cubeb_audio_dump_stream_t, audio_samples: *mut c_void, count: u32) { unsafe { let rv = ffi::cubeb_audio_dump_write(stream, audio_samples, count); @@ -569,7 +569,7 @@ extern "C" fn audiounit_input_callback( } else { assert_eq!(status, NO_ERR); - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { dump_audio( stm.core_stream_data.audio_dump_input, @@ -628,15 +628,15 @@ extern "C" fn audiounit_input_callback( 0, ); if outframes < 0 { - stm.stopped.store(true, Ordering::SeqCst); - stm.notify_state_changed(State::Error); - let queue = stm.queue.clone(); - // Use a new thread, through the queue, to avoid deadlock when calling - // AudioOutputUnitStop method from inside render callback - queue.run_async(move || { - stm.core_stream_data.stop_audiounits(); - }); - return handle; + if !stm.stopped.swap(true, Ordering::SeqCst) { + stm.notify_state_changed(State::Error); + // Use a new thread, through the queue, to avoid deadlock when calling + // AudioOutputUnitStop method from inside render callback + stm.queue.clone().run_async(move || { + stm.core_stream_data.stop_audiounits(); + }); + } + return ErrorHandle::Return(status); } if outframes < total_input_frames { stm.draining.store(true, Ordering::SeqCst); @@ -654,15 +654,16 @@ extern "C" fn audiounit_input_callback( // If the input (input-only stream) is drained, cancel this callback. Whenever an output // is involved, the output callback handles stopping all units and notifying of state. - if stm.core_stream_data.output_unit.is_null() && stm.draining.load(Ordering::SeqCst) { - stm.stopped.store(true, Ordering::SeqCst); + if stm.core_stream_data.output_unit.is_null() + && stm.draining.load(Ordering::SeqCst) + && !stm.stopped.swap(true, Ordering::SeqCst) + { cubeb_alog!("({:p}) Input-only drained.", stm as *const AudioUnitStream); stm.notify_state_changed(State::Drained); - let queue = stm.queue.clone(); // Use a new thread, through the queue, to avoid deadlock when calling // AudioOutputUnitStop method from inside render callback let stm_ptr = user_ptr as usize; - queue.run_async(move || { + stm.queue.clone().run_async(move || { let stm = unsafe { &mut *(stm_ptr as *mut AudioUnitStream) }; stm.core_stream_data.stop_audiounits(); }); @@ -735,7 +736,7 @@ extern "C" fn audiounit_output_callback( if stm.stopped.load(Ordering::SeqCst) { cubeb_alog!("({:p}) output stopped.", stm as *const AudioUnitStream); audiounit_make_silent(&buffers[0]); - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { dump_audio( stm.core_stream_data.audio_dump_output, @@ -749,12 +750,8 @@ extern "C" fn audiounit_output_callback( if stm.draining.load(Ordering::SeqCst) { // Cancel all callbacks. For input-only streams, the input callback handles // cancelling itself. - stm.stopped.store(true, Ordering::SeqCst); - cubeb_alog!("({:p}) output drained.", stm as *const AudioUnitStream); - stm.notify_state_changed(State::Drained); - let queue = stm.queue.clone(); audiounit_make_silent(&buffers[0]); - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { dump_audio( stm.core_stream_data.audio_dump_output, @@ -762,11 +759,15 @@ extern "C" fn audiounit_output_callback( output_frames * stm.core_stream_data.output_dev_desc.mChannelsPerFrame, ); } - // Use a new thread, through the queue, to avoid deadlock when calling - // AudioOutputUnitStop method from inside render callback - queue.run_async(move || { - stm.core_stream_data.stop_audiounits(); - }); + if !stm.stopped.swap(true, Ordering::SeqCst) { + cubeb_alog!("({:p}) output drained.", stm as *const AudioUnitStream); + stm.notify_state_changed(State::Drained); + // Use a new thread, through the queue, to avoid deadlock when calling + // AudioOutputUnitStop method from inside render callback + stm.queue.clone().run_async(move || { + stm.core_stream_data.stop_audiounits(); + }); + } return NO_ERR; } @@ -886,12 +887,9 @@ extern "C" fn audiounit_output_callback( ); if outframes < 0 || outframes > i64::from(output_frames) { - stm.stopped.store(true, Ordering::SeqCst); - stm.notify_state_changed(State::Error); - let queue = stm.queue.clone(); audiounit_make_silent(&buffers[0]); - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { dump_audio( stm.core_stream_data.audio_dump_output, @@ -899,11 +897,14 @@ extern "C" fn audiounit_output_callback( output_frames * stm.core_stream_data.output_dev_desc.mChannelsPerFrame, ); } - // Use a new thread, through the queue, to avoid deadlock when calling - // AudioOutputUnitStop method from inside render callback - queue.run_async(move || { - stm.core_stream_data.stop_audiounits(); - }); + if !stm.stopped.swap(true, Ordering::SeqCst) { + stm.notify_state_changed(State::Error); + // Use a new thread, through the queue, to avoid deadlock when calling + // AudioOutputUnitStop method from inside render callback + stm.queue.clone().run_async(move || { + stm.core_stream_data.stop_audiounits(); + }); + } return NO_ERR; } @@ -951,7 +952,7 @@ extern "C" fn audiounit_output_callback( ); } - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { dump_audio( stm.core_stream_data.audio_dump_output, @@ -1001,15 +1002,16 @@ extern "C" fn audiounit_property_listener_callback( // Handle the events if explicit_device_dead { - cubeb_log!("The user-selected input or output device is dead, entering error state"); - stm.stopped.store(true, Ordering::SeqCst); + if !stm.stopped.swap(true, Ordering::SeqCst) { + cubeb_log!("The user-selected input or output device is dead, entering error state"); - // Use a different thread, through the queue, to avoid deadlock when calling - // Get/SetProperties method from inside notify callback - stm.queue.clone().run_async(move || { - stm.core_stream_data.stop_audiounits(); - stm.close_on_error(); - }); + // Use a different thread, through the queue, to avoid deadlock when calling + // Get/SetProperties method from inside notify callback + stm.queue.clone().run_async(move || { + stm.core_stream_data.stop_audiounits(); + stm.close_on_error(); + }); + } return NO_ERR; } { @@ -1026,6 +1028,7 @@ extern "C" fn audiounit_property_listener_callback( } fn get_default_device(devtype: DeviceType) -> Option { + debug_assert_running_serially(); match get_default_device_id(devtype) { Err(e) => { cubeb_log!("Cannot get default {:?} device. Error: {}", devtype, e); @@ -1040,6 +1043,7 @@ fn get_default_device(devtype: DeviceType) -> Option { } fn get_default_device_id(devtype: DeviceType) -> std::result::Result { + debug_assert_running_serially(); let address = get_property_address( match devtype { DeviceType::INPUT => Property::HardwareDefaultInputDevice, @@ -1087,6 +1091,7 @@ fn audiounit_convert_channel_layout(layout: &AudioChannelLayout) -> Result Result> { + debug_assert_running_serially(); let mut rv = NO_ERR; let mut size: usize = 0; rv = audio_unit_get_property_info( @@ -1129,6 +1134,7 @@ fn audiounit_get_preferred_channel_layout(output_unit: AudioUnit) -> Result Result> { + debug_assert_running_serially(); let mut rv = NO_ERR; let mut size: usize = 0; rv = audio_unit_get_property_info( @@ -1169,6 +1175,7 @@ fn audiounit_get_current_channel_layout(output_unit: AudioUnit) -> Result Result> { + debug_assert_running_serially(); audiounit_get_current_channel_layout(output_unit) .or_else(|_| { // The kAudioUnitProperty_AudioChannelLayout property isn't known before @@ -1208,6 +1215,7 @@ fn create_audiounit(device: &device_info) -> Result { assert!(!device .flags .contains(device_flags::DEV_INPUT | device_flags::DEV_OUTPUT)); + debug_assert_running_serially(); let unit = create_blank_audiounit()?; let mut bus = AU_OUT_BUS; @@ -1610,6 +1618,7 @@ fn get_channel_count( devtype: DeviceType, ) -> std::result::Result { assert_ne!(devid, kAudioObjectUnknown); + debug_assert_running_serially(); let mut streams = get_device_streams(devid, devtype)?; let model_uid = @@ -1691,6 +1700,7 @@ fn get_range_of_sample_rates( devid: AudioObjectID, devtype: DeviceType, ) -> std::result::Result<(f64, f64), String> { + debug_assert_running_serially(); let result = get_ranges_of_device_sample_rate(devid, devtype); if let Err(e) = result { return Err(format!("status {}", e)); @@ -1712,6 +1722,7 @@ fn get_range_of_sample_rates( } fn get_fixed_latency(devid: AudioObjectID, devtype: DeviceType) -> u32 { + debug_assert_running_serially(); let device_latency = match get_device_latency(devid, devtype) { Ok(latency) => latency, Err(e) => { @@ -1754,6 +1765,7 @@ fn get_device_group_id( id: AudioDeviceID, devtype: DeviceType, ) -> std::result::Result { + debug_assert_running_serially(); match get_device_transport_type(id, devtype) { Ok(kAudioDeviceTransportTypeBuiltIn) => { cubeb_log!( @@ -1789,6 +1801,8 @@ fn get_device_group_id( } fn get_custom_group_id(id: AudioDeviceID, devtype: DeviceType) -> Option { + debug_assert_running_serially(); + const IMIC: u32 = 0x696D_6963; // "imic" (internal microphone) const ISPK: u32 = 0x6973_706B; // "ispk" (internal speaker) const EMIC: u32 = 0x656D_6963; // "emic" (external microphone) @@ -1830,10 +1844,12 @@ fn get_device_label( id: AudioDeviceID, devtype: DeviceType, ) -> std::result::Result { + debug_assert_running_serially(); get_device_source_name(id, devtype).or_else(|_| get_device_name(id, devtype)) } fn get_device_global_uid(id: AudioDeviceID) -> std::result::Result { + debug_assert_running_serially(); get_device_uid(id, DeviceType::INPUT | DeviceType::OUTPUT) } @@ -2016,6 +2032,7 @@ fn destroy_cubeb_device_info(device: &mut ffi::cubeb_device_info) { } fn audiounit_get_devices() -> Vec { + debug_assert_running_serially(); let mut size: usize = 0; let address = get_property_address( Property::HardwareDevices, @@ -2042,6 +2059,7 @@ fn audiounit_get_devices() -> Vec { fn audiounit_get_devices_of_type(devtype: DeviceType) -> Vec { assert!(devtype.intersects(DeviceType::INPUT | DeviceType::OUTPUT)); + debug_assert_running_serially(); let mut devices = audiounit_get_devices(); @@ -2708,17 +2726,21 @@ impl ContextOps for AudioUnitContext { } #[cfg(not(target_os = "ios"))] fn max_channel_count(&mut self) -> Result { - let device = match get_default_device(DeviceType::OUTPUT) { - None => { - cubeb_log!("Could not get default output device"); - return Err(Error::error()); - } - Some(id) => id, - }; - get_channel_count(device, DeviceType::OUTPUT).map_err(|e| { - cubeb_log!("Cannot get the channel count. Error: {}", e); - Error::error() - }) + self.serial_queue + .run_sync(|| { + let device = match get_default_device(DeviceType::OUTPUT) { + None => { + cubeb_log!("Could not get default output device"); + return Err(Error::error()); + } + Some(id) => id, + }; + get_channel_count(device, DeviceType::OUTPUT).map_err(|e| { + cubeb_log!("Cannot get the channel count. Error: {}", e); + Error::error() + }) + }) + .unwrap() } #[cfg(target_os = "ios")] fn min_latency(&mut self, _params: StreamParams) -> Result { @@ -2726,21 +2748,25 @@ impl ContextOps for AudioUnitContext { } #[cfg(not(target_os = "ios"))] fn min_latency(&mut self, _params: StreamParams) -> Result { - let device = match get_default_device(DeviceType::OUTPUT) { - None => { - cubeb_log!("Could not get default output device"); - return Err(Error::error()); - } - Some(id) => id, - }; + self.serial_queue + .run_sync(|| { + let device = match get_default_device(DeviceType::OUTPUT) { + None => { + cubeb_log!("Could not get default output device"); + return Err(Error::error()); + } + Some(id) => id, + }; - let range = - get_device_buffer_frame_size_range(device, DeviceType::OUTPUT).map_err(|e| { - cubeb_log!("Could not get acceptable latency range. Error: {}", e); - Error::error() - })?; + let range = get_device_buffer_frame_size_range(device, DeviceType::OUTPUT) + .map_err(|e| { + cubeb_log!("Could not get acceptable latency range. Error: {}", e); + Error::error() + })?; - Ok(cmp::max(range.mMinimum as u32, SAFE_MIN_LATENCY_FRAMES)) + Ok(cmp::max(range.mMinimum as u32, SAFE_MIN_LATENCY_FRAMES)) + }) + .unwrap() } #[cfg(target_os = "ios")] fn preferred_sample_rate(&mut self) -> Result { @@ -2748,21 +2774,25 @@ impl ContextOps for AudioUnitContext { } #[cfg(not(target_os = "ios"))] fn preferred_sample_rate(&mut self) -> Result { - let device = match get_default_device(DeviceType::OUTPUT) { - None => { - cubeb_log!("Could not get default output device"); - return Err(Error::error()); - } - Some(id) => id, - }; - let rate = get_device_sample_rate(device, DeviceType::OUTPUT).map_err(|e| { - cubeb_log!( - "Cannot get the sample rate of the default output device. Error: {}", - e - ); - Error::error() - })?; - Ok(rate as u32) + self.serial_queue + .run_sync(|| { + let device = match get_default_device(DeviceType::OUTPUT) { + None => { + cubeb_log!("Could not get default output device"); + return Err(Error::error()); + } + Some(id) => id, + }; + let rate = get_device_sample_rate(device, DeviceType::OUTPUT).map_err(|e| { + cubeb_log!( + "Cannot get the sample rate of the default output device. Error: {}", + e + ); + Error::error() + })?; + Ok(rate as u32) + }) + .unwrap() } fn supported_input_processing_params(&mut self) -> Result { Ok(InputProcessingParams::ECHO_CANCELLATION @@ -2774,19 +2804,27 @@ impl ContextOps for AudioUnitContext { devtype: DeviceType, collection: &DeviceCollectionRef, ) -> Result<()> { - let mut device_infos = Vec::new(); - let dev_types = [DeviceType::INPUT, DeviceType::OUTPUT]; - for dev_type in dev_types.iter() { - if !devtype.contains(*dev_type) { - continue; - } - let devices = audiounit_get_devices_of_type(*dev_type); - for device in devices { - if let Ok(info) = create_cubeb_device_info(device, *dev_type) { - device_infos.push(info); + let device_infos = self + .serial_queue + .run_sync(|| { + let mut dev_types = vec![DeviceType::INPUT, DeviceType::OUTPUT]; + dev_types.retain(|&dt| devtype.contains(dt)); + let device_ids: Vec<(DeviceType, Vec)> = dev_types + .iter() + .map(|&dt| (dt, audiounit_get_devices_of_type(dt))) + .collect(); + let count = device_ids.iter().map(|(_dt, ids)| ids.len()).sum(); + let mut device_infos = Vec::with_capacity(count); + for (dt, dev_ids) in device_ids { + for dev_id in dev_ids { + if let Ok(info) = create_cubeb_device_info(dev_id, dt) { + device_infos.push(info); + } + } } - } - } + device_infos + }) + .unwrap(); let (ptr, len) = if device_infos.is_empty() { (ptr::null_mut(), 0) } else { @@ -3071,13 +3109,13 @@ struct CoreStreamData<'ctx> { output_alive_listener: Option, output_source_listener: Option, input_logging: Option, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_session: ffi::cubeb_audio_dump_session_t, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_session_running: bool, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_input: ffi::cubeb_audio_dump_stream_t, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_output: ffi::cubeb_audio_dump_stream_t, } @@ -3119,13 +3157,13 @@ impl<'ctx> Default for CoreStreamData<'ctx> { output_alive_listener: None, output_source_listener: None, input_logging: None, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_session: ptr::null_mut(), - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_session_running: false, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_input: ptr::null_mut(), - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_output: ptr::null_mut(), } } @@ -3174,13 +3212,13 @@ impl<'ctx> CoreStreamData<'ctx> { output_alive_listener: None, output_source_listener: None, input_logging: None, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_session: ptr::null_mut(), - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_session_running: false, - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_input: ptr::null_mut(), - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] audio_dump_output: ptr::null_mut(), } } @@ -3539,7 +3577,7 @@ impl<'ctx> CoreStreamData<'ctx> { assert!(!self.stm_ptr.is_null()); let stream = unsafe { &(*self.stm_ptr) }; - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] unsafe { ffi::cubeb_audio_dump_init(&mut self.audio_dump_session); } @@ -3584,7 +3622,7 @@ impl<'ctx> CoreStreamData<'ctx> { let r = audio_unit_get_property( self.input_unit, kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, + kAudioUnitScope_Output, AU_IN_BUS, &mut input_hw_desc, &mut size, @@ -3601,9 +3639,6 @@ impl<'ctx> CoreStreamData<'ctx> { self.stm_ptr, input_hw_desc ); - // In some cases with VPIO the stream format's mChannelsPerFrame is higher than - // expected. Use get_channel_count as source of truth. - input_hw_desc.mChannelsPerFrame = device_channel_count; // Notice: when we are using aggregate device, the input_hw_desc.mChannelsPerFrame is // the total of all the input channel count of the devices added in the aggregate device. // Due to our aggregate device settings, the data captured by the output device's input @@ -3613,12 +3648,7 @@ impl<'ctx> CoreStreamData<'ctx> { // channels to the audio callback. let params = unsafe { let mut p = *self.input_stream_params.as_ptr(); - p.channels = if using_voice_processing_unit { - // VPIO is always MONO. - 1 - } else { - input_hw_desc.mChannelsPerFrame - }; + p.channels = input_hw_desc.mChannelsPerFrame; // Input AudioUnit must be configured with device's sample rate. // we will resample inside input callback. p.rate = input_hw_desc.mSampleRate as _; @@ -3633,7 +3663,7 @@ impl<'ctx> CoreStreamData<'ctx> { e })?; - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { let name = format!("input-{:p}.wav", self.stm_ptr); let cname = CString::new(name).expect("OK"); @@ -3789,7 +3819,7 @@ impl<'ctx> CoreStreamData<'ctx> { let r = audio_unit_get_property( self.output_unit, kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, + kAudioUnitScope_Input, AU_OUT_BUS, &mut output_hw_desc, &mut size, @@ -3807,11 +3837,6 @@ impl<'ctx> CoreStreamData<'ctx> { output_hw_desc ); - // In some cases with (other streams using) VPIO the stream format's mChannelsPerFrame - // is higher than expected. Use get_channel_count as source of truth. - output_hw_desc.mChannelsPerFrame = - get_channel_count(self.output_device.id, DeviceType::OUTPUT).unwrap_or(0); - // This has been observed in the wild. if output_hw_desc.mChannelsPerFrame == 0 { cubeb_log!( @@ -3827,12 +3852,7 @@ impl<'ctx> CoreStreamData<'ctx> { // channels will be appended at the end of the raw data given by the output callback. let params = unsafe { let mut p = *self.output_stream_params.as_ptr(); - p.channels = if using_voice_processing_unit { - // VPIO is always MONO. - 1 - } else { - output_hw_desc.mChannelsPerFrame - }; + p.channels = output_hw_desc.mChannelsPerFrame; if using_voice_processing_unit { // VPIO will always use the sample rate of the input hw for both input and output, // as reported to us. (We can override it but we cannot improve quality this way). @@ -3849,7 +3869,7 @@ impl<'ctx> CoreStreamData<'ctx> { e })?; - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { let name = format!("output-{:p}.wav", self.stm_ptr); let cname = CString::new(name).expect("OK"); @@ -4038,7 +4058,7 @@ impl<'ctx> CoreStreamData<'ctx> { self.input_logging = Some(InputCallbackLogger::new()); } - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { unsafe { ffi::cubeb_audio_dump_start(self.audio_dump_session) }; self.audio_dump_session_running = true; @@ -4217,7 +4237,7 @@ impl<'ctx> CoreStreamData<'ctx> { // Return the VPIO unit if present. self.voiceprocessing_unit_handle = None; - #[cfg(feature = "audio_dump")] + #[cfg(feature = "audio-dump")] { if !self.audio_dump_session.is_null() { unsafe { @@ -4682,6 +4702,11 @@ impl<'ctx> AudioUnitStream<'ctx> { self.core_stream_data.stop_audiounits(); } + if self.stopped.load(Ordering::SeqCst) { + // Something stopped the stream, we must not reinit. + return Ok(()); + } + debug_assert!( !self.core_stream_data.input_unit.is_null() || !self.core_stream_data.output_unit.is_null() @@ -4840,9 +4865,8 @@ impl<'ctx> AudioUnitStream<'ctx> { // which locks a mutex inside CoreAudio framework, then this call will block the current // thread until the callback is finished since this call asks to lock a mutex inside // CoreAudio framework that is used by the data callback. - if !self.stopped.load(Ordering::SeqCst) { + if !self.stopped.swap(true, Ordering::SeqCst) { self.core_stream_data.stop_audiounits(); - self.stopped.store(true, Ordering::SeqCst); } self.destroy_internal(); @@ -4886,18 +4910,18 @@ impl<'ctx> StreamOps for AudioUnitStream<'ctx> { Ok(()) } fn stop(&mut self) -> Result<()> { - self.stopped.store(true, Ordering::SeqCst); + if !self.stopped.swap(true, Ordering::SeqCst) { + // Execute stop in serial queue to avoid racing with destroy or reinit. + self.queue + .run_sync(|| self.core_stream_data.stop_audiounits()); - // Execute stop in serial queue to avoid racing with destroy or reinit. - self.queue - .run_sync(|| self.core_stream_data.stop_audiounits()); + self.notify_state_changed(State::Stopped); - self.notify_state_changed(State::Stopped); - - cubeb_log!( - "Cubeb stream ({:p}) stopped successfully.", - self as *const AudioUnitStream - ); + cubeb_log!( + "Cubeb stream ({:p}) stopped successfully.", + self as *const AudioUnitStream + ); + } Ok(()) } fn position(&mut self) -> Result { diff --git a/third_party/rust/cubeb-coreaudio/src/backend/tests/aggregate_device.rs b/third_party/rust/cubeb-coreaudio/src/backend/tests/aggregate_device.rs index 6c5e4940591d..c846cadb4b6a 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/tests/aggregate_device.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/tests/aggregate_device.rs @@ -352,7 +352,7 @@ fn test_aggregate_activate_clock_drift_compensation() { assert_eq!(devices.len(), compensations.len()); for (device, compensation) in zip(devices, compensations) { - let uid = get_device_uid(device); + let uid = run_serially(|| get_device_uid(device)); assert_eq!( compensation, if uid == master_device_uid { diff --git a/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs b/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs index ea08a5ef4593..3ef3930dbd14 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs @@ -1123,7 +1123,11 @@ fn test_get_channel_count_of_unknwon_type() { fn test_channel_count(scope: Scope) { if let Some(device) = test_get_default_device(scope.clone()) { - assert!(get_channel_count(device, DeviceType::UNKNOWN).is_err()); + assert!(run_serially_forward_panics(|| get_channel_count( + device, + DeviceType::UNKNOWN + ) + .is_err())); } else { panic!("Panic by default: No device for {:?}.", scope); } @@ -1181,7 +1185,8 @@ fn test_get_device_presentation_latency() { fn test_get_device_presentation_latencies_in_scope(scope: Scope) { if let Some(device) = test_get_default_device(scope.clone()) { // TODO: The latencies very from devices to devices. Check nothing here. - let latency = run_serially(|| get_fixed_latency(device, scope.clone().into())); + let latency = + run_serially_forward_panics(|| get_fixed_latency(device, scope.clone().into())); println!( "present latency on the device {} in scope {:?}: {}", device, scope, latency @@ -1197,7 +1202,7 @@ fn test_get_device_presentation_latency() { #[test] fn test_get_device_group_id() { if let Some(device) = test_get_default_device(Scope::Input) { - match run_serially(|| get_device_group_id(device, DeviceType::INPUT)) { + match run_serially_forward_panics(|| get_device_group_id(device, DeviceType::INPUT)) { Ok(id) => println!("input group id: {:?}", id), Err(e) => println!("No input group id. Error: {}", e), } @@ -1206,7 +1211,7 @@ fn test_get_device_group_id() { } if let Some(device) = test_get_default_device(Scope::Output) { - match run_serially(|| get_device_group_id(device, DeviceType::OUTPUT)) { + match run_serially_forward_panics(|| get_device_group_id(device, DeviceType::OUTPUT)) { Ok(id) => println!("output group id: {:?}", id), Err(e) => println!("No output group id. Error: {}", e), } @@ -1229,8 +1234,10 @@ fn test_get_same_group_id_for_builtin_device_pairs() { let mut input_group_ids = HashMap::::new(); let input_devices = test_get_devices_in_scope(Scope::Input); for device in input_devices.iter() { - match run_serially(|| get_device_source(*device, DeviceType::INPUT)) { - Ok(source) => match run_serially(|| get_device_group_id(*device, DeviceType::INPUT)) { + match run_serially_forward_panics(|| get_device_source(*device, DeviceType::INPUT)) { + Ok(source) => match run_serially_forward_panics(|| { + get_device_group_id(*device, DeviceType::INPUT) + }) { Ok(id) => assert!(input_group_ids .insert(source, id.into_string().unwrap()) .is_none()), @@ -1245,8 +1252,10 @@ fn test_get_same_group_id_for_builtin_device_pairs() { let mut output_group_ids = HashMap::::new(); let output_devices = test_get_devices_in_scope(Scope::Output); for device in output_devices.iter() { - match run_serially(|| get_device_source(*device, DeviceType::OUTPUT)) { - Ok(source) => match run_serially(|| get_device_group_id(*device, DeviceType::OUTPUT)) { + match run_serially_forward_panics(|| get_device_source(*device, DeviceType::OUTPUT)) { + Ok(source) => match run_serially_forward_panics(|| { + get_device_group_id(*device, DeviceType::OUTPUT) + }) { Ok(id) => assert!(output_group_ids .insert(source, id.into_string().unwrap()) .is_none()), @@ -1286,14 +1295,16 @@ fn test_get_device_group_id_by_unknown_device() { #[test] fn test_get_device_label() { if let Some(device) = test_get_default_device(Scope::Input) { - let name = run_serially(|| get_device_label(device, DeviceType::INPUT)).unwrap(); + let name = + run_serially_forward_panics(|| get_device_label(device, DeviceType::INPUT)).unwrap(); println!("input device label: {}", name.into_string()); } else { println!("No input device."); } if let Some(device) = test_get_default_device(Scope::Output) { - let name = run_serially(|| get_device_label(device, DeviceType::OUTPUT)).unwrap(); + let name = + run_serially_forward_panics(|| get_device_label(device, DeviceType::OUTPUT)).unwrap(); println!("output device label: {}", name.into_string()); } else { println!("No output device."); @@ -1316,14 +1327,14 @@ fn test_get_device_label_by_unknown_device() { fn test_get_device_global_uid() { // Input device. if let Some(input) = test_get_default_device(Scope::Input) { - let uid = run_serially(|| get_device_global_uid(input)).unwrap(); + let uid = run_serially_forward_panics(|| get_device_global_uid(input)).unwrap(); let uid = uid.into_string(); assert!(!uid.is_empty()); } // Output device. if let Some(output) = test_get_default_device(Scope::Output) { - let uid = run_serially(|| get_device_global_uid(output)).unwrap(); + let uid = run_serially_forward_panics(|| get_device_global_uid(output)).unwrap(); let uid = uid.into_string(); assert!(!uid.is_empty()); } @@ -1333,7 +1344,7 @@ fn test_get_device_global_uid() { #[should_panic] fn test_get_device_global_uid_by_unknwon_device() { // Unknown device. - assert!(get_device_global_uid(kAudioObjectUnknown).is_err()); + assert!(run_serially_forward_panics(|| get_device_global_uid(kAudioObjectUnknown)).is_err()); } // create_cubeb_device_info @@ -1381,7 +1392,9 @@ fn test_create_cubeb_device_info() { let dev_types = [DeviceType::INPUT, DeviceType::OUTPUT]; let mut results = VecDeque::new(); for dev_type in dev_types.iter() { - results.push_back(run_serially(|| create_cubeb_device_info(id, *dev_type))); + results.push_back(run_serially_forward_panics(|| { + create_cubeb_device_info(id, *dev_type) + })); } results } @@ -1441,9 +1454,11 @@ fn test_create_device_info_with_unknown_type() { fn test_create_device_info_with_unknown_type_by_scope(scope: Scope) { if let Some(device) = test_get_default_device(scope.clone()) { - assert!( - run_serially(|| create_cubeb_device_info(device, DeviceType::UNKNOWN)).is_err() - ); + assert!(run_serially_forward_panics(|| create_cubeb_device_info( + device, + DeviceType::UNKNOWN + )) + .is_err()); } } } @@ -1475,7 +1490,7 @@ fn test_create_device_from_hwdev_with_inout_type() { fn test_create_device_from_hwdev_with_inout_type_by_scope(scope: Scope) { if let Some(device) = test_get_default_device(scope.clone()) { // Get a kAudioHardwareUnknownPropertyError in get_channel_count actually. - assert!(run_serially(|| create_cubeb_device_info( + assert!(run_serially_forward_panics(|| create_cubeb_device_info( device, DeviceType::INPUT | DeviceType::OUTPUT )) @@ -1492,10 +1507,13 @@ fn test_create_device_from_hwdev_with_inout_type() { fn test_get_devices_of_type() { use std::collections::HashSet; - let all_devices = - run_serially(|| audiounit_get_devices_of_type(DeviceType::INPUT | DeviceType::OUTPUT)); - let input_devices = run_serially(|| audiounit_get_devices_of_type(DeviceType::INPUT)); - let output_devices = run_serially(|| audiounit_get_devices_of_type(DeviceType::OUTPUT)); + let all_devices = run_serially_forward_panics(|| { + audiounit_get_devices_of_type(DeviceType::INPUT | DeviceType::OUTPUT) + }); + let input_devices = + run_serially_forward_panics(|| audiounit_get_devices_of_type(DeviceType::INPUT)); + let output_devices = + run_serially_forward_panics(|| audiounit_get_devices_of_type(DeviceType::OUTPUT)); let mut expected_all = test_get_all_devices(DeviceFilter::ExcludeCubebAggregateAndVPIO); expected_all.sort(); diff --git a/third_party/rust/cubeb-coreaudio/src/backend/tests/interfaces.rs b/third_party/rust/cubeb-coreaudio/src/backend/tests/interfaces.rs index aa15b7428bf0..c3f4a388cd19 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/tests/interfaces.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/tests/interfaces.rs @@ -2,9 +2,9 @@ extern crate itertools; use self::itertools::iproduct; use super::utils::{ - draining_data_callback, get_devices_info_in_scope, noop_data_callback, + draining_data_callback, get_devices_info_in_scope, noop_data_callback, state_tracking_cb, test_device_channels_in_scope, test_get_default_device, test_ops_context_operation, - test_ops_stream_operation, test_ops_stream_operation_on_context, Scope, + test_ops_stream_operation, test_ops_stream_operation_on_context, Scope, StateCallbackData, }; use super::*; use std::thread; @@ -1177,6 +1177,77 @@ fn test_ops_stream_device_destroy() { }); } +pub extern "C" fn reiniting_and_erroring_data_callback( + stream: *mut ffi::cubeb_stream, + _user_ptr: *mut c_void, + _input_buffer: *const c_void, + output_buffer: *mut c_void, + nframes: i64, +) -> i64 { + assert!(!stream.is_null()); + + let stm = unsafe { &mut *(stream as *mut AudioUnitStream) }; + + // Feed silence data to output buffer + if !output_buffer.is_null() { + let channels = stm.core_stream_data.output_stream_params.channels(); + let samples = nframes as usize * channels as usize; + let sample_size = cubeb_sample_size(stm.core_stream_data.output_stream_params.format()); + unsafe { + ptr::write_bytes(output_buffer, 0, samples * sample_size); + } + } + + // Trigger an async reinit before the backend handles the error below. + // This scenario could happen in the backend's internal input callback. + stm.reinit_async(); + + ffi::CUBEB_ERROR.into() +} + +#[test] +fn test_ops_stream_racy_reinit() { + // Make sure the parameters meet the requirements of AudioUnitContext::stream_init + // (in the comments). + let mut input_params = ffi::cubeb_stream_params::default(); + input_params.format = ffi::CUBEB_SAMPLE_FLOAT32NE; + input_params.rate = 48000; + input_params.channels = 1; + input_params.layout = ffi::CUBEB_LAYOUT_UNDEFINED; + input_params.prefs = ffi::CUBEB_STREAM_PREF_NONE; + + let mut output_params = ffi::cubeb_stream_params::default(); + output_params.format = ffi::CUBEB_SAMPLE_FLOAT32NE; + output_params.rate = 44100; + output_params.channels = 2; + output_params.layout = ffi::CUBEB_LAYOUT_UNDEFINED; + output_params.prefs = ffi::CUBEB_STREAM_PREF_NONE; + + let mut data = StateCallbackData::default(); + test_ops_stream_operation( + "stream: racy reinit", + ptr::null_mut(), // Use default input device. + &mut input_params, + ptr::null_mut(), // Use default output device. + &mut output_params, + 4096, // TODO: Get latency by get_min_latency instead ? + Some(reiniting_and_erroring_data_callback), + Some(state_tracking_cb), + &mut data as *mut StateCallbackData as *mut c_void, + |stream| { + assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK); + while data.error_cnt() == 0 && data.stopped_cnt() == 0 { + thread::sleep(Duration::from_millis(1)); + } + assert_eq!(unsafe { OPS.stream_stop.unwrap()(stream) }, ffi::CUBEB_OK); + }, + ); + assert_eq!(data.started_cnt(), 1); + assert_eq!(data.stopped_cnt(), 0); + assert_eq!(data.drained_cnt(), 0); + assert_eq!(data.error_cnt(), 1); +} + #[test] fn test_ops_stream_register_device_changed_callback() { extern "C" fn callback(_: *mut c_void) {} diff --git a/third_party/rust/cubeb-coreaudio/src/backend/tests/manual.rs b/third_party/rust/cubeb-coreaudio/src/backend/tests/manual.rs index 3bf96c65c631..24df0addb534 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/tests/manual.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/tests/manual.rs @@ -441,7 +441,7 @@ fn test_stream_tester() { return; } let mut params = InputProcessingParams::NONE; - { + run_serially(|| { let mut bypass = u32::from(true); let mut size: usize = mem::size_of::(); assert_eq!( @@ -477,7 +477,7 @@ fn test_stream_tester() { if agc == 1 { params.set(InputProcessingParams::AUTOMATIC_GAIN_CONTROL, true); } - } + }); let mut done = false; while !done { println!( diff --git a/third_party/rust/cubeb-coreaudio/src/backend/tests/utils.rs b/third_party/rust/cubeb-coreaudio/src/backend/tests/utils.rs index 6fb6d38fb315..e14c5851958d 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/tests/utils.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/tests/utils.rs @@ -48,6 +48,56 @@ pub extern "C" fn draining_data_callback( nframes - 1 } +#[derive(Default)] +pub struct StateCallbackData { + started_cnt: AtomicU32, + stopped_cnt: AtomicU32, + drained_cnt: AtomicU32, + error_cnt: AtomicU32, +} + +impl StateCallbackData { + pub fn started_cnt(&self) -> u32 { + self.started_cnt.load(Ordering::SeqCst) + } + pub fn stopped_cnt(&self) -> u32 { + self.stopped_cnt.load(Ordering::SeqCst) + } + pub fn drained_cnt(&self) -> u32 { + self.drained_cnt.load(Ordering::SeqCst) + } + pub fn error_cnt(&self) -> u32 { + self.error_cnt.load(Ordering::SeqCst) + } +} + +pub extern "C" fn state_tracking_cb( + stream: *mut ffi::cubeb_stream, + _usr_ptr: *mut c_void, + state: u32, +) { + let data = unsafe { (_usr_ptr as *mut StateCallbackData).as_mut() }.unwrap(); + match state { + ffi::CUBEB_STATE_STARTED => { + data.started_cnt.fetch_add(1, Ordering::SeqCst); + cubeb_log!("({:p}) state is now started", stream); + } + ffi::CUBEB_STATE_STOPPED => { + data.stopped_cnt.fetch_add(1, Ordering::SeqCst); + cubeb_log!("({:p}) state is now stopped", stream); + } + ffi::CUBEB_STATE_DRAINED => { + data.drained_cnt.fetch_add(1, Ordering::SeqCst); + cubeb_log!("({:p}) state is now drained", stream); + } + ffi::CUBEB_STATE_ERROR => { + data.error_cnt.fetch_add(1, Ordering::SeqCst); + cubeb_log!("({:p}) state is now error", stream); + } + _ => unreachable!("unknown state"), + }; +} + #[derive(Clone, Debug, PartialEq)] pub enum Scope { Input, @@ -357,14 +407,14 @@ impl TestDeviceInfo { } fn get_label(id: AudioObjectID, scope: Scope) -> String { - match get_device_uid(id, scope.into()) { + match run_serially_forward_panics(|| get_device_uid(id, scope.into())) { Ok(uid) => uid.into_string(), Err(status) => format!("Unknow. Error: {}", status).to_string(), } } fn get_uid(id: AudioObjectID, scope: Scope) -> String { - match get_device_label(id, scope.into()) { + match run_serially_forward_panics(|| get_device_label(id, scope.into())) { Ok(label) => label.into_string(), Err(status) => format!("Unknown. Error: {}", status).to_string(), } diff --git a/third_party/rust/cubeb-pulse/.cargo-checksum.json b/third_party/rust/cubeb-pulse/.cargo-checksum.json index d33abb439310..769b8c77afbc 100644 --- a/third_party/rust/cubeb-pulse/.cargo-checksum.json +++ b/third_party/rust/cubeb-pulse/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".github/workflows/build.yml":"477366d58c9dc059dbe4a158a6e910f23a3e9ecac7411f73616e06375583b764","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"4bdd3962429c676eda59de96cad567478bb20b01c785c9ce3ba03b2e7837dd67","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"0079450bb4b013bac065ed1750851e461a3710ebad1f323817da1cb82db0bc4f","src/backend/context.rs":"51dbf887e78aed5cd5e2255ac98f50c287960d8949ea3f66f2b05214b76800d8","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"11ca424e4eb77f8eb9fd5a6717d1e791facf9743156a8534f0016fcf64d57b0f","src/backend/mod.rs":"dfb30ec497d6215e4535e936fea8fe3a407ef24dc1cec43b52c0ffa923d9229c","src/backend/stream.rs":"b3dcaa382981cbaa3af3c445b0ed6b5012b61d420d2e52a5ebd3cb0dd09a917c","src/capi.rs":"fa0fa020f0d0efe55aa0fc3596405e8407bbe2cbe6c7a558345304e6da87994e","src/lib.rs":"b41bbdc562cbfb130ed7c1e53fe69944774f515705341d8ce48a2f82c8c0c2c5"},"package":null} \ No newline at end of file +{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".github/workflows/build.yml":"477366d58c9dc059dbe4a158a6e910f23a3e9ecac7411f73616e06375583b764","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"8a0a450ae4990e1df322464867212e48587b474dfdc7f8c270fac06980be176a","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"0079450bb4b013bac065ed1750851e461a3710ebad1f323817da1cb82db0bc4f","src/backend/context.rs":"c0db5f2447de1d6df5aa2812fa342a085e73156a072c221c7379b9a6a9b86786","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"11ca424e4eb77f8eb9fd5a6717d1e791facf9743156a8534f0016fcf64d57b0f","src/backend/mod.rs":"dfb30ec497d6215e4535e936fea8fe3a407ef24dc1cec43b52c0ffa923d9229c","src/backend/stream.rs":"dfe5b747e100cae4aeae36cf2ebb9dc4715b411b4116721a40eec2944eb0ec23","src/capi.rs":"fa0fa020f0d0efe55aa0fc3596405e8407bbe2cbe6c7a558345304e6da87994e","src/lib.rs":"b41bbdc562cbfb130ed7c1e53fe69944774f515705341d8ce48a2f82c8c0c2c5"},"package":null} \ No newline at end of file diff --git a/third_party/rust/cubeb-pulse/Cargo.toml b/third_party/rust/cubeb-pulse/Cargo.toml index c8be5b482ca5..eec888a5f50b 100644 --- a/third_party/rust/cubeb-pulse/Cargo.toml +++ b/third_party/rust/cubeb-pulse/Cargo.toml @@ -24,7 +24,7 @@ crate-type = [ ] [dependencies] -cubeb-backend = "0.12.0" +cubeb-backend = "0.13" ringbuf = "0.2" semver = "1.0" diff --git a/third_party/rust/cubeb-pulse/src/backend/context.rs b/third_party/rust/cubeb-pulse/src/backend/context.rs index 556b7a6a9027..52bd7a5efe60 100644 --- a/third_party/rust/cubeb-pulse/src/backend/context.rs +++ b/third_party/rust/cubeb-pulse/src/backend/context.rs @@ -515,7 +515,7 @@ impl ContextOps for PulseContext { Ok(()) } - #[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] + #[allow(clippy::too_many_arguments)] fn stream_init( &mut self, stream_name: Option<&CStr>, diff --git a/third_party/rust/cubeb-pulse/src/backend/stream.rs b/third_party/rust/cubeb-pulse/src/backend/stream.rs index 8e87110907d5..a1740eba6363 100644 --- a/third_party/rust/cubeb-pulse/src/backend/stream.rs +++ b/third_party/rust/cubeb-pulse/src/backend/stream.rs @@ -283,7 +283,7 @@ pub struct PulseStream<'ctx> { } impl<'ctx> PulseStream<'ctx> { - #[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] + #[allow(clippy::too_many_arguments)] pub fn new( context: &'ctx PulseContext, stream_name: Option<&CStr>, @@ -447,9 +447,9 @@ impl<'ctx> PulseStream<'ctx> { latency_frames * stm.output_sample_spec.frame_size() as u32; let battr = pa_buffer_attr { - maxlength: u32::max_value(), - prebuf: u32::max_value(), - fragsize: u32::max_value(), + maxlength: u32::MAX, + prebuf: u32::MAX, + fragsize: u32::MAX, tlength: buffer_size_bytes * 2, minreq: buffer_size_bytes / 4, }; @@ -490,8 +490,8 @@ impl<'ctx> PulseStream<'ctx> { let buffer_size_bytes = latency_frames * stm.input_sample_spec.frame_size() as u32; let battr = pa_buffer_attr { - maxlength: u32::max_value(), - prebuf: u32::max_value(), + maxlength: u32::MAX, + prebuf: u32::MAX, fragsize: buffer_size_bytes, tlength: buffer_size_bytes, minreq: buffer_size_bytes, @@ -1033,7 +1033,7 @@ impl<'ctx> PulseStream<'ctx> { true } - #[cfg_attr(feature = "cargo-clippy", allow(clippy::cognitive_complexity))] + #[allow(clippy::cognitive_complexity)] fn trigger_user_callback(&mut self, input_data: *const c_void, nbytes: usize) { fn drained_cb( a: &pulse::MainloopApi, @@ -1074,7 +1074,7 @@ impl<'ctx> PulseStream<'ctx> { read_offset ); let read_ptr = unsafe { (input_data as *const u8).add(read_offset) }; - #[cfg_attr(feature = "cargo-clippy", allow(clippy::unnecessary_cast))] + #[allow(clippy::unnecessary_cast)] let mut got = unsafe { self.data_callback.unwrap()( self as *const _ as *mut _, diff --git a/third_party/rust/cubeb-sys/.cargo-checksum.json b/third_party/rust/cubeb-sys/.cargo-checksum.json index 4beef82df80e..f49bd0249d2f 100644 --- a/third_party/rust/cubeb-sys/.cargo-checksum.json +++ b/third_party/rust/cubeb-sys/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"2c8c46a775578cfb496f14a40131753dcda6228a6692257886ca0092f6b1ed5d","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","build.rs":"4572cbb7b2bb0ac41330dc1535dbc6685d38ea4f485029ee932639e2feb94d7b","libcubeb/AUTHORS":"829e45d138c7c8827799f302806fa4be8cd8bd4bad70a2fe26c3a27a5cf36948","libcubeb/CMakeLists.txt":"7b1a53117f2520471ef4293f9b8107e04f7d60021580418e8d4255c69d481dda","libcubeb/Config.cmake.in":"a156fb5cd30208aedcb9ef025d94187df82142fd4442e3a7d0e2a688668a3da9","libcubeb/INSTALL.md":"1fa77e15423e6f583c30861528cd2732d52a028982020cd3a7a9da4a452d7311","libcubeb/LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","libcubeb/README.md":"9b01cda3464a448373176c07368d1ce4a2b4f87ec9f8f02cbac0b4a40719c141","libcubeb/cmake/compile_tests/oss_is_v4.c":"482bcd4c569e8a26f4ab0fe3a3bed25e9d4b296bf678896a2cc1dc8abbad492d","libcubeb/cmake/sanitizers-cmake/CMakeLists.txt":"89b282c19b3897ff666f7847d5e679ae928ca7e76ffd0d23f7c58c9464048b61","libcubeb/cmake/sanitizers-cmake/LICENSE":"4b67e7ae8c91e68e1a929eb1cbaa4c773c6d19aa91aaa12c390cf9560d1c9799","libcubeb/cmake/sanitizers-cmake/README.md":"f3b85a594e1601ae65bb09393c56fbc8a98e3f3f49234e56f86bd78803c3544e","libcubeb/cmake/sanitizers-cmake/cmake/FindASan.cmake":"bd30b1c3cb0682b8a2b0b599f6c51fbf99ef4908b00eba8826f0d484c623b01b","libcubeb/cmake/sanitizers-cmake/cmake/FindMSan.cmake":"55e40f0994b47f8e779622af2007c69252d9456be99f4aa4fba7dd49c23d5580","libcubeb/cmake/sanitizers-cmake/cmake/FindSanitizers.cmake":"2ffd9717a49e3e9de848ec0d91097bdbab3f75a7866211d902f9659f59271ffc","libcubeb/cmake/sanitizers-cmake/cmake/FindTSan.cmake":"ceace234abd5a463ad1b8134ad06c4c8004895b2e8fc9edb67e64620ea97ca47","libcubeb/cmake/sanitizers-cmake/cmake/FindUBSan.cmake":"4720ec96ea42a2a9c07d887c1fc5562ed3e8c222f5778a18b78c46678b23f156","libcubeb/cmake/sanitizers-cmake/cmake/asan-wrapper":"4e543936e6374e24b80a0f92135c07c2e2101c0d110e51bddaf0e70ae8ec391e","libcubeb/cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake":"c0c225f22bebd27eb68b807b2a61962d28afc61609735fe652c2fde6aa6a005b","libcubeb/cmake/sanitizers-cmake/tests/CMakeLists.txt":"64b7aea469a043f27414e3d652aaa89a03a11843d152c4cd42f30561e6ef51bc","libcubeb/cmake/sanitizers-cmake/tests/asan_test.cpp":"a25de95282aaee22d977d0b474468b946c1422b80b15424c04266dba038eba2e","libcubeb/cmake/sanitizers-cmake/tests/shortest.ext.test.cpp":"a25de95282aaee22d977d0b474468b946c1422b80b15424c04266dba038eba2e","libcubeb/cmake/toolchain-cross-mingw.cmake":"1c26749465364061ddf37aaa00f363eaf057c4b6a70181086e13b0a4d09bd376","libcubeb/cubeb.supp":"19f33e59f8dc91a327c923e44c2c3f9af0a043ce1d6a8cac275ba094b4bfe0da","libcubeb/docs/Doxyfile.in":"e721a50ccf3a010b9b5169b97f93a24f66bd4b88cade17b5b5088de19fa89716","libcubeb/include/cubeb/cubeb.h":"6485142e549973b455f01b878ea46e12c5c9b69d4c2d648d455976e6ab60668e","libcubeb/scan-build-install.sh":"1ecf22aca367a4d02f810c4cb78db8636e08a12787e94e30c441ce439cf4a265","libcubeb/src/android/audiotrack_definitions.h":"7cbb2a68924d20ec651cead5a923f63eb20192f109b597a3fa1594a79196693b","libcubeb/src/android/cubeb-output-latency.h":"a3862d9caf60d5c805a61e94bd696f6687ee30d2daa4acc25bd686be38497670","libcubeb/src/android/cubeb_media_library.h":"fa2a26a31adc727f35e9f746c287734ecbc7e15ceb52baf821429919a06c2e52","libcubeb/src/android/sles_definitions.h":"4c9c3cedfc06c8df479cc675fbadb1f158b8219223a96b9cffbcbfac738d7f28","libcubeb/src/cubeb-internal.h":"50d2c0be2945136ff66666dbd8fcedc338f8f1d66eb2d9b09e09399193683ae8","libcubeb/src/cubeb-jni-instances.h":"8195554372bf60dea569873c9e5fb1106a2cf5dedc66a13d2bc967da0ff48a12","libcubeb/src/cubeb-jni.cpp":"cee58136cde7ef82045b59eee032e6eaf9bb677db12e053d8805ad9d67ee304e","libcubeb/src/cubeb-jni.h":"8f95cb6bc410bb62adae84f5e9d28fb8b57610107ed66941db0b4e4124548a72","libcubeb/src/cubeb-speex-resampler.h":"dbf543eee4cc6e40ba3531a39d327e2cec884c19e26c570aa7eae0647e5f7420","libcubeb/src/cubeb.c":"0e60bd826422bd3f2c2290e65fb296fa7ef6e578d234feb37ebcb97b11531af3","libcubeb/src/cubeb_aaudio.cpp":"1d68178a463fe0919d7578eba9a9c20c9144fdb0ef0c3b178fc19b7909066809","libcubeb/src/cubeb_alsa.c":"0f061750afa89f0054a4655bbb23dd35f77124c53a90fcce1eccdb32e23937a9","libcubeb/src/cubeb_android.h":"396922d2bb994c39acb745f7449a78e8dee00ad5146583f647545a3e0a9dd010","libcubeb/src/cubeb_array_queue.h":"86ab9c32eef5f4427413091d5932843ee870144475cddb1f0e18cd39d49f6115","libcubeb/src/cubeb_assert.h":"07841be6cca09999a913d0c1e61ab0a5de02200efed5b66fbf7c481b1d0489b0","libcubeb/src/cubeb_audiotrack.c":"18382213f4b3a9808f3dd6b8c18173d21c7230718ecb3771762850ce6420e602","libcubeb/src/cubeb_audiounit.cpp":"b130de9603ef0e171ac16e80472ddfc3b897346be6d5b1bc866ba73d8fa05f56","libcubeb/src/cubeb_jack.cpp":"9493ca3f274cd9a5dba4b5023783747bf186c4fed0dc14ff34f841dc94c988ee","libcubeb/src/cubeb_kai.c":"3b6d52e4b0eaf2db34bcf902baf4784f72805bfb6349ebe769764d09195186c5","libcubeb/src/cubeb_log.cpp":"387f3f8989b260a1ca6067c25a0fd868e38c3d5bb81263924fad5341415a96fe","libcubeb/src/cubeb_log.h":"8511c7640f2856d107900f6c40775c5dfe711187204fb5b2557562b1a855399f","libcubeb/src/cubeb_mixer.cpp":"6779938a7fd70b0ad23fdf1194dab27b57e9afb8f03ff45885601796f76a1dfe","libcubeb/src/cubeb_mixer.h":"64425dcefad3632acf68d6ae9fbdf59ff7b7b0e92487c34d18cd67f52431dc23","libcubeb/src/cubeb_opensl.cpp":"a669549e89c664a9bd2b6b5195b27e6bd27b8b2d5f4a3e9c74046e4a913f0e4a","libcubeb/src/cubeb_oss.c":"743dfe68354963e4a8553eb57fe36af6a639a7769da0b767afda5294edf865b9","libcubeb/src/cubeb_osx_run_loop.cpp":"e5c9ef5591eced85310af94575f84ea5d3051c7aaef4e41cfd221f8f8b7c4331","libcubeb/src/cubeb_osx_run_loop.h":"aa10dd0d6111973b37488d83403d204ecf6001a3530aac6bffab00c6bb31df15","libcubeb/src/cubeb_pulse.c":"034b4ad4eb072573ff2b97ed33c53622be4ff12523fb21d470d6106ca520a5e7","libcubeb/src/cubeb_resampler.cpp":"78a0c5becc11a92c77ff8215c618fac952e62623cbf87ce9c52dce94014a9775","libcubeb/src/cubeb_resampler.h":"2baa28aaf29143145bde23d12d21aa3b38e325d1db692c62da4d0e908c0a5719","libcubeb/src/cubeb_resampler_internal.h":"9b8b20a9f6afcb608e87633248d7e18e063814f39f90b8d8d9aa3273d8228bc4","libcubeb/src/cubeb_ring_array.h":"cd5b7d807c229e925fe61416d70b6ecfe41c735c361bfc01593ed10a6dad5849","libcubeb/src/cubeb_ringbuffer.h":"8f5dc7a58d8b7ad265ff3bbcac80ae160ff22243d869a5b502bf413fa58fd9b0","libcubeb/src/cubeb_sndio.c":"07b47b0993c4c37f45cef8df08bc555d7915354792edf4ee57b3e026ccf23a14","libcubeb/src/cubeb_strings.c":"6004618393cf4dc3e06cd4f44cb53589459dad21384de3695f8b3d16774edf26","libcubeb/src/cubeb_strings.h":"312f5c2230d9a02e369be1d991ec44a1793373046f208529b3cc54cb9a5b0610","libcubeb/src/cubeb_sun.c":"c9aaf34c2163dde73be4c98a4cf1059c00ca66954a78a9680384c9cb5a8927ed","libcubeb/src/cubeb_tracing.h":"def71a9c9659383ea3cf7e12ff0ba2f2c51a0ead03fef6d418eafde6e70c8f39","libcubeb/src/cubeb_triple_buffer.h":"5e3f25e1de251014b804276247c60a2cd823b5657ccf3e27d9dd46ec7433f90b","libcubeb/src/cubeb_utils.cpp":"8f41899df2f5f82541f816dadcee3d18baab7a1aecf2bc6d0b382567209351aa","libcubeb/src/cubeb_utils.h":"7a3b1e2a97752e96ff11badc19149e1582d4289e4e200817a9ed3f905bf8ab10","libcubeb/src/cubeb_utils_unix.h":"2e67e39daed8ec17092a2d1a9b660a3d4e153fc351698d9e1f3d51ef974979c5","libcubeb/src/cubeb_utils_win.h":"4d7a397f475e08dd7af47fdc4003e9f78cf9058e095348eeb554135ea3c3c454","libcubeb/src/cubeb_wasapi.cpp":"731316daf4350064d8106105f98826607360210118010bbcdcb21e5782455595","libcubeb/src/cubeb_winmm.c":"089987489bea20690e825b3107e31446b89270f316fa8219b2c501941c3bc98d","libcubeb/subprojects/speex/arch.h":"2300bce68c588270cdc684dc7f01377e5e251529f4545d93771e111c56d51b0f","libcubeb/subprojects/speex/fixed_generic.h":"306ee7453677fa6067f16c79d358c6c90a9d3d008850b493cdaa59c07e6375c1","libcubeb/subprojects/speex/resample.c":"9c3a1c64ecf3750af82c980d01ea73d3682f73c332a580465d1e787e5c54cd00","libcubeb/subprojects/speex/resample_neon.h":"7d3fd7af9a1ddde22518b9c7b4419073b72b2dfa5be4c3bc8796992bc87b3da0","libcubeb/subprojects/speex/resample_sse.h":"5a196d8e2d8ab5c956f5252f09f5ddc55aee1f99b1341af3fa54a1f4c2157924","libcubeb/subprojects/speex/speex_config_types.h":"24e3ffbf29e5519611a48e5acb959645b01d166dcb4369380d5f776c3f53d4cd","libcubeb/subprojects/speex/speex_resampler.h":"7e439ec0dd30c32216b3ced17135f8992e5aaf53389d3f5996a7d900c453e65f","libcubeb/subprojects/speex/stack_alloc.h":"e8a2fc0874942d2c7177475fcc141fdd0c0156200b8a4e7656d4a20313e2e569","libcubeb/test/README.md":"1c11b038f87daf10ea78abc17bdbdd157940c241df548c24d5872d142a98c1af","libcubeb/test/common.h":"b61e28e52dc5747f73a232b5758a65608b55755ec7a164ef90471bfa697065a1","libcubeb/test/test_audio.cpp":"cf094d11993c9d7602cc0a7f2dcf92d47ffd6142fdd5813c3010143fa08db080","libcubeb/test/test_callback_ret.cpp":"4f004b79476c44e059136478e2368c030920c9137180637e548eb2e6db7e5f6e","libcubeb/test/test_device_changed_callback.cpp":"9e02dd526602d7abfc5485c80c8b86ffa27c0a8c87e587a850f77eff9bfd14aa","libcubeb/test/test_devices.cpp":"1ea25e6ae19940d224011cd8c255d1038a858d1d9be0e7c32ea0455a0e8163f9","libcubeb/test/test_duplex.cpp":"0ea570fc3d9d19091bd4053325833a44a736e20d6c2bc725c9d5fd2e1e660102","libcubeb/test/test_latency.cpp":"a1d75355e49895ea105eb814d20c6e1a37e8cf98be01f73832f4768eb7e1176f","libcubeb/test/test_logging.cpp":"72522cf7794212dceb2f26a98f5c9297a6366f2eab90128066f59422a6edb7c5","libcubeb/test/test_loopback.cpp":"92dbdebd71aa2e844694100818ac11e5145bccb01aa3e6d7ce3bc990931dda3d","libcubeb/test/test_overload_callback.cpp":"593c36fc78ea2fccd4dc2b6e565cb3bf53503f402522737e9005d9eab7fc4732","libcubeb/test/test_record.cpp":"90484423d4e5c4ffb8e6f65c9bae1f7384cac7eeeb4f42c0fcca768ee0e5c8e6","libcubeb/test/test_resampler.cpp":"e821f7e114f772cc163aa12c274efe12a3abda1a66961c4b46106244c826a912","libcubeb/test/test_ring_array.cpp":"c0420d04c914b0f61bdc81b9c4511c1b535518b2f87f32a5539f9ca6310dd5b1","libcubeb/test/test_ring_buffer.cpp":"cf247fda806f976d2b8dd2790e5a25bda68943423d7b0bcd4ac69a57f94e2f88","libcubeb/test/test_sanity.cpp":"b1b474be02e90fa310c265d4abdc712e5637bc5420c670f26d79be98b092804f","libcubeb/test/test_tone.cpp":"75e32348aa18583130bc3f2849862a4153729f19f7e5b1bcc9e91cc6ab7bcbe7","libcubeb/test/test_triple_buffer.cpp":"4f6bd0dad20c2badb5a8374002eb6b0b4c9ed7fe48d21b7421e582401195b3ab","libcubeb/test/test_utils.cpp":"ec18e3c14519d053cfd544ae59b2ba39716500cd7da72b5b50366eefff0a0481","libcubeb/tools/cubeb-test.cpp":"e1a29a10ba824a49dad4d0d6c9f495786148f0dc942558ae990786dba6065f4e","src/callbacks.rs":"a83d9a16ee66b3cd7100dd06e1f409698a727d642df0dfa797c067b5cf1def66","src/channel.rs":"02fd91384195180a56663aba87f00660c20e71fe7654c7b68d8f470173f40d5f","src/context.rs":"23b9326f58494b0860d080ec5f0e76be2325172da7f0274ebba152dc35182f3b","src/device.rs":"08a4292bb35f09c129c4b6dcb85653ffe7e7aa98dee3202d47605f3a2b8c4244","src/error.rs":"406e3b843ed2d263fe677c4b34fb96a6d780a68bcb56a6f85f041d20d70227bd","src/format.rs":"d4d27790c20eab0b16592f60d5e487425a45a268cf4c74cf843c10ac91bbff4c","src/internal.rs":"c3af5f53dc7957860bf3bc0cd9737d094fb8ac000e7b40c569304cfa76a43145","src/lib.rs":"cdc36b11f18e274d10df592d216f142e05e1d22db5aac4c7e346893d6b1510db","src/log.rs":"8ac402b6c4d20db651cbddb87b27b3aa5ab0c3c50dac08a6c09fb1b7f9a3a391","src/macros.rs":"caef13f5d23f7a3ec1a54ec3ca2390ac4ad89d521893f1d0864daf70d57a20aa","src/mixer.rs":"e72e92855614da187da6419ed0a115062a05670cb73443b2ea4313d8f5108a68","src/resampler.rs":"b16bd6a4b1179b25f2a5391133fcd4410467e6a68c0a46cf15a12d280c1862e0","src/stream.rs":"5d3ec1e48fdb96054e8ff678ae6c784e23b551b496154958433b746ee473f3c8"},"package":"3c20c457d7b34dad6e0c1a9c759c96b4420b9e9917a572998b81835799a07e1d"} \ No newline at end of file +{"files":{"Cargo.toml":"02bccb7b588c2495ed8423b134c23c05b8013065f0a07095fd523ee5e6473ce9","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","build.rs":"4572cbb7b2bb0ac41330dc1535dbc6685d38ea4f485029ee932639e2feb94d7b","libcubeb/AUTHORS":"829e45d138c7c8827799f302806fa4be8cd8bd4bad70a2fe26c3a27a5cf36948","libcubeb/CMakeLists.txt":"e82ca863291d8bf09c7614f74b67ca93d272c1d00733f2113ea28f5349a11928","libcubeb/Config.cmake.in":"a156fb5cd30208aedcb9ef025d94187df82142fd4442e3a7d0e2a688668a3da9","libcubeb/INSTALL.md":"1fa77e15423e6f583c30861528cd2732d52a028982020cd3a7a9da4a452d7311","libcubeb/LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","libcubeb/README.md":"9b01cda3464a448373176c07368d1ce4a2b4f87ec9f8f02cbac0b4a40719c141","libcubeb/cmake/compile_tests/oss_is_v4.c":"482bcd4c569e8a26f4ab0fe3a3bed25e9d4b296bf678896a2cc1dc8abbad492d","libcubeb/cmake/sanitizers-cmake/CMakeLists.txt":"89b282c19b3897ff666f7847d5e679ae928ca7e76ffd0d23f7c58c9464048b61","libcubeb/cmake/sanitizers-cmake/LICENSE":"4b67e7ae8c91e68e1a929eb1cbaa4c773c6d19aa91aaa12c390cf9560d1c9799","libcubeb/cmake/sanitizers-cmake/README.md":"f3b85a594e1601ae65bb09393c56fbc8a98e3f3f49234e56f86bd78803c3544e","libcubeb/cmake/sanitizers-cmake/cmake/FindASan.cmake":"bd30b1c3cb0682b8a2b0b599f6c51fbf99ef4908b00eba8826f0d484c623b01b","libcubeb/cmake/sanitizers-cmake/cmake/FindMSan.cmake":"55e40f0994b47f8e779622af2007c69252d9456be99f4aa4fba7dd49c23d5580","libcubeb/cmake/sanitizers-cmake/cmake/FindSanitizers.cmake":"2ffd9717a49e3e9de848ec0d91097bdbab3f75a7866211d902f9659f59271ffc","libcubeb/cmake/sanitizers-cmake/cmake/FindTSan.cmake":"ceace234abd5a463ad1b8134ad06c4c8004895b2e8fc9edb67e64620ea97ca47","libcubeb/cmake/sanitizers-cmake/cmake/FindUBSan.cmake":"4720ec96ea42a2a9c07d887c1fc5562ed3e8c222f5778a18b78c46678b23f156","libcubeb/cmake/sanitizers-cmake/cmake/asan-wrapper":"4e543936e6374e24b80a0f92135c07c2e2101c0d110e51bddaf0e70ae8ec391e","libcubeb/cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake":"c0c225f22bebd27eb68b807b2a61962d28afc61609735fe652c2fde6aa6a005b","libcubeb/cmake/sanitizers-cmake/tests/CMakeLists.txt":"64b7aea469a043f27414e3d652aaa89a03a11843d152c4cd42f30561e6ef51bc","libcubeb/cmake/sanitizers-cmake/tests/asan_test.cpp":"a25de95282aaee22d977d0b474468b946c1422b80b15424c04266dba038eba2e","libcubeb/cmake/sanitizers-cmake/tests/shortest.ext.test.cpp":"a25de95282aaee22d977d0b474468b946c1422b80b15424c04266dba038eba2e","libcubeb/cmake/toolchain-cross-mingw.cmake":"1c26749465364061ddf37aaa00f363eaf057c4b6a70181086e13b0a4d09bd376","libcubeb/cubeb.supp":"19f33e59f8dc91a327c923e44c2c3f9af0a043ce1d6a8cac275ba094b4bfe0da","libcubeb/docs/Doxyfile.in":"e721a50ccf3a010b9b5169b97f93a24f66bd4b88cade17b5b5088de19fa89716","libcubeb/include/cubeb/cubeb.h":"db3eb7d8d5c4d45b5d86f9c0524ff7d041f0cc596c39097c59cdfc82702b18a8","libcubeb/scan-build-install.sh":"1ecf22aca367a4d02f810c4cb78db8636e08a12787e94e30c441ce439cf4a265","libcubeb/src/android/audiotrack_definitions.h":"7cbb2a68924d20ec651cead5a923f63eb20192f109b597a3fa1594a79196693b","libcubeb/src/android/cubeb-output-latency.h":"a3862d9caf60d5c805a61e94bd696f6687ee30d2daa4acc25bd686be38497670","libcubeb/src/android/cubeb_media_library.h":"fa2a26a31adc727f35e9f746c287734ecbc7e15ceb52baf821429919a06c2e52","libcubeb/src/android/sles_definitions.h":"4c9c3cedfc06c8df479cc675fbadb1f158b8219223a96b9cffbcbfac738d7f28","libcubeb/src/cubeb-internal.h":"50d2c0be2945136ff66666dbd8fcedc338f8f1d66eb2d9b09e09399193683ae8","libcubeb/src/cubeb-jni-instances.h":"8195554372bf60dea569873c9e5fb1106a2cf5dedc66a13d2bc967da0ff48a12","libcubeb/src/cubeb-jni.cpp":"cee58136cde7ef82045b59eee032e6eaf9bb677db12e053d8805ad9d67ee304e","libcubeb/src/cubeb-jni.h":"8f95cb6bc410bb62adae84f5e9d28fb8b57610107ed66941db0b4e4124548a72","libcubeb/src/cubeb-speex-resampler.h":"dbf543eee4cc6e40ba3531a39d327e2cec884c19e26c570aa7eae0647e5f7420","libcubeb/src/cubeb.c":"83a05dabbec76b45f21dce6934b655e4cca9d10eca30c0fb2248cc475b4f7541","libcubeb/src/cubeb_aaudio.cpp":"de745d91bd459f10eacbd89ccc8d00d7f694abab61dfc0ca93439d7ad12aa035","libcubeb/src/cubeb_alsa.c":"0f061750afa89f0054a4655bbb23dd35f77124c53a90fcce1eccdb32e23937a9","libcubeb/src/cubeb_android.h":"396922d2bb994c39acb745f7449a78e8dee00ad5146583f647545a3e0a9dd010","libcubeb/src/cubeb_array_queue.h":"86ab9c32eef5f4427413091d5932843ee870144475cddb1f0e18cd39d49f6115","libcubeb/src/cubeb_assert.h":"07841be6cca09999a913d0c1e61ab0a5de02200efed5b66fbf7c481b1d0489b0","libcubeb/src/cubeb_audio_dump.cpp":"3186e3b7a5cf88fc3b35ad9ae24fa58f8c9aeec035e103886b472532cc2d430d","libcubeb/src/cubeb_audio_dump.h":"93da746cff7326ce904bd2ef1aef400d8fd36e8ab2fceb372d459127003a5dae","libcubeb/src/cubeb_audiotrack.c":"18382213f4b3a9808f3dd6b8c18173d21c7230718ecb3771762850ce6420e602","libcubeb/src/cubeb_audiounit.cpp":"4285a1ec1bb65e502443b82e1f988ed7af9eb2957c985fe2168574e17ffe8b06","libcubeb/src/cubeb_jack.cpp":"9493ca3f274cd9a5dba4b5023783747bf186c4fed0dc14ff34f841dc94c988ee","libcubeb/src/cubeb_kai.c":"3b6d52e4b0eaf2db34bcf902baf4784f72805bfb6349ebe769764d09195186c5","libcubeb/src/cubeb_log.cpp":"387f3f8989b260a1ca6067c25a0fd868e38c3d5bb81263924fad5341415a96fe","libcubeb/src/cubeb_log.h":"8511c7640f2856d107900f6c40775c5dfe711187204fb5b2557562b1a855399f","libcubeb/src/cubeb_mixer.cpp":"6779938a7fd70b0ad23fdf1194dab27b57e9afb8f03ff45885601796f76a1dfe","libcubeb/src/cubeb_mixer.h":"64425dcefad3632acf68d6ae9fbdf59ff7b7b0e92487c34d18cd67f52431dc23","libcubeb/src/cubeb_opensl.cpp":"a669549e89c664a9bd2b6b5195b27e6bd27b8b2d5f4a3e9c74046e4a913f0e4a","libcubeb/src/cubeb_oss.c":"743dfe68354963e4a8553eb57fe36af6a639a7769da0b767afda5294edf865b9","libcubeb/src/cubeb_osx_run_loop.cpp":"e5c9ef5591eced85310af94575f84ea5d3051c7aaef4e41cfd221f8f8b7c4331","libcubeb/src/cubeb_osx_run_loop.h":"aa10dd0d6111973b37488d83403d204ecf6001a3530aac6bffab00c6bb31df15","libcubeb/src/cubeb_pulse.c":"034b4ad4eb072573ff2b97ed33c53622be4ff12523fb21d470d6106ca520a5e7","libcubeb/src/cubeb_resampler.cpp":"78a0c5becc11a92c77ff8215c618fac952e62623cbf87ce9c52dce94014a9775","libcubeb/src/cubeb_resampler.h":"2baa28aaf29143145bde23d12d21aa3b38e325d1db692c62da4d0e908c0a5719","libcubeb/src/cubeb_resampler_internal.h":"9b8b20a9f6afcb608e87633248d7e18e063814f39f90b8d8d9aa3273d8228bc4","libcubeb/src/cubeb_ring_array.h":"cd5b7d807c229e925fe61416d70b6ecfe41c735c361bfc01593ed10a6dad5849","libcubeb/src/cubeb_ringbuffer.h":"8f5dc7a58d8b7ad265ff3bbcac80ae160ff22243d869a5b502bf413fa58fd9b0","libcubeb/src/cubeb_sndio.c":"07b47b0993c4c37f45cef8df08bc555d7915354792edf4ee57b3e026ccf23a14","libcubeb/src/cubeb_strings.c":"6004618393cf4dc3e06cd4f44cb53589459dad21384de3695f8b3d16774edf26","libcubeb/src/cubeb_strings.h":"312f5c2230d9a02e369be1d991ec44a1793373046f208529b3cc54cb9a5b0610","libcubeb/src/cubeb_sun.c":"c9aaf34c2163dde73be4c98a4cf1059c00ca66954a78a9680384c9cb5a8927ed","libcubeb/src/cubeb_tracing.h":"def71a9c9659383ea3cf7e12ff0ba2f2c51a0ead03fef6d418eafde6e70c8f39","libcubeb/src/cubeb_triple_buffer.h":"5e3f25e1de251014b804276247c60a2cd823b5657ccf3e27d9dd46ec7433f90b","libcubeb/src/cubeb_utils.cpp":"8f41899df2f5f82541f816dadcee3d18baab7a1aecf2bc6d0b382567209351aa","libcubeb/src/cubeb_utils.h":"7a3b1e2a97752e96ff11badc19149e1582d4289e4e200817a9ed3f905bf8ab10","libcubeb/src/cubeb_utils_unix.h":"2e67e39daed8ec17092a2d1a9b660a3d4e153fc351698d9e1f3d51ef974979c5","libcubeb/src/cubeb_utils_win.h":"4d7a397f475e08dd7af47fdc4003e9f78cf9058e095348eeb554135ea3c3c454","libcubeb/src/cubeb_wasapi.cpp":"9cbe6b81be6ab6475d20eb1b77ff58372f12ed342959ce7811641a2ab0dae188","libcubeb/src/cubeb_winmm.c":"089987489bea20690e825b3107e31446b89270f316fa8219b2c501941c3bc98d","libcubeb/subprojects/speex/arch.h":"2300bce68c588270cdc684dc7f01377e5e251529f4545d93771e111c56d51b0f","libcubeb/subprojects/speex/fixed_generic.h":"306ee7453677fa6067f16c79d358c6c90a9d3d008850b493cdaa59c07e6375c1","libcubeb/subprojects/speex/resample.c":"9c3a1c64ecf3750af82c980d01ea73d3682f73c332a580465d1e787e5c54cd00","libcubeb/subprojects/speex/resample_neon.h":"7d3fd7af9a1ddde22518b9c7b4419073b72b2dfa5be4c3bc8796992bc87b3da0","libcubeb/subprojects/speex/resample_sse.h":"5a196d8e2d8ab5c956f5252f09f5ddc55aee1f99b1341af3fa54a1f4c2157924","libcubeb/subprojects/speex/speex_config_types.h":"24e3ffbf29e5519611a48e5acb959645b01d166dcb4369380d5f776c3f53d4cd","libcubeb/subprojects/speex/speex_resampler.h":"7e439ec0dd30c32216b3ced17135f8992e5aaf53389d3f5996a7d900c453e65f","libcubeb/subprojects/speex/stack_alloc.h":"e8a2fc0874942d2c7177475fcc141fdd0c0156200b8a4e7656d4a20313e2e569","libcubeb/test/README.md":"1c11b038f87daf10ea78abc17bdbdd157940c241df548c24d5872d142a98c1af","libcubeb/test/common.h":"b61e28e52dc5747f73a232b5758a65608b55755ec7a164ef90471bfa697065a1","libcubeb/test/test_audio.cpp":"cf094d11993c9d7602cc0a7f2dcf92d47ffd6142fdd5813c3010143fa08db080","libcubeb/test/test_audio_dump.cpp":"5716fd3ea828a26dd80252cafa2334404003639663334b9a96c87df2831b5553","libcubeb/test/test_callback_ret.cpp":"4f004b79476c44e059136478e2368c030920c9137180637e548eb2e6db7e5f6e","libcubeb/test/test_device_changed_callback.cpp":"9e02dd526602d7abfc5485c80c8b86ffa27c0a8c87e587a850f77eff9bfd14aa","libcubeb/test/test_devices.cpp":"1ea25e6ae19940d224011cd8c255d1038a858d1d9be0e7c32ea0455a0e8163f9","libcubeb/test/test_duplex.cpp":"2297abf827e21fe8695cae63c7e8076bc59e6ab4350aa8dbbd821e0f079732c4","libcubeb/test/test_latency.cpp":"a1d75355e49895ea105eb814d20c6e1a37e8cf98be01f73832f4768eb7e1176f","libcubeb/test/test_logging.cpp":"72522cf7794212dceb2f26a98f5c9297a6366f2eab90128066f59422a6edb7c5","libcubeb/test/test_loopback.cpp":"92dbdebd71aa2e844694100818ac11e5145bccb01aa3e6d7ce3bc990931dda3d","libcubeb/test/test_overload_callback.cpp":"593c36fc78ea2fccd4dc2b6e565cb3bf53503f402522737e9005d9eab7fc4732","libcubeb/test/test_record.cpp":"90484423d4e5c4ffb8e6f65c9bae1f7384cac7eeeb4f42c0fcca768ee0e5c8e6","libcubeb/test/test_resampler.cpp":"e821f7e114f772cc163aa12c274efe12a3abda1a66961c4b46106244c826a912","libcubeb/test/test_ring_array.cpp":"c0420d04c914b0f61bdc81b9c4511c1b535518b2f87f32a5539f9ca6310dd5b1","libcubeb/test/test_ring_buffer.cpp":"cf247fda806f976d2b8dd2790e5a25bda68943423d7b0bcd4ac69a57f94e2f88","libcubeb/test/test_sanity.cpp":"b1b474be02e90fa310c265d4abdc712e5637bc5420c670f26d79be98b092804f","libcubeb/test/test_tone.cpp":"75e32348aa18583130bc3f2849862a4153729f19f7e5b1bcc9e91cc6ab7bcbe7","libcubeb/test/test_triple_buffer.cpp":"4f6bd0dad20c2badb5a8374002eb6b0b4c9ed7fe48d21b7421e582401195b3ab","libcubeb/test/test_utils.cpp":"ec18e3c14519d053cfd544ae59b2ba39716500cd7da72b5b50366eefff0a0481","libcubeb/tools/cubeb-test.cpp":"e1a29a10ba824a49dad4d0d6c9f495786148f0dc942558ae990786dba6065f4e","src/audio_dump.rs":"2491741d58a609e93de1a46d003fd4e26e4cd88cd89d4c9584635141964e0274","src/callbacks.rs":"a83d9a16ee66b3cd7100dd06e1f409698a727d642df0dfa797c067b5cf1def66","src/channel.rs":"02fd91384195180a56663aba87f00660c20e71fe7654c7b68d8f470173f40d5f","src/context.rs":"23b9326f58494b0860d080ec5f0e76be2325172da7f0274ebba152dc35182f3b","src/device.rs":"08a4292bb35f09c129c4b6dcb85653ffe7e7aa98dee3202d47605f3a2b8c4244","src/error.rs":"406e3b843ed2d263fe677c4b34fb96a6d780a68bcb56a6f85f041d20d70227bd","src/format.rs":"d4d27790c20eab0b16592f60d5e487425a45a268cf4c74cf843c10ac91bbff4c","src/internal.rs":"c3af5f53dc7957860bf3bc0cd9737d094fb8ac000e7b40c569304cfa76a43145","src/lib.rs":"0fa0602859889c4f608ca4178c45f43d7e4b258ea0185a64341fab4532ebcd0e","src/log.rs":"8ac402b6c4d20db651cbddb87b27b3aa5ab0c3c50dac08a6c09fb1b7f9a3a391","src/macros.rs":"caef13f5d23f7a3ec1a54ec3ca2390ac4ad89d521893f1d0864daf70d57a20aa","src/mixer.rs":"e72e92855614da187da6419ed0a115062a05670cb73443b2ea4313d8f5108a68","src/resampler.rs":"b16bd6a4b1179b25f2a5391133fcd4410467e6a68c0a46cf15a12d280c1862e0","src/stream.rs":"5d3ec1e48fdb96054e8ff678ae6c784e23b551b496154958433b746ee473f3c8"},"package":"26073cd50c7b6ba4272204839f56921557609a0d67e092882cbb903df94cab39"} \ No newline at end of file diff --git a/third_party/rust/cubeb-sys/Cargo.toml b/third_party/rust/cubeb-sys/Cargo.toml index 36c447c7074b..7c89d3d2cc41 100644 --- a/third_party/rust/cubeb-sys/Cargo.toml +++ b/third_party/rust/cubeb-sys/Cargo.toml @@ -11,7 +11,7 @@ [package] name = "cubeb-sys" -version = "0.12.0" +version = "0.13.0" authors = ["Dan Glastonbury "] build = "build.rs" links = "cubeb" diff --git a/third_party/rust/cubeb-sys/libcubeb/CMakeLists.txt b/third_party/rust/cubeb-sys/libcubeb/CMakeLists.txt index 530e3a46019b..541120a7f09f 100644 --- a/third_party/rust/cubeb-sys/libcubeb/CMakeLists.txt +++ b/third_party/rust/cubeb-sys/libcubeb/CMakeLists.txt @@ -78,6 +78,7 @@ endif() add_library(cubeb src/cubeb.c + src/cubeb_audio_dump.cpp src/cubeb_mixer.cpp src/cubeb_resampler.cpp src/cubeb_log.cpp @@ -264,7 +265,7 @@ if(USE_WASAPI) target_sources(cubeb PRIVATE src/cubeb_wasapi.cpp) target_compile_definitions(cubeb PRIVATE USE_WASAPI) - target_link_libraries(cubeb PRIVATE avrt ole32 ksuser) + target_link_libraries(cubeb PRIVATE ole32 ksuser) endif() check_include_files("windows.h;mmsystem.h" USE_WINMM) @@ -406,6 +407,7 @@ if(BUILD_TESTS) cubeb_add_test(duplex) cubeb_add_test(logging) cubeb_add_test(triple_buffer) + cubeb_add_test(audio_dump) if (USE_WASAPI) cubeb_add_test(overload_callback) diff --git a/third_party/rust/cubeb-sys/libcubeb/include/cubeb/cubeb.h b/third_party/rust/cubeb-sys/libcubeb/include/cubeb/cubeb.h index 17ead45b1b94..c970246283b7 100644 --- a/third_party/rust/cubeb-sys/libcubeb/include/cubeb/cubeb.h +++ b/third_party/rust/cubeb-sys/libcubeb/include/cubeb/cubeb.h @@ -274,7 +274,7 @@ typedef enum { typedef struct { cubeb_sample_format format; /**< Requested sample format. One of #cubeb_sample_format. */ - uint32_t rate; /**< Requested sample rate. Valid range is [1000, 192000]. */ + uint32_t rate; /**< Requested sample rate. Valid range is [1000, 384000]. */ uint32_t channels; /**< Requested channel count. Valid range is [1, 8]. */ cubeb_channel_layout layout; /**< Requested channel layout. This must be consistent with the diff --git a/third_party/rust/cubeb-sys/libcubeb/src/cubeb.c b/third_party/rust/cubeb-sys/libcubeb/src/cubeb.c index 16bb84a9fa79..b0db033d4f07 100644 --- a/third_party/rust/cubeb-sys/libcubeb/src/cubeb.c +++ b/third_party/rust/cubeb-sys/libcubeb/src/cubeb.c @@ -95,7 +95,7 @@ validate_stream_params(cubeb_stream_params * input_stream_params, XASSERT(input_stream_params || output_stream_params); if (output_stream_params) { if (output_stream_params->rate < 1000 || - output_stream_params->rate > 192000 || + output_stream_params->rate > 768000 || output_stream_params->channels < 1 || output_stream_params->channels > UINT8_MAX) { return CUBEB_ERROR_INVALID_FORMAT; @@ -103,7 +103,7 @@ validate_stream_params(cubeb_stream_params * input_stream_params, } if (input_stream_params) { if (input_stream_params->rate < 1000 || - input_stream_params->rate > 192000 || + input_stream_params->rate > 768000 || input_stream_params->channels < 1 || input_stream_params->channels > UINT8_MAX) { return CUBEB_ERROR_INVALID_FORMAT; @@ -533,7 +533,7 @@ int cubeb_stream_set_input_processing_params(cubeb_stream * stream, cubeb_input_processing_params params) { - if (!stream || !params) { + if (!stream) { return CUBEB_ERROR_INVALID_PARAMETER; } diff --git a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_aaudio.cpp b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_aaudio.cpp index f6ed5c610df5..cfae2d6f918c 100644 --- a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_aaudio.cpp +++ b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_aaudio.cpp @@ -244,13 +244,24 @@ shutdown_with_error(cubeb_stream * stm) } int64_t poll_frequency_ns = NS_PER_S * stm->out_frame_size / stm->sample_rate; + int rv; if (stm->istream) { - wait_for_state_change(stm->istream, AAUDIO_STREAM_STATE_STOPPED, - poll_frequency_ns); + rv = wait_for_state_change(stm->istream, AAUDIO_STREAM_STATE_STOPPED, + poll_frequency_ns); + if (rv != CUBEB_OK) { + LOG("Failure when waiting for stream change on the input side when " + "shutting down in error"); + // Not much we can do, carry on + } } if (stm->ostream) { - wait_for_state_change(stm->ostream, AAUDIO_STREAM_STATE_STOPPED, - poll_frequency_ns); + rv = wait_for_state_change(stm->ostream, AAUDIO_STREAM_STATE_STOPPED, + poll_frequency_ns); + if (rv != CUBEB_OK) { + LOG("Failure when waiting for stream change on the output side when " + "shutting down in error"); + // Not much we can do, carry on + } } assert(!stm->in_data_callback.load()); @@ -920,7 +931,7 @@ aaudio_error_cb(AAudioStream * astream, void * user_data, aaudio_result_t error) assert(stm->ostream == astream || stm->istream == astream); // Device change -- reinitialize on the new default device. - if (error == AAUDIO_ERROR_DISCONNECTED) { + if (error == AAUDIO_ERROR_DISCONNECTED || error == AAUDIO_ERROR_TIMEOUT) { LOG("Audio device change, reinitializing stream"); reinitialize_stream(stm); return; diff --git a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.cpp b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.cpp new file mode 100644 index 000000000000..a290ff2849d6 --- /dev/null +++ b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.cpp @@ -0,0 +1,231 @@ +/* + * Copyright © 2023 Mozilla Foundation + * + * This program is made available under an ISC-style license. See the + * accompanying file LICENSE for details. + */ + +#define NOMINMAX + +#include "cubeb_audio_dump.h" +#include "cubeb/cubeb.h" +#include "cubeb_ringbuffer.h" +#include +#include +#include +#include + +using std::thread; +using std::vector; + +uint32_t +bytes_per_sample(cubeb_stream_params params) +{ + switch (params.format) { + case CUBEB_SAMPLE_S16LE: + case CUBEB_SAMPLE_S16BE: + return sizeof(int16_t); + case CUBEB_SAMPLE_FLOAT32LE: + case CUBEB_SAMPLE_FLOAT32BE: + return sizeof(float); + }; +} + +struct cubeb_audio_dump_stream { +public: + explicit cubeb_audio_dump_stream(cubeb_stream_params params) + : sample_size(bytes_per_sample(params)), + ringbuffer( + static_cast(params.rate * params.channels * sample_size)) + { + } + + int open(const char * name) + { + file = fopen(name, "wb"); + if (!file) { + return CUBEB_ERROR; + } + return CUBEB_OK; + } + int close() + { + if (fclose(file)) { + return CUBEB_ERROR; + } + return CUBEB_OK; + } + + // Directly write to the file. Useful to write the header. + size_t write(uint8_t * data, uint32_t count) + { + return fwrite(data, count, 1, file); + } + + size_t write_all() + { + size_t written = 0; + const int buf_sz = 16 * 1024; + uint8_t buf[buf_sz]; + while (int rv = ringbuffer.dequeue(buf, buf_sz)) { + written += fwrite(buf, rv, 1, file); + } + return written; + } + int dump(void * samples, uint32_t count) + { + int bytes = static_cast(count * sample_size); + int rv = ringbuffer.enqueue(static_cast(samples), bytes); + return rv == bytes; + } + +private: + uint32_t sample_size; + FILE * file{}; + lock_free_queue ringbuffer; +}; + +struct cubeb_audio_dump_session { +public: + cubeb_audio_dump_session() = default; + ~cubeb_audio_dump_session() + { + assert(streams.empty()); + session_thread.join(); + } + cubeb_audio_dump_session(const cubeb_audio_dump_session &) = delete; + cubeb_audio_dump_session & + operator=(const cubeb_audio_dump_session &) = delete; + cubeb_audio_dump_session & operator=(cubeb_audio_dump_session &&) = delete; + + cubeb_audio_dump_stream_t create_stream(cubeb_stream_params params, + const char * name) + { + if (running) { + return nullptr; + } + auto * stream = new cubeb_audio_dump_stream(params); + streams.push_back(stream); + int rv = stream->open(name); + if (rv != CUBEB_OK) { + delete stream; + return nullptr; + } + + struct riff_header { + char chunk_id[4] = {'R', 'I', 'F', 'F'}; + int32_t chunk_size = 0; + char format[4] = {'W', 'A', 'V', 'E'}; + + char subchunk_id_1[4] = {'f', 'm', 't', 0x20}; + int32_t subchunk_1_size = 16; + int16_t audio_format{}; + int16_t num_channels{}; + int32_t sample_rate{}; + int32_t byte_rate{}; + int16_t block_align{}; + int16_t bits_per_sample{}; + + char subchunk_id_2[4] = {'d', 'a', 't', 'a'}; + int32_t subchunkd_2_size = std::numeric_limits::max(); + }; + + riff_header header; + // 1 is integer PCM, 3 is float PCM + header.audio_format = bytes_per_sample(params) == 2 ? 1 : 3; + header.num_channels = params.channels; + header.sample_rate = params.rate; + header.byte_rate = bytes_per_sample(params) * params.rate * params.channels; + header.block_align = params.channels * bytes_per_sample(params); + header.bits_per_sample = bytes_per_sample(params) * 8; + + stream->write(reinterpret_cast(&header), sizeof(riff_header)); + + return stream; + } + int delete_stream(cubeb_audio_dump_stream * stream) + { + assert(!running); + stream->close(); + streams.erase(std::remove(streams.begin(), streams.end(), stream), + streams.end()); + return CUBEB_OK; + } + int start() + { + assert(!running); + running = true; + session_thread = std::thread([this] { + while (running) { + for (auto * stream : streams) { + stream->write_all(); + } + const int DUMP_INTERVAL = 10; + std::this_thread::sleep_for(std::chrono::milliseconds(DUMP_INTERVAL)); + } + }); + return CUBEB_OK; + } + int stop() + { + assert(running); + running = false; + return CUBEB_OK; + } + +private: + thread session_thread; + vector streams{}; + std::atomic running = false; +}; + +int +cubeb_audio_dump_init(cubeb_audio_dump_session_t * session) +{ + *session = new cubeb_audio_dump_session; + return CUBEB_OK; +} + +int +cubeb_audio_dump_shutdown(cubeb_audio_dump_session_t session) +{ + delete session; + return CUBEB_OK; +} + +int +cubeb_audio_dump_stream_init(cubeb_audio_dump_session_t session, + cubeb_audio_dump_stream_t * stream, + cubeb_stream_params stream_params, + const char * name) +{ + *stream = session->create_stream(stream_params, name); + return CUBEB_OK; +} + +int +cubeb_audio_dump_stream_shutdown(cubeb_audio_dump_session_t session, + cubeb_audio_dump_stream_t stream) +{ + return session->delete_stream(stream); +} + +int +cubeb_audio_dump_start(cubeb_audio_dump_session_t session) +{ + return session->start(); +} + +int +cubeb_audio_dump_stop(cubeb_audio_dump_session_t session) +{ + return session->stop(); +} + +int +cubeb_audio_dump_write(cubeb_audio_dump_stream_t stream, void * audio_samples, + uint32_t count) +{ + stream->dump(audio_samples, count); + return CUBEB_OK; +} diff --git a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.h b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.h new file mode 100644 index 000000000000..ae473e6e5570 --- /dev/null +++ b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audio_dump.h @@ -0,0 +1,108 @@ +/* + * Copyright © 2023 Mozilla Foundation + * + * This program is made available under an ISC-style license. See the + * accompanying file LICENSE for details. + */ + +#ifndef CUBEB_AUDIO_DUMP +#define CUBEB_AUDIO_DUMP + +#include "cubeb/cubeb.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +typedef struct cubeb_audio_dump_stream * cubeb_audio_dump_stream_t; +typedef struct cubeb_audio_dump_session * cubeb_audio_dump_session_t; + +// Start audio dumping session +// This can only be called if the other API functions +// aren't currently being called: synchronized externally. +// This is not real-time safe. +// +// This is generally called when deciding to start logging some audio. +// +// Returns 0 in case of success. +int +cubeb_audio_dump_init(cubeb_audio_dump_session_t * session); + +// End audio dumping session +// This can only be called if the other API functions +// aren't currently being called: synchronized externally. +// +// This is generally called when deciding to stop logging some audio. +// +// This is not real-time safe. +// Returns 0 in case of success. +int +cubeb_audio_dump_shutdown(cubeb_audio_dump_session_t session); + +// Register a stream for dumping to a file +// This can only be called if cubeb_audio_dump_write +// isn't currently being called: synchronized externally. +// +// This is generally called when setting up a system-level stream side (either +// input or output). +// +// This is not real-time safe. +// Returns 0 in case of success. +int +cubeb_audio_dump_stream_init(cubeb_audio_dump_session_t session, + cubeb_audio_dump_stream_t * stream, + cubeb_stream_params stream_params, + const char * name); + +// Unregister a stream for dumping to a file +// This can only be called if cubeb_audio_dump_write +// isn't currently being called: synchronized externally. +// +// This is generally called when a system-level audio stream side +// (input/output) has been stopped and drained, and the audio callback isn't +// going to be called. +// +// This is not real-time safe. +// Returns 0 in case of success. +int +cubeb_audio_dump_stream_shutdown(cubeb_audio_dump_session_t session, + cubeb_audio_dump_stream_t stream); + +// Start dumping. +// cubeb_audio_dump_write can now be called. +// +// This starts dumping the audio to disk. Generally this is called when +// cubeb_stream_start is caled is called, but can be called at the beginning of +// the application. +// +// This is not real-time safe. +// Returns 0 in case of success. +int +cubeb_audio_dump_start(cubeb_audio_dump_session_t session); + +// Stop dumping. +// cubeb_audio_dump_write can't be called at this point. +// +// This stops dumping the audio to disk cubeb_stream_stop is caled is called, +// but can be called before exiting the application. +// +// This is not real-time safe. +// Returns 0 in case of success. +int +cubeb_audio_dump_stop(cubeb_audio_dump_session_t session); + +// Dump some audio samples for audio stream id. +// +// This is generally called from the real-time audio callback. +// +// This is real-time safe. +// Returns 0 in case of success. +int +cubeb_audio_dump_write(cubeb_audio_dump_stream_t stream, void * audio_samples, + uint32_t count); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audiounit.cpp b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audiounit.cpp index 0341c8d3321a..d823e80ff8d4 100644 --- a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audiounit.cpp +++ b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_audiounit.cpp @@ -377,6 +377,15 @@ cubeb_channel_to_channel_label(cubeb_channel channel) } } +bool +is_common_sample_rate(Float64 sample_rate) +{ + /* Some commonly used sample rates and their multiples and divisors. */ + return sample_rate == 8000 || sample_rate == 16000 || sample_rate == 22050 || + sample_rate == 32000 || sample_rate == 44100 || sample_rate == 48000 || + sample_rate == 88200 || sample_rate == 96000; +} + #if TARGET_OS_IPHONE typedef UInt32 AudioDeviceID; typedef UInt32 AudioObjectID; @@ -2502,6 +2511,12 @@ audiounit_configure_output(cubeb_stream * stm) return CUBEB_ERROR; } stm->output_hw_rate = output_hw_desc.mSampleRate; + if (!is_common_sample_rate(stm->output_desc.mSampleRate)) { + /* For uncommon sample rates, we may run into issues with the OS + resampler if we don't do the resampling ourselves, so set the + AudioUnit sample rate to the hardware rate and resample. */ + stm->output_desc.mSampleRate = stm->output_hw_rate; + } LOG("(%p) Output device sampling rate: %.2f", stm, output_hw_desc.mSampleRate); stm->context->channels = output_hw_desc.mChannelsPerFrame; @@ -2709,11 +2724,16 @@ audiounit_setup_stream(cubeb_stream * stm) input_unconverted_params.rate = stm->input_hw_rate; } - /* Create resampler. Output params are unchanged - * because we do not need conversion on the output. */ + cubeb_stream_params output_unconverted_params; + if (has_output(stm)) { + output_unconverted_params = stm->output_stream_params; + output_unconverted_params.rate = stm->output_desc.mSampleRate; + } + + /* Create resampler. */ stm->resampler.reset(cubeb_resampler_create( stm, has_input(stm) ? &input_unconverted_params : NULL, - has_output(stm) ? &stm->output_stream_params : NULL, target_sample_rate, + has_output(stm) ? &output_unconverted_params : NULL, target_sample_rate, stm->data_callback, stm->user_ptr, CUBEB_RESAMPLER_QUALITY_DESKTOP, CUBEB_RESAMPLER_RECLOCK_NONE)); if (!stm->resampler) { diff --git a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_wasapi.cpp b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_wasapi.cpp index 01417a52e333..b2e95be665ed 100644 --- a/third_party/rust/cubeb-sys/libcubeb/src/cubeb_wasapi.cpp +++ b/third_party/rust/cubeb-sys/libcubeb/src/cubeb_wasapi.cpp @@ -204,6 +204,11 @@ struct auto_stream_ref { cubeb_stream * stm; }; +using set_mm_thread_characteristics_function = + decltype(&AvSetMmThreadCharacteristicsW); +using revert_mm_thread_characteristics_function = + decltype(&AvRevertMmThreadCharacteristics); + extern cubeb_ops const wasapi_ops; static com_heap_ptr @@ -301,6 +306,13 @@ struct cubeb { nullptr; void * output_collection_changed_user_ptr = nullptr; UINT64 performance_counter_frequency; + /* Library dynamically opened to increase the render thread priority, and + the two function pointers we need. */ + HMODULE mmcss_module = nullptr; + set_mm_thread_characteristics_function set_mm_thread_characteristics = + nullptr; + revert_mm_thread_characteristics_function revert_mm_thread_characteristics = + nullptr; }; class wasapi_endpoint_notification_client; @@ -1401,7 +1413,8 @@ static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream) /* We could consider using "Pro Audio" here for WebAudio and maybe WebRTC. */ - mmcss_handle = AvSetMmThreadCharacteristicsA("Audio", &mmcss_task_index); + mmcss_handle = + stm->context->set_mm_thread_characteristics(L"Audio", &mmcss_task_index); if (!mmcss_handle) { /* This is not fatal, but we might glitch under heavy load. */ LOG("Unable to use mmcss to bump the render thread priority: %lx", @@ -1509,7 +1522,7 @@ static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream) } if (mmcss_handle) { - AvRevertMmThreadCharacteristics(mmcss_handle); + stm->context->revert_mm_thread_characteristics(mmcss_handle); } if (FAILED(hr)) { @@ -1522,6 +1535,18 @@ static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream) void wasapi_destroy(cubeb * context); +HANDLE WINAPI +set_mm_thread_characteristics_noop(LPCWSTR, LPDWORD mmcss_task_index) +{ + return (HANDLE)1; +} + +BOOL WINAPI +revert_mm_thread_characteristics_noop(HANDLE mmcss_handle) +{ + return true; +} + HRESULT register_notification_client(cubeb_stream * stm) { @@ -1757,6 +1782,31 @@ wasapi_init(cubeb ** context, char const * context_name) ctx->performance_counter_frequency = 0; } + ctx->mmcss_module = LoadLibraryW(L"Avrt.dll"); + + bool success = false; + if (ctx->mmcss_module) { + ctx->set_mm_thread_characteristics = + reinterpret_cast( + GetProcAddress(ctx->mmcss_module, "AvSetMmThreadCharacteristicsW")); + ctx->revert_mm_thread_characteristics = + reinterpret_cast( + GetProcAddress(ctx->mmcss_module, + "AvRevertMmThreadCharacteristics")); + success = ctx->set_mm_thread_characteristics && + ctx->revert_mm_thread_characteristics; + } + if (!success) { + // This is not a fatal error, but we might end up glitching when + // the system is under high load. + LOG("Could not load avrt.dll or fetch AvSetMmThreadCharacteristicsW " + "AvRevertMmThreadCharacteristics: %lx", + GetLastError()); + ctx->set_mm_thread_characteristics = &set_mm_thread_characteristics_noop; + ctx->revert_mm_thread_characteristics = + &revert_mm_thread_characteristics_noop; + } + *context = ctx; return CUBEB_OK; @@ -1813,6 +1863,10 @@ wasapi_destroy(cubeb * context) } } + if (context->mmcss_module) { + FreeLibrary(context->mmcss_module); + } + delete context; } diff --git a/third_party/rust/cubeb-sys/libcubeb/test/test_audio_dump.cpp b/third_party/rust/cubeb-sys/libcubeb/test/test_audio_dump.cpp new file mode 100644 index 000000000000..f01c609a2711 --- /dev/null +++ b/third_party/rust/cubeb-sys/libcubeb/test/test_audio_dump.cpp @@ -0,0 +1,74 @@ +/* + * Copyright © 2023 Mozilla Foundation + * + * This program is made available under an ISC-style license. See the + * accompanying file LICENSE for details. + */ + +#define NOMINMAX +#define _USE_MATH_DEFINES + +#include "cubeb/cubeb.h" +#include + +#include "cubeb_audio_dump.h" +#include "gtest/gtest.h" +#include +#include +#include +#include +#include + +TEST(cubeb, audio_dump) +{ + cubeb_audio_dump_session_t session; + int rv = cubeb_audio_dump_init(&session); + ASSERT_EQ(rv, 0); + + cubeb_stream_params params; + params.rate = 44100; + params.channels = 2; + params.format = CUBEB_SAMPLE_FLOAT32NE; + + cubeb_audio_dump_stream_t dump_stream; + rv = cubeb_audio_dump_stream_init(session, &dump_stream, params, "test.wav"); + ASSERT_EQ(rv, 0); + + rv = cubeb_audio_dump_start(session); + ASSERT_EQ(rv, 0); + + float phase = 0; + const size_t buf_sz = 2 * 44100 / 50; + float buf[buf_sz]; + for (uint32_t iteration = 0; iteration < 50; iteration++) { + uint32_t write_idx = 0; + for (uint32_t i = 0; i < buf_sz / params.channels; i++) { + for (uint32_t j = 0; j < params.channels; j++) { + buf[write_idx++] = sin(phase); + } + phase += 440 * M_PI * 2 / 44100; + if (phase > 2 * M_PI) { + phase -= 2 * M_PI; + } + } + rv = cubeb_audio_dump_write(dump_stream, buf, 2 * 44100 / 50); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + ASSERT_EQ(rv, 0); + } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + rv = cubeb_audio_dump_stop(session); + ASSERT_EQ(rv, 0); + + rv = cubeb_audio_dump_stream_shutdown(session, dump_stream); + ASSERT_EQ(rv, 0); + + rv = cubeb_audio_dump_shutdown(session); + ASSERT_EQ(rv, 0); + + std::ifstream file("test.wav"); + ASSERT_TRUE(file.good()); +} + +#undef NOMINMAX diff --git a/third_party/rust/cubeb-sys/libcubeb/test/test_duplex.cpp b/third_party/rust/cubeb-sys/libcubeb/test/test_duplex.cpp index 518f44f509e1..98a67013a3d5 100644 --- a/third_party/rust/cubeb-sys/libcubeb/test/test_duplex.cpp +++ b/third_party/rust/cubeb-sys/libcubeb/test/test_duplex.cpp @@ -201,6 +201,7 @@ TEST(cubeb, duplex_collection_change) ASSERT_EQ(r, CUBEB_OK); } +#ifdef GTEST_HAS_DEATH_TEST TEST(cubeb, duplex_collection_change_no_unregister) { cubeb * ctx; @@ -221,6 +222,7 @@ TEST(cubeb, duplex_collection_change_no_unregister) duplex_collection_change_impl(ctx); } +#endif long data_cb_input(cubeb_stream * stream, void * user, const void * inputbuffer, diff --git a/third_party/rust/cubeb-sys/src/audio_dump.rs b/third_party/rust/cubeb-sys/src/audio_dump.rs new file mode 100644 index 000000000000..7ba8688708f2 --- /dev/null +++ b/third_party/rust/cubeb-sys/src/audio_dump.rs @@ -0,0 +1,35 @@ +// Copyright © 2017-2023 Mozilla Foundation +// +// This program is made available under an ISC-style license. See the +// accompanying file LICENSE for details. + +use std::os::raw::{c_char, c_int, c_void}; +use stream::cubeb_stream_params; + +pub enum cubeb_audio_dump_stream {} +pub enum cubeb_audio_dump_session {} +pub type cubeb_audio_dump_stream_t = *mut cubeb_audio_dump_stream; +pub type cubeb_audio_dump_session_t = *mut cubeb_audio_dump_session; + +extern "C" { + pub fn cubeb_audio_dump_init(session: *mut cubeb_audio_dump_session_t) -> c_int; + pub fn cubeb_audio_dump_shutdown(session: cubeb_audio_dump_session_t) -> c_int; + pub fn cubeb_audio_dump_stream_init( + session: cubeb_audio_dump_session_t, + stream: *mut cubeb_audio_dump_stream_t, + stream_params: cubeb_stream_params, + name: *const c_char, + ) -> c_int; + pub fn cubeb_audio_dump_stream_shutdown( + session: cubeb_audio_dump_session_t, + stream: cubeb_audio_dump_stream_t, + ) -> c_int; + pub fn cubeb_audio_dump_start(session: cubeb_audio_dump_session_t) -> c_int; + pub fn cubeb_audio_dump_stop(session: cubeb_audio_dump_session_t) -> c_int; + pub fn cubeb_audio_dump_write( + stream: cubeb_audio_dump_stream_t, + audio_samples: *mut c_void, + count: u32, + ) -> c_int; + +} diff --git a/third_party/rust/cubeb-sys/src/lib.rs b/third_party/rust/cubeb-sys/src/lib.rs index 7767910ff6c0..fca6aa04be41 100644 --- a/third_party/rust/cubeb-sys/src/lib.rs +++ b/third_party/rust/cubeb-sys/src/lib.rs @@ -8,6 +8,7 @@ #[macro_use] mod macros; +mod audio_dump; mod callbacks; mod channel; mod context; @@ -19,6 +20,7 @@ mod mixer; mod resampler; mod stream; +pub use audio_dump::*; pub use callbacks::*; pub use channel::*; pub use context::*; diff --git a/third_party/rust/cubeb/.cargo-checksum.json b/third_party/rust/cubeb/.cargo-checksum.json index f68cd93289c9..78b758645d1f 100644 --- a/third_party/rust/cubeb/.cargo-checksum.json +++ b/third_party/rust/cubeb/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"d3b573eee37b0b0f709f168d4026071803c499f8c0d3efb830367d762c40754f","Cargo.toml":"8b0bd9b5b8f74492a893f3281dd14ca6ebd0f47ce3368c9927f16b76498fc340","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","README.md":"408c573ec240927cf5b9c036098e94e374ec41f71991415422586f450586b214","examples/common/mod.rs":"3363405f3d21ad120617473a0288c337a7b15eb79f5bb1035cfd258bd9bedf2b","examples/devices.rs":"ff5dcd588e7036165c4b4c20ec355d036e0ae90cf88b3b0f5cd86621fe2ce61d","examples/tone.rs":"8f5f9851b6d99f6f16c597fcb9312e3ef81769cbfb89341d2ea2522ca2e2214e","src/context.rs":"176f0923c13245acdc3934f649608fea1c17ad254daa3396d8929f38374e932e","src/frame.rs":"649cedaa2e9e1c5d2c3146bd0d66fd28bb230e68142493a9ea7dbab4a15f5adc","src/lib.rs":"58c78cad9541ebaef0ea96c67bc1db7d25e68e4e3d2f9a90f371c473e25c181f","src/sample.rs":"0d4645cc1d6ac26f198f6f59a44e193422e5646ecef0de46224653bef79d1a10","src/stream.rs":"0f51eab71d08685afdd0e748b85513541b9a612da1cad329c8c897dc0f79607c"},"package":"6db57570f2617f0214c11721e8d2325816d9dc936c2c472661ac5d90a30fba98"} \ No newline at end of file +{"files":{"Cargo.lock":"d86a793ee92e01a15c886f5f73c9823eead21298f88455fa71717aeefa9b1af3","Cargo.toml":"4642a8d5f6fce1799a16b9e43d326e5aee5b886f51c2dded8617c6d6b659f81c","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","README.md":"408c573ec240927cf5b9c036098e94e374ec41f71991415422586f450586b214","examples/common/mod.rs":"3363405f3d21ad120617473a0288c337a7b15eb79f5bb1035cfd258bd9bedf2b","examples/devices.rs":"ff5dcd588e7036165c4b4c20ec355d036e0ae90cf88b3b0f5cd86621fe2ce61d","examples/tone.rs":"8f5f9851b6d99f6f16c597fcb9312e3ef81769cbfb89341d2ea2522ca2e2214e","src/context.rs":"176f0923c13245acdc3934f649608fea1c17ad254daa3396d8929f38374e932e","src/frame.rs":"649cedaa2e9e1c5d2c3146bd0d66fd28bb230e68142493a9ea7dbab4a15f5adc","src/lib.rs":"58c78cad9541ebaef0ea96c67bc1db7d25e68e4e3d2f9a90f371c473e25c181f","src/sample.rs":"a8ed35c007541722e4322df82035086f160072ce549b34a73d54052148bcae07","src/stream.rs":"0f51eab71d08685afdd0e748b85513541b9a612da1cad329c8c897dc0f79607c"},"package":"3d105547cf8036cdb30e796ce0d06832af4766106a44574402fa2fd3c861a042"} \ No newline at end of file diff --git a/third_party/rust/cubeb/Cargo.lock b/third_party/rust/cubeb/Cargo.lock index 726259fde983..eaf5bcecb8ba 100644 --- a/third_party/rust/cubeb/Cargo.lock +++ b/third_party/rust/cubeb/Cargo.lock @@ -10,9 +10,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" [[package]] name = "cmake" @@ -25,16 +25,16 @@ dependencies = [ [[package]] name = "cubeb" -version = "0.12.0" +version = "0.13.0" dependencies = [ "cubeb-core", ] [[package]] name = "cubeb-core" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380c03a7df0ea3744f6a210d6340f423935e53cbf2fd68ada84b5e808e46ac7" +checksum = "ac08d314dd1ec6d41d9ccdeec70899c98ed3b89845367000dd6096099481bc73" dependencies = [ "bitflags", "cubeb-sys", @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "cubeb-sys" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c20c457d7b34dad6e0c1a9c759c96b4420b9e9917a572998b81835799a07e1d" +checksum = "26073cd50c7b6ba4272204839f56921557609a0d67e092882cbb903df94cab39" dependencies = [ "cmake", "pkg-config", @@ -52,6 +52,6 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" diff --git a/third_party/rust/cubeb/Cargo.toml b/third_party/rust/cubeb/Cargo.toml index d79451598cc6..08fc56b93313 100644 --- a/third_party/rust/cubeb/Cargo.toml +++ b/third_party/rust/cubeb/Cargo.toml @@ -11,7 +11,7 @@ [package] name = "cubeb" -version = "0.12.0" +version = "0.13.0" authors = ["Dan Glastonbury "] description = """ Bindings to libcubeb for interacting with system audio from rust. @@ -24,7 +24,7 @@ license = "ISC" repository = "https://github.com/mozilla/cubeb-rs" [dependencies.cubeb-core] -version = "0.12.0" +version = "0.13.0" [features] gecko-in-tree = ["cubeb-core/gecko-in-tree"] diff --git a/third_party/rust/cubeb/src/sample.rs b/third_party/rust/cubeb/src/sample.rs index 7d4dc7d475ce..de9e05a6498d 100644 --- a/third_party/rust/cubeb/src/sample.rs +++ b/third_party/rust/cubeb/src/sample.rs @@ -13,7 +13,7 @@ pub trait Sample: Send + Copy { impl Sample for i16 { fn from_float(x: f32) -> i16 { - (x * f32::from(i16::max_value())) as i16 + (x * f32::from(i16::MAX)) as i16 } } diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 8927ad1041f0..f49d3f5d941b 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -22,11 +22,11 @@ static_prefs = { path = "../../../../modules/libpref/init/static_prefs" } profiler_helper = { path = "../../../../tools/profiler/rust-helper", optional = true } mozurl = { path = "../../../../netwerk/base/mozurl" } webrender_bindings = { path = "../../../../gfx/webrender_bindings" } -cubeb-coreaudio = { git = "https://github.com/mozilla/cubeb-coreaudio-rs", rev = "4ca174cf83ebe32b3198478c2211d69678845bc7", optional = true } -cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="8ff972c8e2ec1782ff262ac4071c0415e69b1367", optional = true, features=["pulse-dlopen"] } -cubeb-sys = { version = "0.12.0", optional = true, features=["gecko-in-tree"] } -audioipc2-client = { git = "https://github.com/mozilla/audioipc", rev = "409e11f8de6288e9ddfe269654523735302e59e6", optional = true } -audioipc2-server = { git = "https://github.com/mozilla/audioipc", rev = "409e11f8de6288e9ddfe269654523735302e59e6", optional = true } +cubeb-coreaudio = { git = "https://github.com/mozilla/cubeb-coreaudio-rs", rev = "0989726a1b9b640a30dfdf3ea005a12c73ab8155", optional = true } +cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="8678dcab1c287de79c4c184ccc2e065bc62b70e2", optional = true, features=["pulse-dlopen"] } +cubeb-sys = { version = "0.13", optional = true, features=["gecko-in-tree"] } +audioipc2-client = { git = "https://github.com/mozilla/audioipc", rev = "3495905752a4263827f5d43737f9ca3ed0243ce0", optional = true } +audioipc2-server = { git = "https://github.com/mozilla/audioipc", rev = "3495905752a4263827f5d43737f9ca3ed0243ce0", optional = true } encoding_glue = { path = "../../../../intl/encoding_glue" } authrs_bridge = { path = "../../../../dom/webauthn/authrs_bridge" } gkrust_utils = { path = "../../../../xpcom/rust/gkrust_utils" }