00001 #ifndef foosamplehfoo
00002 #define foosamplehfoo
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <inttypes.h>
00027 #include <sys/types.h>
00028 #include <sys/param.h>
00029 #include <math.h>
00030
00031 #include <pulse/gccmacro.h>
00032 #include <pulse/cdecl.h>
00033 #include <pulse/version.h>
00034
00110 PA_C_DECL_BEGIN
00111
00112 #if !defined(WORDS_BIGENDIAN)
00113 #if defined(__BYTE_ORDER)
00114 #if __BYTE_ORDER == __BIG_ENDIAN
00115 #define WORDS_BIGENDIAN
00116 #endif
00117 #endif
00118 #endif
00119
00121 #define PA_CHANNELS_MAX 32U
00122
00124 #define PA_RATE_MAX (48000U*4U)
00125
00127 typedef enum pa_sample_format {
00128 PA_SAMPLE_U8,
00131 PA_SAMPLE_ALAW,
00134 PA_SAMPLE_ULAW,
00137 PA_SAMPLE_S16LE,
00140 PA_SAMPLE_S16BE,
00143 PA_SAMPLE_FLOAT32LE,
00146 PA_SAMPLE_FLOAT32BE,
00149 PA_SAMPLE_S32LE,
00152 PA_SAMPLE_S32BE,
00155 PA_SAMPLE_S24LE,
00158 PA_SAMPLE_S24BE,
00161 PA_SAMPLE_S24_32LE,
00164 PA_SAMPLE_S24_32BE,
00167 PA_SAMPLE_MAX,
00170 PA_SAMPLE_INVALID = -1
00172 } pa_sample_format_t;
00173
00174 #ifdef WORDS_BIGENDIAN
00175
00176 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
00177
00178 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
00179
00180 #define PA_SAMPLE_S32NE PA_SAMPLE_S32BE
00181
00182 #define PA_SAMPLE_S24NE PA_SAMPLE_S24BE
00183
00184 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32BE
00185
00187 #define PA_SAMPLE_S16RE PA_SAMPLE_S16LE
00188
00189 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE
00190
00191 #define PA_SAMPLE_S32RE PA_SAMPLE_S32LE
00192
00193 #define PA_SAMPLE_S24RE PA_SAMPLE_S24LE
00194
00195 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32LE
00196 #else
00197
00198 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
00199
00200 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
00201
00202 #define PA_SAMPLE_S32NE PA_SAMPLE_S32LE
00203
00204 #define PA_SAMPLE_S24NE PA_SAMPLE_S24LE
00205
00206 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32LE
00207
00209 #define PA_SAMPLE_S16RE PA_SAMPLE_S16BE
00210
00211 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE
00212
00213 #define PA_SAMPLE_S32RE PA_SAMPLE_S32BE
00214
00215 #define PA_SAMPLE_S24RE PA_SAMPLE_S24BE
00216
00217 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32BE
00218 #endif
00219
00221 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
00222
00224
00225 #define PA_SAMPLE_U8 PA_SAMPLE_U8
00226 #define PA_SAMPLE_ALAW PA_SAMPLE_ALAW
00227 #define PA_SAMPLE_ULAW PA_SAMPLE_ULAW
00228 #define PA_SAMPLE_S16LE PA_SAMPLE_S16LE
00229 #define PA_SAMPLE_S16BE PA_SAMPLE_S16BE
00230 #define PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE
00231 #define PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE
00232 #define PA_SAMPLE_S32LE PA_SAMPLE_S32LE
00233 #define PA_SAMPLE_S32BE PA_SAMPLE_S32BE
00234 #define PA_SAMPLE_S24LE PA_SAMPLE_S24LE
00235 #define PA_SAMPLE_S24BE PA_SAMPLE_S24BE
00236 #define PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE
00237 #define PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE
00238
00241 typedef struct pa_sample_spec {
00242 pa_sample_format_t format;
00245 uint32_t rate;
00248 uint8_t channels;
00250 } pa_sample_spec;
00251
00253 typedef uint64_t pa_usec_t;
00254
00256 size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE;
00257
00259 size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
00260
00262 size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
00263
00266 size_t pa_sample_size_of_format(pa_sample_format_t f) PA_GCC_PURE;
00267
00271 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE;
00272
00276 size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE;
00277
00281 pa_sample_spec* pa_sample_spec_init(pa_sample_spec *spec);
00282
00284 int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE;
00285
00287 int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE;
00288
00290 const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE;
00291
00293 pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE;
00294
00300 #define PA_SAMPLE_SPEC_SNPRINT_MAX 32
00301
00303 char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec);
00304
00306 char* pa_bytes_snprint(char *s, size_t l, unsigned v);
00307
00308 PA_C_DECL_END
00309
00310 #endif