/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDevice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/audio/AudioOutputDevice.cpp

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

revision 272 by schoenebeck, Fri Oct 8 21:03:32 2004 UTC revision 840 by persson, Sun Feb 26 13:00:08 2006 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 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 182  namespace LinuxSampler { Line 183  namespace LinuxSampler {
183          {          {
184              std::vector<AudioChannel*>::iterator iter = Channels.begin();              std::vector<AudioChannel*>::iterator iter = Channels.begin();
185              while (iter != Channels.end()) {              while (iter != Channels.end()) {
                 Channels.erase(iter);  
186                  delete *iter;                  delete *iter;
187                  iter++;                  iter++;
188              }              }
189                Channels.clear();
190          }          }
191    
192          // delete all device parameters          // delete all device parameters
193          {          {
194              std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin();              std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin();
195              while (iter != Parameters.end()) {              while (iter != Parameters.end()) {
                 Parameters.erase(iter);  
196                  delete iter->second;                  delete iter->second;
197                  iter++;                  iter++;
198              }              }
199                Parameters.clear();
200          }          }
201      }      }
202    
203      void AudioOutputDevice::Connect(Engine* pEngine) {      void AudioOutputDevice::Connect(Engine* pEngine) {
204          if (Engines.find(pEngine) == Engines.end()) {          std::set<Engine*>& engines = Engines.GetConfigForUpdate();
205              pEngine->Connect(this);          if (engines.find(pEngine) == engines.end()) {
206              Engines.insert(pEngine);              engines.insert(pEngine);
207                Engines.SwitchConfig().insert(pEngine);
208                // make sure the engine knows about the connection
209                //pEngine->Connect(this);
210          }          }
211      }      }
212    
213      void AudioOutputDevice::Disconnect(Engine* pEngine) {      void AudioOutputDevice::Disconnect(Engine* pEngine) {
214          if (Engines.find(pEngine) != Engines.end()) { // if clause to prevent disconnect loop          std::set<Engine*>& engines = Engines.GetConfigForUpdate();
215              Engines.erase(pEngine);          if (engines.find(pEngine) != engines.end()) { // if clause to prevent disconnect loop
216              pEngine->DisconnectAudioOutputDevice();              engines.erase(pEngine);
217                Engines.SwitchConfig().erase(pEngine);
218                // make sure the engine knows about the disconnection
219                //pEngine->DisconnectAudioOutputDevice();
220          }          }
221      }      }
222    
# Line 244  namespace LinuxSampler { Line 250  namespace LinuxSampler {
250          int result = 0;          int result = 0;
251    
252          // let all connected engines render audio for the current audio fragment cycle          // let all connected engines render audio for the current audio fragment cycle
253          #if USE_EXCEPTIONS          const std::set<Engine*>& engines = Engines.Lock();
254            #if CONFIG_RT_EXCEPTIONS
255          try          try
256          #endif // USE_EXCEPTIONS          #endif // CONFIG_RT_EXCEPTIONS
257          {          {
258              std::set<Engine*>::iterator iterEngine = Engines.begin();              std::set<Engine*>::iterator iterEngine = engines.begin();
259              std::set<Engine*>::iterator end        = Engines.end();              std::set<Engine*>::iterator end        = engines.end();
260              for (; iterEngine != end; iterEngine++) {              for (; iterEngine != end; iterEngine++) {
261                  int res = (*iterEngine)->RenderAudio(Samples);                  int res = (*iterEngine)->RenderAudio(Samples);
262                  if (res != 0) result = res;                  if (res != 0) result = res;
263              }              }
264          }          }
265          #if USE_EXCEPTIONS          #if CONFIG_RT_EXCEPTIONS
266          catch (std::runtime_error se) {          catch (std::runtime_error se) {
267              std::cerr << "std::runtime_error: " << se.what() << std::endl << std::flush;              std::cerr << "std::runtime_error: " << se.what() << std::endl << std::flush;
268              exit(EXIT_FAILURE);              exit(EXIT_FAILURE);
269          }          }
270          #endif // USE_EXCEPTIONS          #endif // CONFIG_RT_EXCEPTIONS
271    
272            Engines.Unlock();
273          return result;          return result;
274      }      }
275    

Legend:
Removed from v.272  
changed lines
  Added in v.840

  ViewVC Help
Powered by ViewVC