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

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

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

revision 1826 by iliev, Sat Jan 24 14:32:35 2009 UTC revision 2277 by persson, Sat Oct 1 08:23:02 2011 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2005 - 2007 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2011 Christian Schoenebeck                       *
4   *                                                                         *   *                                                                         *
5   *   This library is free software; you can redistribute it and/or modify  *   *   This library 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 53  namespace LinuxSampler { Line 53  namespace LinuxSampler {
53          }          }
54                    
55                    
         // already tell the engine which instrument to load  
         pEngineChannel->PrepareLoadInstrument(Filename.c_str(), uiInstrumentIndex);  
   
56          command_t cmd;          command_t cmd;
57          cmd.type           = command_t::DIRECT_LOAD;          cmd.type           = command_t::DIRECT_LOAD;
58          cmd.pEngineChannel = pEngineChannel;          cmd.pEngineChannel = pEngineChannel;
59            cmd.instrumentId.Index = uiInstrumentIndex;
60            cmd.instrumentId.FileName = Filename;
61    
62          mutex.Lock();          mutex.Lock();
63          queue.push_back(cmd);          queue.push_back(cmd);
# Line 99  namespace LinuxSampler { Line 98  namespace LinuxSampler {
98      int InstrumentManagerThread::Main() {      int InstrumentManagerThread::Main() {
99          while (true) {          while (true) {
100    
101                          #if CONFIG_PTHREAD_TESTCANCEL              #if CONFIG_PTHREAD_TESTCANCEL
102                          TestCancel();              TestCancel();
103                          #endif              #endif
104    
105              while (!queue.empty()) {              while (!queue.empty()) {
106                  command_t cmd;                  command_t cmd;
# Line 116  namespace LinuxSampler { Line 115  namespace LinuxSampler {
115                      switch (cmd.type) {                      switch (cmd.type) {
116                          case command_t::DIRECT_LOAD:                          case command_t::DIRECT_LOAD:
117                              EngineChannelFactory::SetDeleteEnabled(cmd.pEngineChannel, false);                              EngineChannelFactory::SetDeleteEnabled(cmd.pEngineChannel, false);
118                                cmd.pEngineChannel->PrepareLoadInstrument(cmd.instrumentId.FileName.c_str(), cmd.instrumentId.Index);
119                              cmd.pEngineChannel->LoadInstrument();                              cmd.pEngineChannel->LoadInstrument();
120                              EngineChannelFactory::SetDeleteEnabled(cmd.pEngineChannel, true);                              EngineChannelFactory::SetDeleteEnabled(cmd.pEngineChannel, true);
121                              break;                              break;
# Line 145  namespace LinuxSampler { Line 145  namespace LinuxSampler {
145              // unlock condition object so it can be turned again by other thread              // unlock condition object so it can be turned again by other thread
146              conditionJobsLeft.Unlock();              conditionJobsLeft.Unlock();
147          }          }
148            return 0;
149      }      }
150        
151      void InstrumentManagerThread::EventHandler::ChannelToBeRemoved(SamplerChannel* pChannel) {      void InstrumentManagerThread::EventHandler::ChannelToBeRemoved(SamplerChannel* pChannel) {
152          /*          /*
153             Removing from the queue an eventual scheduled loading of an instrument             Removing from the queue an eventual scheduled loading of an instrument
# Line 166  namespace LinuxSampler { Line 167  namespace LinuxSampler {
167          }          }
168          pThread->mutex.Unlock();          pThread->mutex.Unlock();
169      }      }
170    
171    #ifdef __APPLE__
172        int InstrumentManagerThread::StopThread() {
173            // This is a fix for Mac OS X, where SignalStopThread doesn't
174            // wake up a thread waiting for a condition variable.
175            SignalStopThread(); // send stop signal, but don't wait
176            conditionJobsLeft.Set(true); // wake thread
177            return Thread::StopThread(); // then wait for it to cancel
178        }
179    #endif
180    
181  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.1826  
changed lines
  Added in v.2277

  ViewVC Help
Powered by ViewVC