mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-13 06:57:07 +03:00
update CSpot
This commit is contained in:
@@ -12,8 +12,12 @@ class AudioSink
|
||||
virtual ~AudioSink() {}
|
||||
virtual void feedPCMFrames(const uint8_t *buffer, size_t bytes) = 0;
|
||||
virtual void volumeChanged(uint16_t volume) {}
|
||||
// return true if the sink supports rate changing
|
||||
virtual bool setRate(uint16_t sampleRate) { return false; }
|
||||
// Return false if the sink doesn't support reconfiguration.
|
||||
virtual bool setParams(uint32_t sampleRate, uint8_t channelCount, uint8_t bitDepth) { return false; }
|
||||
// Deprecated. Implement/use setParams() instead.
|
||||
virtual inline bool setRate(uint16_t sampleRate) {
|
||||
return setParams(sampleRate, 2, 16);
|
||||
}
|
||||
bool softwareVolumeControl = true;
|
||||
bool usign = false;
|
||||
};
|
||||
|
||||
@@ -78,6 +78,7 @@ struct HTTPConnection {
|
||||
std::string httpMethod;
|
||||
bool toBeClosed = false;
|
||||
bool isEventConnection = false;
|
||||
bool isCaptivePortal = false;
|
||||
};
|
||||
|
||||
class BaseHTTPServer {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
namespace bell {
|
||||
|
||||
std::string generateRandomUUID();
|
||||
void freeAndNull(void *&ptr);
|
||||
|
||||
} // namespace bell
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class BiquadFilter
|
||||
private:
|
||||
std::mutex processMutex;
|
||||
float coeffs[5];
|
||||
float w[2];
|
||||
float w[2] = {0, 0};
|
||||
|
||||
public:
|
||||
BiquadFilter(){};
|
||||
|
||||
@@ -36,14 +36,14 @@ class HTTPClient {
|
||||
std::map<std::string, std::string> headers;
|
||||
|
||||
uint16_t statusCode;
|
||||
size_t contentLength;
|
||||
uint32_t contentLength;
|
||||
std::string contentType;
|
||||
std::string location;
|
||||
bool isChunked = false;
|
||||
bool isGzip = false;
|
||||
bool isComplete = false;
|
||||
bool isRedirect = false;
|
||||
size_t redirectCount = 0;
|
||||
uint8_t redirectCount = 0;
|
||||
std::ostream *dumpFs = nullptr;
|
||||
std::ostream *dumpRawFs = nullptr;
|
||||
|
||||
@@ -51,34 +51,34 @@ class HTTPClient {
|
||||
void close() override;
|
||||
|
||||
void readHeaders();
|
||||
size_t read(char *dst, size_t len, bool wait = false);
|
||||
uint32_t read(char *dst, uint32_t len, bool wait = false);
|
||||
std::string readToString();
|
||||
|
||||
inline size_t skip(size_t len) override {
|
||||
return read((char *)nullptr, len);
|
||||
return (size_t)read((char *)nullptr, len);
|
||||
}
|
||||
inline size_t read(uint8_t *dst, size_t len) override {
|
||||
return read((char *)dst, len);
|
||||
return (size_t)read((char *)dst, len, false);
|
||||
}
|
||||
inline size_t read(uint8_t *dst, size_t len, bool wait) {
|
||||
inline uint32_t read(uint8_t *dst, uint32_t len, bool wait) {
|
||||
return read((char *)dst, len, wait);
|
||||
}
|
||||
inline size_t size() override {
|
||||
return contentLength;
|
||||
return (size_t)contentLength;
|
||||
}
|
||||
inline size_t position() override {
|
||||
return bodyRead;
|
||||
return (size_t)bodyRead;
|
||||
}
|
||||
|
||||
private:
|
||||
char *buf = nullptr; // allocated buffer
|
||||
char *bufPtr = nullptr; // reading pointer within buf
|
||||
size_t bodyRead = 0;
|
||||
size_t bufRemaining = 0;
|
||||
size_t chunkRemaining = 0;
|
||||
uint32_t bodyRead = 0;
|
||||
uint32_t bufRemaining = 0;
|
||||
uint32_t chunkRemaining = 0;
|
||||
bool isStreaming = false;
|
||||
size_t readRaw(char *dst);
|
||||
bool skipRaw(size_t len, bool dontRead = false);
|
||||
uint32_t readRaw(char *dst);
|
||||
bool skipRaw(uint32_t len, bool dontRead = false);
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<struct HTTPClient::HTTPResponse> HTTPResponse_t;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace bell
|
||||
std::vector<std::string> splitUrl(const std::string &url, char delimiter);
|
||||
std::mutex responseMutex;
|
||||
std::vector<char> responseBuffer = std::vector<char>(128);
|
||||
|
||||
void redirectCaptivePortal(int connectionFd);
|
||||
void readFromClient(int clientFd);
|
||||
std::map<std::string, std::string> parseQueryString(const std::string &queryString);
|
||||
unsigned char h2int(char c);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define JSONOBJECT_H
|
||||
#include <cJSON.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace bell {
|
||||
class JSONValue
|
||||
@@ -24,6 +26,7 @@ namespace bell {
|
||||
~JSONObject();
|
||||
JSONValue operator[](std::string index);
|
||||
std::string toString();
|
||||
std::vector<uint8_t> toVector();
|
||||
|
||||
private:
|
||||
cJSON* body;
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace bell
|
||||
sizeof(int)); /* length of option value */
|
||||
|
||||
freeaddrinfo(addr);
|
||||
std::cout << "Socket opened" << std::endl;
|
||||
}
|
||||
|
||||
size_t read(uint8_t *buf, size_t len) {
|
||||
@@ -83,11 +84,11 @@ namespace bell
|
||||
return send(sockFd, buf, len, 0);
|
||||
}
|
||||
|
||||
size_t poll() {
|
||||
int value;
|
||||
ioctl(sockFd, FIONREAD, &value);
|
||||
return value;
|
||||
}
|
||||
size_t poll() {
|
||||
int value;
|
||||
ioctl(sockFd, FIONREAD, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
void close() {
|
||||
if (!isClosed) {
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
class BufferedAudioSink : public AudioSink
|
||||
{
|
||||
public:
|
||||
void feedPCMFrames(const uint8_t *buffer, size_t bytes);
|
||||
bool setRate(uint16_t sampleRate) override;
|
||||
void feedPCMFrames(const uint8_t *buffer, size_t bytes) override;
|
||||
bool setParams(uint32_t sampleRate, uint8_t channelCount, uint8_t bitDepth) override;
|
||||
protected:
|
||||
void startI2sFeed(size_t buf_size = 4096 * 8);
|
||||
void feedPCMFramesInternal(const void *pvItem, size_t xItemSize);
|
||||
|
||||
@@ -19,8 +19,7 @@ public:
|
||||
explicit SPDIFAudioSink(uint8_t spdifPin);
|
||||
~SPDIFAudioSink() override;
|
||||
void feedPCMFrames(const uint8_t *buffer, size_t bytes) override;
|
||||
void initialize(uint16_t sampleRate);
|
||||
bool setRate(uint16_t sampleRate) override;
|
||||
bool setParams(uint32_t sampleRate, uint8_t channelCount, uint8_t bitDepth) override;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include "portaudio.h"
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include "AudioSink.h"
|
||||
|
||||
@@ -10,11 +10,10 @@ class PortAudioSink : public AudioSink
|
||||
{
|
||||
public:
|
||||
PortAudioSink();
|
||||
~PortAudioSink();
|
||||
void feedPCMFrames(const uint8_t *buffer, size_t bytes);
|
||||
void initialize(uint16_t sampleRate);
|
||||
bool setRate(uint16_t sampleRate) override;
|
||||
~PortAudioSink() override;
|
||||
void feedPCMFrames(const uint8_t *buffer, size_t bytes) override;
|
||||
bool setParams(uint32_t sampleRate, uint8_t channelCount, uint8_t bitDepth) override;
|
||||
|
||||
private:
|
||||
PaStream *stream;
|
||||
PaStream *stream = nullptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user