Bug 1735905 - Upgrade cubeb-pulse to fix a race condition that can lead to shutdown deadlock. r=kinetik

Differential Revision: https://phabricator.services.mozilla.com/D128657
This commit is contained in:
Mike Hommey 2021-10-16 01:19:56 +00:00
Родитель 6ff665fec1
Коммит 0cc5c4b32e
5 изменённых файлов: 25 добавлений и 20 удалений

Просмотреть файл

@ -25,7 +25,7 @@ rev = "fd02134161505f978e132114cbabdac057ce3b71"
[source."https://github.com/mozilla/cubeb-pulse-rs"]
git = "https://github.com/mozilla/cubeb-pulse-rs"
replace-with = "vendored-sources"
rev = "e9e55a4529642da99e64452467ecaef9f7753531"
rev = "9695281319fcb3e40db6a32cc0661548d6192f4d"
[source."https://github.com/mozilla/cubeb-coreaudio-rs"]
git = "https://github.com/mozilla/cubeb-coreaudio-rs"

6
Cargo.lock сгенерированный
Просмотреть файл

@ -1059,7 +1059,7 @@ dependencies = [
[[package]]
name = "cubeb-pulse"
version = "0.3.0"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=e9e55a4529642da99e64452467ecaef9f7753531#e9e55a4529642da99e64452467ecaef9f7753531"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=9695281319fcb3e40db6a32cc0661548d6192f4d#9695281319fcb3e40db6a32cc0661548d6192f4d"
dependencies = [
"cubeb-backend",
"pulse",
@ -3935,7 +3935,7 @@ dependencies = [
[[package]]
name = "pulse"
version = "0.3.0"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=e9e55a4529642da99e64452467ecaef9f7753531#e9e55a4529642da99e64452467ecaef9f7753531"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=9695281319fcb3e40db6a32cc0661548d6192f4d#9695281319fcb3e40db6a32cc0661548d6192f4d"
dependencies = [
"bitflags",
"pulse-ffi",
@ -3944,7 +3944,7 @@ dependencies = [
[[package]]
name = "pulse-ffi"
version = "0.1.0"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=e9e55a4529642da99e64452467ecaef9f7753531#e9e55a4529642da99e64452467ecaef9f7753531"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=9695281319fcb3e40db6a32cc0661548d6192f4d#9695281319fcb3e40db6a32cc0661548d6192f4d"
dependencies = [
"libc",
]

Просмотреть файл

@ -1 +1 @@
{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".github/workflows/build.yml":"95d0d2542c04f0c932f58591b92c3051db5c95657bf5f24b6a6110f7b667568d","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"56e90cb82ec36ead07e551a28fc2455fa658fa8308c3d73f8d856d85bfcd2122","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"0079450bb4b013bac065ed1750851e461a3710ebad1f323817da1cb82db0bc4f","src/backend/context.rs":"8969b300850b56ace07abe570940e2099774bf0bf20325be1d3ec0f5f408c8ce","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"11ca424e4eb77f8eb9fd5a6717d1e791facf9743156a8534f0016fcf64d57b0f","src/backend/mod.rs":"d5da05348bf1a7f65c85b14372964a49dc4849f0aee96c75e2c18b51fb03fcaf","src/backend/stream.rs":"b17829f1b65055ada69454d0714dd7526d4d5cdeda7bba4ee03ffb6f27297e61","src/capi.rs":"fa0fa020f0d0efe55aa0fc3596405e8407bbe2cbe6c7a558345304e6da87994e","src/lib.rs":"b41bbdc562cbfb130ed7c1e53fe69944774f515705341d8ce48a2f82c8c0c2c5"},"package":null}
{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".github/workflows/build.yml":"95d0d2542c04f0c932f58591b92c3051db5c95657bf5f24b6a6110f7b667568d","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"56e90cb82ec36ead07e551a28fc2455fa658fa8308c3d73f8d856d85bfcd2122","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"0079450bb4b013bac065ed1750851e461a3710ebad1f323817da1cb82db0bc4f","src/backend/context.rs":"8969b300850b56ace07abe570940e2099774bf0bf20325be1d3ec0f5f408c8ce","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"11ca424e4eb77f8eb9fd5a6717d1e791facf9743156a8534f0016fcf64d57b0f","src/backend/mod.rs":"d5da05348bf1a7f65c85b14372964a49dc4849f0aee96c75e2c18b51fb03fcaf","src/backend/stream.rs":"585b616d5487c77f6aa21a76aa6a0f7ae9de8c389bc908401a979fba8bf3450f","src/capi.rs":"fa0fa020f0d0efe55aa0fc3596405e8407bbe2cbe6c7a558345304e6da87994e","src/lib.rs":"b41bbdc562cbfb130ed7c1e53fe69944774f515705341d8ce48a2f82c8c0c2c5"},"package":null}

Просмотреть файл

@ -15,7 +15,7 @@ use ringbuf::RingBuffer;
use std::ffi::{CStr, CString};
use std::os::raw::{c_long, c_void};
use std::slice;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::{mem, ptr};
use self::LinearInputBuffer::*;
@ -272,7 +272,7 @@ pub struct PulseStream<'ctx> {
input_stream: Option<pulse::Stream>,
data_callback: ffi::cubeb_data_callback,
state_callback: ffi::cubeb_state_callback,
drain_timer: *mut pa_time_event,
drain_timer: AtomicPtr<pa_time_event>,
output_sample_spec: pulse::SampleSpec,
input_sample_spec: pulse::SampleSpec,
// output frames count excluding pre-buffering
@ -411,7 +411,7 @@ impl<'ctx> PulseStream<'ctx> {
data_callback,
state_callback,
user_ptr,
drain_timer: ptr::null_mut(),
drain_timer: AtomicPtr::new(ptr::null_mut()),
output_sample_spec: pulse::SampleSpec::default(),
input_sample_spec: pulse::SampleSpec::default(),
output_frame_count: AtomicUsize::new(0),
@ -574,9 +574,10 @@ impl<'ctx> PulseStream<'ctx> {
self.context.mainloop.lock();
{
if let Some(stm) = self.output_stream.take() {
if !self.drain_timer.is_null() {
let drain_timer = self.drain_timer.load(Ordering::Acquire);
if !drain_timer.is_null() {
/* there's no pa_rttime_free, so use this instead. */
self.context.mainloop.get_api().time_free(self.drain_timer);
self.context.mainloop.get_api().time_free(drain_timer);
}
stm.clear_state_callback();
stm.clear_write_callback();
@ -637,7 +638,7 @@ impl<'ctx> StreamOps for PulseStream<'ctx> {
self.shutdown = true;
// If draining is taking place wait to finish
cubeb_log!("Stream stop: waiting for drain.");
while !self.drain_timer.is_null() {
while !self.drain_timer.load(Ordering::Acquire).is_null() {
self.context.mainloop.wait();
}
cubeb_log!("Stream stop: waited for drain.");
@ -988,11 +989,12 @@ impl<'ctx> PulseStream<'ctx> {
) {
cubeb_logv!("Drain finished callback.");
let stm = unsafe { &mut *(u as *mut PulseStream) };
debug_assert_eq!(stm.drain_timer, e);
let drain_timer = stm.drain_timer.load(Ordering::Acquire);
debug_assert_eq!(drain_timer, e);
stm.state_change_callback(ffi::CUBEB_STATE_DRAINED);
/* there's no pa_rttime_free, so use this instead. */
a.time_free(stm.drain_timer);
stm.drain_timer = ptr::null_mut();
a.time_free(drain_timer);
stm.drain_timer.store(ptr::null_mut(), Ordering::Release);
stm.context.mainloop.signal();
}
@ -1109,13 +1111,16 @@ impl<'ctx> PulseStream<'ctx> {
/* pa_stream_drain is useless, see PA bug# 866. this is a workaround. */
/* arbitrary safety margin: double the current latency. */
debug_assert!(self.drain_timer.is_null());
debug_assert!(self.drain_timer.load(Ordering::Acquire).is_null());
let stream_ptr = self as *const _ as *mut _;
if let Some(ref context) = self.context.context {
self.drain_timer = context.rttime_new(
pulse::rtclock_now() + 2 * latency,
drained_cb,
stream_ptr,
self.drain_timer.store(
context.rttime_new(
pulse::rtclock_now() + 2 * latency,
drained_cb,
stream_ptr,
),
Ordering::Release,
);
}
self.shutdown = true;

Просмотреть файл

@ -20,7 +20,7 @@ profiler_helper = { path = "../../../../tools/profiler/rust-helper", optional =
mozurl = { path = "../../../../netwerk/base/mozurl" }
webrender_bindings = { path = "../../../../gfx/webrender_bindings" }
cubeb-coreaudio = { git = "https://github.com/mozilla/cubeb-coreaudio-rs", rev = "5ada876e8b73246b9bb0b5855f9143a0a9848467", optional = true }
cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="e9e55a4529642da99e64452467ecaef9f7753531", optional = true, features=["pulse-dlopen"] }
cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="9695281319fcb3e40db6a32cc0661548d6192f4d", optional = true, features=["pulse-dlopen"] }
cubeb-sys = { version = "0.9", optional = true, features=["gecko-in-tree"] }
encoding_glue = { path = "../../../../intl/encoding_glue" }
audioipc-client = { git = "https://github.com/mozilla/audioipc-2", rev = "03868a0eaf1d46e895353fa6e1f5bcaf7e588e62", optional = true }