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
30 enum cbox_prefetch_pipe_state
41 struct cbox_prefetch_pipe
43 enum cbox_prefetch_pipe_state state
;
45 struct cbox_waveform
*waveform
;
50 uint32_t file_pos_frame
;
51 uint32_t file_loop_start
;
52 uint32_t file_loop_end
;
53 uint32_t buffer_loop_end
;
54 uint32_t play_count
, loop_count
;
62 extern void cbox_prefetch_pipe_init(struct cbox_prefetch_pipe
*pipe
, uint32_t buffer_size
);
63 extern void cbox_prefetch_pipe_consumed(struct cbox_prefetch_pipe
*pipe
, uint32_t frames
);
64 extern void cbox_prefetch_pipe_close(struct cbox_prefetch_pipe
*pipe
);
66 static inline uint32_t cbox_prefetch_pipe_get_remaining(struct cbox_prefetch_pipe
*pipe
)
68 assert(pipe
->consumed
<= pipe
->produced
);
69 return pipe
->produced
- pipe
->consumed
;
72 struct cbox_prefetch_stack
74 struct cbox_prefetch_pipe
*pipes
;
76 pthread_t thr_prefetch
;
81 extern struct cbox_prefetch_stack
*cbox_prefetch_stack_new(int npipes
, uint32_t buffer_size
);
82 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
);
83 extern void cbox_prefetch_stack_push(struct cbox_prefetch_stack
*stack
, struct cbox_prefetch_pipe
*pipe
);
84 extern int cbox_prefetch_stack_get_active_pipe_count(struct cbox_prefetch_stack
*stack
);
85 extern void cbox_prefetch_stack_destroy(struct cbox_prefetch_stack
*stack
);