summaryrefslogtreecommitdiff
path: root/src/cachemanager.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-04-23 15:20:48 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2015-04-23 15:20:48 +0200
commit672e34d2f2066dcffdd54b554fbe9b89d5b85470 (patch)
treeb795c118aad4bd3fccfcc57ab307b04386b90eec /src/cachemanager.h
parent83316b2cc7cba508c9f9a7dfcc4c82026507badf (diff)
Added run sempahore (wait until thread actually started). Fixed localpos bug. Added 'threaded' argument to init that handles events either directly or in a thread when dispatched. Added cachemanager unit test (currently failing).
Diffstat (limited to 'src/cachemanager.h')
-rw-r--r--src/cachemanager.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/cachemanager.h b/src/cachemanager.h
index 25115c3..f2c0122 100644
--- a/src/cachemanager.h
+++ b/src/cachemanager.h
@@ -41,8 +41,9 @@
#define CACHE_DUMMYID -2
#define CACHE_NOID -1
-#define FRAMESIZE 256
-#define CHUNKSIZE FRAMESIZE*100
+#define FRAMESIZE 2048
+#define CHUNKSIZE (FRAMESIZE * 16)
+#define PRELOADSIZE (FRAMESIZE + CHUNKSIZE)
class AudioFile;
typedef int cacheid_t;
@@ -88,7 +89,7 @@ public:
* This method blocks until the thread has been started.
* @param poolsize The maximum number of parellel events supported.
*/
- void init(size_t poolsize);
+ void init(size_t poolsize, bool threaded);
/**
* Stop thread and clean up resources.
@@ -138,6 +139,7 @@ private:
AudioFile *file;
size_t channel;
size_t pos; //< File possition
+ volatile bool ready;
sample_t *front;
sample_t *back;
size_t localpos; //< Intra buffer (front) position.
@@ -157,6 +159,7 @@ private:
// For load next event:
size_t pos;
sample_t *buffer;
+ volatile bool *ready;
AudioFile *file;
size_t channel;
} cevent_t;
@@ -168,6 +171,7 @@ private:
void handleLoadNextEvent(cevent_t &e);
void handleCloseEvent(cevent_t &e);
+ void handleEvent(cevent_t &e);
void pushEvent(cevent_t e);
std::vector<cache_t> id2cache;
@@ -179,8 +183,9 @@ private:
Mutex m_events;
Mutex m_ids;
+ bool threaded; // Indicates if we are running in thread mode or offline mode.
Semaphore sem;
-
+ Semaphore sem_run;
bool running;
};