]>
iEval git - audio-libsamplerate.git/blob - callback_hang_test.c
06246ec3c735c2a765b1602b832cba19e29f41ac
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
16 #if HAVE_ALARM && HAVE_SIGNAL && HAVE_SIGALRM
20 #include <samplerate.h>
24 #define SHORT_BUFFER_LEN 512
25 #define LONG_BUFFER_LEN (1 << 14)
32 static void callback_hang_test (int converter
) ;
34 static void alarm_handler (int number
) ;
35 static long input_callback (void *cb_data
, float **data
) ;
41 /* Set up SIGALRM handler. */
42 signal (SIGALRM
, alarm_handler
) ;
45 callback_hang_test (SRC_ZERO_ORDER_HOLD
) ;
46 callback_hang_test (SRC_LINEAR
) ;
47 callback_hang_test (SRC_SINC_FASTEST
) ;
55 callback_hang_test (int converter
)
56 { static float output
[LONG_BUFFER_LEN
] ;
57 static SRC_PAIR pairs
[] =
59 { 1.2, 5 }, { 1.1, 1 }, { 1.0, 1 }, { 3.0, 1 }, { 2.0, 1 }, { 0.3, 1 },
60 { 1.2, 0 }, { 1.1, 10 }, { 1.0, 1 }
64 SRC_STATE
*src_state
;
66 double src_ratio
= 1.0 ;
69 printf ("\tcallback_hang_test (%-28s) ....... ", src_get_name (converter
)) ;
72 /* Perform sample rate conversion. */
73 src_state
= src_callback_new (input_callback
, converter
, 1, &error
, NULL
) ;
74 if (src_state
== NULL
)
75 { printf ("\n\nLine %d : src_callback_new () failed : %s\n\n", __LINE__
, src_strerror (error
)) ;
79 for (k
= 0 ; k
< ARRAY_LEN (pairs
) ; k
++)
81 src_ratio
= pairs
[k
].ratio
;
82 src_callback_read (src_state
, src_ratio
, pairs
[k
].count
, output
) ;
85 src_state
= src_delete (src_state
) ;
91 } /* callback_hang_test */
94 alarm_handler (int number
)
97 printf ("\n\n Error : Hang inside src_callback_read() detected. Exiting!\n\n") ;
102 input_callback (void *cb_data
, float **data
)
104 static float buffer
[20] ;
109 return ARRAY_LEN (buffer
) ;
110 } /* input_callback */
117 puts ("\tCan't run this test on this platform.") ;
This page took 0.046745 seconds and 3 git commands to generate.