diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-03-19 18:04:43 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-03-19 18:04:43 +0100 |
commit | 30455ab7403a9f48b7ef6d51ee43e972c78b1018 (patch) | |
tree | 7a9e8fe643c5cc3d5928aae13a101a150d3bb75b /src/dabplus-enc-alsa-zmq.cpp | |
parent | ecc1a7dd8e9bc7818bf101e192ae075ecc104d77 (diff) | |
download | fdk-aac-30455ab7403a9f48b7ef6d51ee43e972c78b1018.tar.gz fdk-aac-30455ab7403a9f48b7ef6d51ee43e972c78b1018.tar.bz2 fdk-aac-30455ab7403a9f48b7ef6d51ee43e972c78b1018.zip |
Improve alsa fault detection
Diffstat (limited to 'src/dabplus-enc-alsa-zmq.cpp')
-rw-r--r-- | src/dabplus-enc-alsa-zmq.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/dabplus-enc-alsa-zmq.cpp b/src/dabplus-enc-alsa-zmq.cpp index 3af667f..4739ed0 100644 --- a/src/dabplus-enc-alsa-zmq.cpp +++ b/src/dabplus-enc-alsa-zmq.cpp @@ -469,8 +469,13 @@ int main(int argc, char *argv[]) // -------------- Read Data memset(outbuf, 0x00, outbuf_size); - size_t read; + ssize_t read; if (drift_compensation) { + if (alsa_in_threaded.fault_detected()) { + fprintf(stderr, "Detected fault in alsa input!\n"); + break; + } + size_t overruns; read = queue.pop(input_buf, input_size, &overruns); // returns bytes @@ -486,7 +491,10 @@ int main(int argc, char *argv[]) } else { read = alsa_in_direct.read(input_buf, input_size); - if (read != input_size) { + if (read < 0) { + break; + } + else if (read != input_size) { fprintf(stderr, "Short alsa read !\n"); } } @@ -519,9 +527,11 @@ int main(int argc, char *argv[]) AACENC_ERROR err; if ((err = aacEncEncode(encoder, &in_buf, &out_buf, &in_args, &out_args)) != AACENC_OK) { - if (err == AACENC_ENCODE_EOF) + if (err == AACENC_ENCODE_EOF) { + fprintf(stderr, "encoder error: EOF reached\n"); break; - fprintf(stderr, "Encoding failed\n"); + } + fprintf(stderr, "Encoding failed (%d)\n", err); break; } calls++; @@ -532,7 +542,7 @@ int main(int argc, char *argv[]) // Our timing code depends on this if (! ((sample_rate == 32000 && calls == 2) || (sample_rate == 48000 && calls == 3)) ) { - fprintf(stderr, "INTERNAL ERROR! GURU MEDITATION: sample rate %d, calls %d\n", + fprintf(stderr, "INTERNAL ERROR! sample rate %d, calls %d\n", sample_rate, calls); } calls = 0; |