Jack2  1.9.9
JackFreewheelDriver.cpp
1 /*
2  Copyright (C) 2001 Paul Davis
3  Copyright (C) 2004-2008 Grame
4 
5  This program 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 program 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 program; if not, write to the Free Software
17  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19 */
20 
21 #include "JackSystemDeps.h"
22 #include "JackFreewheelDriver.h"
23 #include "JackEngineControl.h"
24 #include "JackLockedEngine.h"
25 
26 namespace Jack
27 {
28 
29 // When used in "master" mode
30 
31 int JackFreewheelDriver::Process()
32 {
33  int res = 0;
34 
35  jack_log("JackFreewheelDriver::Process master %lld", fEngineControl->fTimeOutUsecs);
36  JackDriver::CycleTakeBeginTime();
37 
38  if (fEngine->Process(fBeginDateUst, fEndDateUst)) {
39 
40  // Resume connected clients in the graph
41  if (ResumeRefNum()) {
42  jack_error("JackFreewheelDriver::Process: ResumeRefNum error");
43  res = -1;
44  }
45 
46  // Special "SuspendRefNum" with longer timeout
47  if (SuspendRefNum() < 0) { // Wait for all clients to finish for 10 sec
48  jack_error("JackFreewheelDriver::ProcessSync: SuspendRefNum error");
49  /* We have a client time-out error, but still continue to process, until a better recovery strategy is chosen */
50  return 0;
51  }
52 
53  } else { // Graph not finished: do not activate it
54  jack_error("JackFreewheelDriver::Process: Process error");
55  res = -1;
56  }
57 
58  return res;
59 }
60 
61 // When used in "slave" mode
62 
63 int JackFreewheelDriver::ProcessReadSync()
64 {
65  // Resume connected clients in the graph
66  if (ResumeRefNum() < 0) { // Signal all clients
67  jack_error("JackFreewheelDriver::ProcessReadSync: ResumeRefNum error");
68  return -1;
69  }
70  return 0;
71 }
72 
73 int JackFreewheelDriver::ProcessWriteSync()
74 {
75  // Generic "SuspendRefNum" here
76  if (JackDriver::SuspendRefNum() < 0) {
77  jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error");
78  return -1;
79  }
80  return 0;
81 }
82 
83 int JackFreewheelDriver::ProcessReadAsync()
84 {
85  // Resume connected clients in the graph
86  if (ResumeRefNum() < 0) { // Signal all clients
87  jack_error("JackFreewheelDriver::ProcessReadAsync: ResumeRefNum error");
88  return -1;
89  }
90  return 0;
91 }
92 
93 int JackFreewheelDriver::ProcessWriteAsync()
94 {
95  return 0;
96 }
97 
98 int JackFreewheelDriver::SuspendRefNum()
99 {
100  return fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, FREEWHEEL_DRIVER_TIMEOUT * 1000000);
101 }
102 
103 } // end of namespace
SERVER_EXPORT void jack_error(const char *fmt,...)
Definition: JackError.cpp:91
SERVER_EXPORT void jack_log(const char *fmt,...)
Definition: JackError.cpp:107