Jack2 1.9.6
|
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 "JackLoopbackDriver.h" 00023 #include "JackDriverLoader.h" 00024 #include "JackEngineControl.h" 00025 #include "JackGraphManager.h" 00026 #include "JackError.h" 00027 #include <iostream> 00028 #include <assert.h> 00029 00030 namespace Jack 00031 { 00032 00033 int JackLoopbackDriver::Process() 00034 { 00035 // Loopback copy 00036 for (int i = 0; i < fCaptureChannels; i++) { 00037 memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(float) * fEngineControl->fBufferSize); 00038 } 00039 00040 fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients 00041 if (fEngineControl->fSyncMode) { 00042 if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) { 00043 jack_error("JackLoopbackDriver::ProcessSync SuspendRefNum error"); 00044 return -1; 00045 } 00046 } 00047 return 0; 00048 } 00049 00050 } // end of namespace 00051 00052 #ifdef __cplusplus 00053 extern "C" 00054 { 00055 #endif 00056 00057 SERVER_EXPORT jack_driver_desc_t * driver_get_descriptor() 00058 { 00059 jack_driver_desc_t * desc; 00060 unsigned int i; 00061 00062 desc = (jack_driver_desc_t*)calloc (1, sizeof (jack_driver_desc_t)); 00063 strcpy(desc->name, "loopback"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1 00064 strcpy(desc->desc, "Loopback backend"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1 00065 00066 desc->nparams = 1; 00067 desc->params = (jack_driver_param_desc_t*)calloc (desc->nparams, sizeof (jack_driver_param_desc_t)); 00068 00069 i = 0; 00070 strcpy(desc->params[i].name, "channels"); 00071 desc->params[i].character = 'c'; 00072 desc->params[i].type = JackDriverParamInt; 00073 desc->params[i].value.ui = 0; 00074 strcpy(desc->params[i].short_desc, "Maximum number of loopback ports"); 00075 strcpy(desc->params[i].long_desc, desc->params[i].short_desc); 00076 00077 return desc; 00078 } 00079 00080 SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params) 00081 { 00082 const JSList * node; 00083 const jack_driver_param_t * param; 00084 int channels = 2; 00085 00086 for (node = params; node; node = jack_slist_next (node)) { 00087 param = (const jack_driver_param_t *) node->data; 00088 00089 switch (param->character) { 00090 00091 case 'c': 00092 channels = param->value.ui; 00093 break; 00094 } 00095 } 00096 00097 Jack::JackDriverClientInterface* driver = new Jack::JackLoopbackDriver(engine, table); 00098 if (driver->Open(1, 1, channels, channels, false, "loopback", "loopback", 0, 0) == 0) { 00099 return driver; 00100 } else { 00101 delete driver; 00102 return NULL; 00103 } 00104 } 00105 00106 #ifdef __cplusplus 00107 } 00108 #endif