Skip to content

Commit b01351d

Browse files
committed
[audio] split audio::AudioResourceId off as independent alias with conversion helper
audio::AudioResourceId is now an independent std::string alias (was a re-export of muse::audioplugins::PluginResourceId). Add toAudioResourceId / toAudioResourceIdList helpers in audio/common/ audiotypes.h - documenting the seam between plugin-identity and audio-pipeline-resource roles. One-directional today: both aliases bottom out at std::string so the conversion is one-to-one; the helper becomes a real bridge if either side later gains a strong wrapper. A static_assert in audioresourcetypes_tests.cpp pins the underlying- std::string contract; a new ToAudioResourceIdRoundTrips test exercises the helper end-to-end. VST and audio-engine resolvers stay on audio::AudioResourceId unchanged - structurally pinned by abstractfxresolver and keeps the Audacity surface unaffected.
1 parent f776762 commit b01351d

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

framework/audio/common/audiotypes.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,23 @@ struct AudioEngineConfig {
171171
using AudioSourceName = std::string;
172172
using AudioUnitConfig = std::map<std::string, std::string>;
173173

174-
using AudioResourceId = muse::audioplugins::PluginResourceId;
175-
using AudioResourceIdList = muse::audioplugins::PluginResourceIdList;
174+
// AudioResourceId addresses a resource within the audio pipeline;
175+
// audioplugins::PluginResourceId is a plugin's identity in the cache.
176+
// Both alias std::string today and convert one-to-one - the seam is
177+
// documentary so the two roles do not drift.
178+
using AudioResourceId = std::string;
179+
using AudioResourceIdList = std::vector<AudioResourceId>;
180+
181+
inline AudioResourceId toAudioResourceId(const muse::audioplugins::PluginResourceId& id)
182+
{
183+
return id;
184+
}
185+
186+
inline AudioResourceIdList toAudioResourceIdList(const muse::audioplugins::PluginResourceIdList& ids)
187+
{
188+
return AudioResourceIdList(ids.begin(), ids.end());
189+
}
190+
176191
using AudioResourceVendor = muse::audioplugins::AudioResourceVendor;
177192
using AudioResourceAttributes = muse::audioplugins::AudioResourceAttributes;
178193
using AudioResourceMeta = muse::audioplugins::AudioResourceMeta;

framework/audio/tests/audioresourcetypes_tests.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131

3232
using namespace muse;
3333

34+
// Document the underlying types behind the named seam between the audio and
35+
// audioplugins resource ids. If either becomes a strong wrapper later, this
36+
// assert fires and the migration is deliberate.
37+
static_assert(std::is_same_v<audio::AudioResourceId, std::string>);
38+
static_assert(std::is_same_v<audioplugins::PluginResourceId, std::string>);
39+
3440
// The on-disk plugin cache stores AudioResourceMeta::type as the canonical
3541
// wire string. These strings must stay stable across releases — caches written
3642
// by older builds must remain readable. Each plugin module owns its own copy
@@ -89,3 +95,23 @@ TEST(Audio_AudioResourceTypes, IsResourceTypeHelper)
8995
EXPECT_FALSE(audio::isResourceType(meta, audio::AudioResourceType::VstPlugin));
9096
EXPECT_TRUE(audio::isResourceType(meta, audio::AudioResourceType::Undefined));
9197
}
98+
99+
// audio::toAudioResourceId is the documentary seam between the audioplugins
100+
// module's PluginResourceId and the audio module's AudioResourceId. Today
101+
// the conversion is one-to-one because both alias std::string; if either
102+
// side later gains a real wrapper, this round-trip becomes a real one and
103+
// this test is where it gets verified.
104+
TEST(Audio_AudioResourceTypes, ToAudioResourceIdRoundTrips)
105+
{
106+
const audioplugins::PluginResourceId plugId = "Muse Reverb";
107+
const audio::AudioResourceId audioId = audio::toAudioResourceId(plugId);
108+
EXPECT_EQ(audioId, plugId);
109+
EXPECT_EQ(audioId, "Muse Reverb");
110+
111+
const audioplugins::PluginResourceIdList plugIds = { "A", "B", "C" };
112+
const audio::AudioResourceIdList audioIds = audio::toAudioResourceIdList(plugIds);
113+
ASSERT_EQ(audioIds.size(), plugIds.size());
114+
for (size_t i = 0; i < plugIds.size(); ++i) {
115+
EXPECT_EQ(audioIds[i], plugIds[i]);
116+
}
117+
}

0 commit comments

Comments
 (0)