/[svn]/linuxsampler/trunk/src/engines/sfz/InstrumentResourceManager.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/sfz/InstrumentResourceManager.cpp

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

revision 2274 by persson, Sun Jun 19 09:09:38 2011 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 - 2011 Grigor Iliev                                *   *   Copyright (C) 2009 - 2011 Grigor Iliev                                *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
# Line 144  namespace LinuxSampler { namespace sfz { Line 144  namespace LinuxSampler { namespace sfz {
144          pEntry->ID.Index      = Key.Index;          pEntry->ID.Index      = Key.Index;
145          pEntry->pSfz          = pSfz;          pEntry->pSfz          = pSfz;
146    
147            // (try to resolve the audio device context)
148          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);
149            AudioOutputDevice* pDevice =
150                (pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL;
151            
152          // and we save this to check if we need to reallocate for a engine with higher value of 'MaxSamplesPerSecond'          // and we save this to check if we need to reallocate for a engine with higher value of 'MaxSamplesPerSecond'
153          pEntry->MaxSamplesPerCycle =          pEntry->MaxSamplesPerCycle =
154              (!pEngineChannel) ? 0 /* don't care for instrument editors */ :              (pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle();
155                  (pEngineChannel->GetEngine()) ?          
                     dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle()  
                     : GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE;  
156          pArg = pEntry;          pArg = pEntry;
157    
158          return pInstrument;          return pInstrument;
# Line 165  namespace LinuxSampler { namespace sfz { Line 167  namespace LinuxSampler { namespace sfz {
167    
168      void InstrumentResourceManager::OnBorrow(::sfz::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg) {      void InstrumentResourceManager::OnBorrow(::sfz::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg) {
169          instr_entry_t* pEntry = (instr_entry_t*) pArg;          instr_entry_t* pEntry = (instr_entry_t*) pArg;
170            
171            // (try to resolve the audio device context)
172          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);
173            AudioOutputDevice* pDevice =
174                (pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL;
175            
176          uint maxSamplesPerCycle =          uint maxSamplesPerCycle =
177              (pEngineChannel && pEngineChannel->GetEngine()) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle()              (pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle();
178                                            : GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE;          
179          if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) {          if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) {
180                dmsg(1,("Completely reloading instrument due to insufficient precached samples ...\n"));
181              Update(pResource, pConsumer);              Update(pResource, pConsumer);
182          }          }
183      }      }

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

  ViewVC Help
Powered by ViewVC