• Main Page
  • Related Pages
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

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.1 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 #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 /* Allow clients to check with #ifdef for these sample formats */
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 
00310 #define PA_BYTES_SNPRINT_MAX 11
00311 
00313 char* pa_bytes_snprint(char *s, size_t l, unsigned v);
00314 
00317 int pa_sample_format_is_le(pa_sample_format_t f) PA_GCC_PURE;
00318 
00321 int pa_sample_format_is_be(pa_sample_format_t f) PA_GCC_PURE;
00322 
00323 #ifdef WORDS_BIGENDIAN
00324 #define pa_sample_format_is_ne(f) pa_sample_format_is_be(f)
00325 #define pa_sample_format_is_re(f) pa_sample_format_is_le(f)
00326 #else
00327 
00329 #define pa_sample_format_is_ne(f) pa_sample_format_is_le(f)
00330 
00332 #define pa_sample_format_is_re(f) pa_sample_format_is_be(f)
00333 #endif
00334 
00335 PA_C_DECL_END
00336 
00337 #endif

Generated on Mon Aug 23 2010 00:25:21 for PulseAudio by  doxygen 1.7.1