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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1763 by schoenebeck, Sun Oct 14 22:00:17 2007 UTC revision 1764 by persson, Sat Sep 6 14:55:18 2008 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2007 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 21  Line 21 
21   *   MA  02111-1307  USA                                                   *   *   MA  02111-1307  USA                                                   *
22   ***************************************************************************/   ***************************************************************************/
23    
 #include "ConditionServer.h"  
   
24  #include "global_private.h"  #include "global_private.h"
25    
26    #include "ConditionServer.h"
27    
28  namespace LinuxSampler {  namespace LinuxSampler {
29    
30  ConditionServer::ConditionServer() {  ConditionServer::ConditionServer() : Reader(Condition) {
31      bConditionQuick = false;      Condition.GetConfigForUpdate() = false;
32      bChangeRequest  = false;      Condition.SwitchConfig() = false;
33      bOldCondition   = false;      bOldCondition = false;
34  }  }
35    
36  bool* ConditionServer::Push(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds) {  bool* ConditionServer::Push(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds) {
37      dmsg(3,("conditionserver:Push() requesting change to %d\n", bCondition));      dmsg(3,("conditionserver:Push() requesting change to %d\n", bCondition));
38      PushMutex.Lock();      PushMutex.Lock();
39      bOldCondition = bConditionQuick;      bool& c = Condition.GetConfigForUpdate();
40      if (bConditionQuick != bCondition) {      bOldCondition = c;
41          bChangeRequest = bCondition;      c = bCondition;
42          int timeoutexceeded = SyncCondition.WaitAndUnlockIf(bOldCondition, TimeoutSeconds, TimeoutNanoSeconds); // wait until actually condition was changed on Pop() side      Condition.SwitchConfig() = bCondition;
         if (timeoutexceeded) return NULL;  
     }  
43      return &bOldCondition;      return &bOldCondition;
44  }  }
45    
# Line 56  void ConditionServer::Unlock() { Line 54  void ConditionServer::Unlock() {
54  }  }
55    
56  bool ConditionServer::GetUnsafe() {  bool ConditionServer::GetUnsafe() {
57      return bConditionQuick;      return Condition.GetConfigForUpdate();
 }  
   
 bool ConditionServer::Pop() {  
     if (bConditionQuick == bChangeRequest) return bConditionQuick;  
     dmsg(3,("conditionserver:Pop() change requested\n"));  
     bConditionQuick = bChangeRequest;  
     SyncCondition.Set(bChangeRequest);  
     dmsg(3,("conditionserver:Pop() condition now: %d\n", bConditionQuick));  
     return bConditionQuick;  
58  }  }
59    
60  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.1763  
changed lines
  Added in v.1764

  ViewVC Help
Powered by ViewVC