MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / audioInitialise

Method audioInitialise

framework/framework.cpp:1008–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1006}
1007
1008void Framework::audioInitialise()
1009{
1010 LogInfo("Initialise Audio");
1011
1012 p->registeredSoundBackends["SDLRaw"].reset(getSDLSoundBackend());
1013 p->registeredSoundBackends["null"].reset(getNullSoundBackend());
1014
1015 auto concurrent_sample_count = Options::audioConcurrentSampleCount.get();
1016
1017 for (auto &soundBackendName : split(Options::audioBackendsOption.get(), ":"))
1018 {
1019 auto backendFactory = p->registeredSoundBackends.find(soundBackendName);
1020 if (backendFactory == p->registeredSoundBackends.end())
1021 {
1022 LogInfo("Sound backend %s not in supported list", soundBackendName);
1023 continue;
1024 }
1025 SoundBackend *backend = backendFactory->second->create(concurrent_sample_count);
1026 if (!backend)
1027 {
1028 LogInfo("Sound backend %s failed to init", soundBackendName);
1029 continue;
1030 }
1031 this->soundBackend.reset(backend);
1032 LogInfo("Using sound backend %s", soundBackendName);
1033 break;
1034 }
1035 if (!this->soundBackend)
1036 {
1037 LogError("No functional sound backend found");
1038 }
1039 this->jukebox = createJukebox(*this);
1040
1041 /* Setup initial gain */
1042 this->soundBackend->setGain(SoundBackend::Gain::Global,
1043 static_cast<float>(Options::audioGlobalGainOption.get()) / 20.0f);
1044 this->soundBackend->setGain(SoundBackend::Gain::Music,
1045 static_cast<float>(Options::audioMusicGainOption.get()) / 20.0f);
1046 this->soundBackend->setGain(SoundBackend::Gain::Sample,
1047 static_cast<float>(Options::audioSampleGainOption.get()) / 20.0f);
1048}
1049
1050void Framework::audioShutdown()
1051{

Callers

nothing calls this directly

Calls 9

getSDLSoundBackendFunction · 0.85
getNullSoundBackendFunction · 0.85
splitFunction · 0.85
createJukeboxFunction · 0.85
endMethod · 0.80
resetMethod · 0.45
getMethod · 0.45
createMethod · 0.45
setGainMethod · 0.45

Tested by

no test coverage detected