00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "vstcomponent.h"
00037
00038 namespace Steinberg {
00039 namespace Vst {
00040
00041
00042
00043
00044 Bus::Bus (const TChar* _name, BusType _busType, int32 _flags)
00045 : busType (_busType)
00046 , name (_name)
00047 , flags (_flags)
00048 , active (false)
00049 {}
00050
00051
00052 bool Bus::getInfo (BusInfo& info)
00053 {
00054 name.copyTo (info.name, USTRINGSIZE (info.name));
00055 info.busType = busType;
00056 info.flags = flags;
00057 return true;
00058 }
00059
00060
00061
00062
00063 EventBus::EventBus (const TChar* name, BusType busType, int32 flags, int32 channelCount)
00064 : Bus (name, busType, flags)
00065 , channelCount (channelCount)
00066 {}
00067
00068
00069 bool EventBus::getInfo (BusInfo& info)
00070 {
00071 info.channelCount = channelCount;
00072 return Bus::getInfo (info);
00073 }
00074
00075
00076
00077
00078
00079 BusList::BusList (MediaType type, BusDirection dir)
00080 : type (type)
00081 , direction (dir)
00082 {}
00083
00084
00085
00086
00087
00088 Component::Component ()
00089 : audioInputs (kAudio, kInput)
00090 , audioOutputs (kAudio, kOutput)
00091 , eventInputs (kEvent, kInput)
00092 , eventOutputs (kEvent, kOutput)
00093 {}
00094
00095
00096 tresult PLUGIN_API Component::queryInterface (const char* iid, void** obj)
00097 {
00098 QUERY_INTERFACE (iid, obj, IComponent::iid, IComponent)
00099 return ComponentBase::queryInterface (iid, obj);
00100 }
00101
00102
00103 tresult PLUGIN_API Component::initialize (FUnknown* context)
00104 {
00105 return ComponentBase::initialize (context);
00106 }
00107
00108
00109 tresult PLUGIN_API Component::terminate ()
00110 {
00111
00112 removeAllBusses ();
00113
00114 return ComponentBase::terminate ();
00115 }
00116
00117
00118 BusList* Component::getBusList (MediaType type, BusDirection dir)
00119 {
00120 if (type == kAudio)
00121 return dir == kInput ? &audioInputs : &audioOutputs;
00122 else if (type == kEvent)
00123 return dir == kInput ? &eventInputs : &eventOutputs;
00124 return 0;
00125 }
00126
00127
00128 tresult Component::removeAudioBusses ()
00129 {
00130 audioInputs.removeAll ();
00131 audioOutputs.removeAll ();
00132
00133 return kResultOk;
00134 }
00135
00136
00137 tresult Component::removeEventBusses ()
00138 {
00139 eventInputs.removeAll ();
00140 eventOutputs.removeAll ();
00141
00142 return kResultOk;
00143 }
00144
00145
00146 tresult Component::removeAllBusses ()
00147 {
00148 removeAudioBusses ();
00149 removeEventBusses ();
00150
00151 return kResultOk;
00152 }
00153
00154
00155 tresult PLUGIN_API Component::getControllerClassId (TUID classID)
00156 {
00157 if (controllerClass.isValid ())
00158 {
00159 controllerClass.toTUID (classID);
00160 return kResultTrue;
00161 }
00162 return kResultFalse;
00163 }
00164
00165
00166 tresult PLUGIN_API Component::setIoMode (IoMode mode)
00167 {
00168 return kNotImplemented;
00169 }
00170
00171
00172 int32 PLUGIN_API Component::getBusCount (MediaType type, BusDirection dir)
00173 {
00174 BusList* busList = getBusList (type, dir);
00175 return busList ? busList->total () : 0;
00176 }
00177
00178
00179 tresult PLUGIN_API Component::getBusInfo (MediaType type, BusDirection dir, int32 index, BusInfo& info)
00180 {
00181 BusList* busList = getBusList (type, dir);
00182 Bus* bus = busList ? (Bus*)busList->at (index) : 0;
00183 if (bus)
00184 {
00185 info.mediaType = type;
00186 info.direction = dir;
00187 if (bus->getInfo (info))
00188 return kResultTrue;
00189 }
00190 return kResultFalse;
00191 }
00192
00193
00194 tresult PLUGIN_API Component::getRoutingInfo (RoutingInfo& inInfo, RoutingInfo& outInfo)
00195 {
00196 return kNotImplemented;
00197 }
00198
00199
00200 tresult PLUGIN_API Component::activateBus (MediaType type, BusDirection dir, int32 index, TBool state)
00201 {
00202 BusList* busList = getBusList (type, dir);
00203 Bus* bus = busList ? (Bus*)busList->at (index) : 0;
00204 if (bus)
00205 {
00206 bus->setActive (state);
00207 return kResultTrue;
00208 }
00209 return kResultFalse;
00210 }
00211
00212
00213 tresult PLUGIN_API Component::setActive (TBool state)
00214 {
00215 return kResultOk;
00216 }
00217
00218
00219 tresult PLUGIN_API Component::setState (IBStream* state)
00220 {
00221 return kNotImplemented;
00222 }
00223
00224
00225 tresult PLUGIN_API Component::getState (IBStream* state)
00226 {
00227 return kNotImplemented;
00228 }
00229
00230 }
00231 }