BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
gsldatacache.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __GSL_DATA_CACHE_H__
00003 #define __GSL_DATA_CACHE_H__
00004 
00005 #include <bse/gslcommon.hh>
00006 
00007 G_BEGIN_DECLS
00008 
00009 /* --- macros --- */
00010 #define GSL_DATA_CACHE_NODE_SIZE(dcache)        (((GslDataCache*) (dcache))->node_size)
00011 
00012 
00013 /* --- typedefs & structures --- */
00014 typedef gfloat                     GslDataType;
00015 typedef struct _GslDataCacheNode   GslDataCacheNode;
00016 struct _GslDataCache
00017 {
00018   GslDataHandle        *dhandle;
00019   guint                 open_count;
00020   Bse::Mutex            mutex;
00021   guint                 ref_count;
00022   guint                 node_size;              /* power of 2, const for all dcaches */
00023   guint                 padding;                /* n_values around blocks */
00024   guint                 max_age;
00025   gboolean              high_persistency;       /* valid for opened caches only */
00026   guint                 n_nodes;
00027   GslDataCacheNode    **nodes;
00028 };
00029 struct _GslDataCacheNode
00030 {
00031   int64         offset;
00032   guint         ref_count;
00033   guint         age;
00034   GslDataType  *data;   /* NULL while busy */
00035 };
00036 typedef enum
00037 {
00038   GSL_DATA_CACHE_REQUEST     = FALSE, /* node->data may be NULL and will be filled */
00039   GSL_DATA_CACHE_DEMAND_LOAD = TRUE,  /* blocks until node->data != NULL */
00040   GSL_DATA_CACHE_PEEK        = 2      /* may return NULL node, data != NULL otherwise */
00041 } GslDataCacheRequest;
00042 
00043 
00044 /* --- prototypes --- */
00045 GslDataCache*     gsl_data_cache_new            (GslDataHandle      *dhandle,
00046                                                  guint               padding);
00047 GslDataCache*     gsl_data_cache_ref            (GslDataCache       *dcache);
00048 void              gsl_data_cache_unref          (GslDataCache       *dcache);
00049 void              gsl_data_cache_open           (GslDataCache       *dcache);
00050 void              gsl_data_cache_close          (GslDataCache       *dcache);
00051 GslDataCacheNode* gsl_data_cache_ref_node       (GslDataCache       *dcache,
00052                                                  int64               offset,
00053                                                  GslDataCacheRequest load_request);
00054 void              gsl_data_cache_unref_node     (GslDataCache       *dcache,
00055                                                  GslDataCacheNode   *node);
00056 void              gsl_data_cache_free_olders    (GslDataCache       *dcache,
00057                                                  guint               max_age);
00058 GslDataCache*     gsl_data_cache_from_dhandle   (GslDataHandle      *dhandle,
00059                                                  guint               min_padding);
00060 
00061 G_END_DECLS
00062 
00063 #endif /* __GSL_DATA_CACHE_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines