28 |
|
|
29 |
#include <gig.h> |
#include <gig.h> |
30 |
|
|
31 |
#include "../../common/global.h" |
#include "../../common/Pool.h" |
32 |
#include "../../common/ResourceManager.h" |
#include "../../common/ResourceManager.h" |
33 |
|
#include "../InstrumentManagerBase.h" |
34 |
#include "../../drivers/audio/AudioOutputDevice.h" |
#include "../../drivers/audio/AudioOutputDevice.h" |
35 |
#include "../InstrumentManager.h" |
#include "../InstrumentManager.h" |
36 |
#include "../../common/ArrayList.h" |
#include "../../common/ArrayList.h" |
43 |
|
|
44 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |
45 |
|
|
|
#include "EngineChannel.h" |
|
|
#include "Engine.h" |
|
46 |
#include "../../plugins/InstrumentEditor.h" |
#include "../../plugins/InstrumentEditor.h" |
47 |
|
|
48 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
|
|
|
|
// just symbol prototyping |
|
|
class EngineChannel; |
|
49 |
class Engine; |
class Engine; |
50 |
|
class EngineChannel; |
51 |
|
|
52 |
/** @brief Gig instrument manager |
/** @brief Gig instrument manager |
53 |
* |
* |
60 |
* instrument / file is not needed anymore, then it will be freed from |
* instrument / file is not needed anymore, then it will be freed from |
61 |
* memory. |
* memory. |
62 |
*/ |
*/ |
63 |
class InstrumentResourceManager : public InstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument>, public InstrumentEditorListener { |
class InstrumentResourceManager : public InstrumentManagerBase< ::gig::File, ::gig::Instrument, ::gig::DimensionRegion, ::gig::Sample>, public InstrumentEditorListener { |
64 |
public: |
public: |
65 |
InstrumentResourceManager() : Gigs(this) {} |
InstrumentResourceManager() : Gigs(this) {} |
66 |
virtual ~InstrumentResourceManager() {} |
virtual ~InstrumentResourceManager() {} |
68 |
|
|
69 |
// implementation of derived abstract methods from 'InstrumentManager' |
// implementation of derived abstract methods from 'InstrumentManager' |
70 |
virtual std::vector<instrument_id_t> Instruments(); |
virtual std::vector<instrument_id_t> Instruments(); |
|
virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID); |
|
|
virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode); |
|
71 |
virtual String GetInstrumentName(instrument_id_t ID); |
virtual String GetInstrumentName(instrument_id_t ID); |
72 |
virtual String GetInstrumentDataStructureName(instrument_id_t ID); |
virtual String GetInstrumentDataStructureName(instrument_id_t ID); |
73 |
virtual String GetInstrumentDataStructureVersion(instrument_id_t ID); |
virtual String GetInstrumentDataStructureVersion(instrument_id_t ID); |
83 |
virtual void OnDataStructureChanged(void* pStruct, String sStructType, InstrumentEditor* pSender); |
virtual void OnDataStructureChanged(void* pStruct, String sStructType, InstrumentEditor* pSender); |
84 |
virtual void OnSampleReferenceChanged(void* pOldSample, void* pNewSample, InstrumentEditor* pSender); |
virtual void OnSampleReferenceChanged(void* pOldSample, void* pNewSample, InstrumentEditor* pSender); |
85 |
|
|
|
void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, |
|
|
RTList< ::gig::DimensionRegion*>* pDimRegionsInUse); |
|
|
void HandBackDimReg(::gig::DimensionRegion* pDimReg); |
|
|
|
|
86 |
#if 0 // currently unused : |
#if 0 // currently unused : |
87 |
void TrySendNoteOnToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument); |
void TrySendNoteOnToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument); |
88 |
void TrySendNoteOffToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument); |
void TrySendNoteOffToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument); |
93 |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
94 |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
95 |
virtual void OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg); |
virtual void OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg); |
96 |
|
virtual void CacheInitialSamples(::gig::Sample* pSample, AbstractEngine* pEngine); |
97 |
|
virtual void CacheInitialSamples(::gig::Sample* pSample, EngineChannel* pEngineChannel); |
98 |
|
virtual void DeleteRegionIfNotUsed(::gig::DimensionRegion* pRegion, region_info_t* pRegInfo); |
99 |
|
virtual void DeleteSampleIfNotUsed(::gig::Sample* pSample, region_info_t* pRegInfo); |
100 |
private: |
private: |
101 |
typedef ResourceConsumer< ::gig::File> GigConsumer; |
typedef ResourceConsumer< ::gig::File> GigConsumer; |
102 |
|
|
113 |
InstrumentResourceManager* parent; |
InstrumentResourceManager* parent; |
114 |
} Gigs; |
} Gigs; |
115 |
|
|
|
void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); |
|
|
void CacheInitialSamples(::gig::Sample* pSample, gig::Engine* pEngine); |
|
116 |
void UncacheInitialSamples(::gig::Sample* pSample); |
void UncacheInitialSamples(::gig::Sample* pSample); |
117 |
std::vector< ::gig::Instrument*> GetInstrumentsCurrentlyUsedOf(::gig::File* pFile, bool bLock); |
std::vector< ::gig::Instrument*> GetInstrumentsCurrentlyUsedOf(::gig::File* pFile, bool bLock); |
118 |
std::set<gig::EngineChannel*> GetEngineChannelsUsing(::gig::Instrument* pInstrument, bool bLock); |
std::set<EngineChannel*> GetEngineChannelsUsing(::gig::Instrument* pInstrument, bool bLock); |
119 |
std::set<gig::Engine*> GetEnginesUsing(::gig::Instrument* pInstrument, bool bLock); |
std::set<Engine*> GetEnginesUsing(::gig::Instrument* pInstrument, bool bLock); |
120 |
std::set<gig::Engine*> GetEnginesUsing(::gig::File* pFile, bool bLock); |
std::set<Engine*> GetEnginesUsing(::gig::File* pFile, bool bLock); |
121 |
bool SampleReferencedByInstrument(::gig::Sample* pSample, ::gig::Instrument* pInstrument); |
bool SampleReferencedByInstrument(::gig::Sample* pSample, ::gig::Instrument* pInstrument); |
122 |
void SuspendEnginesUsing(::gig::Instrument* pInstrument); |
void SuspendEnginesUsing(::gig::Instrument* pInstrument); |
123 |
void SuspendEnginesUsing(::gig::File* pFile); |
void SuspendEnginesUsing(::gig::File* pFile); |
124 |
void ResumeAllEngines(); |
void ResumeAllEngines(); |
125 |
|
|
|
struct dimreg_info_t { |
|
|
int refCount; |
|
|
::gig::File* file; |
|
|
::RIFF::File* riff; |
|
|
}; |
|
|
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 |
|
|
|
|
126 |
Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map |
Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map |
127 |
ArrayList<InstrumentConsumer*> InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor |
ArrayList<InstrumentConsumer*> InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor |
128 |
std::set<Engine*> suspendedEngines; ///< all engines currently completely suspended |
std::set<Engine*> suspendedEngines; ///< all engines currently completely suspended |