Skip to content

Change function names to camelCase #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/ESP32_VS1053_Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ||
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
57 changes: 48 additions & 9 deletions src/ESP32_VS1053_Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
#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));
// Support for old callback names will be dropped with 3.0.0
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));

class ESP32_VS1053_Stream
Expand All @@ -40,13 +41,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();
Expand All @@ -69,6 +70,44 @@ 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);
}

[[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;
Expand Down Expand Up @@ -125,7 +164,7 @@ 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";
};

#endif