chore: assign name to audio thread

This commit is contained in:
Rekai Nyangadzayi Musuka 2020-12-08 17:07:36 -06:00
parent 72cf545e79
commit 45df95704d
1 changed files with 14 additions and 12 deletions

View File

@ -2,6 +2,7 @@ use rodio::{Decoder, OutputStream, Sink};
use std::fs::File; use std::fs::File;
use std::io::BufReader; use std::io::BufReader;
use std::path::PathBuf; use std::path::PathBuf;
use std::thread;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Alert { pub struct Alert {
@ -20,7 +21,9 @@ impl Alert {
pub fn play(&self) { pub fn play(&self) {
let file = File::open(&self.path).unwrap(); let file = File::open(&self.path).unwrap();
std::thread::spawn(move || { thread::Builder::new()
.name("Audio Thread".to_string())
.spawn(move || {
let (_stream, handle) = OutputStream::try_default().unwrap(); let (_stream, handle) = OutputStream::try_default().unwrap();
let source = Decoder::new(BufReader::new(file)).unwrap(); let source = Decoder::new(BufReader::new(file)).unwrap();
let sink = Sink::try_new(&handle).unwrap(); let sink = Sink::try_new(&handle).unwrap();
@ -32,8 +35,7 @@ impl Alert {
break; break;
} }
} }
})
println!("Exited Playback Thread."); .unwrap();
});
} }
} }