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

Diff of /linuxsampler/trunk/src/engines/EngineChannelFactory.cpp

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

revision 2426 by persson, Sun Mar 4 09:01:32 2012 UTC revision 2427 by persson, Sat Mar 2 07:03:04 2013 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2005 - 2012 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2013 Christian Schoenebeck                       *
4   *                                                                         *   *                                                                         *
5   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
6   *   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 92  namespace LinuxSampler { Line 92  namespace LinuxSampler {
92      Mutex EngineChannelFactory::EngineChannelsMutex;      Mutex EngineChannelFactory::EngineChannelsMutex;
93    
94      void EngineChannelFactory::SetDeleteEnabled(const EngineChannel* pEngineChannel, bool enable) {      void EngineChannelFactory::SetDeleteEnabled(const EngineChannel* pEngineChannel, bool enable) {
         LockedChannelsMutex.Lock();  
95          if (!enable) {          if (!enable) {
96                LockGuard lock(LockedChannelsMutex);
97              if (!lockedChannels.Contains(pEngineChannel)) lockedChannels.Add(pEngineChannel);              if (!lockedChannels.Contains(pEngineChannel)) lockedChannels.Add(pEngineChannel);
             LockedChannelsMutex.Unlock();  
98          } else {          } else {
99              bool b = lockedChannels.IsDestroyed(pEngineChannel);              bool b;
100              lockedChannels.Remove(pEngineChannel);              {
101              LockedChannelsMutex.Unlock();                  LockGuard lock(LockedChannelsMutex);
102                    b = lockedChannels.IsDestroyed(pEngineChannel);
103                    lockedChannels.Remove(pEngineChannel);
104                }
105              if (b) delete pEngineChannel;              if (b) delete pEngineChannel;
106          }          }
107      }      }
# Line 123  namespace LinuxSampler { Line 124  namespace LinuxSampler {
124          } else {          } else {
125              throw Exception("Unknown engine type");              throw Exception("Unknown engine type");
126          }          }
127          EngineChannelsMutex.Lock();          LockGuard lock(EngineChannelsMutex);
128          engineChannels.insert(pEngineChannel);          engineChannels.insert(pEngineChannel);
         EngineChannelsMutex.Unlock();  
129          return pEngineChannel;          return pEngineChannel;
130      }      }
131    
132      void EngineChannelFactory::Destroy(LinuxSampler::EngineChannel* pEngineChannel) {      void EngineChannelFactory::Destroy(LinuxSampler::EngineChannel* pEngineChannel) {
133          pEngineChannel->RemoveAllFxSendCountListeners();          pEngineChannel->RemoveAllFxSendCountListeners();
134          EngineChannelsMutex.Lock();          {
135          engineChannels.erase(pEngineChannel);              LockGuard lock(EngineChannelsMutex);
136          EngineChannelsMutex.Unlock();              engineChannels.erase(pEngineChannel);
137            }
138    
139          // Postpone the deletion of the specified EngineChannel if needed (bug #113)          // Postpone the deletion of the specified EngineChannel if needed (bug #113)
140          LockedChannelsMutex.Lock();          {
141          if (lockedChannels.Contains(pEngineChannel)) {              LockGuard lock(LockedChannelsMutex);
142              lockedChannels.SetDestroyed(pEngineChannel);              if (lockedChannels.Contains(pEngineChannel)) {
143              pEngineChannel->SetSamplerChannel(NULL);                  lockedChannels.SetDestroyed(pEngineChannel);
144              LockedChannelsMutex.Unlock();                  pEngineChannel->SetSamplerChannel(NULL);
145              return;                  return;
146                }
147          }          }
         LockedChannelsMutex.Unlock();  
148          ///////          ///////
149    
150          delete pEngineChannel;          delete pEngineChannel;

Legend:
Removed from v.2426  
changed lines
  Added in v.2427

  ViewVC Help
Powered by ViewVC