From 41404434086b096a7f9f9c1b715da9531e1ef3b8 Mon Sep 17 00:00:00 2001 From: nu774 Date: Sat, 14 Feb 2015 13:58:05 +0900 Subject: [PATCH] fix incorrect iTunSMPB written when interrupted by signals --- src/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index f4ecd75..6ffb7b1 100644 --- a/src/main.c +++ b/src/main.c @@ -563,11 +563,20 @@ int encode(aacenc_param_ex_t *params, pcm_reader_t *reader, ++encoded; if (encoded == 1 || encoded == 3) continue; - obp = &obuf[flip]; - if (write_sample(params->output_fp, m4af, obp) < 0) + + if (write_sample(params->output_fp, m4af, &obuf[flip]) < 0) goto END; ++frames_written; } while (remaining > 0); + /* + * When interrupted, we haven't pulled out last extrapolated frames + * from the reader. Therefore, we have to write the final outcome. + */ + if (g_interrupted) { + if (write_sample(params->output_fp, m4af, &obp[flip^1]) < 0) + goto END; + ++frames_written; + } } DONE: if (!params->silent)