diff --git a/.gitmodules b/.gitmodules index 9e5401ab..62a995ff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "externals/tremor"] path = externals/tremor url = https://git.xiph.org/tremor.git +[submodule "externals/vorbis"] + path = externals/vorbis + url = https://git.xiph.org/vorbis.git diff --git a/client/Makefile b/client/Makefile index be189a89..f72afcdf 100644 --- a/client/Makefile +++ b/client/Makefile @@ -36,7 +36,7 @@ else ifeq ($(TARGET), MACOS) CXX = /usr/bin/g++ STRIP = strip -CXXFLAGS += -DHAS_OGG -DHAS_COREAUDIO -DFREEBSD -DMACOS -DHAS_BONJOUR -I/usr/local/include -Wno-unused-local-typedef -Wno-deprecated +CXXFLAGS += -DHAS_OGG -DHAS_COREAUDIO -DFREEBSD -DMACOS -DHAS_BONJOUR -DHAS_DAEMON -I/usr/local/include -Wno-unused-local-typedef -Wno-deprecated LDFLAGS = -logg -lvorbis -lFLAC -L/usr/local/lib -framework AudioToolbox -framework CoreFoundation OBJ += player/coreAudioPlayer.o browseZeroConf/browseBonjour.o diff --git a/externals/build_externals_android.sh b/externals/build_externals_android.sh index 916f8799..21b5568c 100755 --- a/externals/build_externals_android.sh +++ b/externals/build_externals_android.sh @@ -17,6 +17,13 @@ make make install make clean +cd ../vorbis +./autogen.sh +./configure --host=arm --prefix=$NDK_DIR --with-ogg=$NDK_DIR +make +make install +make clean + cd ../tremor ./autogen.sh ./configure --host=arm --prefix=$NDK_DIR --with-ogg=$NDK_DIR diff --git a/externals/vorbis b/externals/vorbis new file mode 160000 index 00000000..143caf40 --- /dev/null +++ b/externals/vorbis @@ -0,0 +1 @@ +Subproject commit 143caf4023a90c09a5eb685fdd46fb9b9c36b1ee diff --git a/server/Makefile b/server/Makefile index ff5be9ec..eb1b6a2c 100644 --- a/server/Makefile +++ b/server/Makefile @@ -9,41 +9,49 @@ else TARGET_DIR ?= /usr endif -CXXFLAGS += -std=c++0x -Wall -Wno-unused-function -O3 -DASIO_STANDALONE -DVERSION=\"$(VERSION)\" -I. -I.. -I../externals/asio/asio/include -I../externals/popl/include +CXXFLAGS += $(ADD_CFLAGS) -std=c++0x -Wall -Wno-unused-function -O3 -DASIO_STANDALONE -DVERSION=\"$(VERSION)\" -I. -I.. -I../externals/asio/asio/include -I../externals/popl/include +LDFLAGS = -lvorbis -lvorbisenc -logg -lFLAC 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 ../common/log.o ../common/sampleFormat.o ../message/pcmChunk.o ifeq ($(ENDIAN), BIG) CXXFLAGS += -DIS_BIG_ENDIAN endif -ifeq ($(TARGET), OPENWRT) +ifeq ($(TARGET), ANDROID) + +CXX = $(NDK_DIR)/bin/arm-linux-androideabi-g++ +STRIP = $(NDK_DIR)/bin/arm-linux-androideabi-strip +CXXFLAGS += -pthread -DANDROID -DNO_CPP11_STRING -fPIC -I$(NDK_DIR)/include +LDFLAGS += -L$(NDK_DIR)/lib -pie + +else ifeq ($(TARGET), OPENWRT) STRIP = echo -CXXFLAGS += -DNO_CPP11_STRING -DHAS_AVAHI -pthread -LDFLAGS = -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common -latomic +CXXFLAGS += -DNO_CPP11_STRING -DHAS_AVAHI -DHAS_DAEMON -pthread +LDFLAGS += -lavahi-client -lavahi-common -latomic OBJ += publishZeroConf/publishAvahi.o else ifeq ($(TARGET), FREEBSD) CXX = /usr/local/bin/g++ STRIP = echo -CXXFLAGS += -DNO_CPP11_STRING -DFREEBSD -DHAS_AVAHI -pthread -LDFLAGS = -lrt -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common -static-libgcc -static-libstdc++ +CXXFLAGS += -DNO_CPP11_STRING -DFREEBSD -DHAS_AVAHI -DHAS_DAEMON -pthread +LDFLAGS += -lrt -lavahi-client -lavahi-common -static-libgcc -static-libstdc++ OBJ += publishZeroConf/publishAvahi.o else ifeq ($(TARGET), MACOS) CXX = /usr/bin/g++ STRIP = strip -CXXFLAGS += -DFREEBSD -DMACOS -DHAS_BONJOUR -Wno-deprecated -I/usr/local/include -LDFLAGS = -lvorbis -lvorbisenc -logg -lFLAC -L/usr/local/lib +CXXFLAGS += -DFREEBSD -DMACOS -DHAS_BONJOUR -DHAS_DAEMON -Wno-deprecated -I/usr/local/include +LDFLAGS += -L/usr/local/lib OBJ += publishZeroConf/publishBonjour.o else CXX = /usr/bin/g++ STRIP = strip -CXXFLAGS += -DHAS_AVAHI -pthread +CXXFLAGS += -DHAS_AVAHI -DHAS_DAEMON -pthread LDFLAGS = -lrt -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common -static-libgcc -static-libstdc++ OBJ += publishZeroConf/publishAvahi.o diff --git a/server/build_android.sh b/server/build_android.sh new file mode 100755 index 00000000..4e8f3c1d --- /dev/null +++ b/server/build_android.sh @@ -0,0 +1,5 @@ +export NDK_DIR="/home/johannes/Develop/android-toolchain-arm-14" +export ADD_CFLAGS="" +make clean; make TARGET=ANDROID -j 3; cp ./snapserver ../android/Snapcast/src/main/assets/bin/armeabi/ +export ADD_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16" +make clean; make TARGET=ANDROID -j 3; cp ./snapserver ../android/Snapcast/src/main/assets/bin/armeabi-v7a/ diff --git a/server/snapServer.cpp b/server/snapServer.cpp index 88d780af..0e7443e3 100644 --- a/server/snapServer.cpp +++ b/server/snapServer.cpp @@ -21,7 +21,9 @@ #include #include "popl.hpp" +#ifdef HAS_DAEMON #include "common/daemon.h" +#endif #include "common/timeDefs.h" #include "common/signalHandler.h" #include "common/snapException.h" @@ -77,7 +79,10 @@ int main(int argc, char* argv[]) .add(codecValue) .add(streamBufferValue) .add(bufferValue) - .add(daemonOption); +#ifdef HAS_DAEMON + .add(daemonOption) +#endif + ; try { @@ -138,6 +143,7 @@ int main(int argc, char* argv[]) if (daemonOption.isSet()) { +#ifdef HAS_DAEMON daemonize("/var/run/snapserver.pid"); if (processPriority < -20) processPriority = -20; @@ -146,6 +152,7 @@ int main(int argc, char* argv[]) if (processPriority != 0) setpriority(PRIO_PROCESS, 0, processPriority); logS(kLogNotice) << "daemon started" << std::endl; +#endif } #if defined(HAS_AVAHI) || defined(HAS_BONJOUR) PublishZeroConf publishZeroConfg("Snapcast"); @@ -180,7 +187,9 @@ int main(int argc, char* argv[]) } logS(kLogNotice) << "daemon terminated." << endl; +#ifdef HAS_DAEMON daemonShutdown(); +#endif return 0; }