From 5ad9a4ac377322b71021cf36959df71e2164b4c1 Mon Sep 17 00:00:00 2001 From: Cellie Date: Fri, 3 Jan 2025 15:01:47 +0100 Subject: [PATCH 1/4] Change function names to camelCase --- src/ESP32_VS1053_Stream.cpp | 22 +++++++++++----------- src/ESP32_VS1053_Stream.h | 32 ++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/ESP32_VS1053_Stream.cpp b/src/ESP32_VS1053_Stream.cpp index 5990dd1..842afa9 100644 --- a/src/ESP32_VS1053_Stream.cpp +++ b/src/ESP32_VS1053_Stream.cpp @@ -158,23 +158,23 @@ bool ESP32_VS1053_Stream::isChipConnected() return _vs1053 ? _vs1053->isChipConnected() : false; } -bool ESP32_VS1053_Stream::connecttohost(const char *url) +bool ESP32_VS1053_Stream::connectToHost(const char *url) { - return connecttohost(url, "", "", 0); + return connectToHost(url, "", "", 0); } -bool ESP32_VS1053_Stream::connecttohost(const char *url, const size_t offset) +bool ESP32_VS1053_Stream::connectToHost(const char *url, const size_t offset) { - return connecttohost(url, "", "", offset); + return connectToHost(url, "", "", offset); } -bool ESP32_VS1053_Stream::connecttohost(const char *url, const char *username, +bool ESP32_VS1053_Stream::connectToHost(const char *url, const char *username, const char *pwd) { - return connecttohost(url, username, pwd, 0); + return connectToHost(url, username, pwd, 0); } -bool ESP32_VS1053_Stream::connecttohost(const char *url, const char *username, +bool ESP32_VS1053_Stream::connectToHost(const char *url, const char *username, const char *pwd, size_t offset) { if (!_vs1053 || _http || _playingFile || !WiFi.isConnected() || @@ -303,7 +303,7 @@ bool ESP32_VS1053_Stream::connecttohost(const char *url, const char *username, strtok(newurl, "\r\n;?"); stopSong(); log_d("playlist reconnects to: %s", newurl); - return connecttohost(newurl, username, pwd, offset); + return connectToHost(newurl, username, pwd, offset); } else if (CONTENT.equals("audio/mpeg")) @@ -809,12 +809,12 @@ void ESP32_VS1053_Stream::bufferStatus(size_t &used, size_t &capacity) capacity = _ringbuffer_handle ? VS1053_PSRAM_BUFFER_SIZE : 0; } -bool ESP32_VS1053_Stream::connecttofile(fs::FS &fs, const char *filename) +bool ESP32_VS1053_Stream::connectToFile(fs::FS &fs, const char *filename) { - return connecttofile(fs, filename, 0); + return connectToFile(fs, filename, 0); } -bool ESP32_VS1053_Stream::connecttofile(fs::FS &fs, const char *filename, const size_t offset) +bool ESP32_VS1053_Stream::connectToFile(fs::FS &fs, const char *filename, const size_t offset) { if (!_vs1053 || _playingFile || _http) return false; diff --git a/src/ESP32_VS1053_Stream.h b/src/ESP32_VS1053_Stream.h index a0bbc09..eb1e011 100644 --- a/src/ESP32_VS1053_Stream.h +++ b/src/ESP32_VS1053_Stream.h @@ -40,13 +40,13 @@ class ESP32_VS1053_Stream bool startDecoder(const uint8_t CS, const uint8_t DCS, const uint8_t DREQ); bool isChipConnected(); - bool connecttohost(const char *url); - bool connecttohost(const char *url, const size_t offset); - bool connecttohost(const char *url, const char *username, const char *pwd); - bool connecttohost(const char *url, const char *username, const char *pwd, const size_t offset); + bool connectToHost(const char *url); + bool connectToHost(const char *url, const size_t offset); + bool connectToHost(const char *url, const char *username, const char *pwd); + bool connectToHost(const char *url, const char *username, const char *pwd, const size_t offset); - bool connecttofile(fs::FS &fs, const char *filename); - bool connecttofile(fs::FS &fs, const char *filename, const size_t offset); + bool connectToFile(fs::FS &fs, const char *filename); + bool connectToFile(fs::FS &fs, const char *filename, const size_t offset); void loop(); bool isRunning(); @@ -69,6 +69,26 @@ class ESP32_VS1053_Stream const char *bufferStatus(); void bufferStatus(size_t &used, size_t &capacity); + + // Compatibility with old function names (deprecated) + [[deprecated("Use connectToHost instead")]] + inline bool connecttohost(const char *url) { return connectToHost(url); } + + [[deprecated("Use connectToHost instead")]] + inline bool connecttohost(const char *url, const size_t offset) { return connectToHost(url, offset); } + + [[deprecated("Use connectToHost instead")]] + inline bool connecttohost(const char *url, const char *username, const char *pwd) { return connectToHost(url, username, pwd); } + + [[deprecated("Use connectToHost instead")]] + inline bool connecttohost(const char *url, const char *username, const char *pwd, const size_t offset) { return connectToHost(url, username, pwd, offset); } + + [[deprecated("Use connectToFile instead")]] + inline bool connecttofile(fs::FS &fs, const char *filename) { return connectToFile(fs, filename); } + + [[deprecated("Use connectToFile instead")]] + inline bool connecttofile(fs::FS &fs, const char *filename, const size_t offset) { return connectToFile(fs, filename, offset); } + private: VS1053 *_vs1053; HTTPClient *_http; From f000b82d4d3ecd15de6ccc6fb9a7edac71fb4a47 Mon Sep 17 00:00:00 2001 From: Cellie Date: Fri, 3 Jan 2025 15:27:06 +0100 Subject: [PATCH 2/4] Change callback names --- src/ESP32_VS1053_Stream.cpp | 8 +++--- src/ESP32_VS1053_Stream.h | 51 +++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/ESP32_VS1053_Stream.cpp b/src/ESP32_VS1053_Stream.cpp index 842afa9..f1bd5eb 100644 --- a/src/ESP32_VS1053_Stream.cpp +++ b/src/ESP32_VS1053_Stream.cpp @@ -116,14 +116,14 @@ void ESP32_VS1053_Stream::_handleMetadata(char *data, const size_t len) if (index++ == data + len) return; index[0] = 0; - audio_showstreamtitle(pch); + audioShowStreamTitle(pch); } void ESP32_VS1053_Stream::_eofStream() { stopSong(); - if (audio_eof_stream) - audio_eof_stream(_url); + if (audioEOFStream) + audioEOFStream(_url); } bool ESP32_VS1053_Stream::_canRedirect() @@ -362,7 +362,7 @@ bool ESP32_VS1053_Stream::connectToHost(const char *url, const char *username, snprintf(newurl, sizeof(newurl), "%s", _http->header(LOCATION).c_str()); stopSong(); log_d("%i redirection to: %s", result, newurl); - return connecttohost(newurl, username, pwd, 0); + return connectToHost(newurl, username, pwd, 0); } log_e("Something went wrong redirecting from %s", url); _redirectCount = 0; diff --git a/src/ESP32_VS1053_Stream.h b/src/ESP32_VS1053_Stream.h index eb1e011..5bc3b61 100644 --- a/src/ESP32_VS1053_Stream.h +++ b/src/ESP32_VS1053_Stream.h @@ -26,9 +26,10 @@ #define VS1053_MAXVOLUME uint8_t(100) /* do not change */ #define VS1053_PLAYBUFFER_SIZE size_t(32) /* do not change */ -extern void audio_showstation(const char *) __attribute__((weak)); -extern void audio_eof_stream(const char *) __attribute__((weak)); -extern void audio_showstreamtitle(const char *) __attribute__((weak)); +// Support for old callback names will be dropped with 3.0.0 +extern void audioShowStation(const char *) __attribute__((weak)); +extern void audioEOFStream(const char *) __attribute__((weak)); +extern void audioShowStreamTitle(const char *) __attribute__((weak)); class ESP32_VS1053_Stream { @@ -69,25 +70,43 @@ class ESP32_VS1053_Stream const char *bufferStatus(); void bufferStatus(size_t &used, size_t &capacity); - // Compatibility with old function names (deprecated) + // Support for old names will be dropped with 3.0.0 [[deprecated("Use connectToHost instead")]] - inline bool connecttohost(const char *url) { return connectToHost(url); } + inline bool connecttohost(const char *url) + { + return connectToHost(url); + } [[deprecated("Use connectToHost instead")]] - inline bool connecttohost(const char *url, const size_t offset) { return connectToHost(url, offset); } + inline bool connecttohost(const char *url, const size_t offset) + { + return connectToHost(url, offset); + } [[deprecated("Use connectToHost instead")]] - inline bool connecttohost(const char *url, const char *username, const char *pwd) { return connectToHost(url, username, pwd); } + inline bool connecttohost(const char *url, const char *username, const char *pwd) + { + return connectToHost(url, username, pwd); + } [[deprecated("Use connectToHost instead")]] - inline bool connecttohost(const char *url, const char *username, const char *pwd, const size_t offset) { return connectToHost(url, username, pwd, offset); } + inline bool connecttohost(const char *url, const char *username, const char *pwd, const size_t offset) + { + return connectToHost(url, username, pwd, offset); + } [[deprecated("Use connectToFile instead")]] - inline bool connecttofile(fs::FS &fs, const char *filename) { return connectToFile(fs, filename); } + inline bool connecttofile(fs::FS &fs, const char *filename) + { + return connectToFile(fs, filename); + } [[deprecated("Use connectToFile instead")]] - inline bool connecttofile(fs::FS &fs, const char *filename, const size_t offset) { return connectToFile(fs, filename, offset); } + inline bool connecttofile(fs::FS &fs, const char *filename, const size_t offset) + { + return connectToFile(fs, filename, offset); + } private: VS1053 *_vs1053; @@ -145,7 +164,17 @@ class ESP32_VS1053_Stream const char *ICY_METAINT = "icy-metaint"; const char *ENCODING = "Transfer-Encoding"; const char *BITRATE = "icy-br"; - const char *LOCATION = "Location"; + const char *LOCATION = "Location"; }; +// Deprecated function names with warnings +[[deprecated("Use audioShowStation instead")]] +extern void audio_showstation(const char *) __attribute__((weak)); + +[[deprecated("Use audioEOFStream instead")]] +extern void audio_eof_stream(const char *) __attribute__((weak)); + +[[deprecated("Use audioShowStreamTitle instead")]] +extern void audio_showstreamtitle(const char *) __attribute__((weak)); + #endif From cfed27fa11805f6a9afc76d7daac75ececddd519 Mon Sep 17 00:00:00 2001 From: Cellie Date: Fri, 3 Jan 2025 16:34:15 +0100 Subject: [PATCH 3/4] Depracate old names --- src/ESP32_VS1053_Stream.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ESP32_VS1053_Stream.h b/src/ESP32_VS1053_Stream.h index 5bc3b61..2b58c78 100644 --- a/src/ESP32_VS1053_Stream.h +++ b/src/ESP32_VS1053_Stream.h @@ -27,6 +27,15 @@ #define VS1053_PLAYBUFFER_SIZE size_t(32) /* do not change */ // Support for old callback names will be dropped with 3.0.0 +// Deprecated function names (old definitions) +[[deprecated("Use audioShowStation instead")]] +extern void audio_showstation(const char *) __attribute__((weak)); +[[deprecated("Use audioEOFStream instead")]] +extern void audio_eof_stream(const char *) __attribute__((weak)); +[[deprecated("Use audioShowStreamTitle instead")]] +extern void audio_showstreamtitle(const char *) __attribute__((weak)); + +// New function names (preferred) extern void audioShowStation(const char *) __attribute__((weak)); extern void audioEOFStream(const char *) __attribute__((weak)); extern void audioShowStreamTitle(const char *) __attribute__((weak)); @@ -167,14 +176,4 @@ class ESP32_VS1053_Stream const char *LOCATION = "Location"; }; -// Deprecated function names with warnings -[[deprecated("Use audioShowStation instead")]] -extern void audio_showstation(const char *) __attribute__((weak)); - -[[deprecated("Use audioEOFStream instead")]] -extern void audio_eof_stream(const char *) __attribute__((weak)); - -[[deprecated("Use audioShowStreamTitle instead")]] -extern void audio_showstreamtitle(const char *) __attribute__((weak)); - #endif From f7bf411e7d27906a406a4de95a67504e73402a94 Mon Sep 17 00:00:00 2001 From: Cellie Date: Fri, 3 Jan 2025 19:34:28 +0100 Subject: [PATCH 4/4] Do not change callbacks yet as there seems no easy fix --- src/ESP32_VS1053_Stream.cpp | 6 +++--- src/ESP32_VS1053_Stream.h | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/ESP32_VS1053_Stream.cpp b/src/ESP32_VS1053_Stream.cpp index f1bd5eb..577bde2 100644 --- a/src/ESP32_VS1053_Stream.cpp +++ b/src/ESP32_VS1053_Stream.cpp @@ -116,14 +116,14 @@ void ESP32_VS1053_Stream::_handleMetadata(char *data, const size_t len) if (index++ == data + len) return; index[0] = 0; - audioShowStreamTitle(pch); + audio_showstreamtitle(pch); } void ESP32_VS1053_Stream::_eofStream() { stopSong(); - if (audioEOFStream) - audioEOFStream(_url); + if (audio_eof_stream) + audio_eof_stream(_url); } bool ESP32_VS1053_Stream::_canRedirect() diff --git a/src/ESP32_VS1053_Stream.h b/src/ESP32_VS1053_Stream.h index 2b58c78..f25b96d 100644 --- a/src/ESP32_VS1053_Stream.h +++ b/src/ESP32_VS1053_Stream.h @@ -27,19 +27,10 @@ #define VS1053_PLAYBUFFER_SIZE size_t(32) /* do not change */ // Support for old callback names will be dropped with 3.0.0 -// Deprecated function names (old definitions) -[[deprecated("Use audioShowStation instead")]] extern void audio_showstation(const char *) __attribute__((weak)); -[[deprecated("Use audioEOFStream instead")]] extern void audio_eof_stream(const char *) __attribute__((weak)); -[[deprecated("Use audioShowStreamTitle instead")]] extern void audio_showstreamtitle(const char *) __attribute__((weak)); -// New function names (preferred) -extern void audioShowStation(const char *) __attribute__((weak)); -extern void audioEOFStream(const char *) __attribute__((weak)); -extern void audioShowStreamTitle(const char *) __attribute__((weak)); - class ESP32_VS1053_Stream {