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

Fixes for ESP32 #169

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open

Fixes for ESP32 #169

wants to merge 63 commits into from

Conversation

tobiasguyer
Copy link

Adjusted main.cpp ro the new cspot structure. I took the cliPlayer as reference and changed as less as possible

tobiasguyer and others added 14 commits December 25, 2023 00:41
)

* fixes for esp32

* fixes for esp32

* reuploaded sdkconfig.defaults

* added gzip compatible mercury decoder (failed if message were trucated) - updated from main-branch

* fix: clang-format

* fix: Minor style fixes

* fix: clear partials on sub res and reconnect

* fix: Restore bell version

* fix: Update bell

---------

Co-authored-by: Filip <[email protected]>
@tobiasguyer
Copy link
Author

So.. i think, i can call the current build stable enough, to be posted in here. There are still problems with seeking on cli and probaly esp's without vs1053. And i ran into some issues with some specific tracks(they bring the mercuryManager to fail in read, and after that, the esp resets, because of some switching issues, but i can't find the faulty declared function). And episodes do have no autoplay yet. But apart from that it runs smooth.
It changed structural quite a lot. I had to switch from spirc to connectState requests, because of information loss in spirc. And most of the other changes are for commits from my side.
And i tried my best with freeing all allocated memory.
If you think, it's too much of an alteration to still call it cspot, just take a peek at the new TrackReference functions, they solve my once intended ghostTrackList change quite smooth.
If you want to stay loyal to spirc, i could try to solve the issues of the memory-loss with my old commit. But the smart shuffle and radio functions are never gonna be properly displayed.
Regards tobi

@tobiasguyer
Copy link
Author

So.. seeking was quite simple.. i've just missed a resetTrackPlayer.
I still have to adjust some things in mercuryManager.
I think MercuryTask has a little to less memory allocated. And the subscriptions seem to be not failsafe yet..

tobiasguyer and others added 4 commits September 29, 2024 16:10
* moved trackmetrics playStart back to TrackPlayer because needed

* changes in track queueing

* Changed structural from spirc to connectState

* minor changes

* minor clang-format changes

* Seeking now supported on all devices

* adjusting stack-sizes to new structure, minor adjustments for bell_nocodec

* Update MercurySession.cpp
@tobiasguyer
Copy link
Author

I'm sorry for that mess :) it's finally working quite good on cli and vs1053, the only problem i haven't resolved is, if there are only queued tracks in the playing-history ( for example after takeover of a list with queuedtracks), the normal shuffle expects it to be the end and switches to autoplay, and the autoplay of episodes.
apart from that i'm quite happy with my build.
i've solved some preloadedTracks issues in an ugly way.
but otherwise it runs smoothly for quite a long time ( it still quited after 200 tracks because of a httpRead error in cdnAudioFile. but i can't find the cause, and 10 hours of a continuos stream is quite satisfying)
regards tobi

… handling in cspot

- **Streaming Stability**:
  Addressed issues with continuous streaming, improving the handling of connection drops and reducing delays in reconnection. Improve playback continuity during network interruptions.

- **Error Handling**:
  Improved error handling, particularly around HTTPClient and other critical components. Introduced exception management to deal with connection errors and retry mechanisms for smoother recovery.

- **Track Handling**:
  Refactored track management logic to streamline the loading and processing of tracks, improving performance and reducing latency in track transitions.

- **Concurrency Improvements**:
  Added thread protection to shared resources, including wrapping log messages with a semaphore to avoid race conditions and data corruption.

- **Other Fixes**:
  - Updated the `getMacAddress` function to work on both WIN32 and ESP32 platforms. (Used for unique deviceID)
  - Fixed issues with FreeRTOS-to-pthread migration for improved compatibility.

---

**Additional Notes**:
- Some exceptions still occur, particularly with mbedtls, but they are logged and managed until a more permanent fix is available.
- Reconnection times in certain cases may still be suboptimal but are currently being handled with exponential backoff.
- The changes in track processing should improve the overall flow, reducing glitches during streaming.
@tobiasguyer
Copy link
Author

So.. i had to take a small detour to feelfreelinux/bell since updating to espidf v5. Currently the bell repository is linked to my bell repository, because it handles quite a lot of errors issueing from mbedtls.

    Reverted the automatic formatting changes in CMake files that caused processing issues.
    Modified queryAutoplay to ensure that resolveRadio is only called once if the radio URL is already generated, preventing redundant calls.
    Increased task priority for VS1053's track_feed to 10, matching the priority of i2sFeed.
    Increased the stream buffer size for VS1053_TRACK to 4098 * 32.
@tobiasguyer
Copy link
Author

There are still a few issues that need attention:

  1. Missread in TLSSocket: Currently, when a read error occurs in the TLSSocket (e.g., network failure or timeout), the TrackPlayer simply skips to the next song. However, it should be possible, to reconnect to the CDN or resend the request, continuing from where the failure happened, instead of skipping the track.
E TLSSocket.cpp:97: TLS read error (-34), retrying... Attempt 1
E TLSSocket.cpp:101: Read error with code -32

E HTTPClient.cpp:116: Underflow error during response reading: Buffer not available and yield failed
E TrackPlayer.cpp:288: An error has occured in the stream -1
I TrackPlayer.cpp:328: Playing done
D DeviceStateHandler.cpp:110: Ended track, needs_to_be_skipped = true
E TrackPlayer.cpp:137: new Track stream
E TrackPlayer.cpp:140: all good with stream
  1. Playlist reshuffling with Classic Shuffle: When using the "classic shuffle" mode, if the playlist gets reshuffled, the player starts loading radio tracks. This seems to be a logical failure in the resolveContext function and should be solved with next update.

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

Successfully merging this pull request may close these issues.

2 participants