diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/odr-padenc.cpp | 45 | ||||
-rw-r--r-- | src/odr-padenc.h | 2 |
2 files changed, 32 insertions, 15 deletions
diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 6506012..94f3d68 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -350,23 +350,38 @@ int PadEncoder::EncodeSlide(bool skip_if_already_queued) { return 0; } - // try to read slides dir (if present) - if (slides.Empty()) { - if (!slides.InitFromDir(options.sls_dir)) - return 1; - } - - // if slides available, encode the first one - if (!slides.Empty()) { - slide_metadata_t slide = slides.GetSlide(); - - if (!sls_encoder.encodeSlide(slide.filepath, slide.fidx, options.raw_slides)) - fprintf(stderr, "ODR-PadEnc Error: cannot encode file '%s'\n", slide.filepath.c_str()); + // usually invoked once + for(;;) { + // try to read slides dir (if present) + if (slides.Empty()) { + if (!slides.InitFromDir(options.sls_dir)) + return 1; + slides_success = false; + } - if (options.erase_after_tx) { - if (unlink(slide.filepath.c_str()) == -1) - perror(("ODR-PadEnc Error: erasing file '" + slide.filepath +"' failed").c_str()); + // if slides available, encode the first one + if (!slides.Empty()) { + slide_metadata_t slide = slides.GetSlide(); + + if (sls_encoder.encodeSlide(slide.filepath, slide.fidx, options.raw_slides)) { + slides_success = true; + if (options.erase_after_tx) { + if (unlink(slide.filepath.c_str()) == -1) + perror(("ODR-PadEnc Error: erasing file '" + slide.filepath +"' failed").c_str()); + } + } else { + /* skip to next slide, except this is the last slide and so far + * no slide worked, to prevent an infinite loop and because + * re-reading the slides dir just moments later won't result in + * a different amount of slides. */ + bool skipping = !(slides.Empty() && !slides_success); + fprintf(stderr, "ODR-PadEnc Error: cannot encode file '%s'; %s\n", slide.filepath.c_str(), skipping ? "skipping" : "giving up for now"); + if (skipping) + continue; + } } + + break; } return 0; diff --git a/src/odr-padenc.h b/src/odr-padenc.h index 46290f5..9d941a4 100644 --- a/src/odr-padenc.h +++ b/src/odr-padenc.h @@ -90,6 +90,7 @@ protected: DLSEncoder dls_encoder; SLSEncoder sls_encoder; SlideStore slides; + bool slides_success; int curr_dls_file; int output_fd; steady_clock::time_point run_timeline; @@ -101,6 +102,7 @@ protected: pad_packetizer(PADPacketizer(options.padlen)), dls_encoder(DLSEncoder(&pad_packetizer)), sls_encoder(SLSEncoder(&pad_packetizer)), + slides_success(false), curr_dls_file(0), output_fd(-1), run_timeline(steady_clock::now()), |