mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-10 05:27:01 +03:00
Start of 5.X work
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include <PlainConnection.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <inttypes.h>
|
||||
#include <fstream>
|
||||
#include <stdarg.h>
|
||||
@@ -29,9 +28,11 @@
|
||||
#include "esp_http_server.h"
|
||||
#include "cspot_private.h"
|
||||
#include "cspot_sink.h"
|
||||
#include "Configurator.h"
|
||||
#include "Config.h"
|
||||
#include "tools.h"
|
||||
#include "accessors.h"
|
||||
#include "tools_http_utils.h"
|
||||
|
||||
static class cspotPlayer *player;
|
||||
|
||||
static const struct {
|
||||
@@ -69,7 +70,7 @@ private:
|
||||
void enableZeroConf(void);
|
||||
|
||||
void runTask();
|
||||
sys_Spotify * cspot_config = NULL;
|
||||
sys_spotify_config * cspot_config = NULL;
|
||||
|
||||
public:
|
||||
typedef enum {TRACK_INIT, TRACK_NOTIFY, TRACK_STREAM, TRACK_END} TrackStatus;
|
||||
@@ -86,7 +87,7 @@ cspotPlayer::cspotPlayer(const char* name, httpd_handle_t server, int port, cspo
|
||||
serverHandle(server), serverPort(port),
|
||||
cmdHandler(cmdHandler), dataHandler(dataHandler) {
|
||||
|
||||
if(!SYS_SERVICES_SPOTIFY(cspot_config)){
|
||||
if(!sys_services_config_SPOTIFY(cspot_config)){
|
||||
return;
|
||||
}
|
||||
volume = cspot_config->volume;
|
||||
@@ -360,8 +361,8 @@ void cspotPlayer::runTask() {
|
||||
// we might have been forced to use zeroConf, so store credentials and reset zeroConf usage
|
||||
if (!zeroConf) {
|
||||
useZeroConf = false;
|
||||
if(configurator_set_string(&sys_State_msg,sys_State_cspot_credentials_tag,sys_state,credentials.c_str())){
|
||||
configurator.RaiseStateModified();
|
||||
if(system_set_string(&sys_state_data_msg,sys_state_data_cspot_credentials_tag,sys_state,credentials.c_str())){
|
||||
config_raise_state_changed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +417,7 @@ void cspotPlayer::runTask() {
|
||||
if (state == DISCO) {
|
||||
// update volume then
|
||||
cspot_config->volume = volume;
|
||||
configurator_raise_changed();
|
||||
config_raise_changed(false);
|
||||
// in ZeroConf mod, stay connected (in this loop)
|
||||
if (!zeroConf) state = LINKED;
|
||||
}
|
||||
|
||||
@@ -1754,6 +1754,9 @@ class ProtoFile:
|
||||
for extension in self.extensions:
|
||||
yield extension.extension_decl()
|
||||
yield '\n'
|
||||
yield '#ifdef __cplusplus\n'
|
||||
yield 'extern "C" {\n'
|
||||
yield '#endif\n\n'
|
||||
|
||||
if self.enums:
|
||||
yield '/* Helper constants for enums */\n'
|
||||
@@ -1761,9 +1764,6 @@ class ProtoFile:
|
||||
yield enum.auxiliary_defines() + '\n'
|
||||
yield '\n'
|
||||
|
||||
yield '#ifdef __cplusplus\n'
|
||||
yield 'extern "C" {\n'
|
||||
yield '#endif\n\n'
|
||||
|
||||
if self.messages:
|
||||
yield '/* Initializer values for message structs */\n'
|
||||
|
||||
@@ -17,6 +17,24 @@
|
||||
#include "pb_decode.h"
|
||||
#include "pb_common.h"
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h> // Include this header for PRIu64
|
||||
|
||||
|
||||
// Macros for debugging encode/decode
|
||||
// #define DUMP_PB_ENABLE 1
|
||||
#ifdef DUMP_PB_ENABLE
|
||||
#define DUMP_PB_FIELD(iter,msg) dump_pb_field(iter,msg, __FUNCTION__, __LINE__)
|
||||
#define DUMP_PB_HEAD(iter,msg) dump_pb_head(iter,msg, __FUNCTION__, __LINE__)
|
||||
#define DUMP_PB_MARK(msg) printf("MRK\t%-30s\t%-20s\t%-5d\n",msg, __FUNCTION__, __LINE__)
|
||||
#define WRITE_DEBUG_HEADER() write_debug_header()
|
||||
#else
|
||||
#define DUMP_PB_FIELD(iter,msg)
|
||||
#define DUMP_PB_HEAD(iter,msg)
|
||||
#define DUMP_PB_MARK(msg)
|
||||
#define WRITE_DEBUG_HEADER()
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************
|
||||
* Declarations internal to this file *
|
||||
**************************************/
|
||||
@@ -122,13 +140,13 @@ void dump_pb_field(const pb_field_iter_t* iter, const char* msg, const char* fun
|
||||
"| %-20s"
|
||||
"| %-20s"
|
||||
"| %-20s"
|
||||
"| %-10zu|\n",
|
||||
"| %-10zu| %-20zu|\n",
|
||||
"FLD", msg, func, line,
|
||||
"","","",
|
||||
iter->submessage_index,iter->index, iter->field_info_index, iter->required_field_index,
|
||||
iter->tag, iter->data_size, iter->array_size,
|
||||
pb_ltype_description(iter->type), pb_htype_description(iter->type), pb_atype_description(iter->type),
|
||||
iter->type);
|
||||
iter->type,PB_LTYPE(iter->type)==PB_LTYPE_STRING && iter->pData && strlen(iter->pData)>0?iter->pData:"");
|
||||
}
|
||||
void dump_pb_head(const pb_msgdesc_t* desc, const char* msg, const char* func, int line) {
|
||||
if (!desc) {
|
||||
@@ -160,18 +178,7 @@ void dump_pb_head(const pb_msgdesc_t* desc, const char* msg, const char* func, i
|
||||
"");
|
||||
}
|
||||
|
||||
// Macros for convenience
|
||||
#ifdef DUMP_PB_ENABLE
|
||||
#define DUMP_PB_FIELD(iter,msg) dump_pb_field(iter,msg, __FUNCTION__, __LINE__)
|
||||
#define DUMP_PB_HEAD(iter,msg) dump_pb_head(iter,msg, __FUNCTION__, __LINE__)
|
||||
#define DUMP_PB_MARK(msg) printf("MRK\t%-30s\t%-20s\t%-5d\n",msg, __FUNCTION__, __LINE__)
|
||||
#define WRITE_DEBUG_HEADER write_debug_header()
|
||||
#else
|
||||
#define DUMP_PB_FIELD(iter,msg)
|
||||
#define DUMP_PB_HEAD(iter,msg)
|
||||
#define DUMP_PB_MARK(msg)
|
||||
#define WRITE_DEBUG_HEADER()
|
||||
#endif
|
||||
|
||||
|
||||
static bool checkreturn buf_read(pb_istream_t *stream, pb_byte_t *buf, size_t count);
|
||||
static bool checkreturn pb_decode_varint32_eof(pb_istream_t *stream, uint32_t *dest, bool *eof);
|
||||
@@ -1282,7 +1289,7 @@ static bool checkreturn pb_decode_inner(pb_istream_t *stream, const pb_msgdesc_t
|
||||
if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
|
||||
&& iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
|
||||
{
|
||||
DUMP_PB_FIELD("Mark field as seen",&iter);
|
||||
DUMP_PB_FIELD(&iter,"Mark field as seen");
|
||||
uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
|
||||
fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
|
||||
}
|
||||
@@ -1595,6 +1602,7 @@ static bool checkreturn pb_dec_bool(pb_istream_t *stream, const pb_field_iter_t
|
||||
return pb_decode_bool(stream, (bool*)field->pData);
|
||||
}
|
||||
|
||||
|
||||
static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_iter_t *field)
|
||||
{
|
||||
if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
|
||||
@@ -1615,8 +1623,11 @@ static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_iter_
|
||||
else
|
||||
PB_RETURN_ERROR(stream, "invalid data_size");
|
||||
|
||||
if (clamped != value)
|
||||
PB_RETURN_ERROR(stream, "integer too large");
|
||||
if (clamped != value) {
|
||||
printf("Clamped value: %" PRIu64 ", Original value: %" PRIu64 "\n", clamped, value);
|
||||
PB_RETURN_ERROR(stream, "integer too large");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1660,8 +1671,10 @@ static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_iter_
|
||||
else
|
||||
PB_RETURN_ERROR(stream, "invalid data_size");
|
||||
|
||||
if (clamped != svalue)
|
||||
if (clamped != svalue){
|
||||
printf("Clamped value: %" PRIi64 ", Original value: %" PRIi64 "\n", clamped, svalue);
|
||||
PB_RETURN_ERROR(stream, "integer too large");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1749,12 +1762,11 @@ static bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_iter_
|
||||
|
||||
if (!pb_read(stream, dest, (size_t)size))
|
||||
return false;
|
||||
|
||||
#ifdef PB_VALIDATE_UTF8
|
||||
if (!pb_validate_utf8((const char*)dest))
|
||||
PB_RETURN_ERROR(stream, "invalid utf8");
|
||||
#endif
|
||||
|
||||
DUMP_PB_FIELD(field,"String");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "esp_console.h"
|
||||
#include "esp_pthread.h"
|
||||
#include "esp_system.h"
|
||||
#include "Configurator.h"
|
||||
#include "Config.h"
|
||||
#include "audio_controls.h"
|
||||
#include "display.h"
|
||||
#include "accessors.h"
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "tools.h"
|
||||
#include "cspot_private.h"
|
||||
#include "cspot_sink.h"
|
||||
#include "tools_http_utils.h"
|
||||
|
||||
char EXT_RAM_ATTR deviceId[16];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user