sample.h

Go to the documentation of this file.
00001 #ifndef foosamplehfoo
00002 #define foosamplehfoo
00003 
00004 /***
00005   This file is part of PulseAudio.
00006 
00007   Copyright 2004-2006 Lennart Poettering
00008   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
00009 
00010   PulseAudio is free software; you can redistribute it and/or modify
00011   it under the terms of the GNU Lesser General Public License as published
00012   by the Free Software Foundation; either version 2 of the License,
00013   or (at your option) any later version.
00014 
00015   PulseAudio is distributed in the hope that it will be useful, but
00016   WITHOUT ANY WARRANTY; without even the implied warranty of
00017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018   General Public License for more details.
00019 
00020   You should have received a copy of the GNU Lesser General Public License
00021   along with PulseAudio; if not, write to the Free Software
00022   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023   USA.
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 
00105 PA_C_DECL_BEGIN
00106 
00107 #if !defined(WORDS_BIGENDIAN)
00108 #if defined(__BYTE_ORDER)
00109 #if __BYTE_ORDER == __BIG_ENDIAN
00110 #define WORDS_BIGENDIAN
00111 #endif
00112 #endif
00113 #endif
00114 
00116 #define PA_CHANNELS_MAX 32U
00117 
00119 #define PA_RATE_MAX (48000U*4U)
00120 
00122 typedef enum pa_sample_format {
00123     PA_SAMPLE_U8,
00126     PA_SAMPLE_ALAW,
00129     PA_SAMPLE_ULAW,
00132     PA_SAMPLE_S16LE,
00135     PA_SAMPLE_S16BE,
00138     PA_SAMPLE_FLOAT32LE,
00141     PA_SAMPLE_FLOAT32BE,
00144     PA_SAMPLE_S32LE,
00147     PA_SAMPLE_S32BE,
00150     PA_SAMPLE_MAX,
00153     PA_SAMPLE_INVALID = -1
00155 } pa_sample_format_t;
00156 
00157 #ifdef WORDS_BIGENDIAN
00158 
00159 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
00160 
00161 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
00162 
00163 #define PA_SAMPLE_S32NE PA_SAMPLE_S32BE
00164 
00165 #define PA_SAMPLE_S16RE PA_SAMPLE_S16LE
00166 
00167 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE
00168 
00169 #define PA_SAMPLE_S32RE PA_SAMPLE_S32LE
00170 #else
00171 
00172 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
00173 
00174 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
00175 
00176 #define PA_SAMPLE_S32NE PA_SAMPLE_S32LE
00177 
00178 #define PA_SAMPLE_S16RE PA_SAMPLE_S16BE
00179 
00180 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE
00181 
00182 #define PA_SAMPLE_S32RE PA_SAMPLE_S32BE
00183 #endif
00184 
00186 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
00187 
00189 /* Allow clients to check with #ifdef for thse sample formats */
00190 #define PA_SAMPLE_U8 PA_SAMPLE_U8
00191 #define PA_SAMPLE_ALAW PA_SAMPLE_ALAW
00192 #define PA_SAMPLE_ULAW PA_SAMPLE_ULAW
00193 #define PA_SAMPLE_S16LE PA_SAMPLE_S16LE
00194 #define PA_SAMPLE_S16BE PA_SAMPLE_S16BE
00195 #define PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE
00196 #define PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE
00197 #define PA_SAMPLE_S32LE PA_SAMPLE_S32LE
00198 #define PA_SAMPLE_S32BE PA_SAMPLE_S32BE
00199 
00202 typedef struct pa_sample_spec {
00203     pa_sample_format_t format;
00206     uint32_t rate;
00209     uint8_t channels;
00211 } pa_sample_spec;
00212 
00214 typedef uint64_t pa_usec_t;
00215 
00217 size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE;
00218 
00220 size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
00221 
00223 size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
00224 
00228 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE;
00229 
00233 size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE;
00234 
00236 int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE;
00237 
00239 int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE;
00240 
00242 const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE;
00243 
00245 pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE;
00246 
00248 #define PA_SAMPLE_SPEC_SNPRINT_MAX 32
00249 
00251 char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec);
00252 
00254 char* pa_bytes_snprint(char *s, size_t l, unsigned v);
00255 
00256 PA_C_DECL_END
00257 
00258 #endif

Generated on Tue Sep 16 10:58:58 2008 for PulseAudio by  doxygen 1.5.4