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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1933 - (hide annotations) (download)
Thu Jul 9 17:37:41 2009 UTC (14 years, 10 months ago) by persson
File size: 2904 byte(s)
* fixed low-level ConditionServer usage bug that caused lockups on
  Windows

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

  ViewVC Help
Powered by ViewVC