1 // Copyright (C) 2012 The SBCELT Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE-file.
4 
5 #ifndef __SBCELT_INTERNAL_H__
6 #define __SBCELT_INTERNAL_H__
7 
8 #define SBCELT_PAGES                   2
9 #define SBCELT_PAGE_SIZE               4096
10 
11 #define SBCELT_SLOTS                   40
12 
13 #define SBCELT_MODE_FUTEX              1
14 #define SBCELT_MODE_RW                 2
15 
16 #define SBCELT_SANDBOX_NONE            0
17 #define SBCELT_SANDBOX_SECCOMP_STRICT  1
18 #define SBCELT_SANDBOX_SECCOMP_BPF     2
19 #define SBCELT_SANDBOX_SEATBELT        3
20 #define SBCELT_SANDBOX_CAPSICUM        4
21 
22 #define SBCELT_SANDBOX_VALID(x) \
23 	(x >= SBCELT_SANDBOX_NONE && x <= SBCELT_SANDBOX_CAPSICUM)
24 
25 struct SBCELTWorkPage {
26 	int            slot;          // The slot that the helper process should work on.
27 	int            ready;         // The ready state (also used for futex synchronization).
28 	unsigned char  busywait;      // Determines whether libsbcelt and the helper may use busy-waiting instead of kernel synchronization.
29 	unsigned char  mode;          // The current operational mode (SBCELT_MODE_FUTEX or SBCELT_MODE_RW)
30 	unsigned char  sandbox;       // The sandbox technique that is used to jail the helper.
31 	unsigned char  pingpong;      // Byte-sized value used for SBCELT_MODE_RW synchronization.
32 	unsigned int   len;           // Specifies the length of encbuf to the helper process.
33 	unsigned char  encbuf[2048];  // Holds the frame to be decoded.
34 	float          decbuf[480];   // Holds the decoded PCM data.
35 };
36 
37 struct SBCELTDecoderSlot {
38 	int   available;
39 	int   dispose;
40 };
41 
42 struct SBCELTDecoderPage {
43 	struct SBCELTDecoderSlot slots[SBCELT_SLOTS];
44 };
45 
46 int SBCELT_Init();
47 
48 #endif
49