support for NyquistIO loading from buffer (if the decoder supports it)

adpcm
Dimitri Diakopoulos 11 years ago
parent 9961412bdf
commit 4c5c8e1737

@ -64,6 +64,7 @@ public:
~NyquistIO(); ~NyquistIO();
int Load(AudioData * data, const std::string & path); int Load(AudioData * data, const std::string & path);
int Load(AudioData *data, std::string extension, std::vector<uint8_t> & buffer);
bool IsFileSupported(const std::string path) const; bool IsFileSupported(const std::string path) const;

@ -74,6 +74,35 @@ int NyquistIO::Load(AudioData * data, const std::string & path)
return IOError::UnknownError; 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 bool NyquistIO::IsFileSupported(const std::string path) const
{ {
auto fileExtension = ParsePathForExtension(path); auto fileExtension = ParsePathForExtension(path);

Loading…
Cancel
Save