+static char *vss_read_chunk(long unsigned current_chunk, ssize_t *len)
+{
+ int ret;
+ size_t pos;
+
+ *len = 0;
+ if (current_chunk >= mmd->chunks_total)
+ return NULL;
+ *len = chunk_table[current_chunk + 1] - chunk_table[current_chunk];
+ if (!*len) /* nothing to send for this run */
+ return inbuf;
+ pos = chunk_table[current_chunk];
+ if (inbuf_size < *len) {
+ PARA_INFO_LOG("increasing inbuf for chunk #%lu/%lu to %zd bytes\n",
+ current_chunk, mmd->chunks_total, *len);
+ inbuf = para_realloc(inbuf, *len);
+ inbuf_size = *len;
+ }
+// PARA_DEBUG_LOG("reading chunk #%lu@%zd (%zd bytes)\n", current_chunk,
+// pos, *len);
+ ret = fseek(audio_file, pos, SEEK_SET);
+ if (ret < 0)
+ return NULL;
+ ret = para_fread(inbuf, *len, 1, audio_file);
+ if (ret != *len)
+ return NULL;
+ return inbuf;
+}
+