2 ** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 ** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
21 ** use license for this code is available, please see:
22 ** http://www.mega-nerd.com/SRC/procedure.html
25 #ifndef COMMON_H_INCLUDED
26 #define COMMON_H_INCLUDED
30 #elif (SIZEOF_INT == 4)
32 #elif (SIZEOF_LONG == 4)
33 typedef long int32_t ;
36 #define SRC_MAX_RATIO 256
37 #define SRC_MAX_RATIO_STR "256"
39 #define SRC_MIN_RATIO_DIFF (1e-20)
41 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
42 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
44 #define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
45 #define OFFSETOF(type,member) ((int) (&((type*) 0)->member))
47 #define MAKE_MAGIC(a,b,c,d,e,f) ((a) + ((b) << 4) + ((c) << 8) + ((d) << 12) + ((e) << 16) + ((f) << 20))
50 # define WARN_UNUSED __attribute__ ((warn_unused_result))
56 #include "samplerate.h"
62 SRC_MODE_PROCESS
= 555,
63 SRC_MODE_CALLBACK
= 556
67 { SRC_ERR_NO_ERROR
= 0,
69 SRC_ERR_MALLOC_FAILED
,
74 SRC_ERR_BAD_SRC_RATIO
,
78 SRC_ERR_BAD_CONVERTER
,
79 SRC_ERR_BAD_CHANNEL_COUNT
,
80 SRC_ERR_SINC_BAD_BUFFER_LEN
,
81 SRC_ERR_SIZE_INCOMPATIBILITY
,
83 SRC_ERR_BAD_SINC_STATE
,
87 SRC_ERR_NULL_CALLBACK
,
88 SRC_ERR_NO_VARIABLE_RATIO
,
89 SRC_ERR_SINC_PREPARE_DATA_BAD_LEN
,
91 /* This must be the last error number. */
95 typedef struct SRC_PRIVATE_tag
96 { double last_ratio
, last_position
;
101 /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
104 /* Pointer to data to converter specific data. */
107 /* Varispeed process function. */
108 int (*vari_process
) (struct SRC_PRIVATE_tag
*psrc
, SRC_DATA
*data
) ;
110 /* Constant speed process function. */
111 int (*const_process
) (struct SRC_PRIVATE_tag
*psrc
, SRC_DATA
*data
) ;
114 void (*reset
) (struct SRC_PRIVATE_tag
*psrc
) ;
116 /* Data specific to SRC_MODE_CALLBACK. */
117 src_callback_t callback_func
;
118 void *user_callback_data
;
124 const char* sinc_get_name (int src_enum
) ;
125 const char* sinc_get_description (int src_enum
) ;
127 int sinc_set_converter (SRC_PRIVATE
*psrc
, int src_enum
) ;
129 /* In src_linear.c */
130 const char* linear_get_name (int src_enum
) ;
131 const char* linear_get_description (int src_enum
) ;
133 int linear_set_converter (SRC_PRIVATE
*psrc
, int src_enum
) ;
136 const char* zoh_get_name (int src_enum
) ;
137 const char* zoh_get_description (int src_enum
) ;
139 int zoh_set_converter (SRC_PRIVATE
*psrc
, int src_enum
) ;
141 /*----------------------------------------------------------
142 ** Common static inline functions.
149 res
= x
- lrint (x
) ;
156 #endif /* COMMON_H_INCLUDED */