summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-03-20 14:42:22 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-03-20 14:42:22 +0100
commit4422ab97c43e13735d274219a2957aae7ec60d76 (patch)
treef85e6899bb832f93060921cb06f45cd7eefa2ada
parent645b9e87fc5dab2cf87bfef1d5b2ba2ce2f85089 (diff)
downloaddabmod-4422ab97c43e13735d274219a2957aae7ec60d76.tar.gz
dabmod-4422ab97c43e13735d274219a2957aae7ec60d76.tar.bz2
dabmod-4422ab97c43e13735d274219a2957aae7ec60d76.zip
Stop using fprintf in input information
-rw-r--r--src/DabMod.cpp2
-rw-r--r--src/InputFileReader.cpp20
-rw-r--r--src/InputReader.h20
-rw-r--r--src/InputTcpReader.cpp5
-rw-r--r--src/InputZeroMQReader.cpp5
5 files changed, 25 insertions, 27 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index e68202e..1266147 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -413,7 +413,7 @@ int launch_modulator(int argc, char* argv[])
flowgraph.connect(modulator, output);
}
- inputReader->PrintInfo();
+ etiLog.level(info) << inputReader->GetPrintableInfo();
run_modulator_state_t st = run_modulator(m);
etiLog.log(trace, "DABMOD,run_modulator() = %d", st);
diff --git a/src/InputFileReader.cpp b/src/InputFileReader.cpp
index 5d4d113..5a9780b 100644
--- a/src/InputFileReader.cpp
+++ b/src/InputFileReader.cpp
@@ -190,31 +190,31 @@ int InputFileReader::IdentifyType()
return -1;
}
-void InputFileReader::PrintInfo() const
+std::string InputFileReader::GetPrintableInfo() const
{
- fprintf(stderr, "Input file format: ");
+ std::string info = "Input file format: ";
switch (streamtype_) {
case EtiStreamType::Raw:
- fprintf(stderr, "raw");
+ info += "raw";
break;
case EtiStreamType::Streamed:
- fprintf(stderr, "streamed");
+ info += "streamed";
break;
case EtiStreamType::Framed:
- fprintf(stderr, "framed");
+ info += "framed";
break;
default:
- fprintf(stderr, "unknown!");
+ info += "unknown!";
break;
}
- fprintf(stderr, "\n");
- fprintf(stderr, "Input file length: %zu\n", inputfilelength_);
+ info += ", length: " + std::to_string(inputfilelength_);
if (~nbframes_ != 0) {
- fprintf(stderr, "Input file nb frames: %lu\n", nbframes_);
+ info += ", nb frames: " + std::to_string(nbframes_);
}
else {
- fprintf(stderr, "Input file nb frames: endless\n");
+ info += ", nb frames: endless";
}
+ return info;
}
int InputFileReader::GetNextFrame(void* buffer)
diff --git a/src/InputReader.h b/src/InputReader.h
index 4ffa2b8..85bf38b 100644
--- a/src/InputReader.h
+++ b/src/InputReader.h
@@ -33,15 +33,16 @@
#include <cstdio>
#include <vector>
+#include <string>
#include <atomic>
#include <memory>
+#include <unistd.h>
#if defined(HAVE_ZEROMQ)
# include "zmq.hpp"
# include "ThreadsafeQueue.h"
#endif
#include "Log.h"
#include "Socket.h"
-#include <unistd.h>
#define INVALID_SOCKET -1
class InputReader
@@ -52,8 +53,8 @@ class InputReader
// returns number of bytes written to buffer, 0 on eof, -1 on error
virtual int GetNextFrame(void* buffer) = 0;
- // Print some information
- virtual void PrintInfo() const = 0;
+ // Get some information
+ virtual std::string GetPrintableInfo() const = 0;
};
class InputFileReader : public InputReader
@@ -68,8 +69,8 @@ class InputFileReader : public InputReader
int Open(std::string filename, bool loop);
// Print information about the file opened
- void PrintInfo() const;
- int GetNextFrame(void* buffer);
+ virtual std::string GetPrintableInfo() const override;
+ virtual int GetNextFrame(void* buffer) override;
private:
int IdentifyType();
@@ -136,10 +137,9 @@ class InputTcpReader : public InputReader
// Put next frame into buffer. This function will never write more than
// 6144 bytes into buffer.
// returns number of bytes written to buffer, 0 on eof, -1 on error
- virtual int GetNextFrame(void* buffer);
+ virtual int GetNextFrame(void* buffer) override;
- // Print some information
- virtual void PrintInfo() const;
+ virtual std::string GetPrintableInfo() const override;
private:
TCPClient m_tcpclient;
@@ -166,8 +166,8 @@ class InputZeroMQReader : public InputReader
~InputZeroMQReader();
int Open(const std::string& uri, size_t max_queued_frames);
- int GetNextFrame(void* buffer);
- void PrintInfo() const;
+ virtual int GetNextFrame(void* buffer) override;
+ virtual std::string GetPrintableInfo() const override;
private:
std::atomic<bool> m_running = ATOMIC_VAR_INIT(false);
diff --git a/src/InputTcpReader.cpp b/src/InputTcpReader.cpp
index e48e258..21f8496 100644
--- a/src/InputTcpReader.cpp
+++ b/src/InputTcpReader.cpp
@@ -83,9 +83,8 @@ int InputTcpReader::GetNextFrame(void* buffer)
return ret;
}
-void InputTcpReader::PrintInfo() const
+std::string InputTcpReader::GetPrintableInfo() const
{
- fprintf(stderr, "Input TCP:\n");
- fprintf(stderr, " Receiving from %s\n\n", m_uri.c_str());
+ return "Input TCP: Receiving from " + m_uri;
}
diff --git a/src/InputZeroMQReader.cpp b/src/InputZeroMQReader.cpp
index e1e1c6d..c7dfd84 100644
--- a/src/InputZeroMQReader.cpp
+++ b/src/InputZeroMQReader.cpp
@@ -134,10 +134,9 @@ int InputZeroMQReader::GetNextFrame(void* buffer)
return framesize;
}
-void InputZeroMQReader::PrintInfo() const
+std::string InputZeroMQReader::GetPrintableInfo() const
{
- fprintf(stderr, "Input ZeroMQ:\n");
- fprintf(stderr, " Receiving from %s\n\n", m_uri.c_str());
+ return "Input ZeroMQ: Receiving from " + m_uri;
}
void InputZeroMQReader::RecvProcess()