sample.h

Go to the documentation of this file.
00001 #ifndef foosamplehfoo
00002 #define foosamplehfoo
00003 
00004 /* $Id: sample.h 2042 2007-11-09 18:24:09Z lennart $ */
00005 
00006 /***
00007   This file is part of PulseAudio.
00008 
00009   Copyright 2004-2006 Lennart Poettering
00010   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
00011 
00012   PulseAudio is free software; you can redistribute it and/or modify
00013   it under the terms of the GNU Lesser General Public License as published
00014   by the Free Software Foundation; either version 2 of the License,
00015   or (at your option) any later version.
00016 
00017   PulseAudio is distributed in the hope that it will be useful, but
00018   WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00020   General Public License for more details.
00021 
00022   You should have received a copy of the GNU Lesser General Public License
00023   along with PulseAudio; if not, write to the Free Software
00024   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025   USA.
00026 ***/
00027 
00028 #include <inttypes.h>
00029 #include <sys/types.h>
00030 #include <math.h>
00031 
00032 #include <pulse/cdecl.h>
00033 
00105 PA_C_DECL_BEGIN
00106 
00108 #define PA_CHANNELS_MAX 32
00109 
00111 #define PA_RATE_MAX (48000*4)
00112 
00114 typedef enum pa_sample_format {
00115     PA_SAMPLE_U8,              
00116     PA_SAMPLE_ALAW,            
00117     PA_SAMPLE_ULAW,            
00118     PA_SAMPLE_S16LE,           
00119     PA_SAMPLE_S16BE,           
00120     PA_SAMPLE_FLOAT32LE,       
00121     PA_SAMPLE_FLOAT32BE,       
00122     PA_SAMPLE_S32LE,           
00123     PA_SAMPLE_S32BE,           
00124     PA_SAMPLE_MAX,             
00125     PA_SAMPLE_INVALID = -1     
00126 } pa_sample_format_t;
00127 
00128 #ifdef WORDS_BIGENDIAN
00129 
00130 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
00131 
00132 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
00133 
00134 #define PA_SAMPLE_S32NE PA_SAMPLE_S32BE
00135 
00136 #define PA_SAMPLE_S16RE PA_SAMPLE_S16LE
00137 
00138 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE
00139 
00140 #define PA_SAMPLE_S32RE PA_SAMPLE_S32LE
00141 #else
00142 
00143 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
00144 
00145 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
00146 
00147 #define PA_SAMPLE_S32NE PA_SAMPLE_S32LE
00148 
00149 #define PA_SAMPLE_S16RE PA_SAMPLE_S16BE
00150 
00151 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE
00152 
00153 #define PA_SAMPLE_S32RE PA_SAMPLE_S32BE
00154 #endif
00155 
00157 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
00158 
00160 typedef struct pa_sample_spec {
00161     pa_sample_format_t format;     
00162     uint32_t rate;                 
00163     uint8_t channels;              
00164 } pa_sample_spec;
00165 
00167 typedef uint64_t pa_usec_t;
00168 
00170 size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE;
00171 
00173 size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
00174 
00176 size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
00177 
00179 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE;
00180 
00182 size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE;
00183 
00185 int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE;
00186 
00188 int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE;
00189 
00191 const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE;
00192 
00194 pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE;
00195 
00197 #define PA_SAMPLE_SPEC_SNPRINT_MAX 32
00198 
00200 char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec);
00201 
00203 char* pa_bytes_snprint(char *s, size_t l, unsigned v);
00204 
00205 PA_C_DECL_END
00206 
00207 #endif

Generated on Sun Jun 28 22:58:14 2009 for PulseAudio by  doxygen 1.4.6