From cc874054b64b5f3c4d05c3205fea0f50dcc522b4 Mon Sep 17 00:00:00 2001 From: e2002 Date: Thu, 16 Mar 2023 17:55:06 +0300 Subject: [PATCH] player_queue_099 --- yoRadio/src/AsyncWebServer/AsyncTCP.cpp | 2 +- yoRadio/src/AsyncWebServer/AsyncTCP.h | 13 +++++- .../src/async-mqtt-client/AsyncMqttClient.cpp | 2 +- yoRadio/src/audioI2S/Audio.cpp | 20 ++++++--- yoRadio/src/audioI2S/AudioEx.h | 3 +- yoRadio/src/audioVS1053/audioVS1053Ex.cpp | 7 +++- yoRadio/src/audioVS1053/audioVS1053Ex.h | 2 + yoRadio/src/core/display.cpp | 9 ++-- yoRadio/src/core/netserver.cpp | 2 +- yoRadio/src/core/options.h | 5 ++- yoRadio/src/core/player.cpp | 19 +++++---- yoRadio/src/core/player.h | 2 +- yoRadio/src/core/telnet.cpp | 3 +- yoRadio/src/displays/conf/displayST7796conf.h | 2 +- yoRadio/src/displays/displayILI9488.h | 2 +- yoRadio/src/displays/displaySSD1322.h | 6 +-- yoRadio/src/displays/displayST7796.h | 4 +- yoRadio/src/displays/displayST7920.h | 4 +- yoRadio/yoRadio.ino | 41 ++++++++----------- 19 files changed, 90 insertions(+), 58 deletions(-) diff --git a/yoRadio/src/AsyncWebServer/AsyncTCP.cpp b/yoRadio/src/AsyncWebServer/AsyncTCP.cpp index 220b4de..d0c5344 100644 --- a/yoRadio/src/AsyncWebServer/AsyncTCP.cpp +++ b/yoRadio/src/AsyncWebServer/AsyncTCP.cpp @@ -95,7 +95,7 @@ static uint32_t _closed_index = []() { static inline bool _init_async_event_queue(){ if(!_async_queue){ - _async_queue = xQueueCreate(32, sizeof(lwip_event_packet_t *)); + _async_queue = xQueueCreate(XQUEUE_SIZE, sizeof(lwip_event_packet_t *)); if(!_async_queue){ return false; } diff --git a/yoRadio/src/AsyncWebServer/AsyncTCP.h b/yoRadio/src/AsyncWebServer/AsyncTCP.h index 28d6568..3c59026 100644 --- a/yoRadio/src/AsyncWebServer/AsyncTCP.h +++ b/yoRadio/src/AsyncWebServer/AsyncTCP.h @@ -32,12 +32,21 @@ extern "C" { //If core is not defined, then we are running in Arduino or PIO #ifndef CONFIG_ASYNC_TCP_RUNNING_CORE -#define CONFIG_ASYNC_TCP_RUNNING_CORE -1 //any available core -#define CONFIG_ASYNC_TCP_USE_WDT 1 //if enabled, adds between 33us and 200us per event + #define CONFIG_ASYNC_TCP_RUNNING_CORE 0 //any available core (-1) #endif + +#ifndef CONFIG_ASYNC_TCP_RUNNING_CORE + #define CONFIG_ASYNC_TCP_USE_WDT 0 //if enabled, adds between 33us and 200us per event (1) +#endif + #ifndef XTASK_MEM_SIZE #define XTASK_MEM_SIZE 8192 / 2 #endif + +#ifndef XQUEUE_SIZE + #define XQUEUE_SIZE 128 // (32) +#endif + class AsyncClient; #define ASYNC_MAX_ACK_TIME 5000 diff --git a/yoRadio/src/async-mqtt-client/AsyncMqttClient.cpp b/yoRadio/src/async-mqtt-client/AsyncMqttClient.cpp index 29c10eb..6ded588 100644 --- a/yoRadio/src/async-mqtt-client/AsyncMqttClient.cpp +++ b/yoRadio/src/async-mqtt-client/AsyncMqttClient.cpp @@ -736,7 +736,7 @@ uint16_t AsyncMqttClient::unsubscribe(const char* topic) { } uint16_t AsyncMqttClient::publish(const char* topic, uint8_t qos, bool retain, const char* payload, size_t length, bool dup, uint16_t message_id) { - if (_state != CONNECTED || GET_FREE_MEMORY() < MQTT_MIN_FREE_MEMORY) return 0; + if (_state != CONNECTED/* || GET_FREE_MEMORY() < MQTT_MIN_FREE_MEMORY*/) return 0; log_i("PUBLISH"); AsyncMqttClientInternals::OutPacket* msg = new AsyncMqttClientInternals::PublishOutPacket(topic, qos, retain, payload, length); diff --git a/yoRadio/src/audioI2S/Audio.cpp b/yoRadio/src/audioI2S/Audio.cpp index 2241f49..086217a 100644 --- a/yoRadio/src/audioI2S/Audio.cpp +++ b/yoRadio/src/audioI2S/Audio.cpp @@ -20,7 +20,10 @@ fs::SDFATFS SD_SDFAT; #endif #ifndef DMA_BUFCOUNT -#define DMA_BUFCOUNT 8 + #define DMA_BUFCOUNT 8 +#endif +#ifndef DMA_BUFLEN + #define DMA_BUFLEN 512 // (512) #endif //--------------------------------------------------------------------------------------------------------------------- AudioBuffer::AudioBuffer(size_t maxBlockSize) { @@ -182,7 +185,7 @@ Audio::Audio(bool internalDAC /* = false */, uint8_t channelEnabled /* = I2S_DAC #else m_i2s_config.dma_buf_count = psramInit()?16:DMA_BUFCOUNT; #endif - m_i2s_config.dma_buf_len = 512; + m_i2s_config.dma_buf_len = psramInit()?512:DMA_BUFLEN; m_i2s_config.use_apll = APLL_DISABLE; // must be disabled in V2.0.1-RC1 m_i2s_config.tx_desc_auto_clear = true; // new in V1.0.1 m_i2s_config.fixed_mclk = I2S_PIN_NO_CHANGE; @@ -374,6 +377,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { if(host == NULL) { AUDIO_INFO("Hostaddress is empty"); + if(audio_error) audio_error("Hostaddress is empty"); return false; } @@ -381,6 +385,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { if(lenHost >= 512 - 10) { AUDIO_INFO("Hostaddress is too long"); + if(audio_error) audio_error("Hostaddress is too long"); return false; } @@ -463,7 +468,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { strcat(rqh, "User-Agent: Mozilla/5.0\r\n"); strcat(rqh, "Connection: keep-alive\r\n\r\n"); - if(ESP_ARDUINO_VERSION_MAJOR == 2 && ESP_ARDUINO_VERSION_MINOR == 0 && ESP_ARDUINO_VERSION_PATCH >= 3){ + if(ESP_ARDUINO_VERSION_MAJOR == 2 && ESP_ARDUINO_VERSION_MINOR == 0 && ESP_ARDUINO_VERSION_PATCH >= 3 && MAX_AUDIO_SOCKET_TIMEOUT){ m_timeout_ms_ssl = UINT16_MAX; // bug in v2.0.3 if hostwoext is a IPaddr not a name m_timeout_ms = UINT16_MAX; // [WiFiClient.cpp:253] connect(): select returned due to timeout 250 ms for fd 48 } @@ -503,6 +508,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { } else{ AUDIO_INFO("Request %s failed!", l_host); + AUDIO_ERROR("Request %s failed!", l_host); if(audio_showstation) audio_showstation(""); if(audio_showstreamtitle) audio_showstreamtitle(""); if(audio_icydescription) audio_icydescription(""); @@ -722,8 +728,10 @@ cardLock(false); if(endsWith(afn, ".wav")) m_codec = CODEC_WAV; if(endsWith(afn, ".flac")) m_codec = CODEC_FLAC; - if(m_codec == CODEC_NONE) AUDIO_INFO("The %s format is not supported", afn + dotPos); - + if(m_codec == CODEC_NONE) { + AUDIO_INFO("The %s format is not supported", afn + dotPos); + AUDIO_ERROR("The %s format is not supported", afn + dotPos); + } if(afn) {free(afn); afn = NULL;} bool ret = initializeDecoder(); @@ -3807,6 +3815,7 @@ bool Audio:: initializeDecoder(){ case CODEC_OGG: m_codec = CODEC_OGG; AUDIO_INFO("ogg not supported"); + AUDIO_ERROR("ogg not supported"); goto exit; break; default: @@ -3919,6 +3928,7 @@ bool Audio::parseContentType(char* ct) { else if(ct_val == CT_NONE){ AUDIO_INFO("ContentType %s not supported", ct); + AUDIO_ERROR("ContentType %s not supported", ct); return false; // nothing valid had been seen } else {;} diff --git a/yoRadio/src/audioI2S/AudioEx.h b/yoRadio/src/audioI2S/AudioEx.h index e5e358d..fdb22b6 100644 --- a/yoRadio/src/audioI2S/AudioEx.h +++ b/yoRadio/src/audioI2S/AudioEx.h @@ -90,9 +90,10 @@ extern __attribute__((weak)) void audio_eof_speech(const char*); extern __attribute__((weak)) void audio_eof_stream(const char*); // The webstream comes to an end extern __attribute__((weak)) void audio_process_extern(int16_t* buff, uint16_t len, bool *continueI2S); // record audiodata or send via BT extern __attribute__((weak)) void audio_progress(uint32_t startpos, uint32_t endpos); +extern __attribute__((weak)) void audio_error(const char*); #define AUDIO_INFO(...) {char buff[512 + 64]; sprintf(buff,__VA_ARGS__); if(audio_info) audio_info(buff);} - +#define AUDIO_ERROR(...) {char buff[512 + 64]; sprintf(buff,__VA_ARGS__); if(audio_error) audio_error(buff);} //---------------------------------------------------------------------------------------------------------------------- class AudioBuffer { diff --git a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp index 9697f3f..10f4726 100644 --- a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp +++ b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp @@ -1520,6 +1520,7 @@ bool Audio::parseContentType(char* ct) { else if(ct_val == CT_NONE){ AUDIO_INFO("ContentType %s not supported", ct); + AUDIO_ERROR("ContentType %s not supported", ct); return false; // nothing valid had been seen } else {;} @@ -1701,6 +1702,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { if(host == NULL) { AUDIO_INFO("Hostaddress is empty"); + if(audio_error) audio_error("Hostaddress is empty"); return false; } @@ -1708,6 +1710,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { if(lenHost >= 512 - 10) { AUDIO_INFO("Hostaddress is too long"); + if(audio_error) audio_error("Hostaddress is too long"); return false; } @@ -1790,7 +1793,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { strcat(rqh, "User-Agent: Mozilla/5.0\r\n"); strcat(rqh, "Connection: keep-alive\r\n\r\n"); - if(ESP_ARDUINO_VERSION_MAJOR == 2 && ESP_ARDUINO_VERSION_MINOR == 0 && ESP_ARDUINO_VERSION_PATCH >= 3){ + if(ESP_ARDUINO_VERSION_MAJOR == 2 && ESP_ARDUINO_VERSION_MINOR == 0 && ESP_ARDUINO_VERSION_PATCH >= 3 && MAX_AUDIO_SOCKET_TIMEOUT){ m_timeout_ms_ssl = UINT16_MAX; // bug in v2.0.3 if hostwoext is a IPaddr not a name m_timeout_ms = UINT16_MAX; // [WiFiClient.cpp:253] connect(): select returned due to timeout 250 ms for fd 48 } @@ -1832,6 +1835,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { } else{ AUDIO_INFO("Request %s failed!", l_host); + AUDIO_ERROR("Request %s failed!", l_host); if(audio_showstation) audio_showstation(""); if(audio_showstreamtitle) audio_showstreamtitle(""); if(audio_icydescription) audio_icydescription(""); @@ -1994,6 +1998,7 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) { sprintf(chbuf, "The %s format is not supported", afn + dotPos); if(audio_info) audio_info(chbuf); + if(audio_error) audio_error(chbuf); cardLock(true); audiofile.close(); cardLock(false); if(afn) free(afn); return false; diff --git a/yoRadio/src/audioVS1053/audioVS1053Ex.h b/yoRadio/src/audioVS1053/audioVS1053Ex.h index e28ccf1..804ea59 100644 --- a/yoRadio/src/audioVS1053/audioVS1053Ex.h +++ b/yoRadio/src/audioVS1053/audioVS1053Ex.h @@ -50,8 +50,10 @@ extern __attribute__((weak)) void audio_icydescription(const char*); extern __attribute__((weak)) void audio_lasthost(const char*); extern __attribute__((weak)) void audio_eof_stream(const char*); // The webstream comes to an end extern __attribute__((weak)) void audio_progress(uint32_t start, uint32_t durarion); +extern __attribute__((weak)) void audio_error(const char*); #define AUDIO_INFO(...) {char buff[512 + 64]; sprintf(buff,__VA_ARGS__); if(audio_info) audio_info(buff);} +#define AUDIO_ERROR(...) {char buff[512 + 64]; sprintf(buff,__VA_ARGS__); if(audio_error) audio_error(buff);} //---------------------------------------------------------------------------------------------------------------------- diff --git a/yoRadio/src/core/display.cpp b/yoRadio/src/core/display.cpp index 99328b6..b69cd30 100644 --- a/yoRadio/src/core/display.cpp +++ b/yoRadio/src/core/display.cpp @@ -345,7 +345,7 @@ void Display::_layoutChange(bool played){ } } #ifndef DSP_QUEUE_TICKS - #define DSP_QUEUE_TICKS 8 + #define DSP_QUEUE_TICKS 0 #endif void Display::loop() { if(_bootStep==0) { @@ -483,9 +483,12 @@ void Display::_title() { } void Display::_time(bool redraw) { + #if LIGHT_SENSOR!=255 - config.store.brightness = AUTOBACKLIGHT(analogRead(LIGHT_SENSOR)); - config.setBrightness(); + if(config.store.dspon) { + config.store.brightness = AUTOBACKLIGHT(analogRead(LIGHT_SENSOR)); + config.setBrightness(); + } #endif _clock.draw(); /*#ifdef USE_NEXTION diff --git a/yoRadio/src/core/netserver.cpp b/yoRadio/src/core/netserver.cpp index 810f786..fd11b98 100644 --- a/yoRadio/src/core/netserver.cpp +++ b/yoRadio/src/core/netserver.cpp @@ -187,7 +187,7 @@ void NetServer::chunkedHtmlPage(const String& contentType, AsyncWebServerRequest #endif #ifndef NS_QUEUE_TICKS - #define NS_QUEUE_TICKS 2 + #define NS_QUEUE_TICKS 0 #endif char wsbuf[BUFLEN * 2]; diff --git a/yoRadio/src/core/options.h b/yoRadio/src/core/options.h index 08cd60f..df20a23 100644 --- a/yoRadio/src/core/options.h +++ b/yoRadio/src/core/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define YOVERSION "0.9.090" +#define YOVERSION "0.9.099" /******************************************************* DO NOT EDIT THIS FILE. @@ -299,6 +299,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #ifndef CLOCKFONT_MONO #define CLOCKFONT_MONO true // monospace clock font #endif +#ifndef MAX_AUDIO_SOCKET_TIMEOUT + #define MAX_AUDIO_SOCKET_TIMEOUT false // max audio socket timeout? +#endif /* *** ST7735 display submodel *** INITR_BLACKTAB // 1.8' https://aliexpress.ru/item/1005002822797745.html diff --git a/yoRadio/src/core/player.cpp b/yoRadio/src/core/player.cpp index 31bb02b..41e0a92 100644 --- a/yoRadio/src/core/player.cpp +++ b/yoRadio/src/core/player.cpp @@ -63,6 +63,7 @@ void Player::init() { forceMono(true); #endif _loadVol(config.store.volume); + setConnectionTimeout(1700, 3700); Serial.println("done"); } @@ -78,7 +79,7 @@ void Player::stopInfo() { requestToStart = true; } -void Player::_stop(){ +void Player::_stop(bool alreadyStopped){ if(config.store.play_mode==PM_SDCARD) config.sdResumePos = player.getFilePos(); _status = STOPPED; setOutputPins(false); @@ -90,10 +91,8 @@ void Player::_stop(){ netserver.requestOnChange(BITRATE, 0); display.putRequest(DBITRATE); display.putRequest(PSTOP); - #ifdef CLEAR_BUFFERS - setDefaults(); - #endif - stopSong(); + setDefaults(); + if(!alreadyStopped) stopSong(); stopInfo(); if (player_on_stop_play) player_on_stop_play(); } @@ -108,7 +107,7 @@ void Player::initHeaders(const char *file) { } #ifndef PL_QUEUE_TICKS - #define PL_QUEUE_TICKS 2 + #define PL_QUEUE_TICKS 0 #endif void Player::loop() { @@ -136,7 +135,7 @@ void Player::loop() { xSemaphoreTake(playmutex, portMAX_DELAY); Audio::loop(); xSemaphoreGive(playmutex); - + if(!isRunning() && _status==PLAYING) _stop(true); if(_volTimer){ if((millis()-_volTicks)>3000){ config.saveVolume(); @@ -166,10 +165,12 @@ void Player::_play(uint16_t stationId) { _loadVol(config.store.volume); display.putRequest(NEWSTATION); netserver.requestOnChange(STATION, 0); + netserver.loop(); + netserver.loop(); if (config.store.play_mode==PM_WEB?connecttohost(config.station.url):connecttoFS(SD,config.station.url,config.sdResumePos==0?_resumeFilePos:config.sdResumePos-player.sd_min)) { _status = PLAYING; if(config.store.play_mode==PM_SDCARD) config.sdResumePos = 0; - config.setTitle(""); + //config.setTitle(""); config.setSmartStart(1); netserver.requestOnChange(MODE, 0); setOutputPins(true); @@ -178,6 +179,7 @@ void Player::_play(uint16_t stationId) { if (player_on_start_play) player_on_start_play(); }else{ telnet.printf("##ERROR#:\tError connecting to %s\n", config.station.url); + _stop(true); }; } @@ -200,6 +202,7 @@ void Player::browseUrl(){ if (player_on_start_play) player_on_start_play(); }else{ telnet.printf("##ERROR#:\tError connecting to %s\n", burl); + _stop(true); } memset(burl, 0, MQTT_BURL_SIZE); } diff --git a/yoRadio/src/core/player.h b/yoRadio/src/core/player.h index d2b0dbd..4c01f19 100644 --- a/yoRadio/src/core/player.h +++ b/yoRadio/src/core/player.h @@ -28,7 +28,7 @@ class Player: public Audio { uint32_t _resumeFilePos; plStatus_e _status; private: - void _stop(); + void _stop(bool alreadyStopped = false); void _play(uint16_t stationId); void _loadVol(uint8_t volume); public: diff --git a/yoRadio/src/core/telnet.cpp b/yoRadio/src/core/telnet.cpp index 4e69c7b..b2e81a1 100644 --- a/yoRadio/src/core/telnet.cpp +++ b/yoRadio/src/core/telnet.cpp @@ -124,7 +124,8 @@ void Telnet::printf(const char *format, ...) { clients[id].print(buf); } } - if(strstr(buf,"> ")==NULL) Serial.print(buf); + if (strcmp(buf, "> ") == 0) return; + if(strstr(buf,"\n> ")==NULL) Serial.print(buf); } void Telnet::printf(byte id, const char *format, ...) { diff --git a/yoRadio/src/displays/conf/displayST7796conf.h b/yoRadio/src/displays/conf/displayST7796conf.h index 64b324e..bd3b321 100644 --- a/yoRadio/src/displays/conf/displayST7796conf.h +++ b/yoRadio/src/displays/conf/displayST7796conf.h @@ -49,7 +49,7 @@ const WidgetConfig bootWdtConf PROGMEM = { 0, 216, 1, WA_CENTER }; const ProgressConfig bootPrgConf PROGMEM = { 90, 14, 4 }; /* BANDS */ /* { onebandwidth, onebandheight, bandsHspace, bandsVspace, numofbands, fadespeed } */ -const VUBandsConfig bandsConf PROGMEM = { 32, 130, 4, 2, 10, 6 }; +const VUBandsConfig bandsConf PROGMEM = { 32, 130, 4, 2, 10, 3 }; /* STRINGS */ const char numtxtFmt[] PROGMEM = "%d"; diff --git a/yoRadio/src/displays/displayILI9488.h b/yoRadio/src/displays/displayILI9488.h index 489c2d3..4f96317 100644 --- a/yoRadio/src/displays/displayILI9488.h +++ b/yoRadio/src/displays/displayILI9488.h @@ -20,7 +20,7 @@ typedef GFXcanvas16 Canvas; #include "widgets/widgets.h" #include "widgets/pages.h" -#if __has_include("conf/displayST7796conf_custom.h") +#if __has_include("conf/displayILI9488conf_custom.h") #include "conf/displayILI9488conf_custom.h" #else #include "conf/displayILI9488conf.h" diff --git a/yoRadio/src/displays/displaySSD1322.h b/yoRadio/src/displays/displaySSD1322.h index 81cfc17..4b7a4ab 100644 --- a/yoRadio/src/displays/displaySSD1322.h +++ b/yoRadio/src/displays/displaySSD1322.h @@ -1,5 +1,5 @@ -#ifndef displaySSD1305_h -#define displaySSD1305_h +#ifndef displaySSD1322_h +#define displaySSD1322_h #include "../core/options.h" #include "Arduino.h" @@ -22,7 +22,7 @@ typedef GFXcanvas1 Canvas; #include "widgets/widgets.h" #include "widgets/pages.h" -#if __has_include("conf/displaySSD1305conf_custom.h") +#if __has_include("conf/displaySSD1322conf_custom.h") #include "conf/displaySSD1322conf_custom.h" #else #include "conf/displaySSD1322conf.h" diff --git a/yoRadio/src/displays/displayST7796.h b/yoRadio/src/displays/displayST7796.h index 5ee94a8..b82d2d8 100644 --- a/yoRadio/src/displays/displayST7796.h +++ b/yoRadio/src/displays/displayST7796.h @@ -1,5 +1,5 @@ -#ifndef displayST7789_h -#define displayST7789_h +#ifndef displayST7796_h +#define displayST7796_h #include "../core/options.h" #include "Arduino.h" diff --git a/yoRadio/src/displays/displayST7920.h b/yoRadio/src/displays/displayST7920.h index 02c8ac3..6f0f305 100644 --- a/yoRadio/src/displays/displayST7920.h +++ b/yoRadio/src/displays/displayST7920.h @@ -1,5 +1,5 @@ -#ifndef displaySSD1305_h -#define displaySSD1305_h +#ifndef displayST7920_h +#define displayST7920_h #include "../core/options.h" #include "Arduino.h" diff --git a/yoRadio/yoRadio.ino b/yoRadio/yoRadio.ino index 74d9635..59dae35 100644 --- a/yoRadio/yoRadio.ino +++ b/yoRadio/yoRadio.ino @@ -100,10 +100,8 @@ void audio_info(const char *info) { nextion.audioinfo(info); #endif if (strstr(info, "skip metadata") != NULL) config.setTitle(config.station.name); - if (strstr(info, "failed!") != NULL || strstr(info, "address is empty") != NULL || strstr(info, "not supported") != NULL || strstr(info, "Account already in use") != NULL || strstr(info, "HTTP/1.0 401") != NULL) { - //config.setTitle(info); + if (strstr(info, "Account already in use") != NULL || strstr(info, "HTTP/1.0 401") != NULL) { telnet.printf("##ERROR#:\t%s\n", info); - player.sendCommand({PR_STOP, 0}); } char* ici; char b[20]={0}; if ((ici = strstr(info, "BitRate: ")) != NULL) { @@ -134,40 +132,37 @@ bool printable(const char *info) { } void audio_showstation(const char *info) { - if (strlen(info) > 0) { - bool p = printable(info); - config.setTitle(p?info:config.station.name); - if(player.remoteStationName){ - config.setStation(p?info:config.station.name); - display.putRequest(NEWSTATION); - netserver.requestOnChange(STATION, 0); - } + bool p = printable(info) && (strlen(info) > 0); + config.setTitle(p?info:config.station.name); + if(player.remoteStationName){ + config.setStation(p?info:config.station.name); + display.putRequest(NEWSTATION); + netserver.requestOnChange(STATION, 0); } } void audio_showstreamtitle(const char *info) { DBGH(); if (strstr(info, "Account already in use") != NULL || strstr(info, "HTTP/1.0 401") != NULL){ - //config.setTitle(info); telnet.printf("##ERROR#:\t%s\n", info); - player.sendCommand({PR_STOP, 0}); - return; - } - if (strlen(info) > 0) { - bool p = printable(info); - #ifdef DEBUG_TITLES - config.setTitle(DEBUG_TITLES); - #else - config.setTitle(p?info:config.station.name); - #endif } + bool p = printable(info) && (strlen(info) > 0); + #ifdef DEBUG_TITLES + config.setTitle(DEBUG_TITLES); + #else + config.setTitle(p?info:config.station.name); + #endif +} + +void audio_error(const char *info) { + config.setTitle(info); + telnet.printf("##ERROR#:\t%s\n", info); } void audio_id3artist(const char *info){ if(printable(info)) config.setStation(info); display.putRequest(NEWSTATION); netserver.requestOnChange(STATION, 0); - } void audio_id3album(const char *info){