[ai] tcp optimizations
This commit is contained in:
@@ -46,6 +46,11 @@ const String &DirectoryNode::getDirPath() const
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
uint16_t DirectoryNode::getFileIdAt(size_t i) const
|
||||
{
|
||||
return (i < ids.size()) ? ids[i] : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
String DirectoryNode::buildFullPath(const String &fileName) const
|
||||
@@ -279,10 +284,7 @@ void DirectoryNode::printDirectoryTree(int level) const
|
||||
{
|
||||
Serial.print(F(" "));
|
||||
}
|
||||
|
||||
// Use buffer for building path
|
||||
buildFullPath(mp3File, buffer, buffer_size);
|
||||
Serial.println(buffer);
|
||||
Serial.println(mp3File);
|
||||
}
|
||||
|
||||
for (DirectoryNode *childNode : subdirectories)
|
||||
@@ -647,7 +649,12 @@ DirectoryNode *DirectoryNode::advanceToNextMP3(const String ¤tGlobal)
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Not used anymore due to new
|
||||
* backpressure-safe, low-heap HTML streaming solution to prevent AsyncTCP cbuf resize OOM during /directory.
|
||||
*
|
||||
* @param out
|
||||
*/
|
||||
void DirectoryNode::streamDirectoryHTML(Print &out) const {
|
||||
#ifdef DEBUG
|
||||
Serial.printf("StreamDirectoryHTML name=%s numOfFiles=%i\n", name, mp3Files.size());
|
||||
@@ -670,20 +677,15 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
|
||||
out.print(F("<li data-id=\""));
|
||||
out.print(ids[i]);
|
||||
out.print(F("\">"));
|
||||
buildFullPath(mp3Files[i], buffer, buffer_size);
|
||||
out.print(buffer);
|
||||
out.print(mp3Files[i].c_str());
|
||||
out.println(F("</li>"));
|
||||
#ifdef DEBUG
|
||||
Serial.printf("stream song: %s\n", buffer);
|
||||
#endif
|
||||
|
||||
// Yield every few items to allow the async web server to send buffered data
|
||||
if (i % 5 == 4) {
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
out.flush();
|
||||
|
||||
for (DirectoryNode* child : subdirectories) {
|
||||
child->streamDirectoryHTML(out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user