1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* * |
7 |
* This program is free software; you can redistribute it and/or modify * |
8 |
* it under the terms of the GNU General Public License as published by * |
9 |
* the Free Software Foundation; either version 2 of the License, or * |
10 |
* (at your option) any later version. * |
11 |
* * |
12 |
* This program is distributed in the hope that it will be useful, * |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 |
* GNU General Public License for more details. * |
16 |
* * |
17 |
* You should have received a copy of the GNU General Public License * |
18 |
* along with this program; if not, write to the Free Software * |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
20 |
* MA 02111-1307 USA * |
21 |
***************************************************************************/ |
22 |
|
23 |
#ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__ |
24 |
#define __LS_AUDIOOUTPUTDEVICEJACK_H__ |
25 |
|
26 |
#include "../../common/global.h" |
27 |
|
28 |
#if HAVE_JACK |
29 |
|
30 |
#include <vector> |
31 |
#include <sstream> |
32 |
#include <jack/jack.h> |
33 |
|
34 |
#include "AudioOutputDevice.h" |
35 |
#include "../../common/ConditionServer.h" |
36 |
|
37 |
namespace LinuxSampler { |
38 |
|
39 |
/** JACK audio output driver |
40 |
* |
41 |
* Implements audio output to the JACK Audio Connection Kit (JACK). |
42 |
*/ |
43 |
class AudioOutputDeviceJack : public AudioOutputDevice { |
44 |
public: |
45 |
AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters); |
46 |
~AudioOutputDeviceJack(); |
47 |
|
48 |
/** |
49 |
* Audio channel implementation for the JACK audio driver. |
50 |
*/ |
51 |
class AudioChannelJack : public AudioChannel { |
52 |
public: |
53 |
/** Audio Channel Parameter 'NAME' |
54 |
* |
55 |
* Used to assign an arbitrary name to an audio channel. |
56 |
*/ |
57 |
class ParameterName : public AudioChannel::ParameterName { |
58 |
public: |
59 |
ParameterName(AudioChannelJack* pChannel); |
60 |
virtual void OnSetValue(String s); |
61 |
protected: |
62 |
AudioChannelJack* pChannel; |
63 |
}; |
64 |
|
65 |
/** Audio Channel Parameter 'JACK_BINDINGS' |
66 |
* |
67 |
* Used to connect to other JACK clients. |
68 |
*/ |
69 |
class ParameterJackBindings : public DeviceRuntimeParameterStrings { |
70 |
public: |
71 |
ParameterJackBindings(AudioChannelJack* pChannel); |
72 |
virtual String Description(); |
73 |
virtual bool Fix(); |
74 |
virtual std::vector<String> PossibilitiesAsString(); |
75 |
virtual void OnSetValue(std::vector<String> vS); |
76 |
static String Name(); |
77 |
protected: |
78 |
AudioChannelJack* pChannel; |
79 |
}; |
80 |
protected: |
81 |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
82 |
~AudioChannelJack(); |
83 |
friend class AudioOutputDeviceJack; |
84 |
private: |
85 |
AudioOutputDeviceJack* pDevice; |
86 |
jack_port_t* hJackPort; |
87 |
uint ChannelNr; |
88 |
|
89 |
float* CreateJackPort(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
90 |
}; |
91 |
|
92 |
// derived abstract methods from class 'AudioOutputDevice' |
93 |
virtual void Play(); |
94 |
virtual bool IsPlaying(); |
95 |
virtual void Stop(); |
96 |
virtual uint MaxSamplesPerCycle(); |
97 |
virtual uint SampleRate(); |
98 |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
99 |
|
100 |
|
101 |
static String Name(); |
102 |
|
103 |
virtual String Driver(); |
104 |
|
105 |
static String Description(); |
106 |
static String Version(); |
107 |
|
108 |
int Process(uint Samples); // FIXME: should be private |
109 |
protected: |
110 |
AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0); |
111 |
private: |
112 |
ConditionServer csIsPlaying; |
113 |
uint uiMaxSamplesPerCycle; |
114 |
jack_client_t* hJackClient; |
115 |
}; |
116 |
|
117 |
// Callback functions for the libjack API |
118 |
int __libjack_process_callback(jack_nframes_t nframes, void* arg); |
119 |
void __libjack_shutdown_callback(void* arg); |
120 |
} |
121 |
|
122 |
#endif // HAVE_JACK |
123 |
#endif // __LS_AUDIOOUTPUTDEVICEJACK_H__ |