/[svn]/linuxsampler/trunk/src/common/ConditionServer.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/common/ConditionServer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1764 - (show annotations) (download)
Sat Sep 6 14:55:18 2008 UTC (15 years, 7 months ago) by persson
File size: 2688 byte(s)
* rewrote the ConditionServer class to make it possible to create
  multiple sample channels when the audio thread isn't running

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2008 Christian Schoenebeck *
7 * *
8 * This program 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 program 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 program; 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 "global_private.h"
25
26 #include "ConditionServer.h"
27
28 namespace LinuxSampler {
29
30 ConditionServer::ConditionServer() : Reader(Condition) {
31 Condition.GetConfigForUpdate() = false;
32 Condition.SwitchConfig() = false;
33 bOldCondition = false;
34 }
35
36 bool* ConditionServer::Push(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds) {
37 dmsg(3,("conditionserver:Push() requesting change to %d\n", bCondition));
38 PushMutex.Lock();
39 bool& c = Condition.GetConfigForUpdate();
40 bOldCondition = c;
41 c = bCondition;
42 Condition.SwitchConfig() = bCondition;
43 return &bOldCondition;
44 }
45
46 bool* ConditionServer::PushAndUnlock(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds) {
47 bool* pBefore = Push(bCondition, TimeoutSeconds, TimeoutNanoSeconds);
48 Unlock();
49 return pBefore;
50 }
51
52 void ConditionServer::Unlock() {
53 PushMutex.Unlock();
54 }
55
56 bool ConditionServer::GetUnsafe() {
57 return Condition.GetConfigForUpdate();
58 }
59
60 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC