Giter Club home page Giter Club logo

Comments (6)

chmorgan avatar chmorgan commented on July 21, 2024 1

@alibukharai how are you able to reproduce this failure condition? Do you have a file that exhibits this behavior? I believe I had some files with some bad data in them and continuing to read got to a point where they worked, and should burn through the data in the file really quickly too, but I can see how several megabytes of bad data could take a long time to read and error through...

from esp-audio-player.

alibukharai avatar alibukharai commented on July 21, 2024

@alibukharai how are you able to reproduce this failure condition? Do you have a file that exhibits this behavior? I believe I had some files with some bad data in them and continuing to read got to a point where they worked, and should burn through the data in the file really quickly too, but I can see how several megabytes of bad data could take a long time to read and error through...

@chmorgan Thank you for your response. The MP3 data is received through an HTTPS Text-to-Speech API. I store this data in a buffer and then pass both the buffer and its length to the audio_player.cpp API to play the MP3. Below is the code snippet that handles the MP3 playback after the HTTPS finish event:

#define MAX_FILE_SIZE       (1*1024*1024)
    case HTTP_EVENT_ON_HEADER:
        ESP_LOGI(TAG, "HTTP_EVENT_ON_HEADER");
        file_total_len = 0;
        break;
    case HTTP_EVENT_ON_DATA:
        ESP_LOGI(TAG, "HTTP_EVENT_ON_DATA, len=%d", evt->data_len);
        if ((file_total_len + evt->data_len) < MAX_FILE_SIZE) {
            memcpy(audio_rx_buffer + file_total_len, (char *)evt->data, evt->data_len);
            file_total_len += evt->data_len;
        }
        break;
    case HTTP_EVENT_ON_FINISH:
        ESP_LOGI(TAG, "HTTP_EVENT_ON_FINISH:%d, %d K", file_total_len, file_total_len / 1024);
        audio_player_play(audio_rx_buffer, file_total_len); // Link: [https://github.com/chmorgan/esp-audio-player/blob/2221e2c848c9f073f9d6ab4fc6a5cd9b46de20c7/audio_player.cpp#L471]
        break;

The challenge is that reproducing this error is not straightforward. However, if such an error occurs, is there any way to provide guidance on how to handle it? The logs indicate a status error of -8 in mp3dec.h.

from esp-audio-player.

chmorgan avatar chmorgan commented on July 21, 2024

@alibukharai well -8 looks like an internal data field/format error. Today we don't do a good job of indicating we are skipping due to errors, that could be something you could use to decide to abort playback entirely, vs. continuing for hundreds of ms to try to play the data file.

from esp-audio-player.

chmorgan avatar chmorgan commented on July 21, 2024

I'd be open to suggestions for api/error reporting changes but keep in mind they could break existing users.

from esp-audio-player.

chmorgan avatar chmorgan commented on July 21, 2024

@alibukharai can you retest with the latest changes on main? It looks like this issue may have been addressed.

from esp-audio-player.

chmorgan avatar chmorgan commented on July 21, 2024

Closing as I think the issue was resolved with some fixes that were contributed.

from esp-audio-player.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.