2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2006 Grame
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.
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.
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.
22 #pragma warning (disable : 4786)
25 #include "JackThreadedDriver.h"
26 #include "JackError.h"
27 #include "JackGlobals.h"
28 #include "JackClient.h"
29 #include "JackEngineControl.h"
34 JackThreadedDriver::JackThreadedDriver(JackDriverClient
* driver
)
36 fThread
= JackGlobals::MakeThread(this);
40 JackThreadedDriver::~JackThreadedDriver()
46 int JackThreadedDriver::Start()
48 JackLog("JackThreadedDriver::Start\n");
51 if ((res
= fDriver
->Start()) < 0) {
52 jack_error("Cannot start driver");
55 if ((res
= fThread
->Start()) < 0) {
56 jack_error("Cannot start thread");
60 if (fDriver
->IsRealTime()) {
61 JackLog("JackThreadedDriver::Start IsRealTime\n");
62 // Will do "something" on OSX only...
63 // fThread->SetParams(fDriver->fEngineControl->fPeriod, fDriver->fEngineControl->fComputation, fDriver->fEngineControl->fConstraint);
64 if (fThread
->AcquireRealTime(GetEngineControl()->fPriority
) < 0) {
65 jack_error("AcquireRealTime error");
72 int JackThreadedDriver::Stop()
74 JackLog("JackThreadedDriver::Stop\n");
77 if ((res
= fThread
->Stop()) < 0) { // Stop when the thread cycle is finished
78 jack_error("Cannot stop thread");
81 if ((res
= fDriver
->Stop()) < 0) {
82 jack_error("Cannot stop driver");
88 bool JackThreadedDriver::Execute()
90 return (Process() == 0);