v0.9.550
This commit is contained in:
@@ -42,9 +42,9 @@ size_t AudioBuffer::init() {
|
||||
}
|
||||
}
|
||||
} else { // no PSRAM available, use ESP32 Flash Memory"
|
||||
m_buffSize = m_buffSizeRAM;
|
||||
m_buffSize = m_buffSizeRAM * config.store.abuff;
|
||||
m_buffer = (uint8_t*) calloc(m_buffSize, sizeof(uint8_t));
|
||||
m_buffSize = m_buffSizeRAM - m_resBuffSizeRAM;
|
||||
m_buffSize = m_buffSizeRAM * config.store.abuff - m_resBuffSizeRAM;
|
||||
}
|
||||
if(!m_buffer)
|
||||
return 0;
|
||||
@@ -1713,6 +1713,22 @@ void Audio::setConnectionTimeout(uint16_t timeout_ms, uint16_t timeout_ms_ssl){
|
||||
if(timeout_ms) m_timeout_ms = timeout_ms;
|
||||
if(timeout_ms_ssl) m_timeout_ms_ssl = timeout_ms_ssl;
|
||||
}
|
||||
|
||||
void Audio::connectTask(void* pvParams) {
|
||||
ConnectParams* params = static_cast<ConnectParams*>(pvParams);
|
||||
Audio* self = params->instance;
|
||||
bool res = true;
|
||||
if(self->_client){
|
||||
self->_connectionResult = self->_client->connect(params->hostwoext, params->port/*, self->m_f_ssl ? self->m_timeout_ms_ssl : self->m_timeout_ms*/);
|
||||
}else{
|
||||
self->_connectionResult = false;
|
||||
}
|
||||
free((void*)params->hostwoext);
|
||||
delete params;
|
||||
self->_connectTaskHandle = nullptr;
|
||||
vTaskDelete(nullptr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool Audio::connecttohost(String host){
|
||||
return connecttohost(host.c_str());
|
||||
@@ -1827,8 +1843,24 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) {
|
||||
|
||||
uint32_t t = millis();
|
||||
if(m_f_Log) AUDIO_INFO("connect to %s on port %d path %s", hostwoext, port, extension);
|
||||
res = _client->connect(hostwoext, port, m_f_ssl ? m_timeout_ms_ssl : m_timeout_ms);
|
||||
|
||||
//res = _client->connect(hostwoext, port, m_f_ssl ? m_timeout_ms_ssl : m_timeout_ms);
|
||||
if(!config.store.watchdog){
|
||||
res = _client->connect(hostwoext, port, m_f_ssl ? m_timeout_ms_ssl : m_timeout_ms);
|
||||
}else{
|
||||
ConnectParams* params = new ConnectParams{ strdup(hostwoext), port, this }; _connectionResult = false;
|
||||
xTaskCreatePinnedToCore(connectTask, "ConnectTask", WATCHDOG_TASK_SIZE, params, WATCHDOG_TASK_PRIORITY, &_connectTaskHandle, WATCHDOG_TASK_CORE_ID);
|
||||
for(;;){
|
||||
if(millis()-t>(m_f_ssl ? m_timeout_ms_ssl : m_timeout_ms) || _connectionResult) break;
|
||||
vTaskDelay(10);
|
||||
}
|
||||
res = _connectionResult;
|
||||
if (_connectTaskHandle!=nullptr) {
|
||||
vTaskDelete(_connectTaskHandle);
|
||||
_connectTaskHandle = nullptr;
|
||||
AUDIO_INFO("WATCH DOG HAS FINISHED A WORK, BYE!");
|
||||
}
|
||||
}
|
||||
|
||||
if(res){
|
||||
uint32_t dt = millis() - t;
|
||||
strcpy(m_lastHost, l_host);
|
||||
|
||||
@@ -9,11 +9,7 @@
|
||||
#ifndef _vs1053_ext
|
||||
#define _vs1053_ext
|
||||
|
||||
#ifndef AUDIOBUFFER_MULTIPLIER2
|
||||
#define AUDIOBUFFER_MULTIPLIER2 10
|
||||
#endif
|
||||
|
||||
#define VS1053VOLM 128 // 128 or 96 only
|
||||
#define VS1053VOLM 128 // 128 or 96 only
|
||||
#define VS1053VOL(v) (VS1053VOLM==128?log10(((float)v+1)) * 50.54571334 + 128:log10(((float)v+1)) * 64.54571334 + 96)
|
||||
|
||||
|
||||
@@ -107,7 +103,7 @@ public:
|
||||
protected:
|
||||
const size_t m_buffSizePSRAM = 300000; // most webstreams limit the advance to 100...300Kbytes
|
||||
//const size_t m_buffSizeRAM = 1600 * 10;
|
||||
const size_t m_buffSizeRAM = 1600 * AUDIOBUFFER_MULTIPLIER2;
|
||||
const size_t m_buffSizeRAM = 1600;
|
||||
size_t m_buffSize = 0;
|
||||
size_t m_freeSpace = 0;
|
||||
size_t m_writeSpace = 0;
|
||||
@@ -136,6 +132,15 @@ private:
|
||||
std::vector<char*> m_playlistURL; // m3u8 streamURLs buffer
|
||||
std::vector<uint32_t> m_hashQueue;
|
||||
|
||||
struct ConnectParams {
|
||||
char *hostwoext = NULL;
|
||||
uint16_t port = 80;
|
||||
Audio* instance;
|
||||
};
|
||||
volatile bool _connectionResult;
|
||||
TaskHandle_t _connectTaskHandle = nullptr;
|
||||
static void connectTask(void* pvParams);
|
||||
|
||||
private:
|
||||
enum : int { AUDIO_NONE, HTTP_RESPONSE_HEADER , AUDIO_DATA, AUDIO_LOCALFILE, AUDIO_METADATA, AUDIO_PLAYLISTINIT,
|
||||
AUDIO_PLAYLISTHEADER, AUDIO_PLAYLISTDATA, VS1053_SWM, VS1053_OGG};
|
||||
@@ -146,10 +151,10 @@ private:
|
||||
enum : int { ST_NONE = 0, ST_WEBFILE = 1, ST_WEBSTREAM = 2};
|
||||
|
||||
private:
|
||||
uint8_t cs_pin ; // Pin where CS line is connected
|
||||
uint8_t dcs_pin ; // Pin where DCS line is connected
|
||||
uint8_t dreq_pin ; // Pin where DREQ line is connected
|
||||
uint8_t curvol ; // Current volume setting 0..100%
|
||||
uint8_t cs_pin ; // Pin where CS line is connected
|
||||
uint8_t dcs_pin ; // Pin where DCS line is connected
|
||||
uint8_t dreq_pin ; // Pin where DREQ line is connected
|
||||
uint8_t curvol ; // Current volume setting 0..100%
|
||||
|
||||
const uint8_t vs1053_chunk_size = 32 ;
|
||||
int8_t m_balance = 0; // -16 (mute left) ... +16 (mute right)
|
||||
@@ -171,11 +176,11 @@ private:
|
||||
const uint8_t SCI_AICTRL2 = 0xE ;
|
||||
const uint8_t SCI_AICTRL3 = 0xF ;
|
||||
// SCI_MODE bits
|
||||
const uint8_t SM_SDINEW = 11 ; // Bitnumber in SCI_MODE always on
|
||||
const uint8_t SM_RESET = 2 ; // Bitnumber in SCI_MODE soft reset
|
||||
const uint8_t SM_CANCEL = 3 ; // Bitnumber in SCI_MODE cancel song
|
||||
const uint8_t SM_TESTS = 5 ; // Bitnumber in SCI_MODE for tests
|
||||
const uint8_t SM_LINE1 = 14 ; // Bitnumber in SCI_MODE for Line input
|
||||
const uint8_t SM_SDINEW = 11 ; // Bitnumber in SCI_MODE always on
|
||||
const uint8_t SM_RESET = 2 ; // Bitnumber in SCI_MODE soft reset
|
||||
const uint8_t SM_CANCEL = 3 ; // Bitnumber in SCI_MODE cancel song
|
||||
const uint8_t SM_TESTS = 5 ; // Bitnumber in SCI_MODE for tests
|
||||
const uint8_t SM_LINE1 = 14 ; // Bitnumber in SCI_MODE for Line input
|
||||
|
||||
SPIClass* spi_VS1053 = NULL;
|
||||
SPISettings VS1053_SPI_DATA; // SPI settings normal speed
|
||||
@@ -242,7 +247,7 @@ protected:
|
||||
inline void DCS_LOW() {(dcs_pin&0x20) ? GPIO.out1_w1tc.data = 1 << (dcs_pin - 32) : GPIO.out_w1tc = 1 << dcs_pin;}
|
||||
inline void CS_HIGH() {( cs_pin&0x20) ? GPIO.out1_w1ts.data = 1 << ( cs_pin - 32) : GPIO.out_w1ts = 1 << cs_pin;}
|
||||
inline void CS_LOW() {( cs_pin&0x20) ? GPIO.out1_w1tc.data = 1 << ( cs_pin - 32) : GPIO.out_w1tc = 1 << cs_pin;}
|
||||
inline void await_data_request() {while(!digitalRead(dreq_pin)) NOP();} // Very short delay
|
||||
inline void await_data_request() {while(!digitalRead(dreq_pin)) NOP();} // Very short delay
|
||||
inline bool data_request() {return(digitalRead(dreq_pin) == HIGH);}
|
||||
|
||||
void initInBuff();
|
||||
@@ -319,8 +324,8 @@ public:
|
||||
size_t bufferFree();
|
||||
size_t inBufferFilled(){ return bufferFilled(); }
|
||||
size_t inBufferFree(){ return bufferFree(); }
|
||||
void setBalance(int8_t bal = 0);
|
||||
void setTone(int8_t gainLowPass, int8_t gainBandPass, int8_t gainHighPass);
|
||||
void setBalance(int8_t bal = 0);
|
||||
void setTone(int8_t gainLowPass, int8_t gainBandPass, int8_t gainHighPass);
|
||||
void setDefaults();
|
||||
void forceMono(bool m) {} // TODO
|
||||
/* VU METER */
|
||||
|
||||
Reference in New Issue
Block a user