From 49d5eaa340ba2d11f74b6efaf2ac4e24c15ec744 Mon Sep 17 00:00:00 2001 From: dheydeck <62849409+dheydeck@users.noreply.github.com> Date: Thu, 11 Mar 2021 16:23:47 +0000 Subject: [PATCH] Update main.cpp Station name "icy-name" is not always present in datastream and, when it isn't, the previous station name appears as the prefix to the current track. This change nulls the station name prior to parsing the datastream and also suppresses the hyphen that separates the normal station name from the track name if it is absent. --- src/main.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 41b3689..1c6490a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4540,6 +4540,7 @@ void handlebyte_ch ( uint8_t b ) metaint = 0 ; // No metaint found LFcount = 0 ; // For detection end of header bitrate = 0 ; // Bitrate still unknown + icyname = "" ; // Clear Station name dbgprint ( "Switch to HEADER" ) ; setdatamode ( HEADER ) ; // Handle header @@ -5199,8 +5200,16 @@ const char* analyzeCmd ( const char* par, const char* val ) } else { - sprintf ( reply, "%s - %s", icyname.c_str(), - icystreamtitle.c_str() ) ; // Streamtitle from metadata + if ( icyname != "" ) // Check for station name + { + sprintf ( reply, "%s - %s", icyname.c_str(), + icystreamtitle.c_str() ) ; // Streamtitle from metadata + } + else + { + sprintf ( reply, "%s", + icystreamtitle.c_str() ) ; // Streamtitle from metadata + } } } else if ( argument.startsWith ( "reset" ) ) // Reset request