summaryrefslogtreecommitdiff
path: root/src/cachemanager.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-04-12 11:27:31 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-20 13:23:13 +0100
commit08e234196ce3cb2eaba4dc15f5eef91e5e7e5961 (patch)
treedf19445240c0288ff9d43c1cf3ecb953f7f22331 /src/cachemanager.h
parentfbe989dad5043cc47a030623593a3fb1499e8d8c (diff)
Added close event to free cache buffers.
Diffstat (limited to 'src/cachemanager.h')
-rw-r--r--src/cachemanager.h38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/cachemanager.h b/src/cachemanager.h
index 557ba23..21579d9 100644
--- a/src/cachemanager.h
+++ b/src/cachemanager.h
@@ -131,46 +131,54 @@ public:
void thread_main();
private:
-
- void pushEvent();
-
typedef struct {
AudioFile *file;
- int channel;
- size_t pos;
+ size_t channel;
+ size_t pos; //< File possition
sample_t *front;
sample_t *back;
- size_t localpos;
+ size_t localpos; //< Intra buffer (front) position.
} cache_t;
- enum cmd_t {
+ typedef enum {
LOADNEXT = 0,
-// CLEAN = 1
- };
+ CLOSE = 1
+ } cmd_t;
typedef struct {
cmd_t cmd;
+
+ // For close event:
+ cacheid_t id;
+
+ // For load next event:
size_t pos;
sample_t *buffer;
AudioFile *file;
+ size_t channel;
} cevent_t;
- cevent_t createLoadNextEvent(AudioFile *file, size_t pos, sample_t* buffer);
- void loadNext(cevent_t &e);
+ cevent_t createLoadNextEvent(AudioFile *file, size_t channel, size_t pos,
+ sample_t* buffer);
+ cevent_t createCloseEvent(cacheid_t id);
+
+ void handleLoadNextEvent(cevent_t &e);
+ void handleCloseEvent(cevent_t &e);
+
void pushEvent(cevent_t e);
- // Protected by mutex
+ std::vector<cache_t> id2cache;
+
+ // Protected by mutex:
std::list<cevent_t> eventqueue;
std::list<cacheid_t> availableids;
- std::vector<cache_t> id2cache;
Mutex m_events;
Mutex m_ids;
- Mutex m_caches;
Semaphore sem;
- int running;
+ bool running;
};
#endif/*__DRUMGIZMO_CACHEMANAGER_H__*/