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

Diff of /linuxsampler/trunk/src/engines/sf2/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 181  namespace LinuxSampler { namespace sf2 { Line 181  namespace LinuxSampler { namespace sf2 {
181          pEntry->ID.Index      = Key.Index;          pEntry->ID.Index      = Key.Index;
182          pEntry->pSf2          = pSf2;          pEntry->pSf2          = pSf2;
183    
184            // (try to resolve the audio device context)
185          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);
186            AudioOutputDevice* pDevice =
187                (pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL;
188            
189          // 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'
190          pEntry->MaxSamplesPerCycle =          pEntry->MaxSamplesPerCycle =
191              (!pEngineChannel) ? 0 /* don't care for instrument editors */ :              (pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle();
192                  (pEngineChannel->GetEngine()) ?  
                     dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle()  
                     : GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE;  
193          pArg = pEntry;          pArg = pEntry;
194    
195          return pInstrument;          return pInstrument;
# Line 202  namespace LinuxSampler { namespace sf2 { Line 204  namespace LinuxSampler { namespace sf2 {
204    
205      void InstrumentResourceManager::OnBorrow(::sf2::Preset* pResource, InstrumentConsumer* pConsumer, void*& pArg) {      void InstrumentResourceManager::OnBorrow(::sf2::Preset* pResource, InstrumentConsumer* pConsumer, void*& pArg) {
206          instr_entry_t* pEntry = (instr_entry_t*) pArg;          instr_entry_t* pEntry = (instr_entry_t*) pArg;
207            
208            // (try to resolve the audio device context)
209          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);          EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer);
210            AudioOutputDevice* pDevice =
211                (pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL;
212    
213          uint maxSamplesPerCycle =          uint maxSamplesPerCycle =
214              (pEngineChannel && pEngineChannel->GetEngine()) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle()              (pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle();
215                                            : GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE;  
216          if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) {          if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) {
217                dmsg(1,("Completely reloading instrument due to insufficient precached samples ...\n"));
218              Update(pResource, pConsumer);              Update(pResource, pConsumer);
219          }          }
220      }      }

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

  ViewVC Help
Powered by ViewVC