BEAST - Free Software Audio Synthesizer and Tracker  0.10.0
gsldatacache.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __GSL_DATA_CACHE_H__
3 #define __GSL_DATA_CACHE_H__
4 
5 #include <bse/gslcommon.hh>
6 
7 G_BEGIN_DECLS
8 
9 /* --- macros --- */
10 #define GSL_DATA_CACHE_NODE_SIZE(dcache) (((GslDataCache*) (dcache))->node_size)
11 
12 
13 /* --- typedefs & structures --- */
14 typedef gfloat GslDataType;
15 typedef struct _GslDataCacheNode GslDataCacheNode;
17 {
18  GslDataHandle *dhandle;
19  guint open_count;
20  Bse::Mutex mutex;
21  guint ref_count;
22  guint node_size; /* power of 2, const for all dcaches */
23  guint padding; /* n_values around blocks */
24  guint max_age;
25  gboolean high_persistency; /* valid for opened caches only */
26  guint n_nodes;
27  GslDataCacheNode **nodes;
28 };
30 {
31  int64 offset;
32  guint ref_count;
33  guint age;
34  GslDataType *data; /* NULL while busy */
35 };
36 typedef enum
37 {
38  GSL_DATA_CACHE_REQUEST = FALSE, /* node->data may be NULL and will be filled */
39  GSL_DATA_CACHE_DEMAND_LOAD = TRUE, /* blocks until node->data != NULL */
40  GSL_DATA_CACHE_PEEK = 2 /* may return NULL node, data != NULL otherwise */
41 } GslDataCacheRequest;
42 
43 
44 /* --- prototypes --- */
45 GslDataCache* gsl_data_cache_new (GslDataHandle *dhandle,
46  guint padding);
47 GslDataCache* gsl_data_cache_ref (GslDataCache *dcache);
48 void gsl_data_cache_unref (GslDataCache *dcache);
49 void gsl_data_cache_open (GslDataCache *dcache);
50 void gsl_data_cache_close (GslDataCache *dcache);
51 GslDataCacheNode* gsl_data_cache_ref_node (GslDataCache *dcache,
52  int64 offset,
53  GslDataCacheRequest load_request);
54 void gsl_data_cache_unref_node (GslDataCache *dcache,
55  GslDataCacheNode *node);
56 void gsl_data_cache_free_olders (GslDataCache *dcache,
57  guint max_age);
58 GslDataCache* gsl_data_cache_from_dhandle (GslDataHandle *dhandle,
59  guint min_padding);
60 
61 G_END_DECLS
62 
63 #endif /* __GSL_DATA_CACHE_H__ */
Definition: gsldatacache.hh:16
Definition: gsldatacache.hh:29