/[svn]/linuxsampler/trunk/src/engines/gig/InstrumentResourceManager.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/InstrumentResourceManager.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1038 by persson, Sat Feb 3 15:33:00 2007 UTC revision 1525 by schoenebeck, Sun Nov 25 17:47:46 2007 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *   *   Copyright (C) 2005 - 2007 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 29  Line 29 
29  #include <gig.h>  #include <gig.h>
30    
31  #include "../../common/global.h"  #include "../../common/global.h"
 #include "../../common/Exception.h"  
32  #include "../../common/ResourceManager.h"  #include "../../common/ResourceManager.h"
33  #include "../../drivers/audio/AudioOutputDevice.h"  #include "../../drivers/audio/AudioOutputDevice.h"
34  #include "../InstrumentManager.h"  #include "../InstrumentManager.h"
# Line 44  namespace LinuxSampler { namespace gig { Line 43  namespace LinuxSampler { namespace gig {
43    
44  #include "EngineChannel.h"  #include "EngineChannel.h"
45  #include "Engine.h"  #include "Engine.h"
46    #include "../../plugins/InstrumentEditor.h"
47    
48  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
49    
50      // just symbol prototyping      // just symbol prototyping
51      class EngineChannel;      class EngineChannel;
52        class Engine;
53    
54      /** @brief Gig instrument manager      /** @brief Gig instrument manager
55       *       *
# Line 61  namespace LinuxSampler { namespace gig { Line 62  namespace LinuxSampler { namespace gig {
62       * instrument / file is not needed anymore, then it will be freed from       * instrument / file is not needed anymore, then it will be freed from
63       * memory.       * memory.
64       */       */
65      class InstrumentResourceManager : public InstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument> {      class InstrumentResourceManager : public InstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument>, public InstrumentEditorListener {
66          public:          public:
67              InstrumentResourceManager() : Gigs(this) {}              InstrumentResourceManager() : Gigs(this) {}
68              virtual ~InstrumentResourceManager() {}              virtual ~InstrumentResourceManager() {}
# Line 72  namespace LinuxSampler { namespace gig { Line 73  namespace LinuxSampler { namespace gig {
73              virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID);              virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID);
74              virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode);              virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode);
75              virtual String GetInstrumentName(instrument_id_t ID);              virtual String GetInstrumentName(instrument_id_t ID);
76                virtual String GetInstrumentDataStructureName(instrument_id_t ID);
77                virtual String GetInstrumentDataStructureVersion(instrument_id_t ID);
78                virtual void LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException);
79                virtual std::vector<instrument_id_t> GetInstrumentFileContent(String File) throw (InstrumentManagerException);
80                virtual instrument_info_t GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException);
81    
82                // implementation of derived abstract methods from 'InstrumentEditorListener'
83                virtual void OnInstrumentEditorQuit(InstrumentEditor* pSender);
84                virtual void OnSamplesToBeRemoved(std::set<void*> Samples, InstrumentEditor* pSender);
85                virtual void OnSamplesRemoved(InstrumentEditor* pSender);
86                virtual void OnDataStructureToBeChanged(void* pStruct, String sStructType, InstrumentEditor* pSender);
87                virtual void OnDataStructureChanged(void* pStruct, String sStructType, InstrumentEditor* pSender);
88                virtual void OnSampleReferenceChanged(void* pOldSample, void* pNewSample, InstrumentEditor* pSender);
89    
90              void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer,              void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer,
91                                      ::gig::DimensionRegion** dimRegionsInUse);                                      ::gig::DimensionRegion** dimRegionsInUse);
92              void HandBackDimReg(::gig::DimensionRegion* pDimReg);              void HandBackDimReg(::gig::DimensionRegion* pDimReg);
93    
94          protected:          protected:
95                // implementation of derived abstract methods from 'ResourceManager'
96              virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg);              virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg);
97              virtual void               Destroy(::gig::Instrument* pResource, void* pArg);              virtual void               Destroy(::gig::Instrument* pResource, void* pArg);
98              virtual void               OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg);              virtual void               OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg);
# Line 86  namespace LinuxSampler { namespace gig { Line 101  namespace LinuxSampler { namespace gig {
101    
102              class GigResourceManager : public ResourceManager<String, ::gig::File> {              class GigResourceManager : public ResourceManager<String, ::gig::File> {
103                  protected:                  protected:
104                        // implementation of derived abstract methods from 'ResourceManager'
105                      virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg);                      virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg);
106                      virtual void         Destroy(::gig::File* pResource, void* pArg);                      virtual void         Destroy(::gig::File* pResource, void* pArg);
107                      virtual void         OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore                      virtual void         OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore
# Line 97  namespace LinuxSampler { namespace gig { Line 113  namespace LinuxSampler { namespace gig {
113              } Gigs;              } Gigs;
114    
115              void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel);              void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel);
116                void CacheInitialSamples(::gig::Sample* pSample, gig::Engine* pEngine);
117                void UncacheInitialSamples(::gig::Sample* pSample);
118                std::vector< ::gig::Instrument*> GetInstrumentsCurrentlyUsedOf(::gig::File* pFile, bool bLock);
119                std::set<gig::Engine*> GetEnginesUsing(::gig::Instrument* pFile, bool bLock);
120                std::set<gig::Engine*> GetEnginesUsing(::gig::File* pFile, bool bLock);
121                bool SampleReferencedByInstrument(::gig::Sample* pSample, ::gig::Instrument* pInstrument);
122                void SuspendEnginesUsing(::gig::Instrument* pInstrument);
123                void SuspendEnginesUsing(::gig::File* pFile);
124                void ResumeAllEngines();
125    
126              struct dimreg_info_t {              struct dimreg_info_t {
127                  int           refCount;                  int           refCount;
# Line 106  namespace LinuxSampler { namespace gig { Line 131  namespace LinuxSampler { namespace gig {
131              Mutex DimRegInfoMutex; ///< protects the DimRegInfo and SampleRefCount maps from concurrent access by the instrument loader and disk threads              Mutex DimRegInfoMutex; ///< protects the DimRegInfo and SampleRefCount maps from concurrent access by the instrument loader and disk threads
132              std::map< ::gig::DimensionRegion*, dimreg_info_t> DimRegInfo; ///< contains dimension regions that are still in use but belong to released instrument              std::map< ::gig::DimensionRegion*, dimreg_info_t> DimRegInfo; ///< contains dimension regions that are still in use but belong to released instrument
133              std::map< ::gig::Sample*, int> SampleRefCount; ///< contains samples that are still in use but belong to a released instrument              std::map< ::gig::Sample*, int> SampleRefCount; ///< contains samples that are still in use but belong to a released instrument
     };  
134    
135      /**              Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map
136       * Will be thrown by the InstrumentResourceManager on errors.              std::map<InstrumentEditor*, InstrumentConsumer*> InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor
137       */              std::set<Engine*> suspendedEngines; ///< all engines currently completely suspended
138      class InstrumentResourceManagerException : public Exception {              Mutex             suspendedEnginesMutex; ///< protects 'suspendedEngines' set
         public:  
             InstrumentResourceManagerException(String msg) : Exception(msg) {}  
139      };      };
140    
141  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.1038  
changed lines
  Added in v.1525

  ViewVC Help
Powered by ViewVC