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>2016-01-20 13:24:28 +0100
commitb67e30cb862ab640e4a7ced48b1905b2421885b9 (patch)
tree73bc34c7c88a6ba33ca6a9c22ed43cff86376e11 /src/cachemanager.h
parenteaa2062ea50fea853fa1852b152354ba50d44985 (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;
};