/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDevicePlugin.cpp
ViewVC logotype

Annotation of /linuxsampler/trunk/src/drivers/audio/AudioOutputDevicePlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1934 - (hide annotations) (download)
Sun Jul 12 10:35:55 2009 UTC (14 years, 9 months ago) by schoenebeck
File size: 5234 byte(s)
* bugfix: don't allow to create or destroy audio devices and MIDI devices
  of host plugin implementations (e.g VST, AU, DSSI, LV2) on their own,
  as they only exist in the context of the plugin instance and would
  otherwise crash the application

1 persson 1777 /***************************************************************************
2     * *
3 schoenebeck 1934 * Copyright (C) 2008 - 2009 Andreas Persson *
4 persson 1777 * *
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 schoenebeck 1934 String s = "$Revision: 1.2 $";
127 persson 1777 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 schoenebeck 1934
138     bool AudioOutputDevicePlugin::isAutonomousDevice() {
139     return false;
140     }
141    
142     bool AudioOutputDevicePlugin::isAutonomousDriver() {
143     return false;
144     }
145 persson 1777 }

  ViewVC Help
Powered by ViewVC