Skip to content

Commit ba7f8b6

Browse files
committed
print only on debug mode
1 parent 24474a8 commit ba7f8b6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/gameboy.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ impl Gameboy {
8989
let _audio_stream = match crate::sound::cpal_audio::CpalPlayer::new() {
9090
Some((player, stream)) => {
9191
self.enable_audio(Box::new(player));
92+
#[cfg(debug_assertions)]
9293
eprintln!("Audio enabled successfully");
9394
Some(stream)
9495
}
9596
None => {
97+
#[cfg(debug_assertions)]
9698
eprintln!("Failed to initialize audio");
9799
None
98100
}

src/sound.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ impl Sound {
767767
}
768768

769769
// Debug: log sound register writes
770+
#[cfg(debug_assertions)]
770771
if a == 0xFF26 && v & 0x80 == 0x80 {
771772
println!("Sound enabled");
772773
}
@@ -908,6 +909,7 @@ pub mod cpal_audio {
908909
let device = match cpal::default_host().default_output_device() {
909910
Some(e) => e,
910911
None => {
912+
#[cfg(debug_assertions)]
911913
eprintln!("No default output device found");
912914
return None;
913915
}
@@ -917,6 +919,7 @@ pub mod cpal_audio {
917919
let supported_configs = match device.supported_output_configs() {
918920
Ok(e) => e,
919921
Err(err) => {
922+
#[cfg(debug_assertions)]
920923
eprintln!("Failed to get supported configs: {}", err);
921924
return None;
922925
}
@@ -935,6 +938,7 @@ pub mod cpal_audio {
935938
}
936939
}
937940
if supported_config.is_none() {
941+
#[cfg(debug_assertions)]
938942
eprintln!("No supported audio configuration found");
939943
return None;
940944
}
@@ -944,8 +948,10 @@ pub mod cpal_audio {
944948
let channels = selected_config.channels();
945949
let config: cpal::StreamConfig = selected_config.into();
946950

947-
let err_fn =
948-
|err| eprintln!("An error occurred on the output audio stream: {}", err);
951+
let err_fn = |err| {
952+
#[cfg(debug_assertions)]
953+
eprintln!("An error occurred on the output audio stream: {}", err);
954+
};
949955

950956
let shared_buffer = Arc::new(Mutex::new(Vec::new()));
951957
let stream_buffer = shared_buffer.clone();
@@ -970,12 +976,14 @@ pub mod cpal_audio {
970976
match stream {
971977
Ok(s) => {
972978
if let Err(e) = s.play() {
979+
#[cfg(debug_assertions)]
973980
eprintln!("Failed to play audio stream: {}", e);
974981
return None;
975982
}
976983
Some((player, s))
977984
}
978985
Err(e) => {
986+
#[cfg(debug_assertions)]
979987
eprintln!("Failed to build audio stream: {}", e);
980988
None
981989
}

0 commit comments

Comments
 (0)