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

Diff of /linuxsampler/trunk/src/engines/InstrumentManagerBase.h

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

revision 2274 by persson, Sun Feb 14 11:40:49 2010 UTC revision 2275 by schoenebeck, Mon Sep 19 21:48:45 2011 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 - 2009 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2011 Christian Schoenebeck                       *
7   *   Copyright (C) 2009 Grigor Iliev                                       *   *   Copyright (C) 2009 Grigor Iliev                                       *
8   *                                                                         *   *                                                                         *
9   *   This library is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
# Line 30  Line 30 
30  #include "AbstractEngineChannel.h"  #include "AbstractEngineChannel.h"
31  #include "../common/ResourceManager.h"  #include "../common/ResourceManager.h"
32  #include "../common/global_private.h"  #include "../common/global_private.h"
33    #include "../drivers/audio/AudioOutputDeviceFactory.h"
34    
35  // We need to know the maximum number of sample points which are going to  // We need to know the maximum number of sample points which are going to
36  // be processed for each render cycle of the audio output driver, to know  // be processed for each render cycle of the audio output driver, to know
# Line 127  namespace LinuxSampler { Line 128  namespace LinuxSampler {
128                  dmsg(2,("InstrumentManagerBase: setting mode for %s (Index=%d) to %d\n",ID.FileName.c_str(),ID.Index,Mode));                  dmsg(2,("InstrumentManagerBase: setting mode for %s (Index=%d) to %d\n",ID.FileName.c_str(),ID.Index,Mode));
129                  SetAvailabilityMode(ID, static_cast<typename ResourceManager<instrument_id_t, I>::mode_t>(Mode));                  SetAvailabilityMode(ID, static_cast<typename ResourceManager<instrument_id_t, I>::mode_t>(Mode));
130              }              }
131                
132                /**
133                 * Used by the implementing instrument manager descendents in case
134                 * they don't have a reference to a sampler channel, which in turn
135                 * provides a reference to an audio device which would actually
136                 * define the maximum amount of sample points per audio render
137                 * cycle. So in those missing cases (e.g. when MIDI instrument maps
138                 * are created), this method will iterate through all already
139                 * existing audio devices and return the biggest max. samples per
140                 * cycle value of those audio devices.
141                 *
142                 * In case no audio device is currently created, this method will
143                 * return a hard coded constant default value.
144                 *
145                 * Background: We need to know the maximum number of sample points
146                 * which are going to be processed for each render cycle of the
147                 * audio output driver, to know how many initial sample points we
148                 * need to cache into RAM by the implementing instrument manager.
149                 */
150                virtual uint DefaultMaxSamplesPerCycle() {
151                    uint samples = 0;
152                    std::map<uint, AudioOutputDevice*> devices = AudioOutputDeviceFactory::Devices();
153                    for (std::map<uint, AudioOutputDevice*>::iterator iter = devices.begin(); iter != devices.end(); ++iter) {
154                        AudioOutputDevice* pDevice = iter->second;
155                        if (pDevice->MaxSamplesPerCycle() > samples)
156                            samples = pDevice->MaxSamplesPerCycle();
157                    }
158                    return (samples != 0) ? samples : 128 /* some fallback default value*/;
159                }
160    
161          protected:          protected:
162              Mutex RegionInfoMutex; ///< protects the RegionInfo and SampleRefCount maps from concurrent access by the instrument loader and disk threads              Mutex RegionInfoMutex; ///< protects the RegionInfo and SampleRefCount maps from concurrent access by the instrument loader and disk threads

Legend:
Removed from v.2274  
changed lines
  Added in v.2275

  ViewVC Help
Powered by ViewVC