size_t size;
- if (conf.begin_chunk_arg < 0)
- return -ERRNO_TO_PARA_ERROR(EINVAL);
- first_chunk = conf.begin_chunk_arg;
-
- if (conf.end_chunk_given) {
- if (conf.end_chunk_arg < 0)
- return -ERRNO_TO_PARA_ERROR(EINVAL);
- if (conf.end_chunk_arg >= afhi->chunks_total)
+ if (conf.begin_chunk_arg < 0) {
+ if (-conf.begin_chunk_arg > afhi->chunks_total)
return -ERRNO_TO_PARA_ERROR(EINVAL);
- last_chunk = conf.end_chunk_arg;
+ first_chunk = afhi->chunks_total + conf.begin_chunk_arg;
+ } else
+ first_chunk = conf.begin_chunk_arg;
+ if (conf.end_chunk_given) {
+ if (conf.end_chunk_arg < 0) {
+ if (-conf.end_chunk_arg > afhi->chunks_total)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ last_chunk = afhi->chunks_total + conf.end_chunk_arg;
+ } else {
+ if (conf.end_chunk_arg >= afhi->chunks_total)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ last_chunk = conf.end_chunk_arg;
+ }
} else
last_chunk = afhi->chunks_total - 1;
+ if (first_chunk >= last_chunk)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
if (!afhi->chunks_total)
return 1;
afh_get_header(afhi, audio_file_data, &buf, &size);
dependon="stream"
optional
details="
- The chunk_num argument must be non-negative as chunks start
- at zero.
+ The chunk_num argument must be between -num_chunks and
+ num_chunks - 1 inclusively where num_chunks is the total number
+ of chunks which is printed when using the --info option. If
+ chunk_num is negative, the given number of chunks are counted
+ backwards from the end of the file. For example --begin_chunk
+ -100 instructs para_afh to start output at chunk num_chunks
+ - 100. This is mainly useful for cutting off the end of an
+ audio file.
"
option "end_chunk" e
dependon="stream"
optional
details="
- The chunk_num argument must be less than the total number of
- chunks. The default is to write up to the last chunk.
+ For the chunk_num argument the same rules as for --begin_chunk
+ apply. The default is to write up to the last chunk.
"
option "just_in_time" j