PulseAudio 0.9.22-5.mga1
|
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 00113 PA_C_DECL_BEGIN 00114 00115 #if !defined(WORDS_BIGENDIAN) 00116 #if defined(__BYTE_ORDER) 00117 #if __BYTE_ORDER == __BIG_ENDIAN 00118 #define WORDS_BIGENDIAN 00119 #endif 00120 #endif 00121 #endif 00122 00124 #define PA_CHANNELS_MAX 32U 00125 00127 #define PA_RATE_MAX (48000U*4U) 00128 00130 typedef enum pa_sample_format { 00131 PA_SAMPLE_U8, 00134 PA_SAMPLE_ALAW, 00137 PA_SAMPLE_ULAW, 00140 PA_SAMPLE_S16LE, 00143 PA_SAMPLE_S16BE, 00146 PA_SAMPLE_FLOAT32LE, 00149 PA_SAMPLE_FLOAT32BE, 00152 PA_SAMPLE_S32LE, 00155 PA_SAMPLE_S32BE, 00158 PA_SAMPLE_S24LE, 00161 PA_SAMPLE_S24BE, 00164 PA_SAMPLE_S24_32LE, 00167 PA_SAMPLE_S24_32BE, 00170 PA_SAMPLE_MAX, 00173 PA_SAMPLE_INVALID = -1 00175 } pa_sample_format_t; 00176 00177 #ifdef WORDS_BIGENDIAN 00178 00179 #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE 00180 00181 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE 00182 00183 #define PA_SAMPLE_S32NE PA_SAMPLE_S32BE 00184 00185 #define PA_SAMPLE_S24NE PA_SAMPLE_S24BE 00186 00187 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32BE 00188 00190 #define PA_SAMPLE_S16RE PA_SAMPLE_S16LE 00191 00192 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE 00193 00194 #define PA_SAMPLE_S32RE PA_SAMPLE_S32LE 00195 00196 #define PA_SAMPLE_S24RE PA_SAMPLE_S24LE 00197 00198 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32LE 00199 #else 00200 00201 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE 00202 00203 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE 00204 00205 #define PA_SAMPLE_S32NE PA_SAMPLE_S32LE 00206 00207 #define PA_SAMPLE_S24NE PA_SAMPLE_S24LE 00208 00209 #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32LE 00210 00212 #define PA_SAMPLE_S16RE PA_SAMPLE_S16BE 00213 00214 #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE 00215 00216 #define PA_SAMPLE_S32RE PA_SAMPLE_S32BE 00217 00218 #define PA_SAMPLE_S24RE PA_SAMPLE_S24BE 00219 00220 #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32BE 00221 #endif 00222 00224 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE 00225 00227 /* Allow clients to check with #ifdef for these sample formats */ 00228 #define PA_SAMPLE_U8 PA_SAMPLE_U8 00229 #define PA_SAMPLE_ALAW PA_SAMPLE_ALAW 00230 #define PA_SAMPLE_ULAW PA_SAMPLE_ULAW 00231 #define PA_SAMPLE_S16LE PA_SAMPLE_S16LE 00232 #define PA_SAMPLE_S16BE PA_SAMPLE_S16BE 00233 #define PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE 00234 #define PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE 00235 #define PA_SAMPLE_S32LE PA_SAMPLE_S32LE 00236 #define PA_SAMPLE_S32BE PA_SAMPLE_S32BE 00237 #define PA_SAMPLE_S24LE PA_SAMPLE_S24LE 00238 #define PA_SAMPLE_S24BE PA_SAMPLE_S24BE 00239 #define PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE 00240 #define PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE 00241 00244 typedef struct pa_sample_spec { 00245 pa_sample_format_t format; 00248 uint32_t rate; 00251 uint8_t channels; 00253 } pa_sample_spec; 00254 00256 typedef uint64_t pa_usec_t; 00257 00259 size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE; 00260 00262 size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE; 00263 00265 size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE; 00266 00269 size_t pa_sample_size_of_format(pa_sample_format_t f) PA_GCC_PURE; 00270 00274 pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE; 00275 00279 size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE; 00280 00284 pa_sample_spec* pa_sample_spec_init(pa_sample_spec *spec); 00285 00287 int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE; 00288 00290 int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE; 00291 00293 const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE; 00294 00296 pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE; 00297 00303 #define PA_SAMPLE_SPEC_SNPRINT_MAX 32 00304 00306 char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec); 00307 00313 #define PA_BYTES_SNPRINT_MAX 11 00314 00316 char* pa_bytes_snprint(char *s, size_t l, unsigned v); 00317 00320 int pa_sample_format_is_le(pa_sample_format_t f) PA_GCC_PURE; 00321 00324 int pa_sample_format_is_be(pa_sample_format_t f) PA_GCC_PURE; 00325 00326 #ifdef WORDS_BIGENDIAN 00327 #define pa_sample_format_is_ne(f) pa_sample_format_is_be(f) 00328 #define pa_sample_format_is_re(f) pa_sample_format_is_le(f) 00329 #else 00330 00332 #define pa_sample_format_is_ne(f) pa_sample_format_is_le(f) 00333 00335 #define pa_sample_format_is_re(f) pa_sample_format_is_be(f) 00336 #endif 00337 00338 PA_C_DECL_END 00339 00340 #endif