- fc->group.num_chunks = i - fc->group.first_chunk;
- fc->slice.num = 0;
- fc->slice.bytes = ROUND_UP(fc->group.bytes, k) / k;
-
- /* The last slice will not be fully used */
- last_payload_size = fc->group.bytes % fc->slice.bytes;
- if (!last_payload_size)
- last_payload_size = fc->slice.bytes;
-
- tv_scale(fc->group.first_chunk - fc->first_stream_chunk, chunk_tv,
- &tmp);
- tv_add(&fc->stream_start, &tmp, &fc->group.start);
- if (fc->group.num) /* quick hack to avoid buffer underruns */
- fc->group.start.tv_sec--;
- tv_scale(fc->group.num_chunks, chunk_tv, &fc->group.duration);
- tv_divide(fc->fcp->slices_per_group, &fc->group.duration,
- &fc->group.slice_duration);
-
- for (i = 0; i < k; i++)
- fc->src_data[i] = (const unsigned char *)start_buf
- + i * fc->slice.bytes;
-
- if (start_buf + k * fc->slice.bytes > vsst->map + mmd->size) {
- /* can not use last slice as it goes beyond the map */
- if (fc->extra_src_buf_size < fc->slice.bytes) {
- fc->extra_src_buf = para_realloc(fc->extra_src_buf, fc->slice.bytes);
- fc->extra_src_buf_size = fc->slice.bytes;
- }
- memcpy(fc->extra_src_buf, start_buf + (k - 1) * fc->slice.bytes,
- last_payload_size);
- memset(fc->extra_src_buf + last_payload_size, 0,
- fc->slice.bytes - last_payload_size);
- fc->src_data[k - 1] = fc->extra_src_buf;
+ g->num_chunks = i - g->first_chunk;
+ assert(g->num_chunks);
+ fc->current_slice_num = 0;
+
+ /* setup header slices */
+ buf = vsst->header_buf;
+ for (i = 0; i < g->num_header_slices; i++) {
+ fc->src_data[i] = (const unsigned char *)buf;
+ buf += slice_bytes;
+ }
+
+ /* setup data slices */
+ buf = start_buf;
+ for (i = g->num_header_slices; i < k; i++) {
+ if (buf + slice_bytes > vsst->map + mmd->size)
+ /*
+ * Can not use the memory mapped audio file for this
+ * slice as it goes beyond the map. This slice will not
+ * be fully used.
+ */
+ break;
+ fc->src_data[i] = (const unsigned char *)buf;
+ buf += slice_bytes;