@@ -307,11 +307,11 @@ bool AppendToFileList(const std::string &filelist_file,
307
307
return true ;
308
308
}
309
309
310
- static void PresentImages (LoadedImageSources *loaded_sources,
311
- const timg::DisplayOptions &display_opts,
312
- const timg::PresentationOptions &present,
313
- timg::BufferedWriteSequencer *sequencer,
314
- bool *any_animations_seen) {
310
+ static int PresentImages (LoadedImageSources *loaded_sources,
311
+ const timg::DisplayOptions &display_opts,
312
+ const timg::PresentationOptions &present,
313
+ timg::BufferedWriteSequencer *sequencer,
314
+ bool *any_animations_seen) {
315
315
using timg::ThreadPool;
316
316
std::unique_ptr<ThreadPool> compression_pool;
317
317
std::unique_ptr<TerminalCanvas> canvas;
@@ -374,10 +374,12 @@ static void PresentImages(LoadedImageSources *loaded_sources,
374
374
375
375
// Showing them in order of files on the command line.
376
376
bool is_first = true ;
377
+ int valid_images = 0 ;
377
378
for (auto &source_future : *loaded_sources) {
378
379
if (interrupt_received) break ;
379
380
std::unique_ptr<timg::ImageSource> source (source_future.get ());
380
381
if (!source) continue ;
382
+ valid_images++;
381
383
*any_animations_seen |= source->IsAnimationBeforeFrameLimit ();
382
384
before_image_show (is_first);
383
385
source->SendFrames (present.duration_per_image , present.loops ,
@@ -389,6 +391,7 @@ static void PresentImages(LoadedImageSources *loaded_sources,
389
391
is_first = false ;
390
392
}
391
393
sequencer->Flush ();
394
+ return valid_images;
392
395
}
393
396
394
397
static std::optional<Pixelation> ParsePixelation (const char *as_text) {
@@ -943,6 +946,10 @@ int main(int argc, char *argv[]) {
943
946
944
947
// Asynconrous image loading (filelist.size()) and terminal query (+1)
945
948
thread_count = (thread_count > 0 ? thread_count : kDefaultThreadCount );
949
+
950
+ // Note: this thread pool will be leaked explicitly to not unnecessarily
951
+ // have to wait on potentially blocking cleanup at program exit where it
952
+ // does not matter.
946
953
timg::ThreadPool *const pool =
947
954
new timg::ThreadPool (std::min (thread_count, (int )filelist.size () + 1 ));
948
955
@@ -1012,8 +1019,9 @@ int main(int argc, char *argv[]) {
1012
1019
output_fd, buffer_allow_skipping, kAsyncWriteQueueSize ,
1013
1020
debug_no_frame_delay, interrupt_received);
1014
1021
const Time start_show = Time::Now ();
1015
- PresentImages (&loaded_sources, display_opts, present, &sequencer,
1016
- &cell_size_warning_needed);
1022
+ const int successful_images =
1023
+ PresentImages (&loaded_sources, display_opts, present, &sequencer,
1024
+ &cell_size_warning_needed);
1017
1025
const Time end_show = Time::Now ();
1018
1026
1019
1027
// Error messages have been collected to not clutter the image output
@@ -1093,9 +1101,10 @@ int main(int argc, char *argv[]) {
1093
1101
const uint64_t written_bytes =
1094
1102
sequencer.bytes_total () - sequencer.bytes_skipped ();
1095
1103
fprintf (stderr,
1096
- " %d file%s; %s written (%s/s) "
1104
+ " %d file%s (%d successful) ; %s written (%s/s) "
1097
1105
" %" PRId64 " frames" ,
1098
1106
(int )filelist.size (), filelist.size () == 1 ? " " : " s" ,
1107
+ successful_images,
1099
1108
timg::HumanReadableByteValue (written_bytes).c_str (),
1100
1109
timg::HumanReadableByteValue (written_bytes / d).c_str (),
1101
1110
sequencer.frames_total ());
0 commit comments