2 * Copyright 2012, Gerasim Troeglazov (3dEyes**), 3dEyes@gmail.com.
4 * Distributed under the terms of the MIT License.
9 #include <FindDirectory.h>
10 #include <PathFinder.h>
11 #include <StringList.h>
16 extern "C" _EXPORT BMediaAddOn
* make_media_addon(image_id image
)
18 return new VSTAddOn(image
);
21 VSTAddOn::VSTAddOn(image_id image
)
25 fPluginsList
.MakeEmpty();
29 BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY
,
30 "media/vstplugins/", B_FIND_PATH_EXISTING_ONLY
, folders
);
32 for (int32 i
= 0; i
< folders
.CountStrings(); i
++)
33 ScanPluginsFolder(folders
.StringAt(i
).String());
42 VSTAddOn::InitCheck(const char** text
)
48 VSTAddOn::CountFlavors()
50 return fPluginsList
.CountItems();
54 VSTAddOn::GetFlavorAt(int32 idx
, const flavor_info
** info
)
56 if (idx
< 0 || idx
>= fPluginsList
.CountItems())
59 VSTPlugin
*plugin
= (VSTPlugin
*)fPluginsList
.ItemAt(idx
);
61 flavor_info
*f_info
= new flavor_info
;
62 f_info
->internal_id
= idx
;
63 f_info
->kinds
= B_BUFFER_CONSUMER
| B_BUFFER_PRODUCER
| B_CONTROLLABLE
;
64 f_info
->possible_count
= 0;
65 f_info
->flavor_flags
= 0;
66 f_info
->name
= (char *)plugin
->ModuleName();
67 f_info
->info
= (char *)plugin
->Product();
69 media_format
*format
= new media_format
;
70 format
->type
= B_MEDIA_RAW_AUDIO
;
71 format
->u
.raw_audio
= media_raw_audio_format::wildcard
;
72 format
->u
.raw_audio
.format
= media_raw_audio_format::B_AUDIO_FLOAT
;
74 f_info
->in_format_count
= 1;
75 f_info
->in_formats
= format
;
77 format
= new media_format
;
78 format
->type
= B_MEDIA_RAW_AUDIO
;
79 format
->u
.raw_audio
= media_raw_audio_format::wildcard
;
80 format
->u
.raw_audio
.format
= media_raw_audio_format::B_AUDIO_FLOAT
;
82 f_info
->out_format_count
= 1;
83 f_info
->out_formats
= format
;
91 VSTAddOn::InstantiateNodeFor(const flavor_info
* info
, BMessage
* config
,
94 VSTPlugin
* plugin
= (VSTPlugin
*)fPluginsList
.ItemAt(info
->internal_id
);
95 VSTNode
* node
= new VSTNode(this, plugin
->ModuleName(), plugin
->Path());
100 VSTAddOn::ScanPluginsFolder(const char* path
, bool make_dir
)
104 BDirectory
dir(path
);
105 if (dir
.InitCheck() != B_OK
) {
106 if (make_dir
== true)
107 create_directory(path
, 0755);
111 while(dir
.GetNextEntry(&ent
) == B_OK
) {
113 if (ent
.IsDirectory()) {
114 ScanPluginsFolder(p
.Path());
116 VSTPlugin
* plugin
= new VSTPlugin();
117 int ret
= plugin
->LoadModule(p
.Path());
119 plugin
->UnLoadModule();
120 fPluginsList
.AddItem(plugin
);
129 VSTAddOn::GetConfigurationFor(BMediaNode
* node
, BMessage
* message
)
135 VSTAddOn::WantsAutoStart()
141 VSTAddOn::AutoStart(int count
, BMediaNode
** node
, int32
* id
, bool* more
)