From 97c52fe8f3d5d51e3be8ebc5b4dee7b0e950b75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Fri, 6 Jun 2025 14:28:33 +0200 Subject: [PATCH] logging --- src/audio.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 482d094..4ea9164 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -58,12 +58,12 @@ void audioStop() { bool audioPlayInit(const Entry &entry) { audioStop(); - Serial.printf("[AUDIO ] [%-4s] Start: %s\n", entry.type.c_str(), entry.url.c_str()); + Serial.printf("[AUDIO ] [%s] Opening: %s\n", entry.type.c_str(), entry.url.c_str()); running = true; if (entry.type == "ICY" || entry.type == "SNAP") { if (!isWifiConnected()) { - Serial.printf("[AUDIO ] [%-4s] WiFi not connected.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] WiFi not connected.\n", entry.type.c_str()); audioStop(); return false; } @@ -71,7 +71,7 @@ bool audioPlayInit(const Entry &entry) { if (entry.type == "SD") { if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) { - Serial.printf("[AUDIO ] [%-4s] Failed to mount SD-card.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to mount SD-card.\n", entry.type.c_str()); audioStop(); return false; } @@ -82,13 +82,13 @@ bool audioPlayInit(const Entry &entry) { bool audioBeginMP3Stream(const Entry &entry, Stream &source) { if (!mp3Decoder.begin()) { - Serial.printf("[AUDIO ] [%-4s] Failed to start MP3DecoderHelix.", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to start MP3DecoderHelix.", entry.type.c_str()); audioStop(); return false; } if (!mp3Stream.begin()) { - Serial.printf("[AUDIO ] [%-4s] Failed to start EncodedAudioStream.", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to start EncodedAudioStream.", entry.type.c_str()); audioStop(); return false; } @@ -96,11 +96,12 @@ bool audioBeginMP3Stream(const Entry &entry, Stream &source) { copier.begin(mp3Stream, source); if (copier.copy() == 0) { - Serial.printf("[AUDIO ] [%-4s] Failed to copy initial data.", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to copy initial data.", entry.type.c_str()); audioStop(); return false; } + Serial.printf("[AUDIO ] [%s] Stream running.\n", entry.type.c_str()); return true; } @@ -110,7 +111,7 @@ bool audioPlayICY(const Entry &entry) { } if (!icy.begin(entry.url.c_str())) { - Serial.printf("[AUDIO ] [%-4s] Failed to start ICYStream.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to start ICYStream.\n", entry.type.c_str()); audioStop(); return false; } @@ -125,30 +126,31 @@ bool audioPlaySNAP(const Entry &entry) { IPAddress ip; if (!WiFiClass::hostByName(entry.url.c_str(), ip)) { - Serial.printf("[AUDIO ] [%-4s] Failed to resolve host.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to resolve host.\n", entry.type.c_str()); audioStop(); return false; } snap.setServerIP(ip); if (!snap.begin()) { - Serial.printf("[AUDIO ] [%-4s] Failed to connect.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to connect.\n", entry.type.c_str()); audioStop(); return false; } if (!opusDecoder.begin()) { - Serial.printf("[AUDIO ] [%-4s] Failed to start OpusAudioDecoder.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to start OpusAudioDecoder.\n", entry.type.c_str()); audioStop(); return false; } if (!snap.doLoop()) { - Serial.printf("[AUDIO ] [%-4s] Failed to copy initial data.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to copy initial data.\n", entry.type.c_str()); audioStop(); return false; } + Serial.printf("[AUDIO ] [%s] Stream running.\n", entry.type.c_str()); return true; } @@ -158,14 +160,14 @@ bool audioPlaySD(const Entry &entry) { } if (!SD.exists(entry.url.c_str())) { - Serial.printf("[AUDIO ] [%-4s] File not found.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] File not found.\n", entry.type.c_str()); audioStop(); return false; } file = SD.open(entry.url.c_str(), FILE_READ); if (!file) { - Serial.printf("[AUDIO ] [%-4s] Failed to open file.\n", entry.type.c_str()); + Serial.printf("[AUDIO ] [%s] Failed to open file.\n", entry.type.c_str()); audioStop(); return false; }