+/**
+ * Call get_file_info() to obtain an afhi structure.
+ *
+ * \param path The full path of the audio file.
+ * \param data Pointer to the contents of the (mapped) file.
+ * \param size The file size in bytes.
+ * \param afhi Result pointer.
+ *
+ * \return The number of the audio format on success, \p -E_AUDIO_FORMAT if no
+ * compiled in audio format handler is able to handler the file.
+ *
+ * This function tries to find an audio format handler that can interpret the
+ * file given by \a data and \a size.
+ *
+ * It first tries to determine the audio format from the filename given by \a
+ * path. If this doesn't work, all other audio format handlers are tried until
+ * one is found that can handle the file.
+ */
+int compute_afhi(const char *path, char *data, size_t size,
+ struct audio_format_info *afhi)
+{
+ int ret, i, format = guess_audio_format(path);
+
+ if (format >= 0) {
+ ret = afl[format].get_file_info(data, size, afhi);
+ if (ret >= 0)
+ return format;
+ }
+ FOR_EACH_AUDIO_FORMAT(i) {
+ if (i == format) /* we already tried this one to no avail */
+ continue;
+ ret = afl[i].get_file_info(data, size, afhi);
+ if (ret >= 0)
+ return i;
+ PARA_WARNING_LOG("%s\n", PARA_STRERROR(-ret));
+ }
+ return -E_AUDIO_FORMAT;
+}
+