PulseAudio 2.0
|
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 00030 #include <pulse/gccmacro.h> 00031 #include <pulse/cdecl.h> 00032 #include <pulse/version.h> 00033 00112 PA_C_DECL_BEGIN 00113 00114 #if !defined(WORDS_BIGENDIAN) 00115 #if defined(__BYTE_ORDER) 00116 #if __BYTE_ORDER == __BIG_ENDIAN 00117 #define WORDS_BIGENDIAN 00118 #endif 00119 #endif 00120 #endif 00121 00123 #define PA_CHANNELS_MAX 32U 00124 00126 #define PA_RATE_MAX (48000U*4U) 00127 00129 typedef enum pa_sample_format { 00130 PA_SAMPLE_U8, 00133 PA_SAMPLE_ALAW, 00136 PA_SAMPLE_ULAW, 00139 PA_SAMPLE_S16LE, 00142 PA_SAMPLE_S16BE, 00145 PA_SAMPLE_FLOAT32LE, 00148 PA_SAMPLE_FLOAT32BE, 00151 PA_SAMPLE_S32LE, 00154 PA_SAMPLE_S32BE, 00157 PA_SAMPLE_S24LE, 00160 PA_SAMPLE_S24BE, 00163 PA_SAMPLE_S24_32LE, 00166 PA_SAMPLE_S24_32BE, 00169 PA_SAMPLE_MAX, 00172 PA_SAMPLE_INVALID = -1 00174 } pa_sample_format_t; 00175 00176 #ifdef WORDS_BIGENDIAN 00177 00178 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE 00179 00180 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE 00181 00182 #define PA_SAMPLE_S32NE PA_SAMPLE_S32BE 00183 00184 #define PA_SAMPLE_S24NE PA_SAMPLE_S24BE 00185 00186 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32BE 00187 00189 #define PA_SAMPLE_S16RE PA_SAMPLE_S16LE 00190 00191 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE 00192 00193 #define PA_SAMPLE_S32RE PA_SAMPLE_S32LE 00194 00195 #define PA_SAMPLE_S24RE PA_SAMPLE_S24LE 00196 00197 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32LE 00198 #else 00199 00200 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE 00201 00202 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE 00203 00204 #define PA_SAMPLE_S32NE PA_SAMPLE_S32LE 00205 00206 #define PA_SAMPLE_S24NE PA_SAMPLE_S24LE 00207 00208 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32LE 00209 00211 #define PA_SAMPLE_S16RE PA_SAMPLE_S16BE 00212 00213 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE 00214 00215 #define PA_SAMPLE_S32RE PA_SAMPLE_S32BE 00216 00217 #define PA_SAMPLE_S24RE PA_SAMPLE_S24BE 00218 00219 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32BE 00220 #endif 00221 00223 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE 00224 00226 /* Allow clients to check with #ifdef for these sample formats */ 00227 #define PA_SAMPLE_U8 PA_SAMPLE_U8 00228 #define PA_SAMPLE_ALAW PA_SAMPLE_ALAW 00229 #define PA_SAMPLE_ULAW PA_SAMPLE_ULAW 00230 #define PA_SAMPLE_S16LE PA_SAMPLE_S16LE 00231 #define PA_SAMPLE_S16BE PA_SAMPLE_S16BE 00232 #define PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE 00233 #define PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE 00234 #define PA_SAMPLE_S32LE PA_SAMPLE_S32LE 00235 #define PA_SAMPLE_S32BE PA_SAMPLE_S32BE 00236 #define PA_SAMPLE_S24LE PA_SAMPLE_S24LE 00237 #define PA_SAMPLE_S24BE PA_SAMPLE_S24BE 00238 #define PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE 00239 #define PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE 00240 00243 typedef struct pa_sample_spec { 00244 pa_sample_format_t format; 00247 uint32_t rate; 00250 uint8_t channels; 00252 } pa_sample_spec; 00253 00255 typedef uint64_t pa_usec_t; 00256 00258 size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE; 00259 00261 size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE; 00262 00264 size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE; 00265 00268 size_t pa_sample_size_of_format(pa_sample_format_t f) PA_GCC_PURE; 00269 00273 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE; 00274 00278 size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE; 00279 00283 pa_sample_spec* pa_sample_spec_init(pa_sample_spec *spec); 00284 00286 int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE; 00287 00289 int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE; 00290 00292 const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE; 00293 00295 pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE; 00296 00302 #define PA_SAMPLE_SPEC_SNPRINT_MAX 32 00303 00305 char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec); 00306 00312 #define PA_BYTES_SNPRINT_MAX 11 00313 00315 char* pa_bytes_snprint(char *s, size_t l, unsigned v); 00316 00319 int pa_sample_format_is_le(pa_sample_format_t f) PA_GCC_PURE; 00320 00323 int pa_sample_format_is_be(pa_sample_format_t f) PA_GCC_PURE; 00324 00325 #ifdef WORDS_BIGENDIAN 00326 #define pa_sample_format_is_ne(f) pa_sample_format_is_be(f) 00327 #define pa_sample_format_is_re(f) pa_sample_format_is_le(f) 00328 #else 00329 00331 #define pa_sample_format_is_ne(f) pa_sample_format_is_le(f) 00332 00334 #define pa_sample_format_is_re(f) pa_sample_format_is_be(f) 00335 #endif 00336 00337 PA_C_DECL_END 00338 00339 #endif