1 |
schoenebeck |
200 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
schoenebeck |
880 |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
7 |
schoenebeck |
200 |
* * |
8 |
|
|
* 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 * |
10 |
|
|
* the Free Software Foundation; either version 2 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, write to the Free Software * |
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
|
|
* MA 02111-1307 USA * |
22 |
|
|
***************************************************************************/ |
23 |
|
|
|
24 |
|
|
#ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__ |
25 |
|
|
#define __LS_AUDIOOUTPUTDEVICEJACK_H__ |
26 |
|
|
|
27 |
|
|
#include "../../common/global.h" |
28 |
|
|
|
29 |
|
|
#if HAVE_JACK |
30 |
|
|
|
31 |
|
|
#include <vector> |
32 |
|
|
#include <sstream> |
33 |
|
|
#include <jack/jack.h> |
34 |
|
|
|
35 |
|
|
#include "AudioOutputDevice.h" |
36 |
|
|
#include "../../common/ConditionServer.h" |
37 |
|
|
|
38 |
|
|
namespace LinuxSampler { |
39 |
|
|
|
40 |
|
|
/** JACK audio output driver |
41 |
|
|
* |
42 |
|
|
* Implements audio output to the JACK Audio Connection Kit (JACK). |
43 |
|
|
*/ |
44 |
|
|
class AudioOutputDeviceJack : public AudioOutputDevice { |
45 |
|
|
public: |
46 |
|
|
AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters); |
47 |
schoenebeck |
374 |
virtual ~AudioOutputDeviceJack(); |
48 |
schoenebeck |
200 |
|
49 |
schoenebeck |
226 |
/** |
50 |
|
|
* Audio channel implementation for the JACK audio driver. |
51 |
schoenebeck |
221 |
*/ |
52 |
schoenebeck |
226 |
class AudioChannelJack : public AudioChannel { |
53 |
schoenebeck |
200 |
public: |
54 |
schoenebeck |
226 |
/** Audio Channel Parameter 'NAME' |
55 |
|
|
* |
56 |
|
|
* Used to assign an arbitrary name to an audio channel. |
57 |
|
|
*/ |
58 |
|
|
class ParameterName : public AudioChannel::ParameterName { |
59 |
|
|
public: |
60 |
|
|
ParameterName(AudioChannelJack* pChannel); |
61 |
|
|
virtual void OnSetValue(String s); |
62 |
|
|
protected: |
63 |
|
|
AudioChannelJack* pChannel; |
64 |
|
|
}; |
65 |
|
|
|
66 |
|
|
/** Audio Channel Parameter 'JACK_BINDINGS' |
67 |
|
|
* |
68 |
|
|
* Used to connect to other JACK clients. |
69 |
|
|
*/ |
70 |
|
|
class ParameterJackBindings : public DeviceRuntimeParameterStrings { |
71 |
|
|
public: |
72 |
|
|
ParameterJackBindings(AudioChannelJack* pChannel); |
73 |
|
|
virtual String Description(); |
74 |
|
|
virtual bool Fix(); |
75 |
|
|
virtual std::vector<String> PossibilitiesAsString(); |
76 |
|
|
virtual void OnSetValue(std::vector<String> vS); |
77 |
|
|
static String Name(); |
78 |
|
|
protected: |
79 |
schoenebeck |
483 |
AudioChannelJack* pChannel; |
80 |
|
|
std::vector<String> Bindings; |
81 |
schoenebeck |
226 |
}; |
82 |
schoenebeck |
200 |
protected: |
83 |
schoenebeck |
226 |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
84 |
|
|
~AudioChannelJack(); |
85 |
|
|
friend class AudioOutputDeviceJack; |
86 |
|
|
private: |
87 |
|
|
AudioOutputDeviceJack* pDevice; |
88 |
|
|
jack_port_t* hJackPort; |
89 |
|
|
uint ChannelNr; |
90 |
|
|
|
91 |
|
|
float* CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
92 |
schoenebeck |
200 |
}; |
93 |
|
|
|
94 |
schoenebeck |
374 |
/** Audio Device Parameter 'NAME' |
95 |
|
|
* |
96 |
|
|
* Used to assign an arbitrary name to the JACK client of this |
97 |
|
|
* audio device. |
98 |
|
|
*/ |
99 |
|
|
class ParameterName : public DeviceCreationParameterString { |
100 |
|
|
public: |
101 |
|
|
ParameterName(); |
102 |
schoenebeck |
880 |
ParameterName(String s) throw (Exception); |
103 |
schoenebeck |
374 |
virtual String Description(); |
104 |
|
|
virtual bool Fix(); |
105 |
|
|
virtual bool Mandatory(); |
106 |
|
|
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters(); |
107 |
|
|
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters); |
108 |
|
|
virtual optional<String> DefaultAsString(std::map<String,String> Parameters); |
109 |
schoenebeck |
880 |
virtual void OnSetValue(String s) throw (Exception); |
110 |
schoenebeck |
374 |
static String Name(); |
111 |
|
|
}; |
112 |
|
|
|
113 |
schoenebeck |
200 |
// derived abstract methods from class 'AudioOutputDevice' |
114 |
|
|
virtual void Play(); |
115 |
|
|
virtual bool IsPlaying(); |
116 |
|
|
virtual void Stop(); |
117 |
|
|
virtual uint MaxSamplesPerCycle(); |
118 |
|
|
virtual uint SampleRate(); |
119 |
schoenebeck |
226 |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
120 |
schoenebeck |
200 |
|
121 |
schoenebeck |
226 |
|
122 |
schoenebeck |
200 |
static String Name(); |
123 |
|
|
|
124 |
|
|
virtual String Driver(); |
125 |
|
|
|
126 |
|
|
static String Description(); |
127 |
|
|
static String Version(); |
128 |
|
|
|
129 |
|
|
int Process(uint Samples); // FIXME: should be private |
130 |
|
|
protected: |
131 |
|
|
AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0); |
132 |
|
|
private: |
133 |
schoenebeck |
226 |
ConditionServer csIsPlaying; |
134 |
|
|
uint uiMaxSamplesPerCycle; |
135 |
|
|
jack_client_t* hJackClient; |
136 |
schoenebeck |
200 |
}; |
137 |
|
|
|
138 |
|
|
// Callback functions for the libjack API |
139 |
|
|
int __libjack_process_callback(jack_nframes_t nframes, void* arg); |
140 |
|
|
void __libjack_shutdown_callback(void* arg); |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
#endif // HAVE_JACK |
144 |
|
|
#endif // __LS_AUDIOOUTPUTDEVICEJACK_H__ |