summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-07 10:39:51 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-07 10:39:51 +0200
commit9c2615425bb4f35a417eb04b1ceebfc77d8e2c8b (patch)
tree6bc07553e7dcc56389d763f849f273bdf6d06681
parent68ee7799a4eeb4148cd4628113ebf9ea3f94a211 (diff)
downloadODR-AudioEnc-9c2615425bb4f35a417eb04b1ceebfc77d8e2c8b.tar.gz
ODR-AudioEnc-9c2615425bb4f35a417eb04b1ceebfc77d8e2c8b.tar.bz2
ODR-AudioEnc-9c2615425bb4f35a417eb04b1ceebfc77d8e2c8b.zip
Move fault_detected() into common input interface
-rw-r--r--src/AlsaInput.h4
-rw-r--r--src/FileInput.h2
-rw-r--r--src/InputInterface.h3
-rw-r--r--src/JackInput.h1
-rw-r--r--src/VLCInput.h2
-rw-r--r--src/odr-audioenc.cpp44
6 files changed, 28 insertions, 28 deletions
diff --git a/src/AlsaInput.h b/src/AlsaInput.h
index 7f88341..08ccbf6 100644
--- a/src/AlsaInput.h
+++ b/src/AlsaInput.h
@@ -100,6 +100,8 @@ class AlsaInputDirect : public AlsaInput
virtual void prepare(void) override;
+ virtual bool fault_detected(void) const override { return false; };
+
/*! Read length Bytes from from the alsa device.
* length must be a multiple of channels * bytes_per_sample.
*
@@ -131,7 +133,7 @@ class AlsaInputThreaded : public AlsaInput
/*! Start the ALSA thread that fills the queue */
virtual void prepare(void) override;
- bool fault_detected() const { return m_fault; };
+ virtual bool fault_detected(void) const override { return m_fault; };
private:
void process();
diff --git a/src/FileInput.h b/src/FileInput.h
index c66441a..59e0f0b 100644
--- a/src/FileInput.h
+++ b/src/FileInput.h
@@ -50,6 +50,8 @@ class FileInput : public InputInterface
/*! Open the file and prepare the wav decoder. */
virtual void prepare(void) override;
+ virtual bool fault_detected(void) const override { return false; };
+
/*! Read length bytes into buf.
*
* \return the number of bytes read.
diff --git a/src/InputInterface.h b/src/InputInterface.h
index 739ca3f..b582c33 100644
--- a/src/InputInterface.h
+++ b/src/InputInterface.h
@@ -31,4 +31,7 @@ class InputInterface {
* runtime_error.
*/
virtual void prepare(void) = 0;
+
+ /*! Return true if the input detected some sort of fault */
+ virtual bool fault_detected(void) const = 0;
};
diff --git a/src/JackInput.h b/src/JackInput.h
index 8cbda45..aa33a03 100644
--- a/src/JackInput.h
+++ b/src/JackInput.h
@@ -59,6 +59,7 @@ class JackInput : public InputInterface
virtual ~JackInput();
virtual void prepare() override;
+ virtual bool fault_detected(void) const override { return m_fault; };
private:
jack_client_t *m_client;
diff --git a/src/VLCInput.h b/src/VLCInput.h
index 789bc70..703641d 100644
--- a/src/VLCInput.h
+++ b/src/VLCInput.h
@@ -140,7 +140,7 @@ class VLCInput : public InputInterface
int getChannels() { return m_channels; }
- bool fault_detected() { return m_fault; };
+ virtual bool fault_detected(void) const override { return m_fault; };
/*! Separator string used when artist/title are written
*/
diff --git a/src/odr-audioenc.cpp b/src/odr-audioenc.cpp
index ea546f7..11978a9 100644
--- a/src/odr-audioenc.cpp
+++ b/src/odr-audioenc.cpp
@@ -398,12 +398,12 @@ int main(int argc, char *argv[])
int raw_input = 0;
// For the VLC input
- std::string vlc_uri = "";
- std::string vlc_icytext_file = "";
+ string vlc_uri;
+ string vlc_icytext_file;
bool vlc_icytext_dlplus = false;
- std::string vlc_gain = "";
- std::string vlc_cache = "";
- std::vector<std::string> vlc_additional_opts;
+ string vlc_gain;
+ string vlc_cache;
+ vector<string> vlc_additional_opts;
unsigned verbosity = 0;
// For the file output
@@ -411,7 +411,7 @@ int main(int argc, char *argv[])
string jack_name;
- std::vector<std::string> output_uris;
+ vector<string> output_uris;
int sample_rate=48000, channels=2;
void *rs_handler = NULL;
@@ -422,11 +422,11 @@ int main(int argc, char *argv[])
AACENC_InfoStruct info = { 0 };
int aot = AOT_NONE;
- std::string decode_wavfilename;
+ string decode_wavfilename;
- std::string dab_channel_mode;
- int dab_psy_model = 1;
- std::deque<uint8_t> toolame_output_buffer;
+ string dab_channel_mode;
+ int dab_psy_model = 1;
+ deque<uint8_t> toolame_output_buffer;
/* Keep track of peaks */
int peak_left = 0;
@@ -765,7 +765,7 @@ int main(int argc, char *argv[])
vec_u8 input_buf;
HANDLE_AACENCODER encoder;
- std::unique_ptr<AACDecoder> decoder;
+ unique_ptr<AACDecoder> decoder;
if (selected_encoder == encoder_selection_t::fdk_dabplus) {
int subchannel_index = bitrate / 8;
@@ -999,6 +999,12 @@ int main(int argc, char *argv[])
* \c drift_compensation_delay() function handles rate throttling.
*/
+ if (input->fault_detected()) {
+ fprintf(stderr, "Detected fault in input!\n");
+ retval = 5;
+ break;
+ }
+
if (not infile.empty()) {
read_bytes = file_in.read(&input_buf[0], input_buf.size());
if (read_bytes < 0) {
@@ -1020,12 +1026,6 @@ int main(int argc, char *argv[])
#if HAVE_VLC
else if (not vlc_uri.empty()) {
- if (drift_compensation && vlc_input.fault_detected()) {
- fprintf(stderr, "Detected fault in VLC input!\n");
- retval = 5;
- break;
- }
-
if (drift_compensation) {
size_t overruns;
size_t bytes_from_queue = queue.pop(&input_buf[0], input_buf.size(), &overruns); // returns bytes
@@ -1066,14 +1066,6 @@ int main(int argc, char *argv[])
}
#endif
else if (drift_compensation or not jack_name.empty()) {
-#if HAVE_ALSA
- if (drift_compensation && alsa_in_threaded.fault_detected()) {
- fprintf(stderr, "Detected fault in alsa input!\n");
- retval = 5;
- break;
- }
-#endif
-
size_t overruns;
size_t bytes_from_queue = queue.pop(&input_buf[0], input_buf.size(), &overruns); // returns bytes
if (bytes_from_queue != input_buf.size()) {
@@ -1229,7 +1221,7 @@ int main(int argc, char *argv[])
try {
decoder->decode_frame(outbuf.data(), numOutBytes);
}
- catch (std::runtime_error &e) {
+ catch (runtime_error &e) {
fprintf(stderr, "Decoding failed with: %s\n", e.what());
return 1;
}