2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 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.
21 #include "JackSystemDeps.h"
22 #include "JackLoopbackDriver.h"
23 #include "JackDriverLoader.h"
24 #include "JackEngineControl.h"
25 #include "JackGraphManager.h"
26 #include "JackError.h"
33 // When used in "slave" mode
35 int JackLoopbackDriver::ProcessReadSync()
40 for (int i
= 0; i
< fCaptureChannels
; i
++) {
41 memcpy(GetInputBuffer(i
), GetOutputBuffer(i
), sizeof(jack_default_audio_sample_t
) * fEngineControl
->fBufferSize
);
44 // Resume connected clients in the graph
45 if (ResumeRefNum() < 0) {
46 jack_error("JackLoopbackDriver::ProcessReadSync - ResumeRefNum error");
53 int JackLoopbackDriver::ProcessWriteSync()
55 // Suspend on connected clients in the graph
56 if (SuspendRefNum() < 0) {
57 jack_error("JackLoopbackDriver::ProcessWriteSync - SuspendRefNum error");
63 int JackLoopbackDriver::ProcessReadAsync()
68 for (int i
= 0; i
< fCaptureChannels
; i
++) {
69 memcpy(GetInputBuffer(i
), GetOutputBuffer(i
), sizeof(jack_default_audio_sample_t
) * fEngineControl
->fBufferSize
);
72 // Resume connected clients in the graph
73 if (ResumeRefNum() < 0) {
74 jack_error("JackLoopbackDriver::ProcessReadAsync - ResumeRefNum error");
81 int JackLoopbackDriver::ProcessWriteAsync()
93 SERVER_EXPORT jack_driver_desc_t
* driver_get_descriptor()
95 jack_driver_desc_t
* desc
;
96 jack_driver_desc_filler_t filler
;
97 jack_driver_param_value_t value
;
99 desc
= jack_driver_descriptor_construct("loopback", JackDriverSlave
, "Loopback backend", &filler
);
102 jack_driver_descriptor_add_parameter(desc
, &filler
, "channels", 'c', JackDriverParamInt
, &value
, NULL
, "Maximum number of loopback ports", NULL
);
107 SERVER_EXPORT
Jack::JackDriverClientInterface
* driver_initialize(Jack::JackLockedEngine
* engine
, Jack::JackSynchro
* table
, const JSList
* params
)
110 const jack_driver_param_t
* param
;
113 for (node
= params
; node
; node
= jack_slist_next (node
)) {
114 param
= (const jack_driver_param_t
*) node
->data
;
116 switch (param
->character
) {
119 channels
= param
->value
.ui
;
124 Jack::JackDriverClientInterface
* driver
= new Jack::JackLoopbackDriver(engine
, table
);
125 if (driver
->Open(0, 0, 1, 1, channels
, channels
, false, "loopback", "loopback", 0, 0) == 0) {