Skip to content

Commit 3758c35

Browse files
committed
Fix pulseaudio core dump.
1 parent 8a276dc commit 3758c35

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ simple_logger = { version = "5.0.0", default-features = false, features = [
2828
"stderr",
2929
"colors",
3030
] }
31-
slimproto = "0.1.24"
31+
slimproto = "0.1.25"
3232
symphonia = { version = "0.5.4", features = ["all-codecs", "all-formats"] }
3333

3434
[profile.dev.package."symphonia"]

src/pulse_out.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ impl Stream {
6060
.set_write_callback(Some(callback));
6161
}
6262

63+
fn unset_write_callback(&mut self) {
64+
(*self.inner).borrow_mut().set_write_callback(None);
65+
}
66+
6367
fn set_underflow_callback(&mut self, callback: Option<Box<dyn FnMut() + 'static>>) {
6468
(*self.inner).borrow_mut().set_underflow_callback(callback)
6569
}
@@ -411,7 +415,6 @@ impl AudioOutput for PulseAudioOutput {
411415
self.enqueue(stream, stream_params.autostart, stream_in.clone());
412416
}
413417

414-
415418
fn unpause(&mut self) -> bool {
416419
if let Some(ref mut stream) = self.playing {
417420
(*self.mainloop).borrow_mut().lock();
@@ -437,6 +440,7 @@ impl AudioOutput for PulseAudioOutput {
437440
fn stop(&mut self) {
438441
if let Some(ref mut stream) = self.playing {
439442
(*self.mainloop).borrow_mut().lock();
443+
stream.unset_write_callback();
440444
stream.disconnect().ok();
441445
(*self.mainloop).borrow_mut().unlock();
442446
}
@@ -449,18 +453,7 @@ impl AudioOutput for PulseAudioOutput {
449453
}
450454

451455
fn shift(&mut self) {
452-
let old_stream = self.playing.take();
453456
self.playing = self.next_up.take();
454-
455-
if let Some(old_stream) = old_stream {
456-
if let Some(pa_stream) = Rc::into_inner(old_stream.into_inner()) {
457-
let mut pa_stream = pa_stream.into_inner();
458-
std::thread::spawn(move || {
459-
std::thread::sleep(Duration::from_secs(1));
460-
pa_stream.disconnect().ok();
461-
});
462-
};
463-
}
464457
}
465458

466459
fn get_dur(&self) -> Duration {

0 commit comments

Comments
 (0)