added ANDROID define

This commit is contained in:
badaix 2016-01-02 12:52:20 +01:00
parent 87b1857d8a
commit a28e5a8f3e
4 changed files with 48 additions and 26 deletions

View file

@ -9,14 +9,21 @@ else
TARGET_DIR ?= /usr TARGET_DIR ?= /usr
endif endif
ifdef ANDROID
CXX = /home/johannes/Develop/android-ndk-r10e-arm-21/bin/arm-linux-androideabi-g++ CXX = /home/johannes/Develop/android-ndk-r10e-arm-21/bin/arm-linux-androideabi-g++
#CXX = /usr/bin/g++ 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 = -std=c++0x -Wall -Wno-unused-function -fPIC -O3 -pthread -DASIO_STANDALONE -DVERSION=\"$(VERSION)\" -I.. -I../externals/asio/asio/include -I../externals/popl/include -I/home/johannes/Develop/build/arm/include
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
else
CXX = /usr/bin/g++
CFLAGS = -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 -lasound -logg -lvorbis -lvorbisenc -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
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
BIN = snapclient BIN = snapclient
all: $(TARGET) all: $(TARGET)
$(TARGET): $(OBJ) $(TARGET): $(OBJ)

View file

@ -20,7 +20,9 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <memory> #include <memory>
//#include "decoder/oggDecoder.h" #ifndef ANDROID
#include "decoder/oggDecoder.h"
#endif
#include "decoder/pcmDecoder.h" #include "decoder/pcmDecoder.h"
#include "decoder/flacDecoder.h" #include "decoder/flacDecoder.h"
#include "timeProvider.h" #include "timeProvider.h"
@ -38,7 +40,6 @@ using namespace std;
Controller::Controller() : MessageReceiver(), active_(false), sampleFormat_(NULL), decoder_(NULL), player_(nullptr), asyncException_(false) Controller::Controller() : MessageReceiver(), active_(false), sampleFormat_(NULL), decoder_(NULL), player_(nullptr), asyncException_(false)
{ {
logE << "Controller\n";
} }
@ -113,15 +114,10 @@ bool Controller::sendTimeSyncMessage(long after)
void Controller::start(const PcmDevice& pcmDevice, const std::string& host, size_t port, size_t latency) void Controller::start(const PcmDevice& pcmDevice, const std::string& host, size_t port, size_t latency)
{ {
logE << "start 1\n";
pcmDevice_ = pcmDevice; pcmDevice_ = pcmDevice;
logE << "start 2\n";
latency_ = latency; latency_ = latency;
logE << "start 3\n";
clientConnection_ = new ClientConnection(this, host, port); clientConnection_ = new ClientConnection(this, host, port);
logE << "start 4\n";
controllerThread_ = new thread(&Controller::worker, this); controllerThread_ = new thread(&Controller::worker, this);
logE << "start 5\n";
} }
@ -162,8 +158,10 @@ void Controller::worker()
logO << "Codec: " << headerChunk->codec << "\n"; logO << "Codec: " << headerChunk->codec << "\n";
if (headerChunk->codec == "pcm") if (headerChunk->codec == "pcm")
decoder_ = new PcmDecoder(); decoder_ = new PcmDecoder();
// if (headerChunk->codec == "ogg") #ifndef ANDROID
// decoder_ = new OggDecoder(); if (headerChunk->codec == "ogg")
decoder_ = new OggDecoder();
#endif
else if (headerChunk->codec == "flac") else if (headerChunk->codec == "flac")
decoder_ = new FlacDecoder(); decoder_ = new FlacDecoder();
decoder_->setHeader(headerChunk.get()); decoder_->setHeader(headerChunk.get());
@ -184,7 +182,11 @@ void Controller::worker()
stream_ = new Stream(*sampleFormat_); stream_ = new Stream(*sampleFormat_);
stream_->setBufferLen(serverSettings->bufferMs - latency_); stream_->setBufferLen(serverSettings->bufferMs - latency_);
#ifndef ANDROID
player_.reset(new AlsaPlayer(pcmDevice_, stream_));
#else
player_.reset(new OpenslPlayer(pcmDevice_, stream_)); player_.reset(new OpenslPlayer(pcmDevice_, stream_));
#endif
player_->setVolume(serverSettings->volume / 100.); player_->setVolume(serverSettings->volume / 100.);
player_->start(); player_->start();

View file

