1 /* limits.h
2 **
3 ** Copyright 2011, The Android Open Source Project
4 **
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions are met:
7 **     * Redistributions of source code must retain the above copyright
8 **       notice, this list of conditions and the following disclaimer.
9 **     * Redistributions in binary form must reproduce the above copyright
10 **       notice, this list of conditions and the following disclaimer in the
11 **       documentation and/or other materials provided with the distribution.
12 **     * Neither the name of The Android Open Source Project nor the names of
13 **       its contributors may be used to endorse or promote products derived
14 **       from this software without specific prior written permission.
15 **
16 ** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND
17 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE
20 ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 ** DAMAGE.
27 */
28 
29 #ifndef TINYALSA_LIMITS_H
30 #define TINYALSA_LIMITS_H
31 
32 #include <tinyalsa/interval.h>
33 
34 #include <limits.h>
35 #include <stdint.h>
36 
37 #define TINYALSA_SIGNED_INTERVAL_MAX SSIZE_MAX
38 #define TINYALSA_SIGNED_INTERVAL_MIN SSIZE_MIN
39 
40 #define TINYALSA_UNSIGNED_INTERVAL_MAX SIZE_MAX
41 #define TINYALSA_UNSIGNED_INTERVAL_MIN SIZE_MIN
42 
43 #define TINYALSA_CHANNELS_MAX 32U
44 #define TINYALSA_CHANNELS_MIN 1U
45 
46 #define TINYALSA_FRAMES_MAX (ULONG_MAX / (TINYALSA_CHANNELS_MAX * 4))
47 #define TINYALSA_FRAMES_MIN 0U
48 
49 #if TINYALSA_FRAMES_MAX > TINYALSA_UNSIGNED_INTERVAL_MAX
50 #error "Frames max exceeds measurable value."
51 #endif
52 
53 #if TINYALSA_FRAMES_MIN < TINYALSA_UNSIGNED_INTERVAL_MIN
54 #error "Frames min exceeds measurable value."
55 #endif
56 
57 extern const struct tinyalsa_unsigned_interval tinyalsa_channels_limit;
58 
59 extern const struct tinyalsa_unsigned_interval tinyalsa_frames_limit;
60 
61 #endif /* TINYALSA_LIMITS_H */
62 
63