diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-09-17 15:05:35 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-09-17 15:05:35 +0200 |
commit | 321a2c3eead634329cda904dbd38d986c3f22c11 (patch) | |
tree | c4339c85c03dd103e0e3ee7b8fb1445c1fc4ffa8 /src | |
parent | b65cd1fe9d453365f0dec0c80d8737eda3d1c338 (diff) | |
parent | ac10ac25317d2027e21b1390054e47201e7aec98 (diff) | |
download | ODR-AudioEnc-321a2c3eead634329cda904dbd38d986c3f22c11.tar.gz ODR-AudioEnc-321a2c3eead634329cda904dbd38d986c3f22c11.tar.bz2 ODR-AudioEnc-321a2c3eead634329cda904dbd38d986c3f22c11.zip |
Merge branch 'next' into padsocket
Diffstat (limited to 'src')
-rw-r--r-- | src/GSTInput.cpp | 4 | ||||
-rw-r--r-- | src/StatsPublish.cpp | 22 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/GSTInput.cpp b/src/GSTInput.cpp index a2401cb..5c63147 100644 --- a/src/GSTInput.cpp +++ b/src/GSTInput.cpp @@ -121,7 +121,11 @@ void GSTInput::prepare() m_gst_data.audio_resample = gst_element_factory_make("audioresample", "audio_resample"); assert(m_gst_data.audio_resample != nullptr); g_object_set(m_gst_data.audio_resample, +#if (GST_VERSION_MAJOR == 1 && GST_VERSION_MINOR >= 10) || GST_VERSION_MAJOR > 1 "sinc-filter-mode", GST_AUDIO_RESAMPLER_FILTER_MODE_FULL, +#else +#warning "GStreamer version is too old to set GST_AUDIO_RESAMPLER_FILTER_MODE_FULL" GST_VERSION_MAJOR +#endif "quality", 6, // between 0 and 10, 10 being best /* default audio-resampler-method: GST_AUDIO_RESAMPLER_METHOD_KAISER */ NULL); diff --git a/src/StatsPublish.cpp b/src/StatsPublish.cpp index cdb32cb..5998913 100644 --- a/src/StatsPublish.cpp +++ b/src/StatsPublish.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------ - * Copyright (C) 2019 Matthias P. Braendli + * Copyright (C) 2020 Matthias P. Braendli * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> +#include <fcntl.h> using namespace std; @@ -35,17 +36,28 @@ StatsPublisher::StatsPublisher(const string& socket_path) : // The client socket binds to a socket whose name depends on PID, and connects to // `socket_path` - m_sock = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0); + m_sock = ::socket(AF_UNIX, SOCK_DGRAM, 0); if (m_sock == -1) { throw runtime_error("Stats socket creation failed: " + string(strerror(errno))); } + int flags = fcntl(m_sock, F_GETFL); + if (flags == -1) { + std::string errstr(strerror(errno)); + throw std::runtime_error("Stats socket: Could not get socket flags: " + errstr); + } + + if (fcntl(m_sock, F_SETFL, flags | O_NONBLOCK) == -1) { + std::string errstr(strerror(errno)); + throw std::runtime_error("Stats socket: Could not set O_NONBLOCK: " + errstr); + } + struct sockaddr_un claddr; memset(&claddr, 0, sizeof(struct sockaddr_un)); claddr.sun_family = AF_UNIX; snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/odr-audioenc.%ld", (long) getpid()); - int ret = bind(m_sock, (const struct sockaddr *) &claddr, sizeof(struct sockaddr_un)); + int ret = ::bind(m_sock, (const struct sockaddr *) &claddr, sizeof(struct sockaddr_un)); if (ret == -1) { throw runtime_error("Stats socket bind failed " + string(strerror(errno))); } @@ -54,7 +66,7 @@ StatsPublisher::StatsPublisher(const string& socket_path) : StatsPublisher::~StatsPublisher() { if (m_sock != -1) { - close(m_sock); + ::close(m_sock); } } @@ -97,7 +109,7 @@ void StatsPublisher::send_stats() claddr.sun_family = AF_UNIX; snprintf(claddr.sun_path, sizeof(claddr.sun_path), "%s", m_socket_path.c_str()); - int ret = sendto(m_sock, yamlstr.data(), yamlstr.size(), 0, + int ret = ::sendto(m_sock, yamlstr.data(), yamlstr.size(), 0, (struct sockaddr *) &claddr, sizeof(struct sockaddr_un)); if (ret == -1) { // This suppresses the -Wlogical-op warning |