mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-25 06:56:15 +02:00
controller
git-svn-id: svn://elaine/murooma/trunk@242 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
e342a4108e
commit
00fac3eccb
15 changed files with 126 additions and 116 deletions
|
@ -9,12 +9,8 @@
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include "common/sampleFormat.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/log.h"
|
||||
#include "stream.h"
|
||||
#include "player.h"
|
||||
#include "serverConnection.h"
|
||||
#include "controller.h"
|
||||
|
||||
|
||||
|
@ -27,32 +23,31 @@ namespace po = boost::program_options;
|
|||
int main (int argc, char *argv[])
|
||||
{
|
||||
int deviceIdx;
|
||||
Stream* stream;
|
||||
string ip;
|
||||
int bufferMs;
|
||||
size_t port;
|
||||
bool runAsDaemon;
|
||||
string sampleFormat;
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help,h", "produce help message")
|
||||
("port,p", po::value<size_t>(&port)->default_value(98765), "port where the server listens on")
|
||||
("ip,i", po::value<string>(&ip)->default_value("192.168.0.2"), "server IP")
|
||||
("soundcard,s", po::value<int>(&deviceIdx)->default_value(-1), "index of the soundcard")
|
||||
("sampleformat,f", po::value<string>(&sampleFormat)->default_value("48000:16:2"), "sample format")
|
||||
("buffer,b", po::value<int>(&bufferMs)->default_value(300), "buffer size [ms]")
|
||||
("daemon,d", po::bool_switch(&runAsDaemon)->default_value(false), "daemonize")
|
||||
;
|
||||
// string sampleFormat;
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help,h", "produce help message")
|
||||
("port,p", po::value<size_t>(&port)->default_value(98765), "port where the server listens on")
|
||||
("ip,i", po::value<string>(&ip)->default_value("192.168.0.2"), "server IP")
|
||||
("soundcard,s", po::value<int>(&deviceIdx)->default_value(-1), "index of the soundcard")
|
||||
// ("sampleformat,f", po::value<string>(&sampleFormat)->default_value("48000:16:2"), "sample format")
|
||||
("buffer,b", po::value<int>(&bufferMs)->default_value(300), "buffer size [ms]")
|
||||
("daemon,d", po::bool_switch(&runAsDaemon)->default_value(false), "daemonize")
|
||||
;
|
||||
|
||||
po::variables_map vm;
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
po::variables_map vm;
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("help"))
|
||||
{
|
||||
cout << desc << "\n";
|
||||
return 1;
|
||||
}
|
||||
if (vm.count("help"))
|
||||
{
|
||||
cout << desc << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::clog.rdbuf(new Log("snapclient", LOG_DAEMON));
|
||||
if (runAsDaemon)
|
||||
|
@ -61,18 +56,13 @@ int main (int argc, char *argv[])
|
|||
std::clog << kLogNotice << "daemon started" << std::endl;
|
||||
}
|
||||
|
||||
stream = new Stream(SampleFormat(sampleFormat));
|
||||
stream->setBufferLen(bufferMs);
|
||||
|
||||
Player player(stream);
|
||||
player.start();
|
||||
ServerConnection serverConnection(stream);
|
||||
serverConnection.start(&serverConnection, ip, port);
|
||||
Controller controller;
|
||||
controller.start(ip, port, bufferMs);
|
||||
|
||||
while(true)
|
||||
usleep(10000);
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue