2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2013 Krzysztof Foltman
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CBOX_PREFETCH_PIPE_H
20 #define CBOX_PREFETCH_PIPE_H
31 enum cbox_prefetch_pipe_state
42 struct cbox_prefetch_pipe
44 enum cbox_prefetch_pipe_state state
;
46 struct cbox_waveform
*waveform
;
47 struct cbox_tarfile_sndstream sndstream
;
52 uint32_t file_pos_frame
;
53 uint32_t file_loop_start
;
54 uint32_t file_loop_end
;
55 uint32_t buffer_loop_end
;
56 uint32_t play_count
, loop_count
;
64 extern void cbox_prefetch_pipe_init(struct cbox_prefetch_pipe
*pipe
, uint32_t buffer_size
);
65 extern void cbox_prefetch_pipe_consumed(struct cbox_prefetch_pipe
*pipe
, uint32_t frames
);
66 extern void cbox_prefetch_pipe_close(struct cbox_prefetch_pipe
*pipe
);
68 static inline uint32_t cbox_prefetch_pipe_get_remaining(struct cbox_prefetch_pipe
*pipe
)
70 assert(pipe
->consumed
<= pipe
->produced
);
71 return pipe
->produced
- pipe
->consumed
;
74 struct cbox_prefetch_stack
76 struct cbox_prefetch_pipe
*pipes
;
78 pthread_t thr_prefetch
;
83 extern struct cbox_prefetch_stack
*cbox_prefetch_stack_new(int npipes
, uint32_t buffer_size
);
84 extern struct cbox_prefetch_pipe
*cbox_prefetch_stack_pop(struct cbox_prefetch_stack
*stack
, struct cbox_waveform
*waveform
, uint32_t file_loop_start
, uint32_t file_loop_end
, uint32_t loop_count
);
85 extern void cbox_prefetch_stack_push(struct cbox_prefetch_stack
*stack
, struct cbox_prefetch_pipe
*pipe
);
86 extern int cbox_prefetch_stack_get_active_pipe_count(struct cbox_prefetch_stack
*stack
);
87 extern void cbox_prefetch_stack_destroy(struct cbox_prefetch_stack
*stack
);