Skip to content
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

Buffering not possible? #1

Open
devnull69 opened this issue Nov 9, 2020 · 0 comments
Open

Buffering not possible? #1

devnull69 opened this issue Nov 9, 2020 · 0 comments

Comments

@devnull69
Copy link

devnull69 commented Nov 9, 2020

I use your ESP32-Web-Radio, with an ESP8266, but it still works fine

Now, I wanted to add a buffer so that internet lag will not directly lead to a jumping MP3 stream. I did this by changing mp3buff to bufferptr with a length of 320, which I wanted to fill up with chunks of 32 bytes to be played by the player later.

I noticed the following:

// This works
void loop() {
      ...
      if (client.available() > 0)
      {
        uint8_t bytesread = client.read(bufferptr, 32);
        player.playChunk(bufferptr, bytesread);
      }
      ...
}
// This doesn't work
bool written = false;
void loop() {
      ...
      if (client.available() > 0 && !written)
      {
        uint8_t bytesread = client.read(bufferptr, 32);
        written = true;
      }
      if(written) {
        player.playChunk(bufferptr, 32);
        written = false;
      }
      ...
}

It should be the same, right? In both cases I let client.read fill up 32 bytes of the buffer at bufferptr before I play the chunk. In case 2 there is an Exception (9) though ...

Can you help me with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant