Skip to content

Commit 08ca988

Browse files
Matthieu Hodgkinsonigorkorsukov
authored andcommitted
virtual AudioResourceType IAudioPluginMetaReader::metaType() const = 0;
1 parent 6d93d82 commit 08ca988

File tree

7 files changed

+25
-9
lines changed

7 files changed

+25
-9
lines changed

src/framework/audioplugins/iaudiopluginmetareader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class IAudioPluginMetaReader
3232
public:
3333
virtual ~IAudioPluginMetaReader() = default;
3434

35+
virtual audio::AudioResourceType metaType() const = 0;
3536
virtual bool canReadMeta(const io::path_t& pluginPath) const = 0;
3637
virtual RetVal<audio::AudioResourceMetaList> readMeta(const io::path_t& pluginPath) const = 0;
3738
};

src/framework/audioplugins/internal/registeraudiopluginsscenario.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,7 @@ Ret RegisterAudioPluginsScenario::registerFailedPlugin(const io::path_t& pluginP
156156
AudioPluginInfo info;
157157
info.meta.id = io::completeBasename(pluginPath).toStdString();
158158

159-
std::string ext = io::suffix(pluginPath);
160-
if (ext.find("vst") != std::string::npos) {
161-
info.meta.type = AudioResourceType::VstPlugin;
162-
}
163-
159+
info.meta.type = metaType(pluginPath);
164160
info.path = pluginPath;
165161
info.enabled = false;
166162
info.errorCode = failCode;
@@ -179,3 +175,9 @@ IAudioPluginMetaReaderPtr RegisterAudioPluginsScenario::metaReader(const io::pat
179175

180176
return nullptr;
181177
}
178+
179+
audio::AudioResourceType RegisterAudioPluginsScenario::metaType(const io::path_t& pluginPath) const
180+
{
181+
const IAudioPluginMetaReaderPtr reader = metaReader(pluginPath);
182+
return reader ? reader->metaType() : audio::AudioResourceType::Undefined;
183+
}

src/framework/audioplugins/internal/registeraudiopluginsscenario.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class RegisterAudioPluginsScenario : public IRegisterAudioPluginsScenario, publi
5757
private:
5858
void processPluginsRegistration(const io::paths_t& pluginPaths);
5959
IAudioPluginMetaReaderPtr metaReader(const io::path_t& pluginPath) const;
60+
audio::AudioResourceType metaType(const io::path_t& pluginPath) const;
6061

6162
Progress m_progress;
6263
bool m_aborted = false;

src/framework/audioplugins/tests/mocks/audiopluginmetareadermock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace muse::audioplugins {
2929
class AudioPluginMetaReaderMock : public IAudioPluginMetaReader
3030
{
3131
public:
32+
MOCK_METHOD(audio::AudioResourceType, metaType, (), (const, override));
3233
MOCK_METHOD(bool, canReadMeta, (const io::path_t&), (const, override));
3334
MOCK_METHOD(RetVal<audio::AudioResourceMetaList>, readMeta, (const io::path_t&), (const, override));
3435
};

src/framework/audioplugins/tests/registeraudiopluginsscenariotest.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class AudioPlugins_RegisterAudioPluginsScenarioTest : public ::testing::Test
5858
m_knownPlugins = std::make_shared<KnownAudioPluginsRegisterMock>();
5959
m_scanners = { std::make_shared<AudioPluginsScannerMock>() };
6060
m_metaReaderRegister = std::make_shared<AudioPluginMetaReaderRegisterMock>();
61-
m_metaReaders = { std::make_shared<AudioPluginMetaReaderMock>() };
61+
62+
const auto metaReaderMock = std::make_shared<AudioPluginMetaReaderMock>();
63+
m_metaReaders = { metaReaderMock };
6264

6365
m_scenario->globalConfiguration.set(m_globalConfiguration);
6466
m_scenario->interactive.set(m_interactive);
@@ -75,6 +77,12 @@ class AudioPlugins_RegisterAudioPluginsScenarioTest : public ::testing::Test
7577

7678
ON_CALL(*m_metaReaderRegister, readers())
7779
.WillByDefault(ReturnRef(m_metaReaders));
80+
81+
ON_CALL(*metaReaderMock, metaType())
82+
.WillByDefault(Return(AudioResourceType::VstPlugin));
83+
84+
ON_CALL(*metaReaderMock, canReadMeta(_))
85+
.WillByDefault(Return(true));
7886
}
7987

8088
std::shared_ptr<RegisterAudioPluginsScenario> m_scenario;
@@ -256,9 +264,6 @@ TEST_F(AudioPlugins_RegisterAudioPluginsScenarioTest, RegisterPlugin)
256264
AudioPluginMetaReaderMock* mock = dynamic_cast<AudioPluginMetaReaderMock*>(m_metaReaders[0].get());
257265
ASSERT_TRUE(mock);
258266

259-
ON_CALL(*mock, canReadMeta(pluginPath))
260-
.WillByDefault(Return(true));
261-
262267
ON_CALL(*mock, readMeta(pluginPath))
263268
.WillByDefault(Return(RetVal<AudioResourceMetaList>::make_ok(metaList)));
264269

src/framework/vst/internal/vstpluginmetareader.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ using namespace muse;
3131
using namespace muse::audio;
3232
using namespace muse::vst;
3333

34+
audio::AudioResourceType VstPluginMetaReader::metaType() const
35+
{
36+
return audio::AudioResourceType::VstPlugin;
37+
}
38+
3439
bool VstPluginMetaReader::canReadMeta(const io::path_t& pluginPath) const
3540
{
3641
return io::suffix(pluginPath) == VST3_PACKAGE_EXTENSION;

src/framework/vst/internal/vstpluginmetareader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace muse::vst {
2929
class VstPluginMetaReader : public audioplugins::IAudioPluginMetaReader
3030
{
3131
public:
32+
audio::AudioResourceType metaType() const override;
3233
bool canReadMeta(const io::path_t& pluginPath) const override;
3334
RetVal<muse::audio::AudioResourceMetaList> readMeta(const io::path_t& pluginPath) const override;
3435
};

0 commit comments

Comments
 (0)