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

Contents of /linuxsampler/trunk/src/engines/InstrumentManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2427 - (show annotations) (download)
Sat Mar 2 07:03:04 2013 UTC (11 years, 1 month ago) by persson
File size: 2576 byte(s)
* code refactoring: added a lock guard class for exception safe mutex
  handling and used it everywhere appropriate

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2013 Christian Schoenebeck *
7 * *
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #include "InstrumentManager.h"
25
26 #include "InstrumentManagerThread.h"
27 #include "../common/Mutex.h"
28
29 namespace LinuxSampler {
30
31 // the thread which actually loads the instruments one by one
32 InstrumentManagerThread thread;
33
34 // used to prevent multiple threads writing to the instrumentLoader at the same time
35 Mutex loaderMutex;
36
37 void InstrumentManager::LoadInstrumentInBackground(InstrumentManager::instrument_id_t ID, EngineChannel* pEngineChannel) {
38 LockGuard lock(loaderMutex);
39 thread.StartNewLoad(ID.FileName, ID.Index, pEngineChannel);
40 }
41
42 void InstrumentManager::SetModeInBackground(const instrument_id_t& ID, mode_t Mode) {
43 LockGuard lock(loaderMutex);
44 thread.StartSettingMode(this, ID, Mode);
45 }
46
47 void InstrumentManager::StopBackgroundThread() {
48 thread.StopThread();
49 }
50
51 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC