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 |
|
|
34 |
|
|
35 |
#include "AudioOutputDevice.h" |
#include "AudioOutputDevice.h" |
36 |
#include "../../common/ConditionServer.h" |
#include "../../common/ConditionServer.h" |
37 |
|
#include "../midi/MidiInputDeviceJack.h" |
38 |
|
|
39 |
namespace LinuxSampler { |
namespace LinuxSampler { |
40 |
|
|
45 |
class AudioOutputDeviceJack : public AudioOutputDevice { |
class AudioOutputDeviceJack : public AudioOutputDevice { |
46 |
public: |
public: |
47 |
AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters); |
AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters); |
48 |
~AudioOutputDeviceJack(); |
virtual ~AudioOutputDeviceJack(); |
49 |
|
|
50 |
/** |
/** |
51 |
* Audio channel implementation for the JACK audio driver. |
* Audio channel implementation for the JACK audio driver. |
77 |
virtual void OnSetValue(std::vector<String> vS); |
virtual void OnSetValue(std::vector<String> vS); |
78 |
static String Name(); |
static String Name(); |
79 |
protected: |
protected: |
80 |
AudioChannelJack* pChannel; |
AudioChannelJack* pChannel; |
81 |
|
std::vector<String> Bindings; |
82 |
}; |
}; |
83 |
protected: |
protected: |
84 |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
92 |
float* CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
float* CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
93 |
}; |
}; |
94 |
|
|
95 |
|
/** Audio Device Parameter 'NAME' |
96 |
|
* |
97 |
|
* Used to assign an arbitrary name to the JACK client of this |
98 |
|
* audio device. |
99 |
|
*/ |
100 |
|
class ParameterName : public DeviceCreationParameterString { |
101 |
|
public: |
102 |
|
ParameterName(); |
103 |
|
ParameterName(String s) throw (Exception); |
104 |
|
virtual String Description(); |
105 |
|
virtual bool Fix(); |
106 |
|
virtual bool Mandatory(); |
107 |
|
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters(); |
108 |
|
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters); |
109 |
|
virtual optional<String> DefaultAsString(std::map<String,String> Parameters); |
110 |
|
virtual void OnSetValue(String s) throw (Exception); |
111 |
|
static String Name(); |
112 |
|
}; |
113 |
|
|
114 |
// derived abstract methods from class 'AudioOutputDevice' |
// derived abstract methods from class 'AudioOutputDevice' |
115 |
virtual void Play(); |
virtual void Play(); |
116 |
virtual bool IsPlaying(); |
virtual bool IsPlaying(); |
120 |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
121 |
|
|
122 |
|
|
123 |
static String Name(); |
static String Name(); |
124 |
|
|
125 |
virtual String Driver(); |
virtual String Driver(); |
126 |
|
|
137 |
}; |
}; |
138 |
|
|
139 |
// Callback functions for the libjack API |
// Callback functions for the libjack API |
140 |
int __libjack_process_callback(jack_nframes_t nframes, void* arg); |
int linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg); |
141 |
void __libjack_shutdown_callback(void* arg); |
void linuxsampler_libjack_shutdown_callback(void* arg); |
142 |
|
|
143 |
|
|
144 |
|
/** JACK client |
145 |
|
* |
146 |
|
* Represents a jack client. This class is shared by |
147 |
|
* AudioOutputDeviceJack and MidiInputDeviceJack. The jack server |
148 |
|
* calls JackClient::Process, which in turn calls |
149 |
|
* AudioOutputDeviceJack::Process and/or |
150 |
|
* MidiInputDeviceJack::Process. |
151 |
|
*/ |
152 |
|
class JackClient { |
153 |
|
public: |
154 |
|
static JackClient* CreateAudio(String Name); |
155 |
|
static JackClient* CreateMidi(String Name); |
156 |
|
static void ReleaseAudio(String Name); |
157 |
|
static void ReleaseMidi(String Name); |
158 |
|
int Process(uint Samples); |
159 |
|
void Stop(); |
160 |
|
void SetAudioOutputDevice(AudioOutputDeviceJack* device); |
161 |
|
void SetMidiInputDevice(MidiInputDeviceJack* device); |
162 |
|
|
163 |
|
jack_client_t* hJackClient; |
164 |
|
|
165 |
|
private: |
166 |
|
static std::map<String, JackClient*> Clients; |
167 |
|
struct config_t { |
168 |
|
AudioOutputDeviceJack* AudioDevice; |
169 |
|
MidiInputDeviceJack* MidiDevice; |
170 |
|
}; |
171 |
|
SynchronizedConfig<config_t> Config; |
172 |
|
SynchronizedConfig<config_t>::Reader ConfigReader; |
173 |
|
bool audio; |
174 |
|
bool midi; |
175 |
|
|
176 |
|
JackClient(String Name); |
177 |
|
~JackClient(); |
178 |
|
}; |
179 |
} |
} |
180 |
|
|
181 |
#endif // HAVE_JACK |
#endif // HAVE_JACK |