@ -24,7 +24,11 @@
#include "decoder/decoder.h" #include "decoder/decoder.h"
#include "message/message.h" #include "message/message.h"
#include "player/pcmDevice.h" #include "player/pcmDevice.h"
#ifdef ANDROID
#include "player/openslPlayer.h" #include "player/openslPlayer.h"
#else
#include "player/alsaPlayer.h"
#endif
#include "clientConnection.h" #include "clientConnection.h"
#include "stream.h" #include "stream.h"

View file

@ -21,9 +21,11 @@
#include "popl.hpp" #include "popl.hpp"
#include "controller.h" #include "controller.h"
//#include "player/alsaPlayer.h" #ifndef ANDROID
//#include "browseAvahi.h" #include "player/alsaPlayer.h"
//#include "common/daemon.h" #include "browseAvahi.h"
#include "common/daemon.h"
#endif
#include "common/log.h" #include "common/log.h"
#include "common/signalHandler.h" #include "common/signalHandler.h"
@ -35,7 +37,8 @@ bool g_terminated = false;
PcmDevice getPcmDevice(const std::string& soundcard) PcmDevice getPcmDevice(const std::string& soundcard)
{ {
/* vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list(); #ifndef ANDROID
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
int soundcardIdx = -1; int soundcardIdx = -1;
try try
@ -52,7 +55,7 @@ PcmDevice getPcmDevice(const std::string& soundcard)
for (auto dev: pcmDevices) for (auto dev: pcmDevices)
if (dev.name.find(soundcard) != string::npos) if (dev.name.find(soundcard) != string::npos)
return dev; return dev;
*/ #endif
PcmDevice pcmDevice; PcmDevice pcmDevice;
return pcmDevice; return pcmDevice;
} }
@ -111,13 +114,15 @@ int main (int argc, char **argv)
if (listSwitch.isSet()) if (listSwitch.isSet())
{ {
/* vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list(); #ifndef ANDROID
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
for (auto dev: pcmDevices) for (auto dev: pcmDevices)
{ {
cout << dev.idx << ": " << dev.name << "\n" cout << dev.idx << ": " << dev.name << "\n"
<< dev.description << "\n\n"; << dev.description << "\n\n";
} }
*/ exit(EXIT_SUCCESS); #endif
exit(EXIT_SUCCESS);
} }
if (helpSwitch.isSet()) if (helpSwitch.isSet())
@ -140,7 +145,8 @@ int main (int argc, char **argv)
if (daemonOption.isSet()) if (daemonOption.isSet())
{ {
/* daemonize("/var/run/snapclient.pid"); #ifndef ANDROID
daemonize("/var/run/snapclient.pid");
if (processPriority < -20) if (processPriority < -20)
processPriority = -20; processPriority = -20;
else if (processPriority > 19) else if (processPriority > 19)
@ -148,7 +154,8 @@ int main (int argc, char **argv)
if (processPriority != 0) if (processPriority != 0)
setpriority(PRIO_PROCESS, 0, processPriority); setpriority(PRIO_PROCESS, 0, processPriority);
logS(kLogNotice) << "daemon started" << std::endl; logS(kLogNotice) << "daemon started" << std::endl;
*/ } #endif
}
PcmDevice pcmDevice = getPcmDevice(soundcard); PcmDevice pcmDevice = getPcmDevice(soundcard);
if (pcmDevice.idx == -1) if (pcmDevice.idx == -1)
@ -159,7 +166,8 @@ int main (int argc, char **argv)
if (host.empty()) if (host.empty())
{ {
/* BrowseAvahi browseAvahi; #ifndef ANDROID
BrowseAvahi browseAvahi;
AvahiResult avahiResult; AvahiResult avahiResult;
while (!g_terminated) while (!g_terminated)
{ {
@ -179,9 +187,8 @@ int main (int argc, char **argv)
} }
usleep(500*1000); usleep(500*1000);
} }
*/ } #endif
}
logO << "host: " << host << "\n";
std::unique_ptr<Controller> controller(new Controller()); std::unique_ptr<Controller> controller(new Controller());
if (!g_terminated) if (!g_terminated)
@ -199,7 +206,9 @@ int main (int argc, char **argv)
} }
logS(kLogNotice) << "daemon terminated." << endl; logS(kLogNotice) << "daemon terminated." << endl;
// daemonShutdown(); #ifndef ANDROID
daemonShutdown();
#endif
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }