63 |
*/ |
*/ |
64 |
class InstrumentResourceManager : public InstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument> { |
class InstrumentResourceManager : public InstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument> { |
65 |
public: |
public: |
66 |
|
InstrumentResourceManager() : Gigs(this) {} |
67 |
virtual ~InstrumentResourceManager() {} |
virtual ~InstrumentResourceManager() {} |
68 |
static void OnInstrumentLoadingProgress(::gig::progress_t* pProgress); |
static void OnInstrumentLoadingProgress(::gig::progress_t* pProgress); |
69 |
|
|
72 |
virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID); |
virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID); |
73 |
virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode); |
virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode); |
74 |
virtual String GetInstrumentName(instrument_id_t ID); |
virtual String GetInstrumentName(instrument_id_t ID); |
75 |
|
|
76 |
|
void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, |
77 |
|
::gig::DimensionRegion** dimRegionsInUse); |
78 |
|
void HandBackDimReg(::gig::DimensionRegion* pDimReg); |
79 |
|
|
80 |
protected: |
protected: |
81 |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
82 |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
90 |
virtual void Destroy(::gig::File* pResource, void* pArg); |
virtual void Destroy(::gig::File* pResource, void* pArg); |
91 |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
92 |
public: |
public: |
93 |
|
GigResourceManager(InstrumentResourceManager* parent) : parent(parent) {} |
94 |
virtual ~GigResourceManager() {} |
virtual ~GigResourceManager() {} |
95 |
|
private: |
96 |
|
InstrumentResourceManager* parent; |
97 |
} Gigs; |
} Gigs; |
98 |
|
|
99 |
void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); |
void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); |
100 |
|
|
101 |
|
struct dimreg_info_t { |
102 |
|
int refCount; |
103 |
|
::gig::File* file; |
104 |
|
::RIFF::File* riff; |
105 |
|
}; |
106 |
|
Mutex DimRegInfoMutex; ///< protects the DimRegInfo and SampleRefCount maps from concurrent access by the instrument loader and disk threads |
107 |
|
std::map< ::gig::DimensionRegion*, dimreg_info_t> DimRegInfo; ///< contains dimension regions that are still in use but belong to released instrument |
108 |
|
std::map< ::gig::Sample*, int> SampleRefCount; ///< contains samples that are still in use but belong to a released instrument |
109 |
}; |
}; |
110 |
|
|
111 |
/** |
/** |