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

Diff of /linuxsampler/trunk/src/drivers/Plugin.cpp

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

revision 1834 by persson, Mon Sep 15 16:58:10 2008 UTC revision 1835 by iliev, Mon Feb 16 17:56:50 2009 UTC
# Line 63  namespace LinuxSampler { Line 63  namespace LinuxSampler {
63      PluginGlobal::~PluginGlobal() {      PluginGlobal::~PluginGlobal() {
64          pEventThread->StopThread();          pEventThread->StopThread();
65          pLSCPServer->StopThread();          pLSCPServer->StopThread();
66            pLSCPServer->RemoveListeners();
67    
68          delete pEventThread;          delete pEventThread;
69          delete pSampler;          delete pSampler;
# Line 92  namespace LinuxSampler { Line 93  namespace LinuxSampler {
93    
94      PluginGlobal* Plugin::global = 0;      PluginGlobal* Plugin::global = 0;
95    
96      Plugin::Plugin() :      Plugin::Plugin(bool bDoPreInit) :
97          pAudioDevice(0),          pAudioDevice(0),
98          pMidiDevice(0) {          pMidiDevice(0) {
99            bPreInitDone = false;
100            if (bDoPreInit) PreInit();
101        }
102    
103        void Plugin::PreInit() {
104            if (bPreInitDone) return;
105    
106            bPreInitDone = true;
107          if (!global) {          if (!global) {
108              global = new PluginGlobal;              global = new PluginGlobal;
109          }          }
110          global->RefCount++;          global->RefCount++;
111      }      }
112    
113      void Plugin::Init(int SampleRate, int FragmentSize) {      void Plugin::Init(int SampleRate, int FragmentSize, int Channels) {
114          std::map<String, String> params;          std::map<String, String> params;
115          params["SAMPLERATE"] = ToString(SampleRate);          params["SAMPLERATE"] = ToString(SampleRate);
116          params["FRAGMENTSIZE"] = ToString(FragmentSize);          params["FRAGMENTSIZE"] = ToString(FragmentSize);
117            if (Channels > 0) params["CHANNELS"] = ToString(Channels);
118          pAudioDevice = dynamic_cast<AudioOutputDevicePlugin*>(          pAudioDevice = dynamic_cast<AudioOutputDevicePlugin*>(
119              global->pSampler->CreateAudioOutputDevice(AudioOutputDevicePlugin::Name(), params));              global->pSampler->CreateAudioOutputDevice(AudioOutputDevicePlugin::Name(), params));
120    
# Line 117  namespace LinuxSampler { Line 127  namespace LinuxSampler {
127          RemoveChannels();          RemoveChannels();
128          if (pAudioDevice) global->pSampler->DestroyAudioOutputDevice(pAudioDevice);          if (pAudioDevice) global->pSampler->DestroyAudioOutputDevice(pAudioDevice);
129          if (pMidiDevice) global->pSampler->DestroyMidiInputDevice(pMidiDevice);          if (pMidiDevice) global->pSampler->DestroyMidiInputDevice(pMidiDevice);
130          if (--global->RefCount == 0) {          if (bPreInitDone) {
131              delete global;              if (--global->RefCount == 0) {
132              global = 0;                  delete global;
133                    global = 0;
134                }
135          }          }
136      }      }
137    
# Line 155  namespace LinuxSampler { Line 167  namespace LinuxSampler {
167      }      }
168    
169      void Plugin::RemoveChannels() {      void Plugin::RemoveChannels() {
170            if(global == NULL) return;
171    
172          std::map<uint, SamplerChannel*> channels = global->pSampler->GetSamplerChannels();          std::map<uint, SamplerChannel*> channels = global->pSampler->GetSamplerChannels();
173    
174          for (std::map<uint, SamplerChannel*>::iterator iter = channels.begin() ;          for (std::map<uint, SamplerChannel*>::iterator iter = channels.begin() ;
175               iter != channels.end() ; iter++) {               iter != channels.end() ; iter++) {
176              if (iter->second->GetAudioOutputDevice() == pAudioDevice) {              if (iter->second->GetAudioOutputDevice() == pAudioDevice) {

Legend:
Removed from v.1834  
changed lines
  Added in v.1835

  ViewVC Help
Powered by ViewVC