Added defines for OGG, AVAHI, ALSA, OPENSL, DAEMON

This commit is contained in:
badaix 2016-03-23 19:37:04 +01:00
parent 750df78090
commit 54f0ad5a51
5 changed files with 21 additions and 16 deletions

View file

@ -28,14 +28,14 @@ ifdef ANDROID
# make ANDROID=1
CXX = $(NDK_DIR)/bin/arm-linux-androideabi-g++
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
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
else
CXX = /usr/bin/g++
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
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

View file

@ -19,7 +19,7 @@
#include <iostream>
#include <string>
#include <memory>
#ifndef ANDROID
#ifdef HAS_OGG
#include "decoder/oggDecoder.h"
#endif
#include "decoder/pcmDecoder.h"
@ -101,7 +101,7 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
if (headerChunk_->codec == "pcm")
decoder_.reset(new PcmDecoder());
#ifndef ANDROID
#ifdef HAS_OGG
else if (headerChunk_->codec == "ogg")
decoder_.reset(new OggDecoder());
#endif
@ -116,10 +116,12 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
stream_.reset(new Stream(sampleFormat_));
stream_->setBufferLen(serverSettings_->bufferMs - latency_);
#ifndef ANDROID
#ifdef HAS_ALSA
player_.reset(new AlsaPlayer(pcmDevice_, stream_.get()));
#else
#elif HAS_OPENSL
player_.reset(new OpenslPlayer(pcmDevice_, stream_.get()));
#else
throw SnapException("No ALSA or OPENSL support");
#endif
player_->setVolume(serverSettings_->volume / 100.);
player_->setMute(serverSettings_->muted);

View file

@ -25,10 +25,10 @@
#include "message/message.h"
#include "message/serverSettings.h"
#include "player/pcmDevice.h"
#ifdef ANDROID
#include "player/openslPlayer.h"
#else
#ifdef HAS_ALSA
#include "player/alsaPlayer.h"
#elif HAS_OPENSL
#include "player/openslPlayer.h"
#endif
#include "clientConnection.h"
#include "stream.h"

View file

@ -21,9 +21,13 @@
#include "popl.hpp"
#include "controller.h"
#ifndef ANDROID
#ifdef HAS_ALSA
#include "player/alsaPlayer.h"
#endif
#ifdef HAS_AVAHI
#include "browseAvahi.h"
#endif
#ifdef HAS_DAEMON
#include "common/daemon.h"
#endif
#include "common/log.h"
@ -37,7 +41,7 @@ bool g_terminated = false;
PcmDevice getPcmDevice(const std::string& soundcard)
{
#ifndef ANDROID
#ifdef HAS_ALSA
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
try
@ -113,7 +117,7 @@ int main (int argc, char **argv)
if (listSwitch.isSet())
{
#ifndef ANDROID
#ifdef HAS_ALSA
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
for (auto dev: pcmDevices)
{
@ -138,7 +142,7 @@ int main (int argc, char **argv)
if (daemonOption.isSet())
{
#ifndef ANDROID
#ifdef HAS_DAEMON
daemonize("/var/run/snapclient.pid");
if (processPriority < -20)
processPriority = -20;
@ -159,7 +163,7 @@ int main (int argc, char **argv)
if (host.empty())
{
#ifndef ANDROID
#ifdef HAS_AVAHI
BrowseAvahi browseAvahi;
AvahiResult avahiResult;
while (!g_terminated)
@ -199,7 +203,7 @@ int main (int argc, char **argv)
}
logS(kLogNotice) << "daemon terminated." << endl;
#ifndef ANDROID
#ifdef HAS_DAEMON
daemonShutdown();
#endif
exit(EXIT_SUCCESS);

View file

@ -311,7 +311,6 @@ void StreamServer::onMessageReceived(StreamSession* connection, const msg::BaseM
}
Config::instance().save();
//TODO: wording pcmStream vs stream
connection->setPcmStream(stream);
auto headerChunk = stream->getHeader();
connection->send(headerChunk.get());