+ need = fn->loaded + (fg->h.data_slices_per_group - i)* sb;
+ if (need > fn->bufsize) {
+ fn->bufsize = PARA_MAX(fn->bufsize * 2, need);
+ if (fn->bufsize > FECDEC_MAX_OUTBUF_SIZE)
+ return -E_FECDEC_OVERRUN;
+ PARA_INFO_LOG("increasing fec buf to %zu\n", fn->bufsize);
+ fn->buf = para_realloc(fn->buf, fn->bufsize);
+ }
+ if (u == FEC_GROUP_USABLE_WITH_HEADER) {
+ PARA_INFO_LOG("writing audio file header\n");
+ written = 0;
+ for (i = 0; i < fg->h.data_slices_per_group; i++) {
+ size_t n = sb;
+ if (written >= fg->h.audio_header_size)
+ break;
+ if (sb + written > fg->h.audio_header_size)
+ n = fg->h.audio_header_size - written;
+ memcpy(fn->buf + fn->loaded, fg->data[i], n);
+ fn->loaded += n;
+ written += n;
+ }
+ }
+ written = 0;
+ for (; i < fg->h.data_slices_per_group; i++) {