diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-09-17 15:06:08 +0200 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-09-17 15:06:08 +0200 | 
| commit | e2edbaeee5d593a24bc97d8210e9a0d525996274 (patch) | |
| tree | c573338cfa37da9c3b8f807670715ebaf7dfeb03 | |
| parent | eb1182eb8760131c591f6b8932a8694849c18e3c (diff) | |
| parent | 33706e0aea432bafe6b2f49e248192b595761f82 (diff) | |
| download | ODR-SourceCompanion-e2edbaeee5d593a24bc97d8210e9a0d525996274.tar.gz ODR-SourceCompanion-e2edbaeee5d593a24bc97d8210e9a0d525996274.tar.bz2 ODR-SourceCompanion-e2edbaeee5d593a24bc97d8210e9a0d525996274.zip | |
Merge branch 'next' into padsocket
| -rw-r--r-- | .travis.yml | 47 | ||||
| -rw-r--r-- | src/StatsPublish.cpp | 22 | ||||
| -rw-r--r-- | src/odr-sourcecompanion.cpp | 13 | 
3 files changed, 77 insertions, 5 deletions
| diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3fd0017 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,47 @@ +language: c++ + +matrix: +  include: +    - env: CONF="" +      os: osx +      osx_image: xcode11 +      compiler: clang + +    - env: CONF="" +      os: linux +      arch: amd64 +      dist: bionic +      sudo: required +      compiler: gcc +      addons: &linuxaddons +        apt: +          sources: &sources +            - sourceline: 'ppa:ubuntu-toolchain-r/test' +          packages: &packages +            - libzmq3-dev +            - libzmq5 +            - libfdk-aac-dev +            - automake +            - libtool +            - g++-9 + +before_install: +  - | +    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then +    brew update +    brew install automake || true +    brew install zeromq || true +    brew install fdk-aac || true +    fi + +script: +  - | +    ./bootstrap +    if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then +    export CC=gcc-9 +    export CXX=g++-9 +    fi +    ./configure $CONF +    make + + 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 diff --git a/src/odr-sourcecompanion.cpp b/src/odr-sourcecompanion.cpp index 8c8a776..7e57698 100644 --- a/src/odr-sourcecompanion.cpp +++ b/src/odr-sourcecompanion.cpp @@ -80,6 +80,7 @@ void usage(const char* name) {      "         --timeout=ms                         Maximum frame waiting time, in milliseconds (def=2000)\n"        "         --pad-port=port                      Port opened for PAD Frame requests (def=0 not opened)\n"      "         --jitter-size=nbFrames               Jitter buffer size, in 24ms frames (def=40)\n" +    "         --version                            Print version information and quit\n"      "   Encoder parameters:\n"      "     -b, --bitrate={ 8, 16, ..., 192 }    Output bitrate in kbps. Must be a multiple of 8.\n"      "     -c, --channels={ 1, 2 }              Nb of input channels (default: 2).\n" @@ -113,6 +114,18 @@ void usage(const char* name) {  int main(int argc, char *argv[])  { +    // Version handling is done very early to ensure nothing else but the version gets printed out +    if (argc == 2 and strcmp(argv[1], "--version") == 0) { +        fprintf(stdout, "%s\n", +#if defined(GITVERSION) +                GITVERSION +#else +                PACKAGE_VERSION +#endif +               ); +        return 0; +    } +      std::string avt_input_uri = "";      std::string avt_output_uri = "";      int32_t avt_timeout = 2000; | 
