From 2ce69092405df11704a394448e2c4a1dcce0e557 Mon Sep 17 00:00:00 2001 From: Avaer Kazmer Date: Fri, 2 Mar 2018 03:27:14 -0800 Subject: [PATCH] Add move semantics to memory buffer decoders --- include/libnyquist/AudioDecoder.h | 6 +++--- include/libnyquist/CafDecoder.h | 4 ++-- include/libnyquist/FlacDecoder.h | 2 +- include/libnyquist/ModplugDecoder.h | 4 ++-- include/libnyquist/MusepackDecoder.h | 4 ++-- include/libnyquist/OpusDecoder.h | 2 +- include/libnyquist/VorbisDecoder.h | 4 ++-- include/libnyquist/WavDecoder.h | 2 +- include/libnyquist/WavPackDecoder.h | 2 +- src/AudioDecoder.cpp | 4 ++-- src/CafDecoder.cpp | 4 ++-- src/FlacDecoder.cpp | 6 +++--- src/ModplugDecoder.cpp | 4 ++-- src/MusepackDecoder.cpp | 6 +++--- src/OpusDecoder.cpp | 6 +++--- src/VorbisDecoder.cpp | 6 +++--- src/WavDecoder.cpp | 2 +- src/WavPackDecoder.cpp | 6 +++--- 18 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/libnyquist/AudioDecoder.h b/include/libnyquist/AudioDecoder.h index c49ef03..5264836 100644 --- a/include/libnyquist/AudioDecoder.h +++ b/include/libnyquist/AudioDecoder.h @@ -53,7 +53,7 @@ struct LoadBufferNotImplEx : public std::runtime_error struct BaseDecoder { virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) = 0; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) = 0; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) = 0; virtual std::vector GetSupportedFileExtensions() = 0; }; @@ -67,7 +67,7 @@ public: ~NyquistIO(); void Load(AudioData * data, const std::string & path); - void Load(AudioData *data, std::string extension, const std::vector & buffer); + void Load(AudioData *data, std::string extension, std::vector & buffer); bool IsFileSupported(const std::string path) const; @@ -88,4 +88,4 @@ private: } // end namespace nqr -#endif \ No newline at end of file +#endif diff --git a/include/libnyquist/CafDecoder.h b/include/libnyquist/CafDecoder.h index e2c0e93..bb68c5d 100644 --- a/include/libnyquist/CafDecoder.h +++ b/include/libnyquist/CafDecoder.h @@ -36,10 +36,10 @@ struct CAFDecoder : public nqr::BaseDecoder CAFDecoder() {}; virtual ~CAFDecoder() {}; virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; } // end namespace nqr -#endif \ No newline at end of file +#endif diff --git a/include/libnyquist/FlacDecoder.h b/include/libnyquist/FlacDecoder.h index 93e737a..c4274e2 100644 --- a/include/libnyquist/FlacDecoder.h +++ b/include/libnyquist/FlacDecoder.h @@ -56,7 +56,7 @@ struct FlacDecoder : public nqr::BaseDecoder FlacDecoder() {} virtual ~FlacDecoder() {} virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; diff --git a/include/libnyquist/ModplugDecoder.h b/include/libnyquist/ModplugDecoder.h index f0b152f..adf6fdb 100644 --- a/include/libnyquist/ModplugDecoder.h +++ b/include/libnyquist/ModplugDecoder.h @@ -36,10 +36,10 @@ struct ModplugDecoder : public nqr::BaseDecoder ModplugDecoder() {}; virtual ~ModplugDecoder() {}; virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; } // end namespace nqr -#endif \ No newline at end of file +#endif diff --git a/include/libnyquist/MusepackDecoder.h b/include/libnyquist/MusepackDecoder.h index 0f5f453..82a94eb 100644 --- a/include/libnyquist/MusepackDecoder.h +++ b/include/libnyquist/MusepackDecoder.h @@ -36,10 +36,10 @@ struct MusepackDecoder : public nqr::BaseDecoder MusepackDecoder() {}; virtual ~MusepackDecoder() {}; virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; } // end namespace nqr -#endif \ No newline at end of file +#endif diff --git a/include/libnyquist/OpusDecoder.h b/include/libnyquist/OpusDecoder.h index 2a40f1b..79f3de8 100644 --- a/include/libnyquist/OpusDecoder.h +++ b/include/libnyquist/OpusDecoder.h @@ -41,7 +41,7 @@ struct OpusDecoder : public nqr::BaseDecoder OpusDecoder() {} virtual ~OpusDecoder() {} virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; diff --git a/include/libnyquist/VorbisDecoder.h b/include/libnyquist/VorbisDecoder.h index 2f2ea47..ae6fb52 100644 --- a/include/libnyquist/VorbisDecoder.h +++ b/include/libnyquist/VorbisDecoder.h @@ -36,9 +36,9 @@ struct VorbisDecoder : public nqr::BaseDecoder VorbisDecoder() {} virtual ~VorbisDecoder() {} virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; } // end namespace nqr -#endif \ No newline at end of file +#endif diff --git a/include/libnyquist/WavDecoder.h b/include/libnyquist/WavDecoder.h index 536de42..1f765f8 100644 --- a/include/libnyquist/WavDecoder.h +++ b/include/libnyquist/WavDecoder.h @@ -173,7 +173,7 @@ struct WavDecoder : public nqr::BaseDecoder WavDecoder() {} virtual ~WavDecoder() {} virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; diff --git a/include/libnyquist/WavPackDecoder.h b/include/libnyquist/WavPackDecoder.h index 6503b65..cdb128f 100644 --- a/include/libnyquist/WavPackDecoder.h +++ b/include/libnyquist/WavPackDecoder.h @@ -36,7 +36,7 @@ struct WavPackDecoder : public nqr::BaseDecoder WavPackDecoder() {}; virtual ~WavPackDecoder() {}; virtual void LoadFromPath(nqr::AudioData * data, const std::string & path) override; - virtual void LoadFromBuffer(nqr::AudioData * data, const std::vector & memory) override; + virtual void LoadFromBuffer(nqr::AudioData * data, std::vector & memory) override; virtual std::vector GetSupportedFileExtensions() override; }; diff --git a/src/AudioDecoder.cpp b/src/AudioDecoder.cpp index b2f4723..0d537a6 100644 --- a/src/AudioDecoder.cpp +++ b/src/AudioDecoder.cpp @@ -70,7 +70,7 @@ void NyquistIO::Load(AudioData * data, const std::string & path) } } -void NyquistIO::Load(AudioData * data, std::string extension, const std::vector & buffer) +void NyquistIO::Load(AudioData * data, std::string extension, std::vector & buffer) { if (decoderTable.find(extension) == decoderTable.end()) { @@ -148,4 +148,4 @@ void NyquistIO::BuildDecoderTable() AddDecoderToTable(std::make_shared()); AddDecoderToTable(std::make_shared()); AddDecoderToTable(std::make_shared()); -} \ No newline at end of file +} diff --git a/src/CafDecoder.cpp b/src/CafDecoder.cpp index 86ae698..f8025dd 100644 --- a/src/CafDecoder.cpp +++ b/src/CafDecoder.cpp @@ -36,7 +36,7 @@ void CAFDecoder::LoadFromPath(AudioData * data, const std::string & path) throw LoadPathNotImplEx(); } -void CAFDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void CAFDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { throw LoadBufferNotImplEx(); } @@ -44,4 +44,4 @@ void CAFDecoder::LoadFromBuffer(AudioData * data, const std::vector & m std::vector CAFDecoder::GetSupportedFileExtensions() { return {}; -} \ No newline at end of file +} diff --git a/src/FlacDecoder.cpp b/src/FlacDecoder.cpp index 32051be..f0200b4 100644 --- a/src/FlacDecoder.cpp +++ b/src/FlacDecoder.cpp @@ -38,7 +38,7 @@ class FlacDecoderInternal public: // FLAC is a big-endian format. All values are unsigned. - FlacDecoderInternal(AudioData * d, std::string filepath) : d(d) + FlacDecoderInternal(AudioData * d, const std::string & filepath) : d(d) { ///////////////////////////// @@ -90,7 +90,7 @@ public: } - FlacDecoderInternal(AudioData * d, const std::vector & memory) : d(d), data(std::move(memory)), dataPos(0) + FlacDecoderInternal(AudioData * d, std::vector & memory) : d(d), data(std::move(memory)), dataPos(0) { ///////////////////////////// @@ -268,7 +268,7 @@ void FlacDecoder::LoadFromPath(AudioData * data, const std::string & path) FlacDecoderInternal decoder(data, path); } -void FlacDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void FlacDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { FlacDecoderInternal decoder(data, memory); } diff --git a/src/ModplugDecoder.cpp b/src/ModplugDecoder.cpp index badd2c4..82b2ee9 100644 --- a/src/ModplugDecoder.cpp +++ b/src/ModplugDecoder.cpp @@ -38,7 +38,7 @@ class ModplugInternal public: - ModplugInternal(AudioData * d, const std::vector & fileData) : d(d) + ModplugInternal(AudioData * d, std::vector & fileData) : d(d) { ModPlug_Settings mps; ModPlug_GetSettings(&mps); @@ -119,7 +119,7 @@ void ModplugDecoder::LoadFromPath(AudioData * data, const std::string & path) ModplugInternal decoder(data, fileBuffer.buffer); } -void ModplugDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void ModplugDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { ModplugInternal decoder(data, memory); } diff --git a/src/MusepackDecoder.cpp b/src/MusepackDecoder.cpp index f95bbea..8f015fd 100644 --- a/src/MusepackDecoder.cpp +++ b/src/MusepackDecoder.cpp @@ -92,7 +92,7 @@ class MusepackInternal public: // Musepack is a purely variable bitrate format and does not work at a constant bitrate. - MusepackInternal(AudioData * d, const std::vector & fileData) : d(d) + MusepackInternal(AudioData * d, std::vector & fileData) : d(d) { decoderMemory = std::make_shared(); @@ -182,7 +182,7 @@ void MusepackDecoder::LoadFromPath(AudioData * data, const std::string & path) MusepackInternal decoder(data, fileBuffer.buffer); } -void MusepackDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void MusepackDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { MusepackInternal decoder(data, memory); } @@ -190,4 +190,4 @@ void MusepackDecoder::LoadFromBuffer(AudioData * data, const std::vector MusepackDecoder::GetSupportedFileExtensions() { return {"mpc", "mpp"}; -} \ No newline at end of file +} diff --git a/src/OpusDecoder.cpp b/src/OpusDecoder.cpp index 16d51f8..9d8b05e 100644 --- a/src/OpusDecoder.cpp +++ b/src/OpusDecoder.cpp @@ -35,7 +35,7 @@ class OpusDecoderInternal public: - OpusDecoderInternal(AudioData * d, const std::vector & fileData) : d(d) + OpusDecoderInternal(AudioData * d, std::vector & fileData) : d(d) { /* @todo proper steaming support + classes const opus_callbacks = { @@ -166,7 +166,7 @@ void nqr::OpusDecoder::LoadFromPath(AudioData * data, const std::string & path) OpusDecoderInternal decoder(data, fileBuffer.buffer); } -void nqr::OpusDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void nqr::OpusDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { OpusDecoderInternal decoder(data, memory); } @@ -174,4 +174,4 @@ void nqr::OpusDecoder::LoadFromBuffer(AudioData * data, const std::vector nqr::OpusDecoder::GetSupportedFileExtensions() { return {"opus"}; -} \ No newline at end of file +} diff --git a/src/VorbisDecoder.cpp b/src/VorbisDecoder.cpp index 478a78c..61b6953 100644 --- a/src/VorbisDecoder.cpp +++ b/src/VorbisDecoder.cpp @@ -35,7 +35,7 @@ class VorbisDecoderInternal public: - VorbisDecoderInternal(AudioData * d, std::string filepath) : d(d) + VorbisDecoderInternal(AudioData * d, const std::string & filepath) : d(d) { fileHandle = new OggVorbis_File(); @@ -96,7 +96,7 @@ public: throw std::runtime_error("could not read any data"); } - VorbisDecoderInternal(AudioData * d, const std::vector & memory) : d(d), data(std::move(memory)), dataPos(0) + VorbisDecoderInternal(AudioData * d, std::vector & memory) : d(d), data(std::move(memory)), dataPos(0) { fileHandle = new OggVorbis_File(); @@ -269,7 +269,7 @@ void VorbisDecoder::LoadFromPath(AudioData * data, const std::string & path) VorbisDecoderInternal decoder(data, path); } -void VorbisDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void VorbisDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { VorbisDecoderInternal decoder(data, memory); } diff --git a/src/WavDecoder.cpp b/src/WavDecoder.cpp index 6712db5..9f73226 100644 --- a/src/WavDecoder.cpp +++ b/src/WavDecoder.cpp @@ -40,7 +40,7 @@ void WavDecoder::LoadFromPath(AudioData * data, const std::string & path) return LoadFromBuffer(data, fileBuffer.buffer); } -void WavDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void WavDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { ////////////////////// // Read RIFF Header // diff --git a/src/WavPackDecoder.cpp b/src/WavPackDecoder.cpp index 9afc7fa..8569335 100644 --- a/src/WavPackDecoder.cpp +++ b/src/WavPackDecoder.cpp @@ -34,7 +34,7 @@ class WavPackInternal public: - WavPackInternal(AudioData * d, const std::string path) : d(d) + WavPackInternal(AudioData * d, const std::string & path) : d(d) { char errorStr[128]; context = WavpackOpenFileInput(path.c_str(), errorStr, OPEN_WVC | OPEN_NORMALIZE, 0); @@ -80,7 +80,7 @@ public: } - WavPackInternal(AudioData * d, const std::vector & memory) : d(d), data(std::move(memory)), dataPos(0) + WavPackInternal(AudioData * d, std::vector & memory) : d(d), data(std::move(memory)), dataPos(0) { WavpackStreamReader64 reader = { read_bytes, @@ -316,7 +316,7 @@ void WavPackDecoder::LoadFromPath(AudioData * data, const std::string & path) WavPackInternal decoder(data, path); } -void WavPackDecoder::LoadFromBuffer(AudioData * data, const std::vector & memory) +void WavPackDecoder::LoadFromBuffer(AudioData * data, std::vector & memory) { WavPackInternal decoder(data, memory); }