Jack2 1.9.10
|
00001 /* 00002 Copyright (C) 2001 Paul Davis 00003 Copyright (C) 2004-2008 Grame 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 */ 00020 00021 #include "JackSystemDeps.h" 00022 #include "JackFreewheelDriver.h" 00023 #include "JackEngineControl.h" 00024 #include "JackLockedEngine.h" 00025 00026 namespace Jack 00027 { 00028 00029 // When used in "master" mode 00030 00031 int JackFreewheelDriver::Process() 00032 { 00033 jack_log("JackFreewheelDriver::Process master %lld", fEngineControl->fTimeOutUsecs); 00034 JackDriver::CycleTakeBeginTime(); 00035 00036 if (fEngine->Process(fBeginDateUst, fEndDateUst)) { 00037 00038 // Resume connected clients in the graph 00039 if (ResumeRefNum() < 0) { 00040 jack_error("JackFreewheelDriver::Process: ResumeRefNum error"); 00041 } 00042 00043 // Special "SuspendRefNum" with longer timeout 00044 if (SuspendRefNum() < 0) { // Wait for all clients to finish for FREEWHEEL_DRIVER_TIMEOUT sec 00045 jack_error("JackFreewheelDriver::Process: SuspendRefNum error"); 00046 } 00047 00048 } else { // Graph not finished: do not activate it 00049 jack_error("JackFreewheelDriver::Process: Process error"); 00050 } 00051 00052 return 0; 00053 } 00054 00055 // When used in "slave" mode 00056 00057 int JackFreewheelDriver::ProcessReadSync() 00058 { 00059 // Resume connected clients in the graph 00060 if (ResumeRefNum() < 0) { // Signal all clients 00061 jack_error("JackFreewheelDriver::ProcessReadSync: ResumeRefNum error"); 00062 return -1; 00063 } 00064 return 0; 00065 } 00066 00067 int JackFreewheelDriver::ProcessWriteSync() 00068 { 00069 // Generic "SuspendRefNum" here 00070 if (JackDriver::SuspendRefNum() < 0) { 00071 jack_error("JackFreewheelDriver::ProcessSync: SuspendRefNum error"); 00072 return -1; 00073 } 00074 return 0; 00075 } 00076 00077 int JackFreewheelDriver::ProcessReadAsync() 00078 { 00079 // Resume connected clients in the graph 00080 if (ResumeRefNum() < 0) { // Signal all clients 00081 jack_error("JackFreewheelDriver::ProcessReadAsync: ResumeRefNum error"); 00082 return -1; 00083 } 00084 return 0; 00085 } 00086 00087 int JackFreewheelDriver::ProcessWriteAsync() 00088 { 00089 return 0; 00090 } 00091 00092 int JackFreewheelDriver::SuspendRefNum() 00093 { 00094 return fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, FREEWHEEL_DRIVER_TIMEOUT * 1000000); 00095 } 00096 00097 } // end of namespace