logging
This commit is contained in:
parent
e8550cc2a5
commit
97c52fe8f3
@ -58,12 +58,12 @@ void audioStop() {
|
|||||||
bool audioPlayInit(const Entry &entry) {
|
bool audioPlayInit(const Entry &entry) {
|
||||||
audioStop();
|
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;
|
running = true;
|
||||||
|
|
||||||
if (entry.type == "ICY" || entry.type == "SNAP") {
|
if (entry.type == "ICY" || entry.type == "SNAP") {
|
||||||
if (!isWifiConnected()) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ bool audioPlayInit(const Entry &entry) {
|
|||||||
|
|
||||||
if (entry.type == "SD") {
|
if (entry.type == "SD") {
|
||||||
if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -82,13 +82,13 @@ bool audioPlayInit(const Entry &entry) {
|
|||||||
|
|
||||||
bool audioBeginMP3Stream(const Entry &entry, Stream &source) {
|
bool audioBeginMP3Stream(const Entry &entry, Stream &source) {
|
||||||
if (!mp3Decoder.begin()) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mp3Stream.begin()) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -96,11 +96,12 @@ bool audioBeginMP3Stream(const Entry &entry, Stream &source) {
|
|||||||
copier.begin(mp3Stream, source);
|
copier.begin(mp3Stream, source);
|
||||||
|
|
||||||
if (copier.copy() == 0) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Serial.printf("[AUDIO ] [%s] Stream running.\n", entry.type.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ bool audioPlayICY(const Entry &entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!icy.begin(entry.url.c_str())) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -125,30 +126,31 @@ bool audioPlaySNAP(const Entry &entry) {
|
|||||||
|
|
||||||
IPAddress ip;
|
IPAddress ip;
|
||||||
if (!WiFiClass::hostByName(entry.url.c_str(), 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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
snap.setServerIP(ip);
|
snap.setServerIP(ip);
|
||||||
if (!snap.begin()) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opusDecoder.begin()) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!snap.doLoop()) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Serial.printf("[AUDIO ] [%s] Stream running.\n", entry.type.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,14 +160,14 @@ bool audioPlaySD(const Entry &entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!SD.exists(entry.url.c_str())) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = SD.open(entry.url.c_str(), FILE_READ);
|
file = SD.open(entry.url.c_str(), FILE_READ);
|
||||||
if (!file) {
|
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();
|
audioStop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user