1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#include "Audio/BsAudioManager.h"
4#include "Utility/BsDynLibManager.h"
5#include "Utility/BsDynLib.h"
6
7namespace bs
8{
9 AudioManager::AudioManager(const String& pluginName)
10 {
11 mPlugin = DynLibManager::instance().load(pluginName);
12
13 if(mPlugin != nullptr)
14 {
15 typedef AudioFactory* (*LoadPluginFunc)();
16
17 LoadPluginFunc loadPluginFunc = (LoadPluginFunc)mPlugin->getSymbol("loadPlugin");
18 mFactory = loadPluginFunc();
19
20 if (mFactory != nullptr)
21 mFactory->startUp();
22 }
23 }
24
25 AudioManager::~AudioManager()
26 {
27 if (mPlugin != nullptr)
28 {
29 if (mFactory != nullptr)
30 {
31 typedef void (*UnloadPluginFunc)(AudioFactory*);
32
33 UnloadPluginFunc unloadPluginFunc = (UnloadPluginFunc)mPlugin->getSymbol("unloadPlugin");
34
35 mFactory->shutDown();
36 unloadPluginFunc(mFactory);
37 }
38
39 DynLibManager::instance().unload(mPlugin);
40 }
41 }
42}