41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
#include <mpg123.h>
|
|
#include <portaudio.h>
|
|
#include <stdexcept>
|
|
#include "argparse/argparse.hpp"
|
|
#include "Manager.hpp"
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
// initialize the mpg123 library
|
|
if (mpg123_init() != MPG123_OK)
|
|
throw std::runtime_error("Error while initializing mpg123.");
|
|
|
|
// initialize the PortAudio library
|
|
if (Pa_Initialize() != paNoError)
|
|
throw std::runtime_error("Could not initialize PortAudio.");
|
|
|
|
argparse::ArgumentParser parser("Program");
|
|
parser.add_argument("-h", "--host").help("Host address").default_value(std::string("127.0.0.1"));
|
|
parser.add_argument("-p", "--port").help("Port").default_value(std::string("15650"));
|
|
parser.add_argument("-6", "--ipv6").help("Use IPv6").flag();
|
|
|
|
try {
|
|
parser.parse_args(argc, argv);
|
|
} catch (const std::exception& exception) {
|
|
std::cerr << exception.what() << std::endl;
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
auto eventManager = Manager(
|
|
parser.get<std::string>("--host"),
|
|
parser.get<std::string>("--port"),
|
|
parser.get<bool>("-6")
|
|
);
|
|
eventManager.loop();
|
|
|
|
// terminate the libraries
|
|
Pa_Terminate();
|
|
mpg123_exit();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|