]>
iEval git - audio-libsamplerate.git/blob - misc_test.c
d177a0e4727cb86a5bca4ac824ff25b56dd99c14
2 ** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
3 ** All rights reserved.
5 ** This code is released under 2-clause BSD license. Please see the
6 ** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
13 #include <samplerate.h>
17 static void name_test (void) ;
18 static void error_test (void) ;
19 static void src_ratio_test (void) ;
20 static void zero_input_test (int converter
) ;
27 printf (" version : %s\n\n", src_get_version ()) ;
29 /* Current max converter is SRC_LINEAR. */
36 zero_input_test (SRC_ZERO_ORDER_HOLD
) ;
37 zero_input_test (SRC_LINEAR
) ;
38 zero_input_test (SRC_SINC_FASTEST
) ;
49 puts (" name_test :") ;
52 { name
= src_get_name (k
) ;
55 printf ("\tName %d : %s\n", k
, name
) ;
56 printf ("\tDesc %d : %s\n", k
, src_get_description (k
)) ;
65 /*------------------------------------------------------------------------------
73 static RATIO_TEST ratio_test
[] =
86 puts (" src_ratio_test (SRC ratio must be in range [1/256, 256]):" ) ;
89 for (k
= 0 ; k
< ARRAY_LEN (ratio_test
) ; k
++)
90 { if (ratio_test
[k
].should_pass
&& src_is_valid_ratio (ratio_test
[k
].ratio
) == 0)
91 { printf ("\n\nLine %d : SRC ratio %f should have passed.\n\n", __LINE__
, ratio_test
[k
].ratio
) ;
94 if (! ratio_test
[k
].should_pass
&& src_is_valid_ratio (ratio_test
[k
].ratio
) != 0)
95 { printf ("\n\nLine %d : SRC ratio %f should not have passed.\n\n", __LINE__
, ratio_test
[k
].ratio
) ;
98 printf ("\t SRC ratio (%9.5f) : %s ................... ok\n", ratio_test
[k
].ratio
,
99 (ratio_test
[k
].should_pass
? "pass" : "fail")) ;
105 } /* src_ratio_test */
109 { const char *errorstr
;
112 puts (" error_test :") ;
114 for (k
= 0 ; 1 ; k
++)
115 { errorstr
= src_strerror (k
) ;
116 printf ("\t%-2d : %s\n", k
, errorstr
) ;
117 if (errorstr
== NULL
)
121 if (strstr (errorstr
, "Placeholder.") == errorstr
)
126 { printf ("\n\nLine %d : Missing error numbers above.\n\n", __LINE__
) ;
136 zero_input_test (int converter
)
142 printf (" %s (%-26s) ........ ", __func__
, src_get_name (converter
)) ;
145 if ((state
= src_new (converter
, 1, &error
)) == NULL
)
146 { printf ("\n\nLine %d : src_new failed : %s.\n\n", __LINE__
, src_strerror (error
)) ;
150 data
.data_in
= (float *) 0xdeadbeef ;
151 data
.input_frames
= 0 ;
152 data
.data_out
= out
;
153 data
.output_frames
= ARRAY_LEN (out
) ;
154 data
.end_of_input
= 0 ;
155 data
.src_ratio
= 1.0 ;
157 if ((error
= src_process (state
, &data
)))
158 { printf ("\n\nLine %d : src_new failed : %s.\n\n", __LINE__
, src_strerror (error
)) ;
162 state
= src_delete (state
) ;
165 } /* zero_input_test */
This page took 0.061786 seconds and 3 git commands to generate.