sample.h

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

Generated on Wed May 30 19:36:31 2007 for PulseAudio by  doxygen 1.5.1