3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
24 |
#ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__ |
#ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__ |
25 |
#define __LS_AUDIOOUTPUTDEVICEJACK_H__ |
#define __LS_AUDIOOUTPUTDEVICEJACK_H__ |
26 |
|
|
27 |
#include "../../common/global.h" |
#include "../../common/global_private.h" |
28 |
|
|
29 |
#if HAVE_JACK |
#if HAVE_JACK |
30 |
|
|
35 |
#include "AudioOutputDevice.h" |
#include "AudioOutputDevice.h" |
36 |
#include "../../common/ConditionServer.h" |
#include "../../common/ConditionServer.h" |
37 |
|
|
38 |
|
#if HAVE_JACK_MIDI |
39 |
|
#include "../midi/MidiInputDeviceJack.h" |
40 |
|
#endif |
41 |
|
|
42 |
namespace LinuxSampler { |
namespace LinuxSampler { |
43 |
|
|
44 |
/** JACK audio output driver |
/** JACK audio output driver |
48 |
class AudioOutputDeviceJack : public AudioOutputDevice { |
class AudioOutputDeviceJack : public AudioOutputDevice { |
49 |
public: |
public: |
50 |
AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters); |
AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters); |
51 |
~AudioOutputDeviceJack(); |
virtual ~AudioOutputDeviceJack(); |
52 |
|
|
53 |
/** |
/** |
54 |
* Audio channel implementation for the JACK audio driver. |
* Audio channel implementation for the JACK audio driver. |
80 |
virtual void OnSetValue(std::vector<String> vS); |
virtual void OnSetValue(std::vector<String> vS); |
81 |
static String Name(); |
static String Name(); |
82 |
protected: |
protected: |
83 |
AudioChannelJack* pChannel; |
AudioChannelJack* pChannel; |
84 |
|
std::vector<String> Bindings; |
85 |
}; |
}; |
86 |
protected: |
protected: |
87 |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
95 |
float* CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
float* CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
96 |
}; |
}; |
97 |
|
|
98 |
|
/** Audio Device Parameter 'NAME' |
99 |
|
* |
100 |
|
* Used to assign an arbitrary name to the JACK client of this |
101 |
|
* audio device. |
102 |
|
*/ |
103 |
|
class ParameterName : public DeviceCreationParameterString { |
104 |
|
public: |
105 |
|
ParameterName(); |
106 |
|
ParameterName(String s) throw (Exception); |
107 |
|
virtual String Description(); |
108 |
|
virtual bool Fix(); |
109 |
|
virtual bool Mandatory(); |
110 |
|
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters(); |
111 |
|
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters); |
112 |
|
virtual optional<String> DefaultAsString(std::map<String,String> Parameters); |
113 |
|
virtual void OnSetValue(String s) throw (Exception); |
114 |
|
static String Name(); |
115 |
|
}; |
116 |
|
|
117 |
// derived abstract methods from class 'AudioOutputDevice' |
// derived abstract methods from class 'AudioOutputDevice' |
118 |
virtual void Play(); |
virtual void Play(); |
119 |
virtual bool IsPlaying(); |
virtual bool IsPlaying(); |
123 |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
124 |
|
|
125 |
|
|
126 |
static String Name(); |
static String Name(); |
127 |
|
|
128 |
virtual String Driver(); |
virtual String Driver(); |
129 |
|
|
140 |
}; |
}; |
141 |
|
|
142 |
// Callback functions for the libjack API |
// Callback functions for the libjack API |
143 |
int __libjack_process_callback(jack_nframes_t nframes, void* arg); |
int linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg); |
144 |
void __libjack_shutdown_callback(void* arg); |
void linuxsampler_libjack_shutdown_callback(void* arg); |
145 |
|
|
146 |
|
|
147 |
|
/** JACK client |
148 |
|
* |
149 |
|
* Represents a jack client. This class is shared by |
150 |
|
* AudioOutputDeviceJack and MidiInputDeviceJack. The jack server |
151 |
|
* calls JackClient::Process, which in turn calls |
152 |
|
* AudioOutputDeviceJack::Process and/or |
153 |
|
* MidiInputDeviceJack::Process. |
154 |
|
*/ |
155 |
|
class JackClient { |
156 |
|
public: |
157 |
|
static JackClient* CreateAudio(String Name); |
158 |
|
static JackClient* CreateMidi(String Name); |
159 |
|
static void ReleaseAudio(String Name); |
160 |
|
static void ReleaseMidi(String Name); |
161 |
|
int Process(uint Samples); |
162 |
|
void Stop(); |
163 |
|
void SetAudioOutputDevice(AudioOutputDeviceJack* device); |
164 |
|
#if HAVE_JACK_MIDI |
165 |
|
void SetMidiInputDevice(MidiInputDeviceJack* device); |
166 |
|
#endif |
167 |
|
|
168 |
|
jack_client_t* hJackClient; |
169 |
|
|
170 |
|
private: |
171 |
|
static std::map<String, JackClient*> Clients; |
172 |
|
struct config_t { |
173 |
|
AudioOutputDeviceJack* AudioDevice; |
174 |
|
#if HAVE_JACK_MIDI |
175 |
|
MidiInputDeviceJack* MidiDevice; |
176 |
|
#endif |
177 |
|
}; |
178 |
|
SynchronizedConfig<config_t> Config; |
179 |
|
SynchronizedConfig<config_t>::Reader ConfigReader; |
180 |
|
bool audio; |
181 |
|
bool midi; |
182 |
|
|
183 |
|
JackClient(String Name); |
184 |
|
~JackClient(); |
185 |
|
}; |
186 |
} |
} |
187 |
|
|
188 |
#endif // HAVE_JACK |
#endif // HAVE_JACK |