Skip to content

Commit ed2fa10

Browse files
EdwardStanford7stacksjb
authored andcommitted
Fixed audio loading issue and cargo clippy
1 parent 50dce4b commit ed2fa10

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/menu_main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ pub async fn display_menu(config_path: &PathBuf) {
4848
let term_height = get_terminal_height() as usize;
4949
let display_height = term_height.saturating_sub(3);
5050

51-
if config.window_title_support {
52-
if let Some(title) = &config.window_title {
53-
set_window_title(title);
54-
}
51+
if config.window_title_support
52+
&& let Some(title) = &config.window_title
53+
{
54+
set_window_title(title);
5555
}
5656

5757
clear_screen();

src/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rodio::{Decoder, OutputStream, Sink};
1+
use rodio::{Decoder, OutputStreamBuilder, Sink};
22
use std::fs::File;
33
use std::io::{BufReader, Write, stdin, stdout};
44
use std::path::PathBuf;
@@ -40,16 +40,17 @@ pub async fn play_sound(file_path: PathBuf) {
4040
let file_path = file_path.clone(); // Cloning the PathBuf to be owned by the closure
4141
task::spawn_blocking(move || {
4242
// Spawning a blocking task
43-
match OutputStream::try_default() {
44-
Ok((_stream, stream_handle)) => {
43+
44+
match OutputStreamBuilder::open_default_stream() {
45+
Ok(stream_handle) => {
4546
// Trying to get the default audio output stream
4647
match File::open(&file_path) {
4748
Ok(file) => {
4849
// Trying to open the audio file
4950
match Decoder::new(BufReader::new(file)) {
5051
Ok(source) => {
5152
// Trying to decode the audio file
52-
let sink = Sink::try_new(&stream_handle).unwrap(); // Creating a sink for the audio stream
53+
let sink = Sink::connect_new(stream_handle.mixer()); // Creating a sink for the audio stream
5354
sink.append(source); // Appending the audio source to the sink
5455
sink.sleep_until_end(); // Sleeping until the audio playback ends
5556
}

0 commit comments

Comments
 (0)