mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-04 20:01:44 +02:00
android hacks
This commit is contained in:
parent
6796209c9f
commit
42bceb60fe
4 changed files with 40 additions and 24 deletions
|
@ -9,18 +9,19 @@ else
|
||||||
TARGET_DIR ?= /usr
|
TARGET_DIR ?= /usr
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CXX = /usr/bin/g++
|
CXX = /home/johannes/Develop/android-ndk-r10e-arm-21/bin/arm-linux-androideabi-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
|
#CXX = /usr/bin/g++
|
||||||
LDFLAGS = -lrt -lasound -logg -lvorbis -lvorbisenc -lFLAC -lavahi-client -lavahi-common
|
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
|
||||||
|
|
||||||
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/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)
|
||||||
$(CXX) $(CFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS)
|
$(CXX) $(CFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS)
|
||||||
strip $(BIN)
|
# strip $(BIN)
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) $(CFLAGS) -c $< -o $@
|
$(CXX) $(CFLAGS) -c $< -o $@
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "decoder/oggDecoder.h"
|
//#include "decoder/oggDecoder.h"
|
||||||
#include "decoder/pcmDecoder.h"
|
#include "decoder/pcmDecoder.h"
|
||||||
#include "decoder/flacDecoder.h"
|
#include "decoder/flacDecoder.h"
|
||||||
#include "timeProvider.h"
|
#include "timeProvider.h"
|
||||||
|
@ -38,6 +38,7 @@ 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,10 +113,15 @@ 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,10 +160,10 @@ void Controller::worker()
|
||||||
shared_ptr<msg::Header> headerChunk(NULL);
|
shared_ptr<msg::Header> headerChunk(NULL);
|
||||||
while (active_ && !(headerChunk = clientConnection_->sendReq<msg::Header>(&requestMsg)));
|
while (active_ && !(headerChunk = clientConnection_->sendReq<msg::Header>(&requestMsg)));
|
||||||
logO << "Codec: " << headerChunk->codec << "\n";
|
logO << "Codec: " << headerChunk->codec << "\n";
|
||||||
if (headerChunk->codec == "ogg")
|
if (headerChunk->codec == "pcm")
|
||||||
decoder_ = new OggDecoder();
|
|
||||||
else if (headerChunk->codec == "pcm")
|
|
||||||
decoder_ = new PcmDecoder();
|
decoder_ = new PcmDecoder();
|
||||||
|
// if (headerChunk->codec == "ogg")
|
||||||
|
// decoder_ = new OggDecoder();
|
||||||
else if (headerChunk->codec == "flac")
|
else if (headerChunk->codec == "flac")
|
||||||
decoder_ = new FlacDecoder();
|
decoder_ = new FlacDecoder();
|
||||||
decoder_->setHeader(headerChunk.get());
|
decoder_->setHeader(headerChunk.get());
|
||||||
|
@ -178,7 +184,7 @@ void Controller::worker()
|
||||||
stream_ = new Stream(*sampleFormat_);
|
stream_ = new Stream(*sampleFormat_);
|
||||||
stream_->setBufferLen(serverSettings->bufferMs - latency_);
|
stream_->setBufferLen(serverSettings->bufferMs - latency_);
|
||||||
|
|
||||||
player_.reset(new AlsaPlayer(pcmDevice_, stream_));
|
player_.reset(new OpenslPlayer(pcmDevice_, stream_));
|
||||||
player_->setVolume(serverSettings->volume / 100.);
|
player_->setVolume(serverSettings->volume / 100.);
|
||||||
player_->start();
|
player_->start();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "decoder/decoder.h"
|
#include "decoder/decoder.h"
|
||||||
#include "message/message.h"
|
#include "message/message.h"
|
||||||
#include "player/pcmDevice.h"
|
#include "player/pcmDevice.h"
|
||||||
#include "player/alsaPlayer.h"
|
#include "player/openslPlayer.h"
|
||||||
#include "clientConnection.h"
|
#include "clientConnection.h"
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
#include "popl.hpp"
|
#include "popl.hpp"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "player/alsaPlayer.h"
|
//#include "player/alsaPlayer.h"
|
||||||
#include "browseAvahi.h"
|
//#include "browseAvahi.h"
|
||||||
#include "common/daemon.h"
|
//#include "common/daemon.h"
|
||||||
#include "common/log.h"
|
#include "common/log.h"
|
||||||
#include "common/signalHandler.h"
|
#include "common/signalHandler.h"
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ bool g_terminated = false;
|
||||||
|
|
||||||
PcmDevice getPcmDevice(const std::string& soundcard)
|
PcmDevice getPcmDevice(const std::string& soundcard)
|
||||||
{
|
{
|
||||||
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
/* vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
||||||
int soundcardIdx = -1;
|
int soundcardIdx = -1;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -52,7 +52,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;
|
||||||
|
*/
|
||||||
PcmDevice pcmDevice;
|
PcmDevice pcmDevice;
|
||||||
return pcmDevice;
|
return pcmDevice;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,9 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
logO << "1\n";
|
||||||
op.parse(argc, argv);
|
op.parse(argc, argv);
|
||||||
|
logO << "2\n";
|
||||||
}
|
}
|
||||||
catch (const std::invalid_argument& e)
|
catch (const std::invalid_argument& e)
|
||||||
{
|
{
|
||||||
|
@ -111,13 +113,13 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
if (listSwitch.isSet())
|
if (listSwitch.isSet())
|
||||||
{
|
{
|
||||||
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
/* 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);
|
*/ exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (helpSwitch.isSet())
|
if (helpSwitch.isSet())
|
||||||
|
@ -126,6 +128,9 @@ int main (int argc, char **argv)
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << "1\n";
|
||||||
|
|
||||||
|
logO << "1\n";
|
||||||
|
|
||||||
std::clog.rdbuf(new Log("snapclient", LOG_DAEMON));
|
std::clog.rdbuf(new Log("snapclient", LOG_DAEMON));
|
||||||
|
|
||||||
|
@ -133,9 +138,11 @@ int main (int argc, char **argv)
|
||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
signal(SIGINT, signal_handler);
|
signal(SIGINT, signal_handler);
|
||||||
|
|
||||||
|
logO << "1\n";
|
||||||
|
|
||||||
if (daemonOption.isSet())
|
if (daemonOption.isSet())
|
||||||
{
|
{
|
||||||
daemonize("/var/run/snapclient.pid");
|
/* daemonize("/var/run/snapclient.pid");
|
||||||
if (processPriority < -20)
|
if (processPriority < -20)
|
||||||
processPriority = -20;
|
processPriority = -20;
|
||||||
else if (processPriority > 19)
|
else if (processPriority > 19)
|
||||||
|
@ -143,18 +150,18 @@ 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;
|
||||||
}
|
*/ }
|
||||||
|
|
||||||
PcmDevice pcmDevice = getPcmDevice(soundcard);
|
PcmDevice pcmDevice = getPcmDevice(soundcard);
|
||||||
if (pcmDevice.idx == -1)
|
if (pcmDevice.idx == -1)
|
||||||
{
|
{
|
||||||
cout << "soundcard \"" << soundcard << "\" not found\n";
|
cout << "soundcard \"" << soundcard << "\" not found\n";
|
||||||
exit(EXIT_FAILURE);
|
// exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host.empty())
|
if (host.empty())
|
||||||
{
|
{
|
||||||
BrowseAvahi browseAvahi;
|
/* BrowseAvahi browseAvahi;
|
||||||
AvahiResult avahiResult;
|
AvahiResult avahiResult;
|
||||||
while (!g_terminated)
|
while (!g_terminated)
|
||||||
{
|
{
|
||||||
|
@ -174,7 +181,9 @@ int main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
usleep(500*1000);
|
usleep(500*1000);
|
||||||
}
|
}
|
||||||
}
|
*/ }
|
||||||
|
|
||||||
|
logO << "host: " << host << "\n";
|
||||||
|
|
||||||
std::unique_ptr<Controller> controller(new Controller());
|
std::unique_ptr<Controller> controller(new Controller());
|
||||||
if (!g_terminated)
|
if (!g_terminated)
|
||||||
|
@ -192,7 +201,7 @@ int main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
logS(kLogNotice) << "daemon terminated." << endl;
|
logS(kLogNotice) << "daemon terminated." << endl;
|
||||||
daemonShutdown();
|
// daemonShutdown();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue