mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-13 15:07:01 +03:00
new cspot/bell
This commit is contained in:
@@ -6,13 +6,14 @@
|
||||
using namespace bell;
|
||||
|
||||
class implMDNSService : public MDNSService {
|
||||
private:
|
||||
const std::string type;
|
||||
const std::string proto;
|
||||
void unregisterService() { mdns_service_remove(type.c_str(), proto.c_str()); }
|
||||
private:
|
||||
const std::string type;
|
||||
const std::string proto;
|
||||
void unregisterService() { mdns_service_remove(type.c_str(), proto.c_str()); }
|
||||
|
||||
public:
|
||||
implMDNSService(std::string type, std::string proto) : type(type), proto(proto) { };
|
||||
public:
|
||||
implMDNSService(std::string type, std::string proto)
|
||||
: type(type), proto(proto){};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -21,30 +22,25 @@ public:
|
||||
**/
|
||||
|
||||
std::unique_ptr<MDNSService> MDNSService::registerService(
|
||||
const std::string& serviceName,
|
||||
const std::string& serviceType,
|
||||
const std::string& serviceProto,
|
||||
const std::string& serviceHost,
|
||||
int servicePort,
|
||||
const std::map<std::string, std::string> txtData
|
||||
) {
|
||||
std::vector<mdns_txt_item_t> txtItems;
|
||||
txtItems.reserve(txtData.size());
|
||||
for (auto& data : txtData) {
|
||||
mdns_txt_item_t item;
|
||||
item.key = data.first.c_str();
|
||||
item.value = data.second.c_str();
|
||||
txtItems.push_back(item);
|
||||
}
|
||||
const std::string& serviceName, const std::string& serviceType,
|
||||
const std::string& serviceProto, const std::string& serviceHost,
|
||||
int servicePort, const std::map<std::string, std::string> txtData) {
|
||||
std::vector<mdns_txt_item_t> txtItems;
|
||||
txtItems.reserve(txtData.size());
|
||||
for (auto& data : txtData) {
|
||||
mdns_txt_item_t item;
|
||||
item.key = data.first.c_str();
|
||||
item.value = data.second.c_str();
|
||||
txtItems.push_back(item);
|
||||
}
|
||||
|
||||
mdns_service_add(
|
||||
serviceName.c_str(), /* instance_name */
|
||||
serviceType.c_str(), /* service_type */
|
||||
serviceProto.c_str(), /* proto */
|
||||
servicePort, /* port */
|
||||
txtItems.data(), /* txt */
|
||||
txtItems.size() /* num_items */
|
||||
);
|
||||
mdns_service_add(serviceName.c_str(), /* instance_name */
|
||||
serviceType.c_str(), /* service_type */
|
||||
serviceProto.c_str(), /* proto */
|
||||
servicePort, /* port */
|
||||
txtItems.data(), /* txt */
|
||||
txtItems.size() /* num_items */
|
||||
);
|
||||
|
||||
return std::make_unique<implMDNSService>(serviceType, serviceProto);
|
||||
return std::make_unique<implMDNSService>(serviceType, serviceProto);
|
||||
}
|
||||
|
||||
@@ -6,36 +6,32 @@
|
||||
|
||||
using namespace bell;
|
||||
|
||||
WrappedSemaphore::WrappedSemaphore(int count)
|
||||
{
|
||||
semaphoreHandle = xSemaphoreCreateCounting(count, 0);
|
||||
WrappedSemaphore::WrappedSemaphore(int count) {
|
||||
semaphoreHandle = xSemaphoreCreateCounting(count, 0);
|
||||
}
|
||||
|
||||
WrappedSemaphore::~WrappedSemaphore()
|
||||
{
|
||||
vSemaphoreDelete(semaphoreHandle);
|
||||
WrappedSemaphore::~WrappedSemaphore() {
|
||||
vSemaphoreDelete(semaphoreHandle);
|
||||
}
|
||||
|
||||
int WrappedSemaphore::wait()
|
||||
{
|
||||
if (xSemaphoreTake(semaphoreHandle, portMAX_DELAY) == pdTRUE) {
|
||||
return 0;
|
||||
}
|
||||
int WrappedSemaphore::wait() {
|
||||
if (xSemaphoreTake(semaphoreHandle, portMAX_DELAY) == pdTRUE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int WrappedSemaphore::twait(long milliseconds)
|
||||
{
|
||||
if (xSemaphoreTake(semaphoreHandle, milliseconds / portTICK_PERIOD_MS) == pdTRUE) {
|
||||
return 0;
|
||||
}
|
||||
int WrappedSemaphore::twait(long milliseconds) {
|
||||
if (xSemaphoreTake(semaphoreHandle, milliseconds / portTICK_PERIOD_MS) ==
|
||||
pdTRUE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void WrappedSemaphore::give()
|
||||
{
|
||||
void WrappedSemaphore::give() {
|
||||
|
||||
xSemaphoreGive(semaphoreHandle);
|
||||
xSemaphoreGive(semaphoreHandle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user