non-crashing CSpot + spi_master and override fixes

This commit is contained in:
Philippe G
2022-01-04 13:52:45 -08:00
parent 33c7ba820d
commit e59188ec44
15 changed files with 52 additions and 30 deletions

View File

@@ -3,7 +3,7 @@
#include "Logger.h"
AudioChunkManager::AudioChunkManager()
: bell::Task("AudioChunkManager", 4 * 1024, +0, 0) {
: bell::Task("AudioChunkManager", 4 * 1024, +1, 0) {
this->chunks = std::vector<std::shared_ptr<AudioChunk>>();
startTask();
}
@@ -96,11 +96,7 @@ void AudioChunkManager::runTask() {
break;
default:
// printf("ID: %d: Got data chunk!\n", seqId);
// 2 first bytes are size so we skip it
// printf("(_)--- Free memory %d\n",
// esp_get_free_heap_size());
if (chunk == nullptr) {
if (chunk.get() == nullptr) {
return;
}
auto actualData = std::vector<uint8_t>(
@@ -114,7 +110,7 @@ void AudioChunkManager::runTask() {
} catch (...) {
}
} else {
// usleep(100*1000);
usleep(100);
}
}

View File

@@ -30,7 +30,7 @@ MercuryManager::MercuryManager(std::unique_ptr<Session> session): bell::Task("me
MercuryManager::~MercuryManager()
{
pbFree(Header_fields, &tempMercuryHeader);
pb_release(Header_fields, tempMercuryHeader);
}
bool MercuryManager::timeoutHandler()

View File

@@ -9,7 +9,7 @@ MercuryResponse::MercuryResponse(std::vector<uint8_t> &data)
}
MercuryResponse::~MercuryResponse() {
pbFree(Header_fields, &mercuryHeader);
pb_release(Header_fields, mercuryHeader);
}
void MercuryResponse::parseResponse(std::vector<uint8_t> &data)

View File

@@ -53,8 +53,8 @@ PlayerState::PlayerState(std::shared_ptr<TimeProvider> timeProvider)
}
PlayerState::~PlayerState() {
pbFree(Frame_fields, &innerFrame);
pbFree(Frame_fields, &remoteFrame);
pb_release(Frame_fields, innerFrame);
pb_release(Frame_fields, remoteFrame);
}
void PlayerState::setPlaybackState(const PlaybackState state)

View File

@@ -18,10 +18,10 @@ Session::Session()
Session::~Session()
{
pbFree(ClientHello_fields, &clientHello);
pbFree(APResponseMessage_fields, &apResponse);
pbFree(ClientResponseEncrypted_fields, &authRequest);
pbFree(ClientResponsePlaintext_fields, &clientResPlaintext);
pb_release(ClientHello_fields, clientHello);
pb_release(APResponseMessage_fields, apResponse);
pb_release(ClientResponseEncrypted_fields, authRequest);
pb_release(ClientResponsePlaintext_fields, clientResPlaintext);
}
void Session::connect(std::unique_ptr<PlainConnection> connection)

View File

@@ -35,8 +35,8 @@ SpotifyTrack::~SpotifyTrack()
{
this->manager->unregisterMercuryCallback(this->reqSeqNum);
this->manager->freeAudioKeyCallback();
pbFree(Track_fields, &this->trackInfo);
pbFree(Episode_fields, &this->episodeInfo);
pb_release(Track_fields, this->trackInfo);
pb_release(Episode_fields, this->episodeInfo);
}
bool SpotifyTrack::countryListContains(std::string countryList, std::string country)
@@ -142,6 +142,21 @@ void SpotifyTrack::episodeInformationCallback(std::unique_ptr<MercuryResponse> r
}
}
if (trackInfoReceived != nullptr)
{
auto imageId = pbArrayToVector(episodeInfo.covers->image[0].file_id);
TrackInfo simpleTrackInfo = {
.name = std::string(episodeInfo.name),
.album = "",
.artist = "",
.imageUrl = "https://i.scdn.co/image/" + bytesToHexString(imageId),
.duration = trackInfo.duration,
};
trackInfoReceived(simpleTrackInfo);
}
this->requestAudioKey(pbArrayToVector(episodeInfo.gid), this->fileId, episodeInfo.duration, position_ms, isPaused);
}

View File

@@ -19,7 +19,7 @@ TrackReference::TrackReference(TrackRef *ref)
TrackReference::~TrackReference()
{
//pbFree(TrackRef_fields, &ref);
pb_release(TrackRef_fields, ref);
}
std::vector<uint8_t> TrackReference::base62Decode(std::string uri)