20 #include "pulsegateway.h" 24 PulseGateway::PulseGateway(std::shared_ptr<ContainerAbstractInterface> container) :
25 Gateway(ID, container),
30 PulseGateway::~PulseGateway()
36 bool configValue =
false;
39 log_error() <<
"Either \"audio\" key is missing, or not a bool in json configuration";
44 m_enableAudio = configValue;
50 bool PulseGateway::enablePulseAudio() {
51 bool hasPulse =
false;
52 std::string dir = Glib::getenv(PULSE_AUDIO_SERVER_ENVIRONMENT_VARIABLE_NAME, hasPulse);
55 log_error() <<
"Should enable pulseaudio gateway, but " 56 << std::string(PULSE_AUDIO_SERVER_ENVIRONMENT_VARIABLE_NAME)
61 log_info() <<
"Enabling pulseaudio gateway. Socket location : " << dir;
62 std::string pathInContainer = buildPath(
"/gateways/", SOCKET_FILE_NAME);
64 std::shared_ptr<ContainerAbstractInterface> container = getContainer();
65 if (!container->bindMountInContainer(std::string(dir), pathInContainer,
false)) {
66 log_error() <<
"Could not bind mount pulseaudio socket in container";
70 std::string unixPath =
"unix:" + pathInContainer;
71 container->setEnvironmentVariable(PULSE_AUDIO_SERVER_ENVIRONMENT_VARIABLE_NAME, unixPath);
78 log_debug() <<
"Audio will be disabled";
81 log_debug() <<
"Audio will be enabled";
83 return enablePulseAudio();
virtual bool activateGateway() override
Implements Gateway::activateGateway.
bool readConfigElement(const json_t *element) override
Gateway specific parsing of config elements.
Developers guide to adding a config item:
static bool read(const json_t *element, const char *key, std::string &result)
Reads a string from a JSON Object.
virtual bool teardownGateway() override
Implements Gateway::teardownGateway.