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

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

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

revision 947 by schoenebeck, Mon Nov 27 21:34:55 2006 UTC revision 2277 by persson, Sat Oct 1 08:23:02 2011 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2005, 2006 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 24  Line 24 
24  #include "../common/global.h"  #include "../common/global.h"
25  #include "../common/Thread.h"  #include "../common/Thread.h"
26  #include "../common/Condition.h"  #include "../common/Condition.h"
27  #include "../common/RingBuffer.h"  #include "../common/Mutex.h"
28  #include "../Sampler.h"  #include "../Sampler.h"
29    #include "../EventListeners.h"
30  #include "InstrumentManager.h"  #include "InstrumentManager.h"
31    
32  /// Maximum numbers of instruments waiting to be loaded by the InstrumentLoader.  #include <list>
 #define INSTRUMENT_LOADER_QUEUE_SIZE    200  
33    
34  namespace LinuxSampler {  namespace LinuxSampler {
35    
# Line 41  namespace LinuxSampler { Line 41  namespace LinuxSampler {
41       * to the API.       * to the API.
42       */       */
43      class InstrumentManagerThread : public Thread {      class InstrumentManagerThread : public Thread {
44            friend class EventHandler;
45            
46          public:          public:
47              InstrumentManagerThread();              InstrumentManagerThread();
48              void StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel);              void StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel);
49              void StartSettingMode(InstrumentManager* pManager, const InstrumentManager::instrument_id_t& ID, InstrumentManager::mode_t Mode);              void StartSettingMode(InstrumentManager* pManager, const InstrumentManager::instrument_id_t& ID, InstrumentManager::mode_t Mode);
50              virtual ~InstrumentManagerThread();              virtual ~InstrumentManagerThread();
51    #ifdef __APPLE__
52                int StopThread();
53    #endif
54          protected:          protected:
55              struct command_t {              struct command_t {
56                  enum cmd_type_t {                  enum cmd_type_t {
# Line 54  namespace LinuxSampler { Line 59  namespace LinuxSampler {
59                  } type;                  } type;
60                  EngineChannel*                     pEngineChannel; ///< only for DIRECT_LOAD commands                  EngineChannel*                     pEngineChannel; ///< only for DIRECT_LOAD commands
61                  InstrumentManager*                 pManager;     ///< only for INSTR_MODE commands                  InstrumentManager*                 pManager;     ///< only for INSTR_MODE commands
62                  InstrumentManager::instrument_id_t instrumentId; ///< only for INSTR_MODE commands                  InstrumentManager::instrument_id_t instrumentId; ///< for both DIRECT_LOAD and INSTR_MODE
63                  InstrumentManager::mode_t          mode;         ///< only for INSTR_MODE commands                  InstrumentManager::mode_t          mode;         ///< only for INSTR_MODE commands
64              };              };
65    
66              // Instance variables.              // Instance variables.
67              RingBuffer<command_t>* pQueue; ///< queue with commands for loading new instruments.              std::list<command_t> queue; ///< queue with commands for loading new instruments.
68              Condition              conditionJobsLeft; ///< synchronizer to block this thread until a new job arrives              Mutex                mutex; ///< for making the queue thread safe
69                Condition            conditionJobsLeft; ///< synchronizer to block this thread until a new job arrives
70    
71              int Main(); ///< Implementation of virtual method from class Thread.              int Main(); ///< Implementation of virtual method from class Thread.
72            private:
73                class EventHandler : public ChannelCountAdapter {
74                    public:
75                        InstrumentManagerThread* pThread;
76                        virtual void ChannelToBeRemoved(SamplerChannel* pChannel);
77                };
78                
79                EventHandler eventHandler;
80      };      };
81    
82  } // namespace LinuxSampler  } // namespace LinuxSampler

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

  ViewVC Help
Powered by ViewVC