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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 989 - (show annotations) (download) (as text)
Tue Dec 19 19:34:08 2006 UTC (17 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3651 byte(s)
* bugfix: sampler was limited to load max. 200 instruments in the
  background (replaced RingBuffer FIFO by a std::list FIFO)

1 /***************************************************************************
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/Mutex.h"
28 #include "../Sampler.h"
29 #include "InstrumentManager.h"
30
31 #include <list>
32
33 namespace LinuxSampler {
34
35 /** @brief Used by InstrumentManager for background tasks.
36 *
37 * This class is just an encapsulation of tasks that should be done by
38 * the InstrumentManager in the background, that is in a separate thread
39 * without blocking the calling thread. This class is thus not exported
40 * to the API.
41 */
42 class InstrumentManagerThread : public Thread {
43 public:
44 InstrumentManagerThread();
45 void StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel);
46 void StartSettingMode(InstrumentManager* pManager, const InstrumentManager::instrument_id_t& ID, InstrumentManager::mode_t Mode);
47 virtual ~InstrumentManagerThread();
48 protected:
49 struct command_t {
50 enum cmd_type_t {
51 DIRECT_LOAD, ///< command was created by a StartNewLoad() call
52 INSTR_MODE ///< command was created by a StartSettingMode() call
53 } type;
54 EngineChannel* pEngineChannel; ///< only for DIRECT_LOAD commands
55 InstrumentManager* pManager; ///< only for INSTR_MODE commands
56 InstrumentManager::instrument_id_t instrumentId; ///< only for INSTR_MODE commands
57 InstrumentManager::mode_t mode; ///< only for INSTR_MODE commands
58 };
59
60 // Instance variables.
61 std::list<command_t> queue; ///< queue with commands for loading new instruments.
62 Mutex mutex; ///< for making the queue thread safe
63 Condition conditionJobsLeft; ///< synchronizer to block this thread until a new job arrives
64
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