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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1934 - (hide annotations) (download) (as text)
Sun Jul 12 10:35:55 2009 UTC (14 years, 9 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4563 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     #ifndef LS_AUDIOOUTPUTDEVICEPLUGIN_H
22     #define LS_AUDIOOUTPUTDEVICEPLUGIN_H
23    
24     #include "AudioOutputDevice.h"
25    
26     namespace LinuxSampler {
27    
28     /** Plugin audio output driver
29     *
30     * Implements audio output when LinuxSampler is running as a
31     * plugin.
32     *
33     * The plugin implementation is given access to the Render
34     * function, which should be called to render audio.
35     */
36     class AudioOutputDevicePlugin : public AudioOutputDevice {
37     public:
38     AudioOutputDevicePlugin(std::map<String,DeviceCreationParameter*> Parameters);
39    
40     /**
41     * Audio channel implementation for the plugin audio driver.
42     */
43     class AudioChannelPlugin : public AudioChannel {
44     protected:
45     AudioChannelPlugin(uint ChannelNr);
46    
47     friend class AudioOutputDevicePlugin;
48     };
49    
50     /**
51 iliev 1907 * Device Parameter 'CHANNELS'
52     */
53     class ParameterChannelsPlugin : public ParameterChannels {
54     public:
55     ParameterChannelsPlugin() : ParameterChannels() { }
56     ParameterChannelsPlugin(String s) : ParameterChannels(s) { }
57     virtual bool Fix() { return true; }
58     };
59    
60     /**
61 persson 1777 * Device Parameter 'FRAGMENTSIZE'
62     *
63     * Used to set the audio fragment size / period size.
64     */
65     class ParameterFragmentSize : public DeviceCreationParameterInt {
66     public:
67     ParameterFragmentSize();
68     ParameterFragmentSize(String s) throw (Exception);
69     String Description();
70     bool Fix();
71     bool Mandatory();
72     std::map<String,DeviceCreationParameter*> DependsAsParameters();
73     optional<int> DefaultAsInt(std::map<String,String> Parameters);
74     optional<int> RangeMinAsInt(std::map<String,String> Parameters);
75     optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
76     std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
77     void OnSetValue(int i) throw (Exception);
78     static String Name();
79     };
80    
81     // derived abstract methods from class 'AudioOutputDevice'
82     void Play();
83     bool IsPlaying();
84     void Stop();
85     uint MaxSamplesPerCycle();
86     uint SampleRate();
87     String Driver();
88     AudioChannel* CreateChannel(uint ChannelNr);
89 schoenebeck 1934 bool isAutonomousDevice();
90 persson 1777 static String Name();
91     static String Version();
92     static String Description();
93 schoenebeck 1934 static bool isAutonomousDriver();
94 persson 1777
95     /**
96     * This should be called by the plugin implementation to let
97     * the engines render audio. The buffers where the data is
98     * rendered can be set with Channel(index)->getBuffer().
99     *
100     * @param Samples - number of sample points to be rendered
101     * @returns 0 on success or the last error return code of one
102     * engine
103     */
104     int Render(uint Samples) { return RenderAudio(Samples); }
105    
106     private:
107     uint uiSampleRate;
108     uint uiMaxSamplesPerCycle;
109     };
110     }
111    
112     #endif

  ViewVC Help
Powered by ViewVC