Jack2  1.9.9
JackWaitThreadedDriver.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 "JackWaitThreadedDriver.h"
23 #include "JackGlobals.h"
24 #include "JackClient.h"
25 #include "JackEngineControl.h"
26 #include "JackException.h"
27 #include "JackError.h"
28 #include "JackTools.h"
29 
30 namespace Jack
31 {
32 
34 {
35  return (fStarter.Start() == 0);
36 }
37 
38 bool JackWaitThreadedDriver::Execute()
39 {
40  try {
41 
42  SetRealTime();
43 
44  // Process a null cycle until NetDriver has started
45  while (!fStarter.fRunning && fThread.GetStatus() == JackThread::kRunning) {
46  // Use base class method
47  assert(static_cast<JackWaiterDriver*>(fDriver));
48  static_cast<JackWaiterDriver*>(fDriver)->ProcessNull();
49  }
50 
51  // Switch to keep running even in case of error
52  while (fThread.GetStatus() == JackThread::kRunning) {
53  fDriver->Process();
54  }
55 
56  return false;
57 
58  } catch (JackNetException& e) {
59 
60  e.PrintMessage();
61  jack_info("Driver is restarted");
62  fThread.DropSelfRealTime();
63 
64  // Thread has been stopped...
65  if (fThread.GetStatus() == JackThread::kIdle) {
66  return false;
67  }
68 
69  // Thread in kIniting status again...
70  fThread.SetStatus(JackThread::kIniting);
71  if (Init()) {
72  // Thread in kRunning status again...
73  fThread.SetStatus(JackThread::kRunning);
74  return true;
75  }
76 
77  return false;
78  }
79 }
80 
81 } // end of namespace
SERVER_EXPORT void jack_info(const char *fmt,...)
Definition: JackError.cpp:99