]> code.delx.au - pulseaudio/commitdiff
add pa_sample_size_of_format()
authorLennart Poettering <lennart@poettering.net>
Wed, 4 Feb 2009 16:10:15 +0000 (17:10 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 4 Feb 2009 16:10:15 +0000 (17:10 +0100)
src/map-file
src/pulse/sample.c
src/pulse/sample.h

index d7addfecd2035d8e4a6ddbece259799206765c78..cdb9debefa4d7f72e7fdeddcc9b0bc55f07049fb 100644 (file)
@@ -181,6 +181,7 @@ pa_proplist_unset_many;
 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;
index ff86d0b813541f43536bcfa1ef4ffd2edf0bfeee..4b13a3370705b028f2d0ae018b28f819fd6cdc44 100644 (file)
@@ -36,7 +36,7 @@
 
 #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,
@@ -54,10 +54,18 @@ size_t pa_sample_size(const pa_sample_spec *spec) {
         [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) {
index 45a481fe5a7c782b36b39af9344209864a3cb6ec..3c05b54a0f480cc40473b9d402d345054f9a66d9 100644 (file)
@@ -261,6 +261,10 @@ size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
 /** 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. */