mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 20:47:08 +03:00
non-crashing CSpot + spi_master and override fixes
This commit is contained in:
@@ -3,4 +3,5 @@ idf_component_register( SRCS ${srcs}
|
|||||||
INCLUDE_DIRS ${IDF_PATH}/components/driver
|
INCLUDE_DIRS ${IDF_PATH}/components/driver
|
||||||
)
|
)
|
||||||
|
|
||||||
message("overriding ${srcs} !! THIS MUST BE REQUIRED BY MAIN !!")
|
# CMake is just a pile of crap
|
||||||
|
message("overriding ${srcs} !! THIS MUST BE REQUIRED BY ONE COMPONENT BUT NO MAIN !!")
|
||||||
@@ -125,6 +125,7 @@ We have two bits to control the interrupt:
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
#include "soc/soc_memory_layout.h"
|
#include "soc/soc_memory_layout.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "hal/spi_hal.h"
|
#include "hal/spi_hal.h"
|
||||||
@@ -158,6 +159,10 @@ typedef struct {
|
|||||||
|
|
||||||
//debug information
|
//debug information
|
||||||
bool polling; //in process of a polling, avoid of queue new transactions into ISR
|
bool polling; //in process of a polling, avoid of queue new transactions into ISR
|
||||||
|
|
||||||
|
// PATCH
|
||||||
|
SemaphoreHandle_t mutex;
|
||||||
|
int count;
|
||||||
} spi_host_t;
|
} spi_host_t;
|
||||||
|
|
||||||
struct spi_device_t {
|
struct spi_device_t {
|
||||||
@@ -392,6 +397,12 @@ esp_err_t spi_bus_add_device(spi_host_device_t host_id, const spi_device_interfa
|
|||||||
spicommon_cs_initialize(host_id, dev_config->spics_io_num, freecs, use_gpio);
|
spicommon_cs_initialize(host_id, dev_config->spics_io_num, freecs, use_gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create a mutex if we have more than one client
|
||||||
|
if (host->count++) {
|
||||||
|
ESP_LOGI(SPI_TAG, "More than one device on SPI %d => creating mutex", host_id);
|
||||||
|
host->mutex = xSemaphoreCreateMutex();
|
||||||
|
}
|
||||||
|
|
||||||
//save a pointer to device in spi_host_t
|
//save a pointer to device in spi_host_t
|
||||||
host->device[freecs] = dev;
|
host->device[freecs] = dev;
|
||||||
//save a pointer to host in spi_device_t
|
//save a pointer to host in spi_device_t
|
||||||
@@ -982,17 +993,15 @@ esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_end(spi_device_handle_t handle,
|
|||||||
esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_transmit(spi_device_handle_t handle, spi_transaction_t* trans_desc)
|
esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_transmit(spi_device_handle_t handle, spi_transaction_t* trans_desc)
|
||||||
{
|
{
|
||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
static SemaphoreHandle_t mutex;
|
if (handle->host->mutex) xSemaphoreTake(handle->host->mutex, portMAX_DELAY);
|
||||||
if (!mutex) mutex = xSemaphoreCreateMutex();
|
|
||||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
|
||||||
|
|
||||||
ret = spi_device_polling_start(handle, trans_desc, portMAX_DELAY);
|
ret = spi_device_polling_start(handle, trans_desc, portMAX_DELAY);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
xSemaphoreGive(mutex);
|
if (handle->host->mutex) xSemaphoreGive(handle->host->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = spi_device_polling_end(handle, portMAX_DELAY);
|
ret = spi_device_polling_end(handle, portMAX_DELAY);
|
||||||
xSemaphoreGive(mutex);
|
if (handle->host->mutex) xSemaphoreGive(handle->host->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
idf_component_register(SRC_DIRS .
|
idf_component_register(SRC_DIRS .
|
||||||
INCLUDE_DIRS . ${IDF_PATH}/components/driver
|
INCLUDE_DIRS .
|
||||||
REQUIRES json tools platform_config display wifi-manager
|
REQUIRES json tools platform_config display wifi-manager
|
||||||
PRIV_REQUIRES soc esp32
|
PRIV_REQUIRES soc esp32
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -262,8 +262,7 @@ function(NANOPB_GENERATE_CPP SRCS HDRS)
|
|||||||
execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version OUTPUT_VARIABLE PROTOC_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version OUTPUT_VARIABLE PROTOC_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
string(REGEX MATCH "[(0-9)].*.[(0-9)].*.[(0-9)].*$" PROTOC_VERSION "${PROTOC_VERSION_STRING}")
|
string(REGEX MATCH "[(0-9)].*.[(0-9)].*.[(0-9)].*$" PROTOC_VERSION "${PROTOC_VERSION_STRING}")
|
||||||
|
|
||||||
#if(PROTOC_VERSION VERSION_LESS "3.6.0")
|
if(PROTOC_VERSION AND PROTOC_VERSION VERSION_LESS "3.6.0")
|
||||||
if(0)
|
|
||||||
#try to use the older way
|
#try to use the older way
|
||||||
string(REGEX MATCH ":" HAS_COLON_IN_PATH ${NANOPB_PLUGIN_OPTIONS} ${NANOPB_OUT})
|
string(REGEX MATCH ":" HAS_COLON_IN_PATH ${NANOPB_PLUGIN_OPTIONS} ${NANOPB_OUT})
|
||||||
if(HAS_COLON_IN_PATH)
|
if(HAS_COLON_IN_PATH)
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ Episode.gid type:FT_POINTER
|
|||||||
Episode.name type:FT_POINTER
|
Episode.name type:FT_POINTER
|
||||||
ImageGroup.image type:FT_POINTER
|
ImageGroup.image type:FT_POINTER
|
||||||
Episode.audio type:FT_POINTER
|
Episode.audio type:FT_POINTER
|
||||||
|
Episode.covers type:FT_POINTER
|
||||||
Restriction.countries_allowed type:FT_POINTER
|
Restriction.countries_allowed type:FT_POINTER
|
||||||
Restriction.countries_forbidden type:FT_POINTER
|
Restriction.countries_forbidden type:FT_POINTER
|
||||||
@@ -45,6 +45,7 @@ message Episode {
|
|||||||
optional string name = 2;
|
optional string name = 2;
|
||||||
optional sint32 duration = 7;
|
optional sint32 duration = 7;
|
||||||
repeated AudioFile audio = 12;
|
repeated AudioFile audio = 12;
|
||||||
|
optional ImageGroup covers = 0x44;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AudioFormat {
|
enum AudioFormat {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
AudioChunkManager::AudioChunkManager()
|
AudioChunkManager::AudioChunkManager()
|
||||||
: bell::Task("AudioChunkManager", 4 * 1024, +0, 0) {
|
: bell::Task("AudioChunkManager", 4 * 1024, +1, 0) {
|
||||||
this->chunks = std::vector<std::shared_ptr<AudioChunk>>();
|
this->chunks = std::vector<std::shared_ptr<AudioChunk>>();
|
||||||
startTask();
|
startTask();
|
||||||
}
|
}
|
||||||
@@ -96,11 +96,7 @@ void AudioChunkManager::runTask() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// printf("ID: %d: Got data chunk!\n", seqId);
|
if (chunk.get() == nullptr) {
|
||||||
// 2 first bytes are size so we skip it
|
|
||||||
// printf("(_)--- Free memory %d\n",
|
|
||||||
// esp_get_free_heap_size());
|
|
||||||
if (chunk == nullptr) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto actualData = std::vector<uint8_t>(
|
auto actualData = std::vector<uint8_t>(
|
||||||
@@ -114,7 +110,7 @@ void AudioChunkManager::runTask() {
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// usleep(100*1000);
|
usleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ MercuryManager::MercuryManager(std::unique_ptr<Session> session): bell::Task("me
|
|||||||
|
|
||||||
MercuryManager::~MercuryManager()
|
MercuryManager::~MercuryManager()
|
||||||
{
|
{
|
||||||
pbFree(Header_fields, &tempMercuryHeader);
|
pb_release(Header_fields, tempMercuryHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MercuryManager::timeoutHandler()
|
bool MercuryManager::timeoutHandler()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ MercuryResponse::MercuryResponse(std::vector<uint8_t> &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MercuryResponse::~MercuryResponse() {
|
MercuryResponse::~MercuryResponse() {
|
||||||
pbFree(Header_fields, &mercuryHeader);
|
pb_release(Header_fields, mercuryHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MercuryResponse::parseResponse(std::vector<uint8_t> &data)
|
void MercuryResponse::parseResponse(std::vector<uint8_t> &data)
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ PlayerState::PlayerState(std::shared_ptr<TimeProvider> timeProvider)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerState::~PlayerState() {
|
PlayerState::~PlayerState() {
|
||||||
pbFree(Frame_fields, &innerFrame);
|
pb_release(Frame_fields, innerFrame);
|
||||||
pbFree(Frame_fields, &remoteFrame);
|
pb_release(Frame_fields, remoteFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerState::setPlaybackState(const PlaybackState state)
|
void PlayerState::setPlaybackState(const PlaybackState state)
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ Session::Session()
|
|||||||
|
|
||||||
Session::~Session()
|
Session::~Session()
|
||||||
{
|
{
|
||||||
pbFree(ClientHello_fields, &clientHello);
|
pb_release(ClientHello_fields, clientHello);
|
||||||
pbFree(APResponseMessage_fields, &apResponse);
|
pb_release(APResponseMessage_fields, apResponse);
|
||||||
pbFree(ClientResponseEncrypted_fields, &authRequest);
|
pb_release(ClientResponseEncrypted_fields, authRequest);
|
||||||
pbFree(ClientResponsePlaintext_fields, &clientResPlaintext);
|
pb_release(ClientResponsePlaintext_fields, clientResPlaintext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::connect(std::unique_ptr<PlainConnection> connection)
|
void Session::connect(std::unique_ptr<PlainConnection> connection)
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ SpotifyTrack::~SpotifyTrack()
|
|||||||
{
|
{
|
||||||
this->manager->unregisterMercuryCallback(this->reqSeqNum);
|
this->manager->unregisterMercuryCallback(this->reqSeqNum);
|
||||||
this->manager->freeAudioKeyCallback();
|
this->manager->freeAudioKeyCallback();
|
||||||
pbFree(Track_fields, &this->trackInfo);
|
pb_release(Track_fields, this->trackInfo);
|
||||||
pbFree(Episode_fields, &this->episodeInfo);
|
pb_release(Episode_fields, this->episodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpotifyTrack::countryListContains(std::string countryList, std::string country)
|
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);
|
this->requestAudioKey(pbArrayToVector(episodeInfo.gid), this->fileId, episodeInfo.duration, position_ms, isPaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ TrackReference::TrackReference(TrackRef *ref)
|
|||||||
|
|
||||||
TrackReference::~TrackReference()
|
TrackReference::~TrackReference()
|
||||||
{
|
{
|
||||||
//pbFree(TrackRef_fields, &ref);
|
pb_release(TrackRef_fields, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> TrackReference::base62Decode(std::string uri)
|
std::vector<uint8_t> TrackReference::base62Decode(std::string uri)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
idf_component_register( SRCS operator.cpp tools.c trace.c
|
idf_component_register( SRCS operator.cpp tools.c trace.c
|
||||||
REQUIRES esp_common pthread
|
REQUIRES _override esp_common pthread
|
||||||
INCLUDE_DIRS .
|
INCLUDE_DIRS .
|
||||||
)
|
)
|
||||||
|
|
||||||
#doing our own implementation of new operator for some pre-compiled binaries
|
#doing our own implementation of new operator for some pre-compiled binaries
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
idf_component_register(SRC_DIRS .
|
idf_component_register(SRC_DIRS .
|
||||||
PRIV_REQUIRES _override esp_common wifi-manager pthread squeezelite-ota platform_console telnet display
|
PRIV_REQUIRES esp_common wifi-manager pthread squeezelite-ota platform_console telnet display
|
||||||
EMBED_FILES ../server_certs/github.pem
|
EMBED_FILES ../server_certs/github.pem
|
||||||
LDFRAGMENTS "linker.lf"
|
LDFRAGMENTS "linker.lf"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user