// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "Operation.hpp" #include #include "IdleOperation.hpp" #include "PlaybackOperation.hpp" #include "RecorderOperation.hpp" #include "RouterOperation.hpp" #include "bsp/audio/bsp_audio.hpp" #include "Audio/decoder/decoder.hpp" namespace audio { std::optional> Operation::Create( Operation::Type t, const char *fileName, const audio::PlaybackType &playbackType, std::function dbCallback) { std::unique_ptr inst; switch (t) { case Type::Idle: inst = std::make_unique(fileName); break; case Type::Playback: inst = std::make_unique(fileName, playbackType, dbCallback); break; case Type::Router: inst = std::make_unique(fileName, dbCallback); break; case Type::Recorder: inst = std::make_unique(fileName, dbCallback); break; } if (inst->isInitialized) { inst->opType = t; inst->filePath = fileName; return inst; } else { return {}; } } std::optional> Operation::GetProfile(const Profile::Type type) { auto ret = std::find_if( availableProfiles.begin(), availableProfiles.end(), [type](const auto &w) { return w->GetType() == type; }); if (ret == availableProfiles.end()) { return std::nullopt; } else { return *ret; } } } // namespace audio