1 |
/*************************************************************************** |
2 |
* * |
3 |
* Copyright (C) 2008 Andreas Persson * |
4 |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
7 |
* the Free Software Foundation; either version 2 of the License, or * |
8 |
* (at your option) any later version. * |
9 |
* * |
10 |
* This program is distributed in the hope that it will be useful, * |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
* GNU General Public License for more details. * |
14 |
* * |
15 |
* You should have received a copy of the GNU General Public License * |
16 |
* along with this program; if not, write to the Free Software * |
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * |
18 |
* MA 02110-1301 USA * |
19 |
***************************************************************************/ |
20 |
|
21 |
#include "AudioOutputDevicePlugin.h" |
22 |
|
23 |
namespace LinuxSampler { |
24 |
|
25 |
// *************** AudioChannelPlugin *************** |
26 |
// * |
27 |
|
28 |
AudioOutputDevicePlugin::AudioChannelPlugin::AudioChannelPlugin(uint ChannelNr) : |
29 |
AudioChannel(ChannelNr, 0, 0) { |
30 |
} |
31 |
|
32 |
|
33 |
// *************** ParameterFragmentSize *************** |
34 |
// * |
35 |
|
36 |
AudioOutputDevicePlugin::ParameterFragmentSize::ParameterFragmentSize() : DeviceCreationParameterInt() { |
37 |
InitWithDefault(); |
38 |
} |
39 |
|
40 |
AudioOutputDevicePlugin::ParameterFragmentSize::ParameterFragmentSize(String s) throw (Exception) : DeviceCreationParameterInt(s) { |
41 |
} |
42 |
|
43 |
String AudioOutputDevicePlugin::ParameterFragmentSize::Description() { |
44 |
return "Size of each buffer fragment"; |
45 |
} |
46 |
|
47 |
bool AudioOutputDevicePlugin::ParameterFragmentSize::Fix() { |
48 |
return true; |
49 |
} |
50 |
|
51 |
bool AudioOutputDevicePlugin::ParameterFragmentSize::Mandatory() { |
52 |
return true; |
53 |
} |
54 |
|
55 |
std::map<String,DeviceCreationParameter*> AudioOutputDevicePlugin::ParameterFragmentSize::DependsAsParameters() { |
56 |
return std::map<String,DeviceCreationParameter*>(); // no dependencies |
57 |
} |
58 |
|
59 |
optional<int> AudioOutputDevicePlugin::ParameterFragmentSize::DefaultAsInt(std::map<String,String> Parameters) { |
60 |
return optional<int>::nothing; |
61 |
} |
62 |
|
63 |
optional<int> AudioOutputDevicePlugin::ParameterFragmentSize::RangeMinAsInt(std::map<String,String> Parameters) { |
64 |
return optional<int>::nothing; |
65 |
} |
66 |
|
67 |
optional<int> AudioOutputDevicePlugin::ParameterFragmentSize::RangeMaxAsInt(std::map<String,String> Parameters) { |
68 |
return optional<int>::nothing; |
69 |
} |
70 |
|
71 |
std::vector<int> AudioOutputDevicePlugin::ParameterFragmentSize::PossibilitiesAsInt(std::map<String,String> Parameters) { |
72 |
return std::vector<int>(); |
73 |
} |
74 |
|
75 |
void AudioOutputDevicePlugin::ParameterFragmentSize::OnSetValue(int i) throw (Exception) { |
76 |
// not posssible, as parameter is fix |
77 |
} |
78 |
|
79 |
String AudioOutputDevicePlugin::ParameterFragmentSize::Name() { |
80 |
return "FRAGMENTSIZE"; |
81 |
} |
82 |
|
83 |
|
84 |
|
85 |
// *************** AudioOutputDevicePlugin *************** |
86 |
// * |
87 |
|
88 |
AudioOutputDevicePlugin::AudioOutputDevicePlugin(std::map<String, DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) { |
89 |
uiSampleRate = dynamic_cast<DeviceCreationParameterInt*>( |
90 |
Parameters["SAMPLERATE"])->ValueAsInt(); |
91 |
uiMaxSamplesPerCycle = dynamic_cast<DeviceCreationParameterInt*>( |
92 |
Parameters["FRAGMENTSIZE"])->ValueAsInt(); |
93 |
|
94 |
// create audio channels |
95 |
AcquireChannels(dynamic_cast<DeviceCreationParameterInt*>( |
96 |
Parameters["CHANNELS"])->ValueAsInt()); |
97 |
} |
98 |
|
99 |
void AudioOutputDevicePlugin::Play() { |
100 |
} |
101 |
|
102 |
bool AudioOutputDevicePlugin::IsPlaying() { |
103 |
return true; |
104 |
} |
105 |
|
106 |
void AudioOutputDevicePlugin::Stop() { |
107 |
} |
108 |
|
109 |
uint AudioOutputDevicePlugin::MaxSamplesPerCycle() { |
110 |
return uiMaxSamplesPerCycle; |
111 |
} |
112 |
|
113 |
uint AudioOutputDevicePlugin::SampleRate() { |
114 |
return uiSampleRate; |
115 |
} |
116 |
|
117 |
String AudioOutputDevicePlugin::Driver() { |
118 |
return Name(); |
119 |
} |
120 |
|
121 |
String AudioOutputDevicePlugin::Name() { |
122 |
return "Plugin"; |
123 |
} |
124 |
|
125 |
String AudioOutputDevicePlugin::Version() { |
126 |
String s = "$Revision: 1.1 $"; |
127 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
128 |
} |
129 |
|
130 |
String AudioOutputDevicePlugin::Description() { |
131 |
return Name(); |
132 |
} |
133 |
|
134 |
AudioChannel* AudioOutputDevicePlugin::CreateChannel(uint ChannelNr) { |
135 |
return new AudioChannelPlugin(ChannelNr); |
136 |
} |
137 |
} |