diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-08-27 08:30:20 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-08-27 08:30:20 +0200 |
commit | 70e72e84212f5b6b15f2e1a2b2d95d1d67abac7f (patch) | |
tree | a21fb353a0b5bcdd89ae249feaf82c4715249cc3 | |
parent | 22df1554f5b6dabfd9c8bb18a0107c36a3cf2aac (diff) | |
download | dabmux-70e72e84212f5b6b15f2e1a2b2d95d1d67abac7f.tar.gz dabmux-70e72e84212f5b6b15f2e1a2b2d95d1d67abac7f.tar.bz2 dabmux-70e72e84212f5b6b15f2e1a2b2d95d1d67abac7f.zip |
Make InputBase::open() return void
-rw-r--r-- | src/DabMultiplexer.cpp | 6 | ||||
-rw-r--r-- | src/input/Edi.cpp | 4 | ||||
-rw-r--r-- | src/input/Edi.h | 2 | ||||
-rw-r--r-- | src/input/File.cpp | 3 | ||||
-rw-r--r-- | src/input/File.h | 2 | ||||
-rw-r--r-- | src/input/Prbs.cpp | 4 | ||||
-rw-r--r-- | src/input/Prbs.h | 2 | ||||
-rw-r--r-- | src/input/Udp.cpp | 8 | ||||
-rw-r--r-- | src/input/Udp.h | 4 | ||||
-rw-r--r-- | src/input/Zmq.cpp | 4 | ||||
-rw-r--r-- | src/input/Zmq.h | 2 | ||||
-rw-r--r-- | src/input/inputs.h | 6 |
12 files changed, 18 insertions, 29 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index 0d68ac2..498e9e0 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -308,10 +308,8 @@ void DabMultiplexer::prepare_data_inputs() (*subchannel)->startAddress = (*(subchannel - 1))->startAddress + (*(subchannel - 1))->getSizeCu(); } - if ((*subchannel)->input->open((*subchannel)->inputUri) == -1) { - perror((*subchannel)->inputUri.c_str()); - throw MuxInitException(); - } + + (*subchannel)->input->open((*subchannel)->inputUri); // TODO Check errors int subch_bitrate = (*subchannel)->input->setBitrate( (*subchannel)->bitrate); diff --git a/src/input/Edi.cpp b/src/input/Edi.cpp index 765a355..58ad38b 100644 --- a/src/input/Edi.cpp +++ b/src/input/Edi.cpp @@ -57,7 +57,7 @@ Edi::~Edi() { } } -int Edi::open(const std::string& name) +void Edi::open(const std::string& name) { const std::regex re_udp("udp://:([0-9]+)"); const std::regex re_tcp("tcp://(.*):([0-9]+)"); @@ -91,8 +91,6 @@ int Edi::open(const std::string& name) m_running = true; m_thread = std::thread(&Edi::m_run, this); - - return 0; } int Edi::readFrame(uint8_t* buffer, size_t size) diff --git a/src/input/Edi.h b/src/input/Edi.h index 66ff682..cd1167c 100644 --- a/src/input/Edi.h +++ b/src/input/Edi.h @@ -52,7 +52,7 @@ class Edi : public InputBase { Edi& operator=(const Edi&) = delete; ~Edi(); - virtual int open(const std::string& name); + virtual void open(const std::string& name); virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); virtual int close(); diff --git a/src/input/File.cpp b/src/input/File.cpp index 20036ae..3c2ef4c 100644 --- a/src/input/File.cpp +++ b/src/input/File.cpp @@ -58,7 +58,7 @@ __attribute((packed)) ; -int FileBase::open(const std::string& name) +void FileBase::open(const std::string& name) { int flags = O_RDONLY | O_BINARY; if (m_nonblock) { @@ -70,7 +70,6 @@ int FileBase::open(const std::string& name) throw std::runtime_error("Could not open input file " + name + ": " + strerror(errno)); } - return 0; } int FileBase::setBitrate(int bitrate) diff --git a/src/input/File.h b/src/input/File.h index b574c39..79b78b5 100644 --- a/src/input/File.h +++ b/src/input/File.h @@ -36,7 +36,7 @@ namespace Inputs { class FileBase : public InputBase { public: - virtual int open(const std::string& name); + virtual void open(const std::string& name); virtual int readFrame(uint8_t* buffer, size_t size) = 0; virtual int setBitrate(int bitrate); virtual int close(); diff --git a/src/input/Prbs.cpp b/src/input/Prbs.cpp index 7856a46..821f7b1 100644 --- a/src/input/Prbs.cpp +++ b/src/input/Prbs.cpp @@ -44,7 +44,7 @@ namespace Inputs { // Preferred polynomial is G(x) = x^20 + x^17 + 1 const uint32_t PRBS_DEFAULT_POLY = (1 << 20) | (1 << 17) | (1 << 0); -int Prbs::open(const string& name) +void Prbs::open(const string& name) { if (name.substr(0, 7) != "prbs://") { throw logic_error("Invalid PRBS name"); @@ -73,8 +73,6 @@ int Prbs::open(const string& name) m_prbs.setup(polynomial); } rewind(); - - return 0; } int Prbs::readFrame(uint8_t* buffer, size_t size) diff --git a/src/input/Prbs.h b/src/input/Prbs.h index 51b7756..76fd6fa 100644 --- a/src/input/Prbs.h +++ b/src/input/Prbs.h @@ -37,7 +37,7 @@ namespace Inputs { class Prbs : public InputBase { public: - virtual int open(const std::string& name); + virtual void open(const std::string& name); virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); virtual int close(); diff --git a/src/input/Udp.cpp b/src/input/Udp.cpp index 5d4f964..b527530 100644 --- a/src/input/Udp.cpp +++ b/src/input/Udp.cpp @@ -38,7 +38,7 @@ using namespace std; namespace Inputs { -int Udp::open(const std::string& name) +void Udp::open(const std::string& name) { // Skip the udp:// part if it is present const string endpoint = (name.substr(0, 6) == "udp://") ? @@ -57,8 +57,6 @@ int Udp::open(const std::string& name) m_name = name; openUdpSocket(endpoint); - - return 0; } void Udp::openUdpSocket(const std::string& endpoint) @@ -149,7 +147,7 @@ static uint16_t unpack2(const uint8_t *buf) return (((uint16_t)buf[0]) << 8) | buf[1]; } -int Sti_d_Rtp::open(const std::string& name) +void Sti_d_Rtp::open(const std::string& name) { // Skip the rtp:// part if it is present const string endpoint = (name.substr(0, 10) == "rtp://") ? @@ -168,8 +166,6 @@ int Sti_d_Rtp::open(const std::string& name) m_name = name; openUdpSocket(endpoint); - - return 0; } void Sti_d_Rtp::receive_packet() diff --git a/src/input/Udp.h b/src/input/Udp.h index dd637c6..d74e92f 100644 --- a/src/input/Udp.h +++ b/src/input/Udp.h @@ -40,7 +40,7 @@ namespace Inputs { */ class Udp : public InputBase { public: - virtual int open(const std::string& name); + virtual void open(const std::string& name); virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); virtual int close(); @@ -67,7 +67,7 @@ class Sti_d_Rtp : public Udp { using vec_u8 = std::vector<uint8_t>; public: - virtual int open(const std::string& name); + virtual void open(const std::string& name); virtual int readFrame(uint8_t* buffer, size_t size); private: diff --git a/src/input/Zmq.cpp b/src/input/Zmq.cpp index 2e35907..ce7f439 100644 --- a/src/input/Zmq.cpp +++ b/src/input/Zmq.cpp @@ -220,7 +220,7 @@ void ZmqBase::rebind() } } -int ZmqBase::open(const std::string& inputUri) +void ZmqBase::open(const std::string& inputUri) { m_inputUri = inputUri; @@ -229,8 +229,6 @@ int ZmqBase::open(const std::string& inputUri) // We want to appear in the statistics ! m_stats.registerAtServer(); - - return 0; } int ZmqBase::close() diff --git a/src/input/Zmq.h b/src/input/Zmq.h index eb67fe5..bf2d5ae 100644 --- a/src/input/Zmq.h +++ b/src/input/Zmq.h @@ -180,7 +180,7 @@ class ZmqBase : public InputBase, public RemoteControllable { INVALIDATE_KEY(m_curve_encoder_key); } - virtual int open(const std::string& inputUri); + virtual void open(const std::string& inputUri); virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); virtual int close(); diff --git a/src/input/inputs.h b/src/input/inputs.h index bfb1fb6..b823998 100644 --- a/src/input/inputs.h +++ b/src/input/inputs.h @@ -2,7 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2019 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -38,7 +38,9 @@ namespace Inputs { /* New input object base */ class InputBase { public: - virtual int open(const std::string& name) = 0; + /* Throws runtime_error or invalid_argument on failure */ + virtual void open(const std::string& name) = 0; + virtual int readFrame(uint8_t* buffer, size_t size) = 0; virtual int setBitrate(int bitrate) = 0; virtual int close() = 0; |