--- linuxsampler/trunk/src/engines/gig/InstrumentResourceManager.h 2007/02/03 15:33:00 1038 +++ linuxsampler/trunk/src/engines/gig/InstrumentResourceManager.h 2007/10/03 18:41:09 1375 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005, 2006 Christian Schoenebeck * + * Copyright (C) 2005 - 2007 Christian Schoenebeck * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -29,7 +29,6 @@ #include #include "../../common/global.h" -#include "../../common/Exception.h" #include "../../common/ResourceManager.h" #include "../../drivers/audio/AudioOutputDevice.h" #include "../InstrumentManager.h" @@ -44,11 +43,13 @@ #include "EngineChannel.h" #include "Engine.h" +#include "../../plugins/InstrumentEditor.h" namespace LinuxSampler { namespace gig { // just symbol prototyping class EngineChannel; + class Engine; /** @brief Gig instrument manager * @@ -61,7 +62,7 @@ * instrument / file is not needed anymore, then it will be freed from * memory. */ - class InstrumentResourceManager : public InstrumentManager, public ResourceManager { + class InstrumentResourceManager : public InstrumentManager, public ResourceManager, public InstrumentEditorListener { public: InstrumentResourceManager() : Gigs(this) {} virtual ~InstrumentResourceManager() {} @@ -72,12 +73,24 @@ virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID); virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode); virtual String GetInstrumentName(instrument_id_t ID); + virtual String GetInstrumentDataStructureName(instrument_id_t ID); + virtual String GetInstrumentDataStructureVersion(instrument_id_t ID); + virtual void LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException); + + // implementation of derived abstract methods from 'InstrumentEditorListener' + virtual void OnInstrumentEditorQuit(InstrumentEditor* pSender); + virtual void OnSamplesToBeRemoved(std::set Samples, InstrumentEditor* pSender); + virtual void OnSamplesRemoved(InstrumentEditor* pSender); + virtual void OnDataStructureToBeChanged(void* pStruct, String sStructType, InstrumentEditor* pSender); + virtual void OnDataStructureChanged(void* pStruct, String sStructType, InstrumentEditor* pSender); + virtual void OnSampleReferenceChanged(void* pOldSample, void* pNewSample, InstrumentEditor* pSender); void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, ::gig::DimensionRegion** dimRegionsInUse); void HandBackDimReg(::gig::DimensionRegion* pDimReg); protected: + // implementation of derived abstract methods from 'ResourceManager' virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); virtual void Destroy(::gig::Instrument* pResource, void* pArg); virtual void OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg); @@ -86,6 +99,7 @@ class GigResourceManager : public ResourceManager { protected: + // implementation of derived abstract methods from 'ResourceManager' virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg); virtual void Destroy(::gig::File* pResource, void* pArg); virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore @@ -97,6 +111,15 @@ } Gigs; void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); + void CacheInitialSamples(::gig::Sample* pSample, gig::Engine* pEngine); + void UncacheInitialSamples(::gig::Sample* pSample); + std::vector< ::gig::Instrument*> GetInstrumentsCurrentlyUsedOf(::gig::File* pFile, bool bLock); + std::set GetEnginesUsing(::gig::Instrument* pFile, bool bLock); + std::set GetEnginesUsing(::gig::File* pFile, bool bLock); + bool SampleReferencedByInstrument(::gig::Sample* pSample, ::gig::Instrument* pInstrument); + void SuspendEnginesUsing(::gig::Instrument* pInstrument); + void SuspendEnginesUsing(::gig::File* pFile); + void ResumeAllEngines(); struct dimreg_info_t { int refCount; @@ -106,14 +129,11 @@ Mutex DimRegInfoMutex; ///< protects the DimRegInfo and SampleRefCount maps from concurrent access by the instrument loader and disk threads std::map< ::gig::DimensionRegion*, dimreg_info_t> DimRegInfo; ///< contains dimension regions that are still in use but belong to released instrument std::map< ::gig::Sample*, int> SampleRefCount; ///< contains samples that are still in use but belong to a released instrument - }; - /** - * Will be thrown by the InstrumentResourceManager on errors. - */ - class InstrumentResourceManagerException : public Exception { - public: - InstrumentResourceManagerException(String msg) : Exception(msg) {} + Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map + std::map InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor + std::set suspendedEngines; ///< all engines currently completely suspended + Mutex suspendedEnginesMutex; ///< protects 'suspendedEngines' set }; }} // namespace LinuxSampler::gig