21 |
***************************************************************************/ |
***************************************************************************/ |
22 |
|
|
23 |
#include "AudioOutputDeviceJack.h" |
#include "AudioOutputDeviceJack.h" |
24 |
|
#include "AudioOutputDeviceFactory.h" |
25 |
|
|
26 |
#if HAVE_JACK |
#if HAVE_JACK |
27 |
|
|
28 |
namespace LinuxSampler { |
namespace LinuxSampler { |
29 |
|
|
30 |
|
REGISTER_AUDIO_OUTPUT_DRIVER("JACK",AudioOutputDeviceJack); |
31 |
|
|
32 |
/** |
/** |
33 |
* Open and initialize connection to the JACK system. The two arguments |
* Open and initialize connection to the JACK system. |
|
* are optional; they allow auto connection to already existing Jack |
|
|
* playback ports. If there are no playback ports to which we should |
|
|
* autoconnect to, then no output ports will be created and the |
|
|
* AcquireChannels() method has to be called to order a minimum amount |
|
|
* of output channels which will then be created. |
|
34 |
* |
* |
35 |
* @param AutoConnectPortIDs - (optional) array of Jack IDs of ports to |
* @param Parameters - optional parameters |
|
* which we should autoconnect to |
|
|
* @param AutoConnectPorts - (optional) size of the AutoConnectPortIDs |
|
|
* array |
|
36 |
* @throws AudioOutputException on error |
* @throws AudioOutputException on error |
37 |
* @see AcquireChannels() |
* @see AcquireChannels() |
38 |
*/ |
*/ |
39 |
AudioOutputDeviceJack::AudioOutputDeviceJack(String* AutoConnectPortIDs, uint AutoConnectPorts) : AudioOutputDevice(AudioOutputDevice::type_jack) { |
AudioOutputDeviceJack::AudioOutputDeviceJack(std::map<String,String> Parameters) : AudioOutputDevice(std::map<String,DeviceCreationParameter*>()) { |
40 |
if ((hJackClient = jack_client_new("LinuxSampler")) == 0) |
if ((hJackClient = jack_client_new("LinuxSampler")) == 0) |
41 |
throw AudioOutputException("Seems Jack server not running."); |
throw AudioOutputException("Seems Jack server not running."); |
42 |
|
|
47 |
|
|
48 |
uiMaxSamplesPerCycle = jack_get_buffer_size(hJackClient); |
uiMaxSamplesPerCycle = jack_get_buffer_size(hJackClient); |
49 |
|
|
50 |
|
#if 0 |
51 |
// create amount of audio channels and jack output ports we need for autoconnect |
// create amount of audio channels and jack output ports we need for autoconnect |
52 |
for (uint p = 0; p < AutoConnectPorts; p++) { |
for (uint p = 0; p < AutoConnectPorts; p++) { |
53 |
// create jack output port |
// create jack output port |
68 |
throw AudioOutputException(err.str()); |
throw AudioOutputException(err.str()); |
69 |
} |
} |
70 |
} |
} |
71 |
|
#endif |
72 |
} |
} |
73 |
|
|
74 |
AudioOutputDeviceJack::~AudioOutputDeviceJack() { |
AudioOutputDeviceJack::~AudioOutputDeviceJack() { |
131 |
return jack_get_sample_rate(hJackClient); |
return jack_get_sample_rate(hJackClient); |
132 |
} |
} |
133 |
|
|
134 |
|
String AudioOutputDeviceJack::Description() { |
135 |
|
return "JACK Audio Connection Kit"; |
136 |
|
} |
137 |
|
|
138 |
|
String AudioOutputDeviceJack::Version() { |
139 |
|
String s = "$Revision: 1.5 $"; |
140 |
|
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
141 |
|
} |
142 |
|
|
143 |
|
std::map<String,DeviceCreationParameter*> AudioOutputDeviceJack::AvailableParameters() { |
144 |
|
// FIXME: not a good solution to get the commot parameters (ACTIVE,SAMPERATE,CHANNELS which have to be offered by all audio output drivers) |
145 |
|
std::map<String,DeviceCreationParameter*> available_parameters = AudioOutputDevice::AvailableParameters(); |
146 |
|
return available_parameters; // this driver currently does not have additional, individual device parameters |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
// libjack callback functions |
// libjack callback functions |