Skip to content

Commit 03e365f

Browse files
committed
Add support for built-in file sources
1 parent 50793b4 commit 03e365f

2 files changed

Lines changed: 67 additions & 3 deletions

File tree

Source/Processors/FileReader/FileReader.cpp

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ FileReader::FileReader()
4949

5050
setEnabledState (false);
5151

52+
//Load pluIn file Sources
5253
const int numFileSources = AccessClass::getPluginManager()->getNumFileSources();
5354
for (int i = 0; i < numFileSources; ++i)
5455
{
@@ -63,6 +64,21 @@ FileReader::FileReader()
6364
supportedExtensions.set (extensions[j].toLowerCase(), i + 1);
6465
}
6566
}
67+
68+
//Load Built-in file Sources
69+
const int numBuiltInFileSources = getNumBuiltInFileSources();
70+
for (int i = 0; i < numBuiltInFileSources; ++i)
71+
{
72+
StringArray extensions;
73+
extensions.addTokens(getBuiltInFileSourceExtensions(i), ";", "\"");
74+
75+
const int numExtensions = extensions.size();
76+
for (int j = 0; j < numExtensions; ++j)
77+
{
78+
supportedExtensions.set(extensions[j].toLowerCase(), i + numFileSources + 1);
79+
}
80+
81+
}
6682
}
6783

6884

@@ -198,9 +214,24 @@ bool FileReader::setFile (String fullpath)
198214

199215
if (isExtensionSupported)
200216
{
201-
const int index = supportedExtensions[ext] - 1;
202-
Plugin::FileSourceInfo sourceInfo = AccessClass::getPluginManager()->getFileSourceInfo (index);
203-
input = sourceInfo.creator();
217+
const int index = supportedExtensions[ext] -1 ;
218+
const int numPluginFileSources = AccessClass::getPluginManager()->getNumFileSources();
219+
220+
if (index < numPluginFileSources)
221+
{
222+
Plugin::FileSourceInfo sourceInfo = AccessClass::getPluginManager()->getFileSourceInfo(index);
223+
input = sourceInfo.creator();
224+
}
225+
else
226+
{
227+
input = createBuiltInFileSource(index - numPluginFileSources);
228+
}
229+
if (!input)
230+
{
231+
std::cerr << "Error creating file source for extension " << ext << std::endl;
232+
return false;
233+
}
234+
204235
}
205236
else
206237
{
@@ -419,3 +450,29 @@ void FileReader::readAndFillBufferCache(HeapBlock<int16> &cacheBuffer)
419450
samplesRead += samplesToRead;
420451
}
421452
}
453+
454+
455+
//Built-In
456+
457+
int FileReader::getNumBuiltInFileSources() const
458+
{
459+
return 0;
460+
}
461+
462+
String FileReader::getBuiltInFileSourceExtensions(int index) const
463+
{
464+
switch (index)
465+
{
466+
default:
467+
return "";
468+
}
469+
}
470+
471+
FileSource* FileReader::createBuiltInFileSource(int index) const
472+
{
473+
switch (index)
474+
{
475+
default:
476+
return nullptr;
477+
}
478+
}

Source/Processors/FileReader/FileReader.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ class FileReader : public GenericProcessor,
125125
*/
126126
void readAndFillBufferCache(HeapBlock<int16> &cacheBuffer);
127127

128+
//Methods for built-in file sources
129+
int getNumBuiltInFileSources() const;
130+
131+
String getBuiltInFileSourceExtensions(int index) const;
132+
133+
FileSource* createBuiltInFileSource(int index) const;
134+
128135

129136
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FileReader);
130137
};

0 commit comments

Comments
 (0)