mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-28 08:26:16 +02:00
server compiles under OpenWrt
This commit is contained in:
parent
b75bb77fd4
commit
212c9c1c6b
9 changed files with 65 additions and 16 deletions
|
@ -41,6 +41,33 @@ namespace cpt
|
|||
return std::stoi(str);
|
||||
#endif
|
||||
}
|
||||
|
||||
static double stod(const std::string& str)
|
||||
{
|
||||
#ifdef NO_CPP11_STRING
|
||||
return strtod(str.c_str(), NULL);
|
||||
#else
|
||||
return std::stod(str.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
static long double strtold(const char* str, char** endptr)
|
||||
{
|
||||
#ifdef NO_CPP11_STRING
|
||||
return strtod(str, endptr);
|
||||
#else
|
||||
return std::strtold(str, endptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static float strtof(const char* str, char** endptr)
|
||||
{
|
||||
#ifdef NO_CPP11_STRING
|
||||
return (float)strtod(str, endptr);
|
||||
#else
|
||||
return std::strtof(str, endptr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,10 +9,23 @@ else
|
|||
TARGET_DIR ?= /usr
|
||||
endif
|
||||
|
||||
CXX = /usr/bin/g++
|
||||
CXXFLAGS = -std=c++0x -static-libgcc -static-libstdc++ -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)
|
||||
|
||||
STRIP = echo
|
||||
CXXFLAGS += -DIS_BIG_ENDIAN -DNO_CPP11_STRING
|
||||
|
||||
else
|
||||
|
||||
CXX = /usr/bin/g++
|
||||
STRIP = strip
|
||||
CXXFLAGS += -static-libgcc -static-libstdc++
|
||||
|
||||
endif
|
||||
|
||||
|
||||
OBJ = snapServer.o config.o controlServer.o controlSession.o streamServer.o streamSession.o json/jsonrpc.o streamreader/streamUri.o streamreader/streamManager.o streamreader/pcmStream.o streamreader/pipeStream.o streamreader/fileStream.o encoder/encoderFactory.o encoder/flacEncoder.o encoder/pcmEncoder.o encoder/oggEncoder.o publishAvahi.o ../common/log.o ../message/pcmChunk.o ../message/sampleFormat.o
|
||||
BIN = snapserver
|
||||
|
||||
|
@ -20,7 +33,7 @@ all: $(TARGET)
|
|||
|
||||
$(TARGET): $(OBJ)
|
||||
$(CXX) $(CXXFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS)
|
||||
strip $(BIN)
|
||||
$(STRIP) $(BIN)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fstream>
|
||||
#include <cerrno>
|
||||
#include "common/snapException.h"
|
||||
#include "common/compat.h"
|
||||
#include "common/log.h"
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "flacEncoder.h"
|
||||
#include "common/log.h"
|
||||
#include "common/compat.h"
|
||||
#include "common/snapException.h"
|
||||
#include "common/log.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -138,7 +139,7 @@ void FlacEncoder::initEncoder()
|
|||
int quality(2);
|
||||
try
|
||||
{
|
||||
quality = std::stoi(codecOptions_);
|
||||
quality = cpt::stoi(codecOptions_);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "oggEncoder.h"
|
||||
#include "common/snapException.h"
|
||||
#include "common/compat.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/log.h"
|
||||
|
||||
|
@ -136,7 +137,7 @@ void OggEncoder::initEncoder()
|
|||
double quality = 1.0;
|
||||
try
|
||||
{
|
||||
quality = std::stod(qual);
|
||||
quality = cpt::stod(qual);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -201,7 +202,7 @@ void OggEncoder::initEncoder()
|
|||
/* pick a random serial number; that way we can more likely build
|
||||
chained streams just by concatenation */
|
||||
srand(time(NULL));
|
||||
ogg_stream_init(&os,rand());
|
||||
ogg_stream_init(&os, rand());
|
||||
|
||||
/* Vorbis streams begin with three headers; the initial header (with
|
||||
most of the codec setup parameters) which is mandated by the Ogg
|
||||
|
|
|
@ -61,6 +61,8 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation.
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "common/compat.h"
|
||||
|
||||
// enable ssize_t on MinGW
|
||||
#ifdef __GNUC__
|
||||
#ifdef __MINGW32__
|
||||
|
@ -2739,7 +2741,7 @@ class basic_json
|
|||
catch (std::out_of_range&)
|
||||
{
|
||||
// create better exception explanation
|
||||
throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
|
||||
throw std::out_of_range("array index " + cpt::to_string(idx) + " is out of range");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2783,7 +2785,7 @@ class basic_json
|
|||
catch (std::out_of_range&)
|
||||
{
|
||||
// create better exception explanation
|
||||
throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
|
||||
throw std::out_of_range("array index " + cpt::to_string(idx) + " is out of range");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -5789,7 +5791,7 @@ class basic_json
|
|||
// use integer array index as key
|
||||
case value_t::array:
|
||||
{
|
||||
return std::to_string(array_index);
|
||||
return cpt::to_string(array_index);
|
||||
}
|
||||
|
||||
// use key from the object
|
||||
|
@ -7781,7 +7783,7 @@ basic_json_parser_64:
|
|||
|
||||
This function (and its overloads) serves to select the most approprate
|
||||
standard floating point number parsing function (i.e., `std::strtof`,
|
||||
`std::strtod`, or `std::strtold`) based on the type supplied via the
|
||||
`std::strtod`, or `cpt::strtold`) based on the type supplied via the
|
||||
first parameter. Set this to @a static_cast<number_float_t>(nullptr).
|
||||
|
||||
@param[in] type the @ref number_float_t in use
|
||||
|
@ -7791,14 +7793,14 @@ basic_json_parser_64:
|
|||
|
||||
@return the floating point number
|
||||
|
||||
@bug This function uses `std::strtof`, `std::strtod`, or `std::strtold`
|
||||
@bug This function uses `std::strtof`, `std::strtod`, or `cpt::strtold`
|
||||
which use the current C locale to determine which character is used as
|
||||
decimal point character. This may yield to parse errors if the locale
|
||||
does not used `.`.
|
||||
*/
|
||||
long double str_to_float_t(long double* /* type */, char** endptr) const
|
||||
{
|
||||
return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
|
||||
return cpt::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
|
||||
}
|
||||
|
||||
/// @copydoc str_to_float_t
|
||||
|
@ -7810,7 +7812,7 @@ basic_json_parser_64:
|
|||
/// @copydoc str_to_float_t
|
||||
float str_to_float_t(float*, char** endptr) const
|
||||
{
|
||||
return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
|
||||
return cpt::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
USA.
|
||||
***/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include "publishAvahi.h"
|
||||
#include "common/log.h"
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
|
||||
#include "pipeStream.h"
|
||||
#include "../encoder/encoderFactory.h"
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "common/utils.h"
|
||||
#include "streamManager.h"
|
||||
#include "pipeStream.h"
|
||||
#include "fileStream.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/compat.h"
|
||||
#include "common/log.h"
|
||||
#include "common/snapException.h"
|
||||
|
||||
|
@ -43,7 +44,7 @@ PcmStream* StreamManager::addStream(const std::string& uri)
|
|||
streamUri.query["codec"] = codec_;
|
||||
|
||||
if (streamUri.query.find("buffer_ms") == streamUri.query.end())
|
||||
streamUri.query["buffer_ms"] = to_string(readBufferMs_);
|
||||
streamUri.query["buffer_ms"] = cpt::to_string(readBufferMs_);
|
||||
|
||||
// logD << "\nURI: " << streamUri.uri << "\nscheme: " << streamUri.scheme << "\nhost: "
|
||||
// << streamUri.host << "\npath: " << streamUri.path << "\nfragment: " << streamUri.fragment << "\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue