mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-06 12:51:42 +02:00
server runs on OpenWrt
This commit is contained in:
parent
212c9c1c6b
commit
41db245efc
4 changed files with 42 additions and 34 deletions
|
@ -17,8 +17,8 @@ include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
define Package/snapcast/Default
|
define Package/snapcast/Default
|
||||||
SECTION := sxx
|
SECTION := sxx
|
||||||
CATEGORY := Sxx
|
CATEGORY := Sxx
|
||||||
TITLE := snapcast
|
TITLE := snapcast
|
||||||
DEPENDS := +libstdcpp +libavahi-client +libatomic +libogg +libflac
|
DEPENDS := +libstdcpp +libavahi-client +libatomic +libogg +libflac
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ endef
|
||||||
|
|
||||||
define Package/snapcast
|
define Package/snapcast
|
||||||
$(call Package/snapcast/Default)
|
$(call Package/snapcast/Default)
|
||||||
TITLE += packages
|
TITLE += packages
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/snapcast/description
|
define Package/snapcast/description
|
||||||
|
@ -39,7 +39,8 @@ endef
|
||||||
|
|
||||||
define Package/snapserver
|
define Package/snapserver
|
||||||
$(call Package/snapcast/Default)
|
$(call Package/snapcast/Default)
|
||||||
TITLE += snapserver
|
TITLE += snapserver
|
||||||
|
DEPENDS += +libvorbis #+libvorbisenc
|
||||||
HIDDEN := 1
|
HIDDEN := 1
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -61,19 +62,19 @@ define Package/snapclient/description
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/snapcast/config
|
define Package/snapcast/config
|
||||||
menu "Select snapcast Options"
|
menu "Select snapcast Options"
|
||||||
depends on PACKAGE_snapcast
|
depends on PACKAGE_snapcast
|
||||||
comment "Choose server or client to compile"
|
comment "Choose server or client to compile"
|
||||||
config PACKAGE_snapserver
|
config PACKAGE_snapserver
|
||||||
prompt "Compile snapserver"
|
prompt "Compile snapserver"
|
||||||
help
|
help
|
||||||
Compile multiroom server.
|
Compile multiroom server
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config PACKAGE_snapclient
|
config PACKAGE_snapclient
|
||||||
prompt "Compile snapclient."
|
prompt "Compile snapclient"
|
||||||
help
|
help
|
||||||
Compile multiroom client.
|
Compile multiroom client
|
||||||
default n
|
default n
|
||||||
endmenu
|
endmenu
|
||||||
endef
|
endef
|
||||||
|
@ -90,8 +91,8 @@ define Build/Prepare
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Compile
|
define Build/Compile
|
||||||
# $(if $(CONFIG_PACKAGE_snapserver), \
|
$(if $(CONFIG_PACKAGE_snapserver), \
|
||||||
# $(call Build/Compile/Default, -C server),)
|
$(call Build/Compile/Default, -C server TARGET=OPENWRT),)
|
||||||
|
|
||||||
$(if $(CONFIG_PACKAGE_snapclient), \
|
$(if $(CONFIG_PACKAGE_snapclient), \
|
||||||
$(call Build/Compile/Default, -C client TARGET=OPENWRT),)
|
$(call Build/Compile/Default, -C client TARGET=OPENWRT),)
|
||||||
|
@ -111,6 +112,6 @@ define Package/snapclient/install
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/client/snapclient $(1)/usr/bin/
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/client/snapclient $(1)/usr/bin/
|
||||||
endef
|
endef
|
||||||
|
|
||||||
#$(eval $(call BuildPackage,snapserver))
|
$(eval $(call BuildPackage,snapserver))
|
||||||
$(eval $(call BuildPackage,snapclient))
|
$(eval $(call BuildPackage,snapclient))
|
||||||
$(eval $(call BuildPackage,snapcast))
|
$(eval $(call BuildPackage,snapcast))
|
||||||
|
|
|
@ -10,18 +10,19 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CXXFLAGS += -std=c++0x -Wall -Wno-unused-function -O3 -pthread -DASIO_STANDALONE -DVERSION=\"$(VERSION)\" -I.. -I../externals/asio/asio/include -I../externals/popl/include
|
CXXFLAGS += -std=c++0x -Wall -Wno-unused-function -O3 -pthread -DASIO_STANDALONE -DVERSION=\"$(VERSION)\" -I.. -I../externals/asio/asio/include -I../externals/popl/include
|
||||||
LDFLAGS = -lrt -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common
|
|
||||||
|
|
||||||
ifeq ($(TARGET), OPENWRT)
|
ifeq ($(TARGET), OPENWRT)
|
||||||
|
|
||||||
STRIP = echo
|
STRIP = echo
|
||||||
CXXFLAGS += -DIS_BIG_ENDIAN -DNO_CPP11_STRING
|
CXXFLAGS += -DIS_BIG_ENDIAN -DNO_CPP11_STRING
|
||||||
|
LDFLAGS = -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common -latomic
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
CXX = /usr/bin/g++
|
CXX = /usr/bin/g++
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
CXXFLAGS += -static-libgcc -static-libstdc++
|
CXXFLAGS += -static-libgcc -static-libstdc++
|
||||||
|
LDFLAGS = -lrt -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,16 @@
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "common/endian.h"
|
||||||
#include "pcmEncoder.h"
|
#include "pcmEncoder.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define ID_RIFF 0x46464952
|
||||||
|
#define ID_WAVE 0x45564157
|
||||||
|
#define ID_FMT 0x20746d66
|
||||||
|
#define ID_DATA 0x61746164
|
||||||
|
|
||||||
|
|
||||||
PcmEncoder::PcmEncoder(const std::string& codecOptions) : Encoder(codecOptions)
|
PcmEncoder::PcmEncoder(const std::string& codecOptions) : Encoder(codecOptions)
|
||||||
{
|
{
|
||||||
headerChunk_.reset(new msg::Header("pcm"));
|
headerChunk_.reset(new msg::Header("pcm"));
|
||||||
|
@ -35,30 +42,22 @@ void PcmEncoder::encode(const msg::PcmChunk* chunk)
|
||||||
|
|
||||||
void PcmEncoder::initEncoder()
|
void PcmEncoder::initEncoder()
|
||||||
{
|
{
|
||||||
//TODO: Endianess
|
|
||||||
headerChunk_->payloadSize = 44;
|
headerChunk_->payloadSize = 44;
|
||||||
headerChunk_->payload = (char*)malloc(headerChunk_->payloadSize);
|
headerChunk_->payload = (char*)malloc(headerChunk_->payloadSize);
|
||||||
memcpy(headerChunk_->payload, "RIFF", 4);
|
char* payload = headerChunk_->payload;
|
||||||
uint32_t int32 = 36;
|
assign(payload, SWAP_32(ID_RIFF));
|
||||||
memcpy(headerChunk_->payload + 4, reinterpret_cast<const char *>(&int32), sizeof(uint32_t));
|
assign(payload + 4, SWAP_32(36));
|
||||||
memcpy(headerChunk_->payload + 8, "WAVEfmt ", 8);
|
assign(payload + 8, SWAP_32(ID_WAVE));
|
||||||
int32 = 16;
|
assign(payload + 12, SWAP_32(ID_FMT));
|
||||||
memcpy(headerChunk_->payload + 16, reinterpret_cast<const char *>(&int32), sizeof(uint32_t));
|
assign(payload + 16, SWAP_32(16));
|
||||||
uint16_t int16 = 1;
|
assign(payload + 20, SWAP_16(1));
|
||||||
memcpy(headerChunk_->payload + 20, reinterpret_cast<const char *>(&int16), sizeof(uint16_t));
|
assign(payload + 22, SWAP_16(sampleFormat_.channels));
|
||||||
int16 = sampleFormat_.channels;
|
assign(payload + 24, SWAP_32(sampleFormat_.rate));
|
||||||
memcpy(headerChunk_->payload + 22, reinterpret_cast<const char *>(&int16), sizeof(uint16_t));
|
assign(payload + 28, SWAP_32(sampleFormat_.rate * sampleFormat_.bits * sampleFormat_.channels / 8));
|
||||||
int32 = sampleFormat_.rate;
|
assign(payload + 32, SWAP_16(sampleFormat_.channels * ((sampleFormat_.bits + 7) / 8)));
|
||||||
memcpy(headerChunk_->payload + 24, reinterpret_cast<const char *>(&int32), sizeof(uint32_t));
|
assign(payload + 34, SWAP_16(sampleFormat_.bits));
|
||||||
int32 = sampleFormat_.rate * sampleFormat_.bits * sampleFormat_.channels / 8;
|
assign(payload + 36, SWAP_32(ID_DATA));
|
||||||
memcpy(headerChunk_->payload + 28, reinterpret_cast<const char *>(&int32), sizeof(uint32_t));
|
assign(payload + 40, SWAP_32(0));
|
||||||
int16 = sampleFormat_.channels * ((sampleFormat_.bits + 7) / 8);
|
|
||||||
memcpy(headerChunk_->payload + 32, reinterpret_cast<const char *>(&int16), sizeof(uint16_t));
|
|
||||||
int16 = sampleFormat_.bits;
|
|
||||||
memcpy(headerChunk_->payload + 34, reinterpret_cast<const char *>(&int16), sizeof(uint16_t));
|
|
||||||
memcpy(headerChunk_->payload + 36, "data", 4);
|
|
||||||
int32 = 0;
|
|
||||||
memcpy(headerChunk_->payload + 40, reinterpret_cast<const char *>(&int32), sizeof(uint32_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,13 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initEncoder();
|
virtual void initEncoder();
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void assign(void* pointer, T val)
|
||||||
|
{
|
||||||
|
T* p = (T*)pointer;
|
||||||
|
*p = val;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue