|
|
|
|
@ -74,6 +74,35 @@ int NyquistIO::Load(AudioData * data, const std::string & path)
|
|
|
|
|
return IOError::UnknownError;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NyquistIO::Load(AudioData *data, std::string extension, std::vector<uint8_t> & buffer)
|
|
|
|
|
{
|
|
|
|
|
if (decoderTable.find(extension) == decoderTable.end())
|
|
|
|
|
{
|
|
|
|
|
return IOError::ExtensionNotSupported;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (decoderTable.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
auto decoder = GetDecoderForExtension(extension);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return decoder->LoadFromBuffer(data, buffer);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception e)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << "Caught fatal exception: " << e.what() << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return IOError::NoDecodersLoaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Should never be reached
|
|
|
|
|
return IOError::UnknownError;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NyquistIO::IsFileSupported(const std::string path) const
|
|
|
|
|
{
|
|
|
|
|
auto fileExtension = ParsePathForExtension(path);
|
|
|
|
|
|