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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 970 - (hide annotations) (download) (as text)
Wed Dec 6 22:28:17 2006 UTC (17 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3701 byte(s)
* fixed crash occuring in conjunction with the new 'MAP MIDI_INSTRUMENT'
  LSCP command (cause: RingBuffer was not able to do deep copies)

1 schoenebeck 947 /***************************************************************************
2     * *
3     * Copyright (C) 2005, 2006 Christian Schoenebeck *
4     * *
5     * 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 *
7     * the Free Software Foundation; either version 2 of the License, or *
8     * (at your option) any later version. *
9     * *
10     * This library is distributed in the hope that it will be useful, *
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13     * GNU General Public License for more details. *
14     * *
15     * You should have received a copy of the GNU General Public License *
16     * along with this library; if not, write to the Free Software *
17     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18     * MA 02111-1307 USA *
19     ***************************************************************************/
20    
21     #ifndef __LS_INSTRUMENTLOADER_H__
22     #define __LS_INSTRUMENTLOADER_H__
23    
24     #include "../common/global.h"
25     #include "../common/Thread.h"
26     #include "../common/Condition.h"
27     #include "../common/RingBuffer.h"
28     #include "../Sampler.h"
29     #include "InstrumentManager.h"
30    
31     /// Maximum numbers of instruments waiting to be loaded by the InstrumentLoader.
32     #define INSTRUMENT_LOADER_QUEUE_SIZE 200
33    
34     namespace LinuxSampler {
35    
36     /** @brief Used by InstrumentManager for background tasks.
37     *
38     * This class is just an encapsulation of tasks that should be done by
39     * the InstrumentManager in the background, that is in a separate thread
40     * without blocking the calling thread. This class is thus not exported
41     * to the API.
42     */
43     class InstrumentManagerThread : public Thread {
44     public:
45     InstrumentManagerThread();
46     void StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel);
47     void StartSettingMode(InstrumentManager* pManager, const InstrumentManager::instrument_id_t& ID, InstrumentManager::mode_t Mode);
48     virtual ~InstrumentManagerThread();
49     protected:
50     struct command_t {
51     enum cmd_type_t {
52     DIRECT_LOAD, ///< command was created by a StartNewLoad() call
53     INSTR_MODE ///< command was created by a StartSettingMode() call
54     } type;
55     EngineChannel* pEngineChannel; ///< only for DIRECT_LOAD commands
56     InstrumentManager* pManager; ///< only for INSTR_MODE commands
57     InstrumentManager::instrument_id_t instrumentId; ///< only for INSTR_MODE commands
58     InstrumentManager::mode_t mode; ///< only for INSTR_MODE commands
59     };
60    
61     // Instance variables.
62 schoenebeck 970 RingBuffer<command_t,true>* pQueue; ///< queue with commands for loading new instruments.
63     Condition conditionJobsLeft; ///< synchronizer to block this thread until a new job arrives
64 schoenebeck 947
65     int Main(); ///< Implementation of virtual method from class Thread.
66     };
67    
68     } // namespace LinuxSampler
69    
70     #endif // __LS_INSTRUMENTLOADER_H__

  ViewVC Help
Powered by ViewVC