2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)ringbuff.h 1.5 01/10/20 Copyright 1998,1999,2000 Heiko Eissfeldt */
14 /* This file contains data structures that reside in the shared memory
19 /* the linux semctl prototype is broken as is the definition
20 of union semun in sys/sem.h. */
22 #ifdef HAVE_UNION_SEMUN
23 # define my_semun semun
28 unsigned short *array;
32 /* Ringbuffer structures.
33 Space for the ringbuffer is allocated page aligned
34 and contains the following
36 -------------------- start of page
37 header (once for the ring buffer) \\
38 space for page alignment ||+- HEADER_SIZE
40 myringbuffer.offset |/
41 -------------------- start of page/-- pagesize
42 myringbuffer.data (SEGMENT_SIZE)\
43 space for page alignment |+- ENTRY_SIZE_PAGE_AL
45 -------------------- start of page
47 space for page alignment
52 UINT4 data[CD_FRAMESAMPLES];
55 struct ringbuffheader {
58 volatile unsigned long total_read;
59 volatile unsigned long total_written;
60 volatile int child_waitstate;
61 volatile int parent_waitstate;
62 volatile int input_littleendian;
63 volatile int end_is_reached;
64 volatile unsigned long nSamplesToDo;
66 UINT4 data[CD_FRAMESAMPLES];
69 extern myringbuff **he_fill_buffer;
70 extern myringbuff **last_buffer;
71 extern volatile unsigned long *total_segments_read;
72 extern volatile unsigned long *total_segments_written;
73 extern volatile int *child_waits;
74 extern volatile int *parent_waits;
75 extern volatile int *in_lendian;
76 extern volatile int *eorecording;
78 #define palign(x, a) (((char *)(x)) + ((a) - 1 - (((unsigned)((x)-1))%(a))))
79 #define multpage(x, a) ((((x) + (a) - 1) / (a)) * (a))
81 #define HEADER_SIZE multpage(offset_of(struct ringbuffheader, data), global.pagesize)
82 #define SEGMENT_SIZE (global.nsectors*CD_FRAMESIZE_RAW)
83 #define ENTRY_SIZE_PAGE_AL multpage(SEGMENT_SIZE + offset_of(myringbuff, data), global.pagesize)
85 #define RB_BASE ((myringbuff *)(((unsigned char *)he_fill_buffer) + HEADER_SIZE - offset_of(myringbuff, data)))
87 #define INC(a) (myringbuff *)(((char *)RB_BASE) + (((((char *) (a))-((char *)RB_BASE))/ENTRY_SIZE_PAGE_AL + 1) % total_buffers)*ENTRY_SIZE_PAGE_AL)
90 void set_total_buffers(unsigned int num_buffers, int mysem_id);
91 const myringbuff *get_previous_read_buffer(void);
92 const myringbuff *get_he_fill_buffer(void);
93 myringbuff *get_next_buffer(void);
94 myringbuff *get_oldest_buffer(void);
95 void define_buffer(void);
96 void drop_buffer(void);
97 void drop_all_buffers(void);