pschatzmann / arduino-libhelix

A simple MP3 and AAC Decoder (not only) for Arduino based on libhelix
GNU General Public License v3.0
64 stars 21 forks source link

Remove flush() in destructor #4

Closed ozziii closed 9 months ago

ozziii commented 9 months ago

if data is not feed, at destructor call. flush() routine block the code.

pschatzmann commented 9 months ago

I think it would be easier to fix the bug in the Range implementation: Just initialize start = 0; and end = 0;


struct Range {
    int start;
    int end;
    bool isValid(uint32_t max) {
        return start>=0 && end>start && (end - start)<=max;
    }
};

I also tried to reproduce your issue, but I could not: So could you please provide a test sketch as well, to demonstrate the issue that you intend to resolve ?

ozziii commented 9 months ago

the code is something like https://github.com/ozziii/test_fix/tree/main

you shuld send tcp:// stream

gst-launch-1.0filesrc location=example.mp4 \ ! qtdemux \ ! faad \ ! audioconvert \ ! audioresample \ ! audio/x-raw, rate=44100, channels=1, format=S16LE \ ! lamemp3enc target=1 bitrate=96\ ! tcpserversink host="0.0.0.0" port=4567 blocksize=1024

the code shuld block at main.cpp row 127.

It's radndomical, try some cicle.

I still not try github code, but in my originary code start and stop of the streamer is triggered by mqtt message.

i tested in ESP32 chip

pschatzmann commented 9 months ago

I was hoping to get a simple example: Your example is crashing when opening the tcp connection, so I commented the tcp part out and then it's working w/o problems. So your correction seems not to be necessary!

Anyhow, I will commit my proposed correction hoping that this will help you and close your pr without merging...

pschatzmann commented 9 months ago

ps: I think my AudioTools would be a good fit for what you are doing and it would make your code much shorter..