From 1de76c80a23060aa7489e366edfcb640d385a618 Mon Sep 17 00:00:00 2001 From: Dimitri Diakopoulos Date: Fri, 25 Dec 2015 06:13:46 -0500 Subject: [PATCH] move impl and fix todo --- include/libnyquist/AudioDecoder.h | 11 +---------- src/AudioDecoder.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/libnyquist/AudioDecoder.h b/include/libnyquist/AudioDecoder.h index 2b54de0..c49ef03 100644 --- a/include/libnyquist/AudioDecoder.h +++ b/include/libnyquist/AudioDecoder.h @@ -79,16 +79,7 @@ private: void BuildDecoderTable(); - void AddDecoderToTable(std::shared_ptr decoder) - { - auto supportedExtensions = decoder->GetSupportedFileExtensions(); - - //@todo: basic sanity checking that the extension isn't already supported - for (const auto ext : supportedExtensions) - { - decoderTable.insert(DecoderPair(ext, decoder)); - } - } + void AddDecoderToTable(std::shared_ptr decoder); std::map> decoderTable; diff --git a/src/AudioDecoder.cpp b/src/AudioDecoder.cpp index a33173e..3cb624e 100644 --- a/src/AudioDecoder.cpp +++ b/src/AudioDecoder.cpp @@ -126,6 +126,17 @@ std::shared_ptr NyquistIO::GetDecoderForExtension(const std::string return nullptr; } +void NyquistIO::AddDecoderToTable(std::shared_ptr decoder) +{ + auto supportedExtensions = decoder->GetSupportedFileExtensions(); + + for (const auto ext : supportedExtensions) + { + if (decoderTable.count(ext) >= 1) throw std::runtime_error("decoder already exists for extension."); + decoderTable.insert(DecoderPair(ext, decoder)); + } +} + void NyquistIO::BuildDecoderTable() { AddDecoderToTable(std::make_shared());