From 42953944da1261584d56405128c6eb3c0e9e7da0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 1 May 2016 21:36:04 +0200 Subject: The last loader thread stuff. --- src/drumkitloader.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/drumkitloader.h') diff --git a/src/drumkitloader.h b/src/drumkitloader.h index 3fd7ec1..01b4f06 100644 --- a/src/drumkitloader.h +++ b/src/drumkitloader.h @@ -36,6 +36,9 @@ #include "drumkit.h" #include "settings.h" +#include "audioinputengine.h" +#include "chresampler.h" +#include "memchecker.h" //! This class is responsible for loading the drumkits in its own thread. //! All interaction calls are simply modifying queues and not doing any @@ -47,41 +50,45 @@ class DrumKitLoader { public: //! The constrcutor starts the loader thread. - DrumKitLoader(Settings& settings); + DrumKitLoader(Settings& settings, DrumKit& kit, AudioInputEngine& ie, + std::array& resampler); //! The destructor signals the thread to stop and waits to merge before //! returning (ie. deleting the object will garantuee that the thread has //! been stopped). ~DrumKitLoader(); - //! Signal the loader to start loading all audio files contained in kit. + bool loadkit(const std::string& file); + + //! Signal the loader to start loading all audio files contained in the kit. //! All other AudioFiles in queue will be removed before the new ones are //! scheduled. void loadKit(DrumKit *kit); - void thread_main(); - - //! Simply reports if the load queue is empty (i.e. all AudioFiles has been - //! loaded). - bool isDone(); - //! Signal the loader to stop and wait until it has. void stop(); //! Skip all queued AudioFiles. void skip(); + //! Set the framesize which will be used to preloading samples in next + //! loadKit call. void setFrameSize(size_t framesize); protected: + void thread_main(); + Semaphore run_semaphore; Semaphore semaphore; Semaphore framesize_semaphore; std::mutex mutex; volatile bool running{false}; std::list load_queue; - std::size_t loaded{0}; std::size_t framesize{0}; Settings& settings; SettingsGetter getter; + DrumKit& kit; + AudioInputEngine& ie; + std::array& resampler; + MemChecker memchecker; }; -- cgit v1.2.3