mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-22 10:57:39 +02:00
Added defines for OGG, AVAHI, ALSA, OPENSL, DAEMON
This commit is contained in:
parent
750df78090
commit
54f0ad5a51
5 changed files with 21 additions and 16 deletions
|
@ -28,14 +28,14 @@ ifdef ANDROID
|
||||||
# make ANDROID=1
|
# make ANDROID=1
|
||||||
CXX = $(NDK_DIR)/bin/arm-linux-androideabi-g++
|
CXX = $(NDK_DIR)/bin/arm-linux-androideabi-g++
|
||||||
STRIP = $(NDK_DIR)/bin/arm-linux-androideabi-strip
|
STRIP = $(NDK_DIR)/bin/arm-linux-androideabi-strip
|
||||||
CFLAGS = $(ADD_CFLAGS) -std=c++0x -Wall -Wno-unused-function -fPIC -O3 -pthread -DASIO_STANDALONE -DANDROID -DVERSION=\"$(VERSION)\" -I.. -I../externals/asio/asio/include -I../externals/popl/include -I/home/johannes/Develop/build/arm/include
|
CFLAGS = $(ADD_CFLAGS) -std=c++0x -Wall -Wno-unused-function -fPIC -O3 -pthread -DASIO_STANDALONE -DANDROID -DHAS_OPENSL -DVERSION=\"$(VERSION)\" -I.. -I../externals/asio/asio/include -I../externals/popl/include -I/home/johannes/Develop/build/arm/include
|
||||||
#-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
#-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
||||||
LDFLAGS = -L/home/johannes/Develop/build/arm/lib -pie -lFLAC -lOpenSLES
|
LDFLAGS = -L/home/johannes/Develop/build/arm/lib -pie -lFLAC -lOpenSLES
|
||||||
OBJ = snapClient.o stream.o clientConnection.o timeProvider.o player/player.o player/openslPlayer.o decoder/pcmDecoder.o decoder/flacDecoder.o controller.o ../message/pcmChunk.o ../common/log.o ../message/sampleFormat.o
|
OBJ = snapClient.o stream.o clientConnection.o timeProvider.o player/player.o player/openslPlayer.o decoder/pcmDecoder.o decoder/flacDecoder.o controller.o ../message/pcmChunk.o ../common/log.o ../message/sampleFormat.o
|
||||||
else
|
else
|
||||||
CXX = /usr/bin/g++
|
CXX = /usr/bin/g++
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
CFLAGS = -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
|
CFLAGS = -std=c++0x -static-libgcc -static-libstdc++ -Wall -Wno-unused-function -O3 -pthread -DASIO_STANDALONE -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON -DVERSION=\"$(VERSION)\" -I.. -I../externals/asio/asio/include -I../externals/popl/include
|
||||||
LDFLAGS = -lrt -lasound -logg -lvorbis -lFLAC -lavahi-client -lavahi-common
|
LDFLAGS = -lrt -lasound -logg -lvorbis -lFLAC -lavahi-client -lavahi-common
|
||||||
OBJ = snapClient.o stream.o clientConnection.o timeProvider.o player/player.o player/alsaPlayer.o decoder/oggDecoder.o decoder/pcmDecoder.o decoder/flacDecoder.o controller.o browseAvahi.o ../message/pcmChunk.o ../common/log.o ../message/sampleFormat.o
|
OBJ = snapClient.o stream.o clientConnection.o timeProvider.o player/player.o player/alsaPlayer.o decoder/oggDecoder.o decoder/pcmDecoder.o decoder/flacDecoder.o controller.o browseAvahi.o ../message/pcmChunk.o ../common/log.o ../message/sampleFormat.o
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#ifndef ANDROID
|
#ifdef HAS_OGG
|
||||||
#include "decoder/oggDecoder.h"
|
#include "decoder/oggDecoder.h"
|
||||||
#endif
|
#endif
|
||||||
#include "decoder/pcmDecoder.h"
|
#include "decoder/pcmDecoder.h"
|
||||||
|
@ -101,7 +101,7 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
|
||||||
|
|
||||||
if (headerChunk_->codec == "pcm")
|
if (headerChunk_->codec == "pcm")
|
||||||
decoder_.reset(new PcmDecoder());
|
decoder_.reset(new PcmDecoder());
|
||||||
#ifndef ANDROID
|
#ifdef HAS_OGG
|
||||||
else if (headerChunk_->codec == "ogg")
|
else if (headerChunk_->codec == "ogg")
|
||||||
decoder_.reset(new OggDecoder());
|
decoder_.reset(new OggDecoder());
|
||||||
#endif
|
#endif
|
||||||
|
@ -116,10 +116,12 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
|
||||||
stream_.reset(new Stream(sampleFormat_));
|
stream_.reset(new Stream(sampleFormat_));
|
||||||
stream_->setBufferLen(serverSettings_->bufferMs - latency_);
|
stream_->setBufferLen(serverSettings_->bufferMs - latency_);
|
||||||
|
|
||||||
#ifndef ANDROID
|
#ifdef HAS_ALSA
|
||||||
player_.reset(new AlsaPlayer(pcmDevice_, stream_.get()));
|
player_.reset(new AlsaPlayer(pcmDevice_, stream_.get()));
|
||||||
#else
|
#elif HAS_OPENSL
|
||||||
player_.reset(new OpenslPlayer(pcmDevice_, stream_.get()));
|
player_.reset(new OpenslPlayer(pcmDevice_, stream_.get()));
|
||||||
|
#else
|
||||||
|
throw SnapException("No ALSA or OPENSL support");
|
||||||
#endif
|
#endif
|
||||||
player_->setVolume(serverSettings_->volume / 100.);
|
player_->setVolume(serverSettings_->volume / 100.);
|
||||||
player_->setMute(serverSettings_->muted);
|
player_->setMute(serverSettings_->muted);
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
#include "message/message.h"
|
#include "message/message.h"
|
||||||
#include "message/serverSettings.h"
|
#include "message/serverSettings.h"
|
||||||
#include "player/pcmDevice.h"
|
#include "player/pcmDevice.h"
|
||||||
#ifdef ANDROID
|
#ifdef HAS_ALSA
|
||||||
#include "player/openslPlayer.h"
|
|
||||||
#else
|
|
||||||
#include "player/alsaPlayer.h"
|
#include "player/alsaPlayer.h"
|
||||||
|
#elif HAS_OPENSL
|
||||||
|
#include "player/openslPlayer.h"
|
||||||
#endif
|
#endif
|
||||||
#include "clientConnection.h"
|
#include "clientConnection.h"
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
|
|
|
@ -21,9 +21,13 @@
|
||||||
|
|
||||||
#include "popl.hpp"
|
#include "popl.hpp"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#ifndef ANDROID
|
#ifdef HAS_ALSA
|
||||||
#include "player/alsaPlayer.h"
|
#include "player/alsaPlayer.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_AVAHI
|
||||||
#include "browseAvahi.h"
|
#include "browseAvahi.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_DAEMON
|
||||||
#include "common/daemon.h"
|
#include "common/daemon.h"
|
||||||
#endif
|
#endif
|
||||||
#include "common/log.h"
|
#include "common/log.h"
|
||||||
|
@ -37,7 +41,7 @@ bool g_terminated = false;
|
||||||
|
|
||||||
PcmDevice getPcmDevice(const std::string& soundcard)
|
PcmDevice getPcmDevice(const std::string& soundcard)
|
||||||
{
|
{
|
||||||
#ifndef ANDROID
|
#ifdef HAS_ALSA
|
||||||
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -113,7 +117,7 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
if (listSwitch.isSet())
|
if (listSwitch.isSet())
|
||||||
{
|
{
|
||||||
#ifndef ANDROID
|
#ifdef HAS_ALSA
|
||||||
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
||||||
for (auto dev: pcmDevices)
|
for (auto dev: pcmDevices)
|
||||||
{
|
{
|
||||||
|
@ -138,7 +142,7 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
if (daemonOption.isSet())
|
if (daemonOption.isSet())
|
||||||
{
|
{
|
||||||
#ifndef ANDROID
|
#ifdef HAS_DAEMON
|
||||||
daemonize("/var/run/snapclient.pid");
|
daemonize("/var/run/snapclient.pid");
|
||||||
if (processPriority < -20)
|
if (processPriority < -20)
|
||||||
processPriority = -20;
|
processPriority = -20;
|
||||||
|
@ -159,7 +163,7 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
if (host.empty())
|
if (host.empty())
|
||||||
{
|
{
|
||||||
#ifndef ANDROID
|
#ifdef HAS_AVAHI
|
||||||
BrowseAvahi browseAvahi;
|
BrowseAvahi browseAvahi;
|
||||||
AvahiResult avahiResult;
|
AvahiResult avahiResult;
|
||||||
while (!g_terminated)
|
while (!g_terminated)
|
||||||
|
@ -199,7 +203,7 @@ int main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
logS(kLogNotice) << "daemon terminated." << endl;
|
logS(kLogNotice) << "daemon terminated." << endl;
|
||||||
#ifndef ANDROID
|
#ifdef HAS_DAEMON
|
||||||
daemonShutdown();
|
daemonShutdown();
|
||||||
#endif
|
#endif
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
|
@ -311,7 +311,6 @@ void StreamServer::onMessageReceived(StreamSession* connection, const msg::BaseM
|
||||||
}
|
}
|
||||||
Config::instance().save();
|
Config::instance().save();
|
||||||
|
|
||||||
//TODO: wording pcmStream vs stream
|
|
||||||
connection->setPcmStream(stream);
|
connection->setPcmStream(stream);
|
||||||
auto headerChunk = stream->getHeader();
|
auto headerChunk = stream->getHeader();
|
||||||
connection->send(headerChunk.get());
|
connection->send(headerChunk.get());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue