mirror of
https://github.com/RustAudio/rodio
synced 2025-03-04 15:07:18 +00:00
Ignore errors if background thread spawning fails
This commit is contained in:
parent
d12b6d560f
commit
a2081a9e41
1 changed files with 5 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::thread;
|
||||
use std::thread::{self, Builder};
|
||||
use std::sync::mpsc::{self, Sender, Receiver};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::Mutex;
|
||||
|
@ -21,7 +21,10 @@ impl Engine {
|
|||
/// Builds the engine.
|
||||
pub fn new() -> Engine {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
thread::spawn(move || background(rx));
|
||||
// we ignore errors when creating the background thread
|
||||
// the user won't get any audio, but that's better than a panic
|
||||
let _ = Builder::new().name("rodio audio processing".to_string())
|
||||
.spawn(move || background(rx));
|
||||
Engine { commands: Mutex::new(tx), next_sound_id: AtomicUsize::new(1) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue