/*
- * Copyright (C) 1997-2013 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2014 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
void flac_afh_init(struct audio_format_handler *);
#endif
+#ifdef HAVE_OPUS
+ void opus_afh_init(struct audio_format_handler *);
+#endif
+
void wma_afh_init(struct audio_format_handler *);
/** The list of all status items */
.name = "flac",
#ifdef HAVE_FLAC
.init = flac_afh_init,
+#endif
+ },
+ {
+ .name = "opus",
+#ifdef HAVE_OPUS
+ .init = opus_afh_init,
#endif
},
{
}
/**
- * Deallocate contents of a filled-in ahi structure
+ * Deallocate the contents of an afh_info structure.
*
* \param afhi The structure to clear.
*
- * The given pointer is kept, everything else is freed.
+ * This only frees the memory the various pointer fields of \a afhi point to.
+ * It does *not* free \a afhi itself.
*/
void clear_afhi(struct afh_info *afhi)
{
return afl[i].name;
}
+static inline size_t get_chunk_len(long unsigned chunk_num,
+ const struct afh_info *afhi)
+{
+ return afhi->chunk_table[chunk_num + 1] - afhi->chunk_table[chunk_num];
+}
+
/**
* Get one chunk of audio data.
*
{
size_t pos = afhi->chunk_table[chunk_num];
*buf = map + pos;
- *len = afhi->chunk_table[chunk_num + 1] - pos;
+ *len = get_chunk_len(chunk_num, afhi);
+}
+
+/**
+ * Find a suitable start chunk.
+ *
+ * \param approx_chunk_num Upper bound for the chunk number to return.
+ * \param afhi Needed for the chunk table.
+ *
+ * \return The first non-empty chunk <= \a approx_chunk_num.
+ *
+ * \sa \ref afh_get_chunk().
+ */
+int32_t afh_get_start_chunk(int32_t approx_chunk_num,
+ const struct afh_info *afhi)
+{
+ int32_t k;
+
+ for (k = PARA_MAX(0, approx_chunk_num); k >= 0; k--)
+ if (get_chunk_len(k, afhi) > 0)
+ break;
+ return k;
}
/**