OpenTTD Source: src/sound/sound_driver.hpp Source File

OpenTTD Source 15.3

sound_driver.hpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef SOUND_SOUND_DRIVER_HPP
11#define SOUND_SOUND_DRIVER_HPP
12
13#include "../driver.h"
14
16 class SoundDriver : public Driver {
17public:
19 virtual void MainLoop() {}
20
27 virtual bool HasOutput() const
28 {
29 return true;
30 }
31
35 static SoundDriver *GetInstance()
36 {
37 return static_cast<SoundDriver *>(DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND).get());
38 }
39};
40
41extern std::string _ini_sounddriver;
42
43#endif /* SOUND_SOUND_DRIVER_HPP */
DriverFactoryBase::GetActiveDriver
static std::unique_ptr< Driver > & GetActiveDriver(Driver::Type type)
Get the active driver for the given type.
Definition driver.h:84
Driver
A driver for communicating with the user.
Definition driver.h:21
Driver::DT_SOUND
@ DT_SOUND
A sound driver.
Definition driver.h:41
SoundDriver
Base for all sound drivers.
Definition sound_driver.hpp:16
SoundDriver::MainLoop
virtual void MainLoop()
Called once every tick.
Definition sound_driver.hpp:19
SoundDriver::GetInstance
static SoundDriver * GetInstance()
Get the currently active instance of the sound driver.
Definition sound_driver.hpp:35
SoundDriver::HasOutput
virtual bool HasOutput() const
Whether the driver has an output from which the user can hear sound.
Definition sound_driver.hpp:27
_ini_sounddriver
std::string _ini_sounddriver
The sound driver a stored in the configuration file.
Definition driver.cpp:32