pa_proplist_update;
pa_sample_format_to_string;
pa_sample_size;
+pa_sample_size_of_format;
pa_sample_spec_equal;
pa_sample_spec_init;
pa_sample_spec_snprint;
#include "sample.h"
-size_t pa_sample_size(const pa_sample_spec *spec) {
+size_t pa_sample_size_of_format(pa_sample_format_t f) {
static const size_t table[] = {
[PA_SAMPLE_U8] = 1,
[PA_SAMPLE_S24_32BE] = 4
};
+ pa_assert(f >= 0);
+ pa_assert(f < PA_SAMPLE_MAX);
+
+ return table[f];
+}
+
+size_t pa_sample_size(const pa_sample_spec *spec) {
+
pa_assert(spec);
pa_return_val_if_fail(pa_sample_spec_valid(spec), 0);
- return table[spec->format];
+ return pa_sample_size_of_format(spec->format);
}
size_t pa_frame_size(const pa_sample_spec *spec) {
/** Return the size of a sample with the specific sample type */
size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
+/** Similar to pa_sample_size() but take a sample format instead of a
+ * full sample spec. \since 0.9.15 */
+size_t pa_sample_size_of_format(pa_sample_format_t f) PA_GCC_PURE;
+
/** Calculate the time the specified bytes take to play with the
* specified sample type. The return value will always be rounded
* down for non-integral return values. */