Revision 5:75b744078d66 JackDevice
| JackDevice/ContextJack.cpp | ||
|---|---|---|
| 1 | 1 |
/* |
| 2 |
Copyright (c) 2015, The Cinder Project |
|
| 3 | 2 |
|
| 4 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 | 5 |
|
| 6 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 7 |
the following conditions are met: |
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
|
|
| 21 |
This file incorporates work covered by the following copyright and permission notice: |
|
| 22 |
|
|
| 23 |
Copyright (c) 2014, The Cinder Project |
|
| 24 |
|
|
| 25 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 26 |
|
|
| 27 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 28 |
the following conditions are met: |
|
| 8 | 29 |
|
| 9 | 30 |
* Redistributions of source code must retain the above copyright notice, this list of conditions and |
| 10 |
the following disclaimer.
|
|
| 31 |
the following disclaimer.
|
|
| 11 | 32 |
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and |
| 12 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 33 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 13 | 34 |
|
| 14 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 15 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 16 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 17 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 18 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 19 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 20 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 21 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 35 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 36 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 37 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 38 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 39 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 40 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 41 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 42 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 43 |
|
|
| 22 | 44 |
*/ |
| 23 | 45 |
|
| 46 |
|
|
| 24 | 47 |
#include "cinder/audio/linux/ContextJack.h" |
| 25 | 48 |
#include "cinder/audio/Exception.h" |
| 26 | 49 |
|
| ... | ... | |
| 60 | 83 |
int OutputDeviceNodeJack::jackCallback(jack_nframes_t nframes, void* userData) |
| 61 | 84 |
{
|
| 62 | 85 |
// retrieve user data |
| 63 |
RenderData *renderData = static_cast<RenderData *>( userData );
|
|
| 86 |
RenderData *renderData = static_cast<RenderData *>( userData );
|
|
| 64 | 87 |
|
| 65 |
OutputDeviceNodeJack *outputDeviceNode = static_cast<OutputDeviceNodeJack *>( renderData->outputNode );
|
|
| 88 |
OutputDeviceNodeJack *outputDeviceNode = static_cast<OutputDeviceNodeJack *>( renderData->outputNode );
|
|
| 66 | 89 |
|
| 67 |
auto ctx = renderData->outputNode->getContext();
|
|
| 68 |
if( ! ctx ) {
|
|
| 90 |
auto ctx = renderData->outputNode->getContext();
|
|
| 91 |
if( ! ctx ) {
|
|
| 69 | 92 |
// this is from some cinder library code but it should not happen in Collidoscope as the context is set |
| 70 | 93 |
for( size_t chan = 0; chan < 2; chan++) |
| 71 |
zeroJackPort( outputDeviceNode->mOutputPorts[chan], nframes );
|
|
| 94 |
zeroJackPort( outputDeviceNode->mOutputPorts[chan], nframes );
|
|
| 72 | 95 |
|
| 73 |
return 0;
|
|
| 74 |
}
|
|
| 96 |
return 0;
|
|
| 97 |
}
|
|
| 75 | 98 |
|
| 76 |
std::lock_guard<std::mutex> lock( ctx->getMutex() );
|
|
| 99 |
std::lock_guard<std::mutex> lock( ctx->getMutex() );
|
|
| 77 | 100 |
|
| 78 |
// verify associated context still exists, which may not be true if we blocked in ~Context() and were then deallocated.
|
|
| 79 |
ctx = renderData->outputNode->getContext();
|
|
| 80 |
if( ! ctx ) {
|
|
| 101 |
// verify associated context still exists, which may not be true if we blocked in ~Context() and were then deallocated.
|
|
| 102 |
ctx = renderData->outputNode->getContext();
|
|
| 103 |
if( ! ctx ) {
|
|
| 81 | 104 |
|
| 82 | 105 |
for( size_t chan = 0; chan < 2; chan++) |
| 83 |
zeroJackPort( outputDeviceNode->mOutputPorts[chan], nframes );
|
|
| 106 |
zeroJackPort( outputDeviceNode->mOutputPorts[chan], nframes );
|
|
| 84 | 107 |
|
| 85 |
return 0;
|
|
| 86 |
}
|
|
| 108 |
return 0;
|
|
| 109 |
}
|
|
| 87 | 110 |
|
| 88 | 111 |
|
| 89 |
Buffer *internalBuffer = outputDeviceNode->getInternalBuffer();
|
|
| 90 |
internalBuffer->zero();
|
|
| 112 |
Buffer *internalBuffer = outputDeviceNode->getInternalBuffer();
|
|
| 113 |
internalBuffer->zero();
|
|
| 91 | 114 |
|
| 92 |
ctx->preProcess();
|
|
| 115 |
ctx->preProcess();
|
|
| 93 | 116 |
// process the whole audio graph using by recursively pulling the input all the way to the top of the graph |
| 94 |
outputDeviceNode->pullInputs( internalBuffer );
|
|
| 117 |
outputDeviceNode->pullInputs( internalBuffer );
|
|
| 95 | 118 |
|
| 96 |
// if clip detection is enabled and buffer clipped, silence it
|
|
| 97 |
//if( outputDeviceNode->checkNotClipping() ){
|
|
| 119 |
// if clip detection is enabled and buffer clipped, silence it
|
|
| 120 |
//if( outputDeviceNode->checkNotClipping() ){
|
|
| 98 | 121 |
//for( size_t chan = 0; chan < 2; chan++) |
| 99 |
// zeroJackPort( outputDeviceNode->mOutputPorts[chan], nframes );
|
|
| 100 |
//}
|
|
| 122 |
// zeroJackPort( outputDeviceNode->mOutputPorts[chan], nframes );
|
|
| 123 |
//}
|
|
| 101 | 124 |
//else {
|
| 102 | 125 |
for( size_t chan = 0; chan < 2; chan++) |
| 103 | 126 |
copyToJackPort( outputDeviceNode->mOutputPorts[chan], internalBuffer->getChannel( chan ), nframes ); |
| 104 | 127 |
//} |
| 105 | 128 |
|
| 106 |
ctx->postProcess();
|
|
| 129 |
ctx->postProcess();
|
|
| 107 | 130 |
|
| 108 | 131 |
return 0; |
| 109 | 132 |
} |
| ... | ... | |
| 181 | 204 |
|
| 182 | 205 |
// connect input ports to physical device (microphones) |
| 183 | 206 |
const char **mikePorts = jack_get_ports (mClient, NULL, NULL, |
| 184 |
JackPortIsPhysical|JackPortIsOutput);
|
|
| 207 |
JackPortIsPhysical|JackPortIsOutput);
|
|
| 185 | 208 |
|
| 186 |
if (mikePorts == NULL) {
|
|
| 209 |
if (mikePorts == NULL) {
|
|
| 187 | 210 |
throw cinder::audio::AudioContextExc("no physical input ports available");
|
| 188 |
}
|
|
| 211 |
}
|
|
| 189 | 212 |
|
| 190 |
if (jack_connect (mClient, mikePorts[0], jack_port_name (mInputDeviceNode->mInputPorts[0]))) {
|
|
| 213 |
if (jack_connect (mClient, mikePorts[0], jack_port_name (mInputDeviceNode->mInputPorts[0]))) {
|
|
| 191 | 214 |
throw cinder::audio::AudioContextExc("cannot connect input port 0");
|
| 192 |
}
|
|
| 215 |
}
|
|
| 193 | 216 |
|
| 194 |
if (jack_connect (mClient, mikePorts[1], jack_port_name( mInputDeviceNode->mInputPorts[1]) )) {
|
|
| 217 |
if (jack_connect (mClient, mikePorts[1], jack_port_name( mInputDeviceNode->mInputPorts[1]) )) {
|
|
| 195 | 218 |
throw cinder::audio::AudioContextExc("cannot connect input port 1");
|
| 196 |
}
|
|
| 219 |
}
|
|
| 197 | 220 |
|
| 198 | 221 |
// connect output ports to physical device (audio out ) |
| 199 | 222 |
const char **speakerPorts = jack_get_ports (mClient, NULL, NULL, |
| 200 |
JackPortIsPhysical|JackPortIsInput);
|
|
| 223 |
JackPortIsPhysical|JackPortIsInput);
|
|
| 201 | 224 |
|
| 202 |
if (speakerPorts == NULL) {
|
|
| 225 |
if (speakerPorts == NULL) {
|
|
| 203 | 226 |
throw cinder::audio::AudioContextExc("no physical output ports available");
|
| 204 |
}
|
|
| 227 |
}
|
|
| 205 | 228 |
|
| 206 |
if (jack_connect (mClient, jack_port_name (mOutputPorts[0]), speakerPorts[0])) {
|
|
| 229 |
if (jack_connect (mClient, jack_port_name (mOutputPorts[0]), speakerPorts[0])) {
|
|
| 207 | 230 |
throw cinder::audio::AudioContextExc("cannot connect output port 0");
|
| 208 |
}
|
|
| 231 |
}
|
|
| 209 | 232 |
|
| 210 |
if (jack_connect (mClient, jack_port_name (mOutputPorts[1]), speakerPorts[1])) {
|
|
| 233 |
if (jack_connect (mClient, jack_port_name (mOutputPorts[1]), speakerPorts[1])) {
|
|
| 211 | 234 |
throw cinder::audio::AudioContextExc("cannot connect output port 1");
|
| 212 |
}
|
|
| 235 |
}
|
|
| 213 | 236 |
|
| 214 |
jack_free( mikePorts );
|
|
| 215 |
jack_free( speakerPorts );
|
|
| 237 |
jack_free( mikePorts );
|
|
| 238 |
jack_free( speakerPorts );
|
|
| 216 | 239 |
} |
| 217 | 240 |
|
| 218 | 241 |
|
| ... | ... | |
| 266 | 289 |
|
| 267 | 290 |
//-------------------------------------------ContextJack----------------------------------------------------------- |
| 268 | 291 |
|
| 269 |
OutputDeviceNodeRef ContextJack::createOutputDeviceNode( const DeviceRef &device, const Node::Format &format )
|
|
| 292 |
OutputDeviceNodeRef ContextJack::createOutputDeviceNode( const DeviceRef &device, const Node::Format &format )
|
|
| 270 | 293 |
{
|
| 271 |
|
|
| 294 |
|
|
| 272 | 295 |
if( mOutputDeviceNode == nullptr ) {
|
| 273 | 296 |
auto thisRef = std::static_pointer_cast<ContextJack>( shared_from_this() ); |
| 274 | 297 |
|
| ... | ... | |
| 283 | 306 |
} |
| 284 | 307 |
} |
| 285 | 308 |
|
| 286 |
return mOutputDeviceNode;
|
|
| 309 |
return mOutputDeviceNode;
|
|
| 287 | 310 |
} |
| 288 | 311 |
|
| 289 | 312 |
InputDeviceNodeRef ContextJack::createInputDeviceNode( const DeviceRef &device, const Node::Format &format ) |
| ... | ... | |
| 302 | 325 |
} |
| 303 | 326 |
} |
| 304 | 327 |
|
| 305 |
return mInputDeviceNode;
|
|
| 328 |
return mInputDeviceNode;
|
|
| 306 | 329 |
} |
| 307 | 330 |
|
| 308 | 331 |
|
| JackDevice/ContextJack.h | ||
|---|---|---|
| 1 | 1 |
/* |
| 2 |
Copyright (c) 2015, The Cinder Project |
|
| 3 | 2 |
|
| 4 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 | 5 |
|
| 6 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 7 |
the following conditions are met: |
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
|
|
| 21 |
This file incorporates work covered by the following copyright and permission notice: |
|
| 22 |
|
|
| 23 |
Copyright (c) 2014, The Cinder Project |
|
| 24 |
|
|
| 25 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 26 |
|
|
| 27 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 28 |
the following conditions are met: |
|
| 8 | 29 |
|
| 9 | 30 |
* Redistributions of source code must retain the above copyright notice, this list of conditions and |
| 10 |
the following disclaimer.
|
|
| 31 |
the following disclaimer.
|
|
| 11 | 32 |
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and |
| 12 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 33 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 13 | 34 |
|
| 14 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 15 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 16 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 17 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 18 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 19 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 20 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 21 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 35 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 36 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 37 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 38 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 39 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 40 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 41 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 42 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 43 |
|
|
| 22 | 44 |
*/ |
| 23 | 45 |
|
| 24 | 46 |
#pragma once |
| ... | ... | |
| 36 | 58 |
*/ |
| 37 | 59 |
class OutputDeviceNodeJack : public OutputDeviceNode {
|
| 38 | 60 |
public: |
| 39 |
OutputDeviceNodeJack( const DeviceRef &device, const Format &format, const std::shared_ptr<ContextJack> &context );
|
|
| 61 |
OutputDeviceNodeJack( const DeviceRef &device, const Format &format, const std::shared_ptr<ContextJack> &context );
|
|
| 40 | 62 |
|
| 41 | 63 |
/** Gives this output node a reference to the JackInputNode. |
| 42 | 64 |
* In initialize() the reference is used to give the input node access to jack input ports |
| ... | ... | |
| 44 | 66 |
void setInput(InputDeviceNodeRef inputDeviceNode); |
| 45 | 67 |
|
| 46 | 68 |
protected: |
| 47 |
void initialize() override;
|
|
| 48 |
void uninitialize() override;
|
|
| 49 |
void enableProcessing() override;
|
|
| 50 |
void disableProcessing() override;
|
|
| 51 |
bool supportsProcessInPlace() const override { return false; }
|
|
| 69 |
void initialize() override;
|
|
| 70 |
void uninitialize() override;
|
|
| 71 |
void enableProcessing() override;
|
|
| 72 |
void disableProcessing() override;
|
|
| 73 |
bool supportsProcessInPlace() const override { return false; }
|
|
| 52 | 74 |
|
| 53 | 75 |
private: |
| 54 | 76 |
// this is called by jack in the audio thread at every tick of the sound card |
| 55 | 77 |
static int jackCallback(jack_nframes_t nframes, void* userData); |
| 56 | 78 |
|
| 57 | 79 |
|
| 58 |
void renderToBufferFromInputs();
|
|
| 80 |
void renderToBufferFromInputs();
|
|
| 59 | 81 |
|
| 60 | 82 |
/** |
| 61 | 83 |
* RenderData is passed as user_data to jack when the jack process callback is installed |
| ... | ... | |
| 70 | 92 |
|
| 71 | 93 |
std::weak_ptr<ContextJack> mCinderContext; |
| 72 | 94 |
|
| 73 |
jack_client_t *mClient;
|
|
| 95 |
jack_client_t *mClient;
|
|
| 74 | 96 |
|
| 75 | 97 |
std::array< jack_port_t*, 2 > mOutputPorts; |
| 76 | 98 |
|
| ... | ... | |
| 84 | 106 |
friend OutputDeviceNodeJack; |
| 85 | 107 |
|
| 86 | 108 |
public: |
| 87 |
InputDeviceNodeJack( const DeviceRef &device, const Format &format, const std::shared_ptr<ContextJack> &context );
|
|
| 109 |
InputDeviceNodeJack( const DeviceRef &device, const Format &format, const std::shared_ptr<ContextJack> &context );
|
|
| 88 | 110 |
|
| 89 | 111 |
protected: |
| 90 |
void initialize() override;
|
|
| 91 |
void uninitialize() override;
|
|
| 92 |
void enableProcessing() override;
|
|
| 93 |
void disableProcessing() override;
|
|
| 94 |
void process( Buffer *buffer ) override;
|
|
| 112 |
void initialize() override;
|
|
| 113 |
void uninitialize() override;
|
|
| 114 |
void enableProcessing() override;
|
|
| 115 |
void disableProcessing() override;
|
|
| 116 |
void process( Buffer *buffer ) override;
|
|
| 95 | 117 |
|
| 96 | 118 |
private: |
| 97 | 119 |
std::array< jack_port_t*, 2 > mInputPorts; |
| ... | ... | |
| 99 | 121 |
|
| 100 | 122 |
class ContextJack : public Context {
|
| 101 | 123 |
public: |
| 102 |
ContextJack() {}
|
|
| 103 |
virtual ~ContextJack() {}
|
|
| 124 |
ContextJack() {}
|
|
| 125 |
virtual ~ContextJack() {}
|
|
| 104 | 126 |
|
| 105 | 127 |
|
| 106 |
OutputDeviceNodeRef createOutputDeviceNode( const DeviceRef &device, const Node::Format &format = Node::Format() ) override;
|
|
| 107 |
InputDeviceNodeRef createInputDeviceNode( const DeviceRef &device, const Node::Format &format = Node::Format() ) override;
|
|
| 128 |
OutputDeviceNodeRef createOutputDeviceNode( const DeviceRef &device, const Node::Format &format = Node::Format() ) override;
|
|
| 129 |
InputDeviceNodeRef createInputDeviceNode( const DeviceRef &device, const Node::Format &format = Node::Format() ) override;
|
|
| 108 | 130 |
|
| 109 |
OutputDeviceNodeRef mOutputDeviceNode;
|
|
| 110 |
InputDeviceNodeRef mInputDeviceNode;
|
|
| 131 |
OutputDeviceNodeRef mOutputDeviceNode;
|
|
| 132 |
InputDeviceNodeRef mInputDeviceNode;
|
|
| 111 | 133 |
|
| 112 | 134 |
|
| 113 | 135 |
private: |
| 114 |
};
|
|
| 136 |
};
|
|
| 115 | 137 |
|
| 116 | 138 |
} } } // namespace cinder::audio::linux |
| 117 | 139 |
|
| JackDevice/DeviceManagerJack.cpp | ||
|---|---|---|
| 1 | 1 |
/* |
| 2 |
Copyright (c) 2015, The Cinder Project |
|
| 3 | 2 |
|
| 4 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 | 5 |
|
| 6 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 7 |
the following conditions are met: |
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
|
|
| 21 |
This file incorporates work covered by the following copyright and permission notice: |
|
| 22 |
|
|
| 23 |
Copyright (c) 2014, The Cinder Project |
|
| 24 |
|
|
| 25 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 26 |
|
|
| 27 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 28 |
the following conditions are met: |
|
| 8 | 29 |
|
| 9 | 30 |
* Redistributions of source code must retain the above copyright notice, this list of conditions and |
| 10 |
|
|
| 11 | 31 |
the following disclaimer. |
| 12 | 32 |
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and |
| 13 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 33 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 14 | 34 |
|
| 15 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 16 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 17 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 18 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 19 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 20 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 21 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 22 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 35 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 36 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 37 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 38 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 39 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 40 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 41 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 42 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 43 |
|
|
| 23 | 44 |
*/ |
| 24 | 45 |
|
| 25 | 46 |
#include "cinder/audio/linux/DeviceManagerJack.h" |
| ... | ... | |
| 39 | 60 |
jack_status_t status; |
| 40 | 61 |
|
| 41 | 62 |
// open a jack client, get info and close |
| 42 |
jack_client_t *client = jack_client_open ("device info", JackNullOption, &status, NULL);
|
|
| 63 |
jack_client_t *client = jack_client_open ("device info", JackNullOption, &status, NULL);
|
|
| 43 | 64 |
if( client == NULL){
|
| 44 | 65 |
|
| 45 | 66 |
std::string msg = "jack_client_open() failed. "; |
| ... | ... | |
| 57 | 78 |
|
| 58 | 79 |
DeviceManagerJack::~DeviceManagerJack() |
| 59 | 80 |
{
|
| 60 |
|
|
| 81 |
|
|
| 61 | 82 |
} |
| 62 | 83 |
|
| 63 | 84 |
const std::vector<DeviceRef>& DeviceManagerJack::getDevices() |
| JackDevice/DeviceManagerJack.h | ||
|---|---|---|
| 1 | 1 |
/* |
| 2 |
Copyright (c) 2015, The Cinder Project |
|
| 3 | 2 |
|
| 4 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 | 5 |
|
| 6 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 7 |
the following conditions are met: |
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
|
|
| 21 |
This file incorporates work covered by the following copyright and permission notice: |
|
| 22 |
|
|
| 23 |
Copyright (c) 2014, The Cinder Project |
|
| 24 |
|
|
| 25 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 26 |
|
|
| 27 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 28 |
the following conditions are met: |
|
| 8 | 29 |
|
| 9 | 30 |
* Redistributions of source code must retain the above copyright notice, this list of conditions and |
| 10 |
the following disclaimer.
|
|
| 31 |
the following disclaimer.
|
|
| 11 | 32 |
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and |
| 12 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 33 |
the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
| 13 | 34 |
|
| 14 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 15 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 16 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 17 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 18 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 19 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 20 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 21 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 35 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 36 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 37 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 38 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 39 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 40 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 41 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 42 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 43 |
|
|
| 22 | 44 |
*/ |
| 23 | 45 |
|
| 24 | 46 |
#pragma once |
| ... | ... | |
| 36 | 58 |
class DeviceManagerJack : public DeviceManager {
|
| 37 | 59 |
public: |
| 38 | 60 |
|
| 39 |
DeviceManagerJack();
|
|
| 40 |
virtual ~DeviceManagerJack();
|
|
| 61 |
DeviceManagerJack();
|
|
| 62 |
virtual ~DeviceManagerJack();
|
|
| 41 | 63 |
|
| 42 |
const std::vector<DeviceRef>& getDevices() override;
|
|
| 43 |
DeviceRef getDefaultOutput() override;
|
|
| 44 |
DeviceRef getDefaultInput() override;
|
|
| 64 |
const std::vector<DeviceRef>& getDevices() override;
|
|
| 65 |
DeviceRef getDefaultOutput() override;
|
|
| 66 |
DeviceRef getDefaultInput() override;
|
|
| 45 | 67 |
|
| 46 |
std::string getName( const DeviceRef &device ) override;
|
|
| 47 |
size_t getNumInputChannels( const DeviceRef &device ) override;
|
|
| 48 |
size_t getNumOutputChannels( const DeviceRef &device ) override;
|
|
| 49 |
size_t getSampleRate( const DeviceRef &device ) override;
|
|
| 50 |
size_t getFramesPerBlock( const DeviceRef &device ) override;
|
|
| 68 |
std::string getName( const DeviceRef &device ) override;
|
|
| 69 |
size_t getNumInputChannels( const DeviceRef &device ) override;
|
|
| 70 |
size_t getNumOutputChannels( const DeviceRef &device ) override;
|
|
| 71 |
size_t getSampleRate( const DeviceRef &device ) override;
|
|
| 72 |
size_t getFramesPerBlock( const DeviceRef &device ) override;
|
|
| 51 | 73 |
|
| 52 |
void setSampleRate( const DeviceRef &device, size_t sampleRate ) override;
|
|
| 53 |
void setFramesPerBlock( const DeviceRef &device, size_t framesPerBlock ) override;
|
|
| 74 |
void setSampleRate( const DeviceRef &device, size_t sampleRate ) override;
|
|
| 75 |
void setFramesPerBlock( const DeviceRef &device, size_t framesPerBlock ) override;
|
|
| 54 | 76 |
|
| 55 |
//! Returns the hardware's actual frames per block, which might not be a power of two.
|
|
| 56 |
size_t getFramesPerBlockHardware( const DeviceRef &device );
|
|
| 77 |
//! Returns the hardware's actual frames per block, which might not be a power of two.
|
|
| 78 |
size_t getFramesPerBlockHardware( const DeviceRef &device );
|
|
| 57 | 79 |
|
| 58 | 80 |
private: |
| 59 | 81 |
|
| 60 |
std::vector<DeviceRef> mDevices;
|
|
| 61 |
DeviceRef mDefaultOutDevice;
|
|
| 62 |
DeviceRef mDefaultInDevice;
|
|
| 82 |
std::vector<DeviceRef> mDevices;
|
|
| 83 |
DeviceRef mDefaultOutDevice;
|
|
| 84 |
DeviceRef mDefaultInDevice;
|
|
| 63 | 85 |
size_t mSampleRate; |
| 64 | 86 |
size_t mBufferSize; |
| 65 |
};
|
|
| 87 |
};
|
|
| 66 | 88 |
|
| 67 |
} } } // namespace cinder::audio::linux |
|
| 89 |
} } } // namespace cinder::audio::linux |
|
Also available in: Unified diff