1/*
2 * LegacyClonk
3 *
4 * Copyright (c) 2020-2021, The LegacyClonk Team and contributors
5 *
6 * Distributed under the terms of the ISC license; see accompanying file
7 * "COPYING" for details.
8 *
9 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
10 * See accompanying file "TRADEMARK" for details.
11 *
12 * To redistribute this file separately, substitute the full license texts
13 * for the above references.
14 */
15
16#include "C4Application.h"
17#include "C4AudioSystem.h"
18#include "C4AudioSystemNone.h"
19#include "C4Config.h"
20#include "C4Log.h"
21
22#ifdef USE_SDL_MIXER
23#include "C4AudioSystemSdl.h"
24#endif
25
26C4AudioSystem *C4AudioSystem::NewInstance(
27 const int maxChannels,
28 [[maybe_unused]] const bool preferLinearResampling
29)
30{
31#ifdef USE_SDL_MIXER
32 try
33 {
34 return CreateC4AudioSystemSdl(maxChannels, preferLinearResampling);
35 }
36 catch (const std::runtime_error &e)
37 {
38 Application.LogSystem.CreateLogger(config&: Config.Logging.AudioSystem)->error(msg: e.what());
39 }
40#endif
41 return new C4AudioSystemNone{};
42}
43