Index: ps/trunk/source/ps/GameSetup/GameSetup.cpp =================================================================== --- ps/trunk/source/ps/GameSetup/GameSetup.cpp +++ ps/trunk/source/ps/GameSetup/GameSetup.cpp @@ -915,7 +915,7 @@ CNetHost::Initialize(); #if CONFIG2_AUDIO - if (!args.Has("autostart-nonvisual")) + if (!args.Has("autostart-nonvisual") && !g_DisableAudio) ISoundManager::CreateSoundManager(); #endif Index: ps/trunk/source/ps/GameSetup/HWDetect.cpp =================================================================== --- ps/trunk/source/ps/GameSetup/HWDetect.cpp +++ ps/trunk/source/ps/GameSetup/HWDetect.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -143,8 +143,11 @@ scriptInterface.SetProperty(settings, "gfx_card", gfx::CardName()); scriptInterface.SetProperty(settings, "gfx_drv_ver", gfx::DriverInfo()); #if CONFIG2_AUDIO - scriptInterface.SetProperty(settings, "snd_card", g_SoundManager->GetSoundCardNames()); - scriptInterface.SetProperty(settings, "snd_drv_ver", g_SoundManager->GetOpenALVersion()); + if (g_SoundManager) + { + scriptInterface.SetProperty(settings, "snd_card", g_SoundManager->GetSoundCardNames()); + scriptInterface.SetProperty(settings, "snd_drv_ver", g_SoundManager->GetOpenALVersion()); + } #endif ReportSDL(scriptInterface, settings); Index: ps/trunk/source/ps/Util.cpp =================================================================== --- ps/trunk/source/ps/Util.cpp +++ ps/trunk/source/ps/Util.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -137,8 +137,15 @@ fprintf(f, "Video Mode : %dx%d:%d\n", g_VideoMode.GetXRes(), g_VideoMode.GetYRes(), g_VideoMode.GetBPP()); #if CONFIG2_AUDIO - fprintf(f, "Sound Card : %s\n", g_SoundManager->GetSoundCardNames().c_str()); - fprintf(f, "Sound Drivers : %s\n", g_SoundManager->GetOpenALVersion().c_str()); + if (g_SoundManager) + { + fprintf(f, "Sound Card : %s\n", g_SoundManager->GetSoundCardNames().c_str()); + fprintf(f, "Sound Drivers : %s\n", g_SoundManager->GetOpenALVersion().c_str()); + } + else if(g_DisableAudio) + fprintf(f, "Sound : Game was ran without audio\n"); + else + fprintf(f, "Sound : No audio device was found\n"); #else fprintf(f, "Sound : Game was compiled without audio\n"); #endif Index: ps/trunk/source/soundmanager/SoundManager.h =================================================================== --- ps/trunk/source/soundmanager/SoundManager.h +++ ps/trunk/source/soundmanager/SoundManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -96,7 +96,7 @@ CStr8 m_SoundCardNames; CStr8 m_OpenALVersion; public: - CSoundManager(); + CSoundManager(ALCdevice* device); virtual ~CSoundManager(); void StartWorker(); Index: ps/trunk/source/soundmanager/SoundManager.cpp =================================================================== --- ps/trunk/source/soundmanager/SoundManager.cpp +++ ps/trunk/source/soundmanager/SoundManager.cpp @@ -184,11 +184,18 @@ void ISoundManager::CreateSoundManager() { - if (!g_SoundManager) + if (g_SoundManager) + return; + + ALCdevice* device = alcOpenDevice(nullptr); + if (!device) { - g_SoundManager = new CSoundManager(); - g_SoundManager->StartWorker(); + LOGWARNING("No audio device was found."); + return; } + + g_SoundManager = new CSoundManager(device); + g_SoundManager->StartWorker(); } void ISoundManager::SetEnabled(bool doEnable) @@ -227,8 +234,8 @@ return static_cast(param)->ReloadChangedFiles(path); } -CSoundManager::CSoundManager() - : m_Context(nullptr), m_Device(nullptr), m_ALSourceBuffer(nullptr), +CSoundManager::CSoundManager(ALCdevice* device) + : m_Context(nullptr), m_Device(device), m_ALSourceBuffer(nullptr), m_CurrentTune(nullptr), m_CurrentEnvirons(nullptr), m_Worker(nullptr), m_DistressMutex(), m_PlayListItems(nullptr), m_SoundGroups(), m_Gain(.5f), m_MusicGain(.5f), m_AmbientGain(.5f), m_ActionGain(.5f), m_UIGain(.5f), @@ -305,7 +312,9 @@ { Status ret = INFO::OK; - m_Device = alcOpenDevice(NULL); + if(!m_Device) + m_Device = alcOpenDevice(nullptr); + if (m_Device) { ALCint attribs[] = {ALC_STEREO_SOURCES, 16, 0};