Changeset - r24218:c32caa9f014d
[Not reviewed]
src/blitter/factory.hpp
Show inline comments
 
@@ -19,16 +19,16 @@
 

	
 
/**
 
 * The base factory, keeping track of all blitters.
 
 */
 
class BlitterFactory {
 
private:
 
	const char *name;        ///< The name of the blitter factory.
 
	const char *description; ///< The description of the blitter.
 
	const std::string name;        ///< The name of the blitter factory.
 
	const std::string description; ///< The description of the blitter.
 

	
 
	typedef std::map<const char *, BlitterFactory *, StringCompare> Blitters; ///< Map of blitter factories.
 
	typedef std::map<std::string, BlitterFactory *> Blitters; ///< Map of blitter factories.
 

	
 
	/**
 
	 * Get the map with currently known blitters.
 
	 * @return The known blitters.
 
	 */
 
	static Blitters &GetBlitters()
 
@@ -55,13 +55,13 @@ protected:
 
	 * @param usable      Whether the blitter is usable (on the current computer). For example for disabling SSE blitters when the CPU can't handle them.
 
	 * @pre name != nullptr.
 
	 * @pre description != nullptr.
 
	 * @pre There is no blitter registered with this name.
 
	 */
 
	BlitterFactory(const char *name, const char *description, bool usable = true) :
 
			name(stredup(name)), description(stredup(description))
 
			name(name), description(description)
 
	{
 
		if (usable) {
 
			/*
 
			 * Only add when the blitter is usable. Do not bail out or
 
			 * do more special things since the blitters are always
 
			 * instantiated upon start anyhow and freed upon shutdown.
 
@@ -75,56 +75,53 @@ protected:
 

	
 
public:
 
	virtual ~BlitterFactory()
 
	{
 
		GetBlitters().erase(this->name);
 
		if (GetBlitters().empty()) delete &GetBlitters();
 

	
 
		free(this->name);
 
		free(this->description);
 
	}
 

	
 
	/**
 
	 * Find the requested blitter and return his class.
 
	 * @param name the blitter to select.
 
	 * @post Sets the blitter so GetCurrentBlitter() returns it too.
 
	 */
 
	static Blitter *SelectBlitter(const char *name)
 
	static Blitter *SelectBlitter(const std::string &name)
 
	{
 
		BlitterFactory *b = GetBlitterFactory(name);
 
		if (b == nullptr) return nullptr;
 

	
 
		Blitter *newb = b->CreateInstance();
 
		delete *GetActiveBlitter();
 
		*GetActiveBlitter() = newb;
 

	
 
		DEBUG(driver, 1, "Successfully %s blitter '%s'", StrEmpty(name) ? "probed" : "loaded", newb->GetName());
 
		DEBUG(driver, 1, "Successfully %s blitter '%s'", name.empty() ? "probed" : "loaded", newb->GetName());
 
		return newb;
 
	}
 

	
 
	/**
 
	 * Get the blitter factory with the given name.
 
	 * @param name the blitter factory to select.
 
	 * @return The blitter factory, or nullptr when there isn't one with the wanted name.
 
	 */
 
	static BlitterFactory *GetBlitterFactory(const char *name)
 
	static BlitterFactory *GetBlitterFactory(const std::string &name)
 
	{
 
#if defined(DEDICATED)
 
		const char *default_blitter = "null";
 
#elif defined(WITH_COCOA)
 
		const char *default_blitter = "32bpp-anim";
 
#else
 
		const char *default_blitter = "8bpp-optimized";
 
#endif
 
		if (GetBlitters().size() == 0) return nullptr;
 
		const char *bname = (StrEmpty(name)) ? default_blitter : name;
 
		const char *bname = name.empty() ? default_blitter : name.c_str();
 

	
 
		Blitters::iterator it = GetBlitters().begin();
 
		for (; it != GetBlitters().end(); it++) {
 
			BlitterFactory *b = (*it).second;
 
			if (strcasecmp(bname, b->name) == 0) {
 
			if (strcasecmp(bname, b->name.c_str()) == 0) {
 
				return b;
 
			}
 
		}
 
		return nullptr;
 
	}
 

	
 
@@ -145,39 +142,39 @@ public:
 
	static char *GetBlittersInfo(char *p, const char *last)
 
	{
 
		p += seprintf(p, last, "List of blitters:\n");
 
		Blitters::iterator it = GetBlitters().begin();
 
		for (; it != GetBlitters().end(); it++) {
 
			BlitterFactory *b = (*it).second;
 
			p += seprintf(p, last, "%18s: %s\n", b->name, b->GetDescription());
 
			p += seprintf(p, last, "%18s: %s\n", b->name.c_str(), b->GetDescription().c_str());
 
		}
 
		p += seprintf(p, last, "\n");
 

	
 
		return p;
 
	}
 

	
 
	/**
 
	 * Get the long, human readable, name for the Blitter-class.
 
	 */
 
	const char *GetName() const
 
	const std::string &GetName() const
 
	{
 
		return this->name;
 
	}
 

	
 
	/**
 
	 * Get a nice description of the blitter-class.
 
	 */
 
	const char *GetDescription() const
 
	const std::string &GetDescription() const
 
	{
 
		return this->description;
 
	}
 

	
 
	/**
 
	 * Create an instance of this Blitter-class.
 
	 */
 
	virtual Blitter *CreateInstance() = 0;
 
};
 

	
 
extern char *_ini_blitter;
 
extern std::string _ini_blitter;
 
extern bool _blitter_autodetected;
 

	
 
#endif /* BLITTER_FACTORY_HPP */
src/driver.cpp
Show inline comments
 
@@ -10,102 +10,100 @@
 
#include "stdafx.h"
 
#include "debug.h"
 
#include "sound/sound_driver.hpp"
 
#include "music/music_driver.hpp"
 
#include "video/video_driver.hpp"
 
#include "string_func.h"
 
#include <string>
 
#include <sstream>
 

	
 
#include "safeguards.h"
 

	
 
char *_ini_videodriver;              ///< The video driver a stored in the configuration file.
 
std::string _ini_videodriver;        ///< The video driver a stored in the configuration file.
 
std::vector<Dimension> _resolutions; ///< List of resolutions.
 
Dimension _cur_resolution;           ///< The current resolution.
 
bool _rightclick_emulate;            ///< Whether right clicking is emulated.
 

	
 
char *_ini_sounddriver;              ///< The sound driver a stored in the configuration file.
 
std::string _ini_sounddriver;        ///< The sound driver a stored in the configuration file.
 

	
 
char *_ini_musicdriver;              ///< The music driver a stored in the configuration file.
 
std::string _ini_musicdriver;        ///< The music driver a stored in the configuration file.
 

	
 
char *_ini_blitter;                  ///< The blitter as stored in the configuration file.
 
std::string _ini_blitter;            ///< The blitter as stored in the configuration file.
 
bool _blitter_autodetected;          ///< Was the blitter autodetected or specified by the user?
 

	
 
/**
 
 * Get a string parameter the list of parameters.
 
 * @param parm The parameters.
 
 * @param name The parameter name we're looking for.
 
 * @return The parameter value.
 
 */
 
const char *GetDriverParam(const char * const *parm, const char *name)
 
const char *GetDriverParam(const StringList &parm, const char *name)
 
{
 
	size_t len;
 

	
 
	if (parm == nullptr) return nullptr;
 
	if (parm.empty()) return nullptr;
 

	
 
	len = strlen(name);
 
	for (; *parm != nullptr; parm++) {
 
		const char *p = *parm;
 

	
 
		if (strncmp(p, name, len) == 0) {
 
			if (p[len] == '=')  return p + len + 1;
 
			if (p[len] == '\0') return p + len;
 
	size_t len = strlen(name);
 
	for (auto &p : parm) {
 
		if (p.compare(0, len, name) == 0) {
 
			if (p.length() == len) return "";
 
			if (p[len] == '=') return p.c_str() + len + 1;
 
		}
 
	}
 
	return nullptr;
 
}
 

	
 
/**
 
 * Get a boolean parameter the list of parameters.
 
 * @param parm The parameters.
 
 * @param name The parameter name we're looking for.
 
 * @return The parameter value.
 
 */
 
bool GetDriverParamBool(const char * const *parm, const char *name)
 
bool GetDriverParamBool(const StringList &parm, const char *name)
 
{
 
	return GetDriverParam(parm, name) != nullptr;
 
}
 

	
 
/**
 
 * Get an integer parameter the list of parameters.
 
 * @param parm The parameters.
 
 * @param name The parameter name we're looking for.
 
 * @param def  The default value if the parameter doesn't exist.
 
 * @return The parameter value.
 
 */
 
int GetDriverParamInt(const char * const *parm, const char *name, int def)
 
int GetDriverParamInt(const StringList &parm, const char *name, int def)
 
{
 
	const char *p = GetDriverParam(parm, name);
 
	return p != nullptr ? atoi(p) : def;
 
}
 

	
 
/**
 
 * Find the requested driver and return its class.
 
 * @param name the driver to select.
 
 * @param type the type of driver to select
 
 * @post Sets the driver so GetCurrentDriver() returns it too.
 
 */
 
void DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
 
void DriverFactoryBase::SelectDriver(const std::string &name, Driver::Type type)
 
{
 
	if (!DriverFactoryBase::SelectDriverImpl(name, type)) {
 
		StrEmpty(name) ?
 
		name.empty() ?
 
			usererror("Failed to autoprobe %s driver", GetDriverTypeName(type)) :
 
			usererror("Failed to select requested %s driver '%s'", GetDriverTypeName(type), name);
 
			usererror("Failed to select requested %s driver '%s'", GetDriverTypeName(type), name.c_str());
 
	}
 
}
 

	
 
/**
 
 * Find the requested driver and return its class.
 
 * @param name the driver to select.
 
 * @param type the type of driver to select
 
 * @post Sets the driver so GetCurrentDriver() returns it too.
 
 * @return True upon success, otherwise false.
 
 */
 
bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
 
bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type type)
 
{
 
	if (GetDrivers().size() == 0) return false;
 

	
 
	if (StrEmpty(name)) {
 
	if (name.empty()) {
 
		/* Probe for this driver, but do not fall back to dedicated/null! */
 
		for (int priority = 10; priority > 0; priority--) {
 
			Drivers::iterator it = GetDrivers().begin();
 
			for (; it != GetDrivers().end(); ++it) {
 
				DriverFactoryBase *d = (*it).second;
 

	
 
@@ -114,13 +112,13 @@ bool DriverFactoryBase::SelectDriverImpl
 
				if (d->priority != priority) continue;
 

	
 
				Driver *oldd = *GetActiveDriver(type);
 
				Driver *newd = d->CreateInstance();
 
				*GetActiveDriver(type) = newd;
 

	
 
				const char *err = newd->Start(nullptr);
 
				const char *err = newd->Start({});
 
				if (err == nullptr) {
 
					DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
 
					delete oldd;
 
					return true;
 
				}
 

	
 
@@ -128,41 +126,33 @@ bool DriverFactoryBase::SelectDriverImpl
 
				DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
 
				delete newd;
 
			}
 
		}
 
		usererror("Couldn't find any suitable %s driver", GetDriverTypeName(type));
 
	} else {
 
		char *parm;
 
		char buffer[256];
 
		const char *parms[32];
 
		/* Extract the driver name and put parameter list in parm */
 
		std::istringstream buffer(name);
 
		std::string dname;
 
		std::getline(buffer, dname, ':');
 

	
 
		/* Extract the driver name and put parameter list in parm */
 
		strecpy(buffer, name, lastof(buffer));
 
		parm = strchr(buffer, ':');
 
		parms[0] = nullptr;
 
		if (parm != nullptr) {
 
			uint np = 0;
 
			/* Tokenize the parm. */
 
			do {
 
				*parm++ = '\0';
 
				if (np < lengthof(parms) - 1) parms[np++] = parm;
 
				while (*parm != '\0' && *parm != ',') parm++;
 
			} while (*parm == ',');
 
			parms[np] = nullptr;
 
		std::string param;
 
		std::vector<std::string> parms;
 
		while (std::getline(buffer, param, ',')) {
 
			parms.push_back(param);
 
		}
 

	
 
		/* Find this driver */
 
		Drivers::iterator it = GetDrivers().begin();
 
		for (; it != GetDrivers().end(); ++it) {
 
			DriverFactoryBase *d = (*it).second;
 

	
 
			/* Check driver type */
 
			if (d->type != type) continue;
 

	
 
			/* Check driver name */
 
			if (strcasecmp(buffer, d->name) != 0) continue;
 
			if (strcasecmp(dname.c_str(), d->name) != 0) continue;
 

	
 
			/* Found our driver, let's try it */
 
			Driver *newd = d->CreateInstance();
 

	
 
			const char *err = newd->Start(parms);
 
			if (err != nullptr) {
 
@@ -172,13 +162,13 @@ bool DriverFactoryBase::SelectDriverImpl
 

	
 
			DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
 
			delete *GetActiveDriver(type);
 
			*GetActiveDriver(type) = newd;
 
			return true;
 
		}
 
		usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
 
		usererror("No such %s driver: %s\n", GetDriverTypeName(type), dname.c_str());
 
	}
 
}
 

	
 
/**
 
 * Build a human readable list of available drivers, grouped by type.
 
 * @param p The buffer to write to.
 
@@ -218,15 +208,13 @@ DriverFactoryBase::DriverFactoryBase(Dri
 
{
 
	/* Prefix the name with driver type to make it unique */
 
	char buf[32];
 
	strecpy(buf, GetDriverTypeName(type), lastof(buf));
 
	strecpy(buf + 5, name, lastof(buf));
 

	
 
	const char *longname = stredup(buf);
 

	
 
	std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
 
	std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(buf, this));
 
	assert(P.second);
 
}
 

	
 
/**
 
 * Frees memory used for this->name
 
 */
 
@@ -237,13 +225,9 @@ DriverFactoryBase::~DriverFactoryBase()
 
	strecpy(buf, GetDriverTypeName(type), lastof(buf));
 
	strecpy(buf + 5, this->name, lastof(buf));
 

	
 
	Drivers::iterator it = GetDrivers().find(buf);
 
	assert(it != GetDrivers().end());
 

	
 
	const char *longname = (*it).first;
 

	
 
	GetDrivers().erase(it);
 
	free(longname);
 

	
 
	if (GetDrivers().empty()) delete &GetDrivers();
 
}
src/driver.h
Show inline comments
 
@@ -9,27 +9,28 @@
 

	
 
#ifndef DRIVER_H
 
#define DRIVER_H
 

	
 
#include "core/enum_type.hpp"
 
#include "core/string_compare_type.hpp"
 
#include "string_type.h"
 
#include <map>
 

	
 
const char *GetDriverParam(const char * const *parm, const char *name);
 
bool GetDriverParamBool(const char * const *parm, const char *name);
 
int GetDriverParamInt(const char * const *parm, const char *name, int def);
 
const char *GetDriverParam(const StringList &parm, const char *name);
 
bool GetDriverParamBool(const StringList &parm, const char *name);
 
int GetDriverParamInt(const StringList &parm, const char *name, int def);
 

	
 
/** A driver for communicating with the user. */
 
class Driver {
 
public:
 
	/**
 
	 * Start this driver.
 
	 * @param parm Parameters passed to the driver.
 
	 * @return nullptr if everything went okay, otherwise an error message.
 
	 */
 
	virtual const char *Start(const char * const *parm) = 0;
 
	virtual const char *Start(const StringList &parm) = 0;
 

	
 
	/**
 
	 * Stop this driver.
 
	 */
 
	virtual void Stop() = 0;
 

	
 
@@ -63,13 +64,13 @@ private:
 

	
 
	Driver::Type type;       ///< The type of driver.
 
	int priority;            ///< The priority of this factory.
 
	const char *name;        ///< The name of the drivers of this factory.
 
	const char *description; ///< The description of this driver.
 

	
 
	typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers; ///< Type for a map of drivers.
 
	typedef std::map<std::string, DriverFactoryBase *> Drivers; ///< Type for a map of drivers.
 

	
 
	/**
 
	 * Get the map with drivers.
 
	 */
 
	static Drivers &GetDrivers()
 
	{
 
@@ -96,13 +97,13 @@ private:
 
	static const char *GetDriverTypeName(Driver::Type type)
 
	{
 
		static const char * const driver_type_name[] = { "music", "sound", "video" };
 
		return driver_type_name[type];
 
	}
 

	
 
	static bool SelectDriverImpl(const char *name, Driver::Type type);
 
	static bool SelectDriverImpl(const std::string &name, Driver::Type type);
 

	
 
protected:
 
	DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
 

	
 
	virtual ~DriverFactoryBase();
 

	
 
@@ -115,13 +116,13 @@ public:
 
		for (Driver::Type dt = Driver::DT_BEGIN; dt < Driver::DT_END; dt++) {
 
			Driver *driver = *GetActiveDriver(dt);
 
			if (driver != nullptr) driver->Stop();
 
		}
 
	}
 

	
 
	static void SelectDriver(const char *name, Driver::Type type);
 
	static void SelectDriver(const std::string &name, Driver::Type type);
 
	static char *GetDriversInfo(char *p, const char *last);
 

	
 
	/**
 
	 * Get a nice description of the driver-class.
 
	 * @return The description.
 
	 */
src/music/allegro_m.cpp
Show inline comments
 
@@ -23,13 +23,13 @@ static MIDI *_midi = nullptr;
 
/**
 
 * There are multiple modules that might be using Allegro and
 
 * Allegro can only be initiated once.
 
 */
 
extern int _allegro_instance_count;
 

	
 
const char *MusicDriver_Allegro::Start(const char * const *param)
 
const char *MusicDriver_Allegro::Start(const StringList &param)
 
{
 
	if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
 
		DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
 
		return "Failed to set up Allegro";
 
	}
 
	_allegro_instance_count++;
src/music/allegro_m.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "music_driver.hpp"
 

	
 
/** Allegro's music player. */
 
class MusicDriver_Allegro : public MusicDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/music/bemidi.cpp
Show inline comments
 
@@ -21,13 +21,13 @@
 
/** The file we're playing. */
 
static BMidiSynthFile midiSynthFile;
 

	
 
/** Factory for BeOS' midi player. */
 
static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
 

	
 
const char *MusicDriver_BeMidi::Start(const char * const *parm)
 
const char *MusicDriver_BeMidi::Start(const StringList &parm)
 
{
 
	return nullptr;
 
}
 

	
 
void MusicDriver_BeMidi::Stop()
 
{
src/music/bemidi.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "music_driver.hpp"
 

	
 
/** The midi player for BeOS. */
 
class MusicDriver_BeMidi : public MusicDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/music/cocoa_m.cpp
Show inline comments
 
@@ -76,13 +76,13 @@ static void DoSetVolume()
 
}
 

	
 

	
 
/**
 
 * Initialized the MIDI player, including QuickTime initialization.
 
 */
 
const char *MusicDriver_Cocoa::Start(const char * const *parm)
 
const char *MusicDriver_Cocoa::Start(const StringList &parm)
 
{
 
	if (NewMusicPlayer(&_player) != noErr) return "failed to create music player";
 

	
 
	return nullptr;
 
}
 

	
src/music/cocoa_m.h
Show inline comments
 
@@ -11,13 +11,13 @@
 
#define MUSIC_MACOSX_COCOA_H
 

	
 
#include "music_driver.hpp"
 

	
 
class MusicDriver_Cocoa : public MusicDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/music/dmusic.cpp
Show inline comments
 
@@ -1068,13 +1068,13 @@ static const char *LoadDefaultDLSFile(co
 
	}
 

	
 
	return nullptr;
 
}
 

	
 

	
 
const char *MusicDriver_DMusic::Start(const char * const *parm)
 
const char *MusicDriver_DMusic::Start(const StringList &parm)
 
{
 
	/* Initialize COM */
 
	if (FAILED(CoInitializeEx(nullptr, COINITBASE_MULTITHREADED))) return "COM initialization failed";
 

	
 
	/* Create the DirectMusic object */
 
	if (FAILED(CoCreateInstance(
src/music/dmusic.h
Show inline comments
 
@@ -14,13 +14,13 @@
 

	
 
/** Music player making use of DirectX. */
 
class MusicDriver_DMusic : public MusicDriver {
 
public:
 
	virtual ~MusicDriver_DMusic();
 

	
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/music/extmidi.cpp
Show inline comments
 
@@ -33,13 +33,13 @@
 
#define EXTERNAL_PLAYER "timidity"
 
#endif
 

	
 
/** Factory for the midi player that uses external players. */
 
static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
 

	
 
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
 
const char *MusicDriver_ExtMidi::Start(const StringList &parm)
 
{
 
	if (strcmp(VideoDriver::GetInstance()->GetName(), "allegro") == 0 ||
 
			strcmp(SoundDriver::GetInstance()->GetName(), "allegro") == 0) {
 
		return "the extmidi driver does not work when Allegro is loaded.";
 
	}
 

	
src/music/extmidi.h
Show inline comments
 
@@ -19,13 +19,13 @@ private:
 
	pid_t pid;
 

	
 
	void DoPlay();
 
	void DoStop();
 

	
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/music/fluidsynth.cpp
Show inline comments
 
@@ -47,13 +47,13 @@ static void RenderMusicStream(int16 *buf
 
	std::unique_lock<std::mutex> lock{ _midi.synth_mutex, std::try_to_lock };
 

	
 
	if (!lock.owns_lock() || !_midi.synth || !_midi.player) return;
 
	fluid_synth_write_s16(_midi.synth, samples, buffer, 0, 2, buffer, 1, 2);
 
}
 

	
 
const char *MusicDriver_FluidSynth::Start(const char * const *param)
 
const char *MusicDriver_FluidSynth::Start(const StringList &param)
 
{
 
	std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
 

	
 
	const char *sfont_name = GetDriverParam(param, "soundfont");
 
	int sfont_id;
 

	
src/music/fluidsynth.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "music_driver.hpp"
 

	
 
/** Music driver making use of FluidSynth. */
 
class MusicDriver_FluidSynth : public MusicDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/music/music_driver.hpp
Show inline comments
 
@@ -45,9 +45,9 @@ public:
 
	 */
 
	static MusicDriver *GetInstance() {
 
		return static_cast<MusicDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_MUSIC));
 
	}
 
};
 

	
 
extern char *_ini_musicdriver;
 
extern std::string _ini_musicdriver;
 

	
 
#endif /* MUSIC_MUSIC_DRIVER_HPP */
src/music/null_m.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "music_driver.hpp"
 

	
 
/** The music player that does nothing. */
 
class MusicDriver_Null : public MusicDriver {
 
public:
 
	const char *Start(const char * const *param) override { return nullptr; }
 
	const char *Start(const StringList &param) override { return nullptr; }
 

	
 
	void Stop() override { }
 

	
 
	void PlaySong(const MusicSongInfo &song) override { }
 

	
 
	void StopSong() override { }
src/music/os2_m.cpp
Show inline comments
 
@@ -77,13 +77,13 @@ bool MusicDriver_OS2::IsSongPlaying()
 
{
 
	char buf[16];
 
	mciSendString("status song mode", buf, sizeof(buf), nullptr, 0);
 
	return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
 
}
 

	
 
const char *MusicDriver_OS2::Start(const char * const *parm)
 
const char *MusicDriver_OS2::Start(const StringList &parm)
 
{
 
	return 0;
 
}
 

	
 
void MusicDriver_OS2::Stop()
 
{
src/music/os2_m.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "music_driver.hpp"
 

	
 
/** OS/2's music player. */
 
class MusicDriver_OS2 : public MusicDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/music/win32_m.cpp
Show inline comments
 
@@ -359,13 +359,13 @@ bool MusicDriver_Win32::IsSongPlaying()
 
void MusicDriver_Win32::SetVolume(byte vol)
 
{
 
	std::lock_guard<std::mutex> mutex_lock(_midi.lock);
 
	_midi.new_volume = vol;
 
}
 

	
 
const char *MusicDriver_Win32::Start(const char * const *parm)
 
const char *MusicDriver_Win32::Start(const StringList &parm)
 
{
 
	DEBUG(driver, 2, "Win32-MIDI: Start: initializing");
 

	
 
	int resolution = GetDriverParamInt(parm, "resolution", 5);
 
	uint port = (uint)GetDriverParamInt(parm, "port", UINT_MAX);
 
	const char *portname = GetDriverParam(parm, "portname");
src/music/win32_m.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "music_driver.hpp"
 

	
 
/** The Windows music player. */
 
class MusicDriver_Win32 : public MusicDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	void StopSong() override;
src/openttd.cpp
Show inline comments
 
@@ -530,16 +530,16 @@ static const OptionData _options[] = {
 
 * @param argc The number of arguments passed to this game.
 
 * @param argv The values of the arguments.
 
 * @return 0 when there is no error.
 
 */
 
int openttd_main(int argc, char *argv[])
 
{
 
	char *musicdriver = nullptr;
 
	char *sounddriver = nullptr;
 
	char *videodriver = nullptr;
 
	char *blitter = nullptr;
 
	std::string musicdriver;
 
	std::string sounddriver;
 
	std::string videodriver;
 
	std::string blitter;
 
	std::string graphics_set;
 
	std::string sounds_set;
 
	std::string music_set;
 
	Dimension resolution = {0, 0};
 
	/* AfterNewGRFScan sets save_config to true after scanning completed. */
 
	bool save_config = false;
 
@@ -563,25 +563,21 @@ int openttd_main(int argc, char *argv[])
 
	int i;
 
	while ((i = mgo.GetOpt()) != -1) {
 
		switch (i) {
 
		case 'I': graphics_set = mgo.opt; break;
 
		case 'S': sounds_set = mgo.opt; break;
 
		case 'M': music_set = mgo.opt; break;
 
		case 'm': free(musicdriver); musicdriver = stredup(mgo.opt); break;
 
		case 's': free(sounddriver); sounddriver = stredup(mgo.opt); break;
 
		case 'v': free(videodriver); videodriver = stredup(mgo.opt); break;
 
		case 'b': free(blitter); blitter = stredup(mgo.opt); break;
 
		case 'm': musicdriver = mgo.opt; break;
 
		case 's': sounddriver = mgo.opt; break;
 
		case 'v': videodriver = mgo.opt; break;
 
		case 'b': blitter = mgo.opt; break;
 
		case 'D':
 
			free(musicdriver);
 
			free(sounddriver);
 
			free(videodriver);
 
			free(blitter);
 
			musicdriver = stredup("null");
 
			sounddriver = stredup("null");
 
			videodriver = stredup("dedicated");
 
			blitter = stredup("null");
 
			musicdriver = "null";
 
			sounddriver = "null";
 
			videodriver = "dedicated";
 
			blitter = "null";
 
			dedicated = true;
 
			SetDebugString("net=6");
 
			if (mgo.opt != nullptr) {
 
				/* Use the existing method for parsing (openttd -n).
 
				 * However, we do ignore the #company part. */
 
				const char *temp = nullptr;
 
@@ -743,34 +739,32 @@ int openttd_main(int argc, char *argv[])
 
	}
 

	
 
	/* Initialize game palette */
 
	GfxInitPalettes();
 

	
 
	DEBUG(misc, 1, "Loading blitter...");
 
	if (blitter == nullptr && _ini_blitter != nullptr) blitter = stredup(_ini_blitter);
 
	_blitter_autodetected = StrEmpty(blitter);
 
	if (blitter.empty() && !_ini_blitter.empty()) blitter = _ini_blitter;
 
	_blitter_autodetected = blitter.empty();
 
	/* Activate the initial blitter.
 
	 * This is only some initial guess, after NewGRFs have been loaded SwitchNewGRFBlitter may switch to a different one.
 
	 *  - Never guess anything, if the user specified a blitter. (_blitter_autodetected)
 
	 *  - Use 32bpp blitter if baseset or 8bpp-support settings says so.
 
	 *  - Use 8bpp blitter otherwise.
 
	 */
 
	if (!_blitter_autodetected ||
 
			(_support8bpp != S8BPP_NONE && (BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->blitter == BLT_8BPP)) ||
 
			BlitterFactory::SelectBlitter("32bpp-anim") == nullptr) {
 
		if (BlitterFactory::SelectBlitter(blitter) == nullptr) {
 
			StrEmpty(blitter) ?
 
			blitter.empty() ?
 
				usererror("Failed to autoprobe blitter") :
 
				usererror("Failed to select requested blitter '%s'; does it exist?", blitter);
 
				usererror("Failed to select requested blitter '%s'; does it exist?", blitter.c_str());
 
		}
 
	}
 
	free(blitter);
 

	
 
	if (videodriver == nullptr && _ini_videodriver != nullptr) videodriver = stredup(_ini_videodriver);
 
	if (videodriver.empty() && !_ini_videodriver.empty()) videodriver = _ini_videodriver;
 
	DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
 
	free(videodriver);
 

	
 
	InitializeSpriteSorter();
 

	
 
	/* Initialize the zoom level of the screen to normal */
 
	_screen.zoom = ZOOM_LVL_NORMAL;
 

	
 
@@ -821,19 +815,17 @@ int openttd_main(int argc, char *argv[])
 
			ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_MUSIC_NOT_FOUND);
 
			msg.SetDParamStr(0, music_set.c_str());
 
			ScheduleErrorMessage(msg);
 
		}
 
	}
 

	
 
	if (sounddriver == nullptr && _ini_sounddriver != nullptr) sounddriver = stredup(_ini_sounddriver);
 
	if (sounddriver.empty() && !_ini_sounddriver.empty()) sounddriver = _ini_sounddriver;
 
	DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
 
	free(sounddriver);
 

	
 
	if (musicdriver == nullptr && _ini_musicdriver != nullptr) musicdriver = stredup(_ini_musicdriver);
 
	if (musicdriver.empty() && !_ini_musicdriver.empty()) musicdriver = _ini_musicdriver;
 
	DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
 
	free(musicdriver);
 

	
 
	/* Take our initial lock on whatever we might want to do! */
 
	try {
 
		modal_work_lock.lock();
 
		modal_paint_lock.lock();
 
	} catch (const std::system_error&) {
 
@@ -865,29 +857,15 @@ int openttd_main(int argc, char *argv[])
 
		WindowDesc::SaveToConfig();
 
		SaveToHighScore();
 
	}
 

	
 
	/* Reset windowing system, stop drivers, free used memory, ... */
 
	ShutdownGame();
 
	goto exit_normal;
 

	
 
exit_noshutdown:
 
	/* These three are normally freed before bootstrap. */
 
	free(videodriver);
 
	free(blitter);
 

	
 
exit_bootstrap:
 
	/* These are normally freed before exit, but after bootstrap. */
 
	free(musicdriver);
 
	free(sounddriver);
 

	
 
exit_normal:
 
	free(_ini_musicdriver);
 
	free(_ini_sounddriver);
 
	free(_ini_videodriver);
 
	free(_ini_blitter);
 

	
 
	delete scanner;
 

	
 
	extern FILE *_log_fd;
 
	if (_log_fd != nullptr) {
 
		fclose(_log_fd);
src/sound/allegro_s.cpp
Show inline comments
 
@@ -47,13 +47,13 @@ void SoundDriver_Allegro::MainLoop()
 
/**
 
 * There are multiple modules that might be using Allegro and
 
 * Allegro can only be initiated once.
 
 */
 
extern int _allegro_instance_count;
 

	
 
const char *SoundDriver_Allegro::Start(const char * const *parm)
 
const char *SoundDriver_Allegro::Start(const StringList &parm)
 
{
 
	if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
 
		DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
 
		return "Failed to set up Allegro";
 
	}
 
	_allegro_instance_count++;
src/sound/allegro_s.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the allegro sound driver. */
 
class SoundDriver_Allegro : public SoundDriver {
 
public:
 
	const char *Start(const char * const *param);
 
	const char *Start(const StringList &param);
 

	
 
	void Stop();
 

	
 
	void MainLoop();
 
	const char *GetName() const { return "allegro"; }
 
};
src/sound/cocoa_s.cpp
Show inline comments
 
@@ -41,13 +41,13 @@ static OSStatus audioCallback(void *inRe
 
	MxMixSamples(ioData->mBuffers[0].mData, ioData->mBuffers[0].mDataByteSize / 4);
 

	
 
	return noErr;
 
}
 

	
 

	
 
const char *SoundDriver_Cocoa::Start(const char * const *parm)
 
const char *SoundDriver_Cocoa::Start(const StringList &parm)
 
{
 
	struct AURenderCallbackStruct callback;
 
	AudioStreamBasicDescription requestedDesc;
 

	
 
	/* Setup a AudioStreamBasicDescription with the requested format */
 
	requestedDesc.mFormatID = kAudioFormatLinearPCM;
src/sound/cocoa_s.h
Show inline comments
 
@@ -11,13 +11,13 @@
 
#define SOUND_COCOA_H
 

	
 
#include "sound_driver.hpp"
 

	
 
class SoundDriver_Cocoa : public SoundDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 
	const char *GetName() const override { return "cocoa"; }
 
};
 

	
 
class FSoundDriver_Cocoa : public DriverFactoryBase {
src/sound/null_s.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the null sound driver. */
 
class SoundDriver_Null : public SoundDriver {
 
public:
 
	const char *Start(const char * const *param) override { return nullptr; }
 
	const char *Start(const StringList &param) override { return nullptr; }
 

	
 
	void Stop() override { }
 
	const char *GetName() const override { return "null"; }
 
};
 

	
 
/** Factory for the null sound driver. */
src/sound/sdl2_s.cpp
Show inline comments
 
@@ -28,13 +28,13 @@ static FSoundDriver_SDL iFSoundDriver_SD
 
 */
 
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
 
{
 
	MxMixSamples(stream, len / 4);
 
}
 

	
 
const char *SoundDriver_SDL::Start(const char * const *parm)
 
const char *SoundDriver_SDL::Start(const StringList &parm)
 
{
 
	SDL_AudioSpec spec;
 
	SDL_AudioSpec spec_actual;
 

	
 
	/* Only initialise SDL if the video driver hasn't done it already */
 
	int ret_code = 0;
src/sound/sdl_s.cpp
Show inline comments
 
@@ -28,13 +28,13 @@ static FSoundDriver_SDL iFSoundDriver_SD
 
 */
 
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
 
{
 
	MxMixSamples(stream, len / 4);
 
}
 

	
 
const char *SoundDriver_SDL::Start(const char * const *parm)
 
const char *SoundDriver_SDL::Start(const StringList &parm)
 
{
 
	SDL_AudioSpec spec;
 

	
 
	/* Only initialise SDL if the video driver hasn't done it already */
 
	int ret_code = 0;
 
	if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
src/sound/sdl_s.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the SDL sound driver. */
 
class SoundDriver_SDL : public SoundDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 
	const char *GetName() const override { return "sdl"; }
 
};
 

	
 
/** Factory for the SDL sound driver. */
src/sound/sound_driver.hpp
Show inline comments
 
@@ -23,9 +23,9 @@ public:
 
	 */
 
	static SoundDriver *GetInstance() {
 
		return static_cast<SoundDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND));
 
	}
 
};
 

	
 
extern char *_ini_sounddriver;
 
extern std::string _ini_sounddriver;
 

	
 
#endif /* SOUND_SOUND_DRIVER_HPP */
src/sound/win32_s.cpp
Show inline comments
 
@@ -55,13 +55,13 @@ static DWORD WINAPI SoundThread(LPVOID a
 
		WaitForSingleObject(_event, INFINITE);
 
	} while (_waveout != nullptr);
 

	
 
	return 0;
 
}
 

	
 
const char *SoundDriver_Win32::Start(const char * const *parm)
 
const char *SoundDriver_Win32::Start(const StringList &parm)
 
{
 
	WAVEFORMATEX wfex;
 
	wfex.wFormatTag = WAVE_FORMAT_PCM;
 
	wfex.nChannels = 2;
 
	wfex.wBitsPerSample = 16;
 
	wfex.nSamplesPerSec = GetDriverParamInt(parm, "hz", 44100);
src/sound/win32_s.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the sound driver for Windows. */
 
class SoundDriver_Win32 : public SoundDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 
	const char *GetName() const override { return "win32"; }
 
};
 

	
 
/** Factory for the sound driver for Windows. */
src/sound/xaudio2_s.cpp
Show inline comments
 
@@ -123,13 +123,13 @@ static StreamingVoiceContext* _voice_con
 
* Initialises the XAudio2 driver.
 
*
 
* @param parm Driver parameters.
 
* @return An error message if unsuccessful, or nullptr otherwise.
 
*
 
*/
 
const char *SoundDriver_XAudio2::Start(const char * const *parm)
 
const char *SoundDriver_XAudio2::Start(const StringList &parm)
 
{
 
	HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
 

	
 
	if (FAILED(hr))
 
	{
 
		DEBUG(driver, 0, "xaudio2_s: CoInitializeEx failed (%08x)", hr);
src/sound/xaudio2_s.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the XAudio2 sound driver. */
 
class SoundDriver_XAudio2 : public SoundDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 
	const char *GetName() const override { return "xaudio2"; }
 
};
 

	
 
/** Factory for the XAudio2 sound driver. */
src/table/misc_settings.ini
Show inline comments
 
@@ -77,34 +77,34 @@ cat      = SC_BASIC
 
name     = ""musicset""
 
type     = SLE_STRQ
 
var      = BaseMusic::ini_set
 
def      = nullptr
 
cat      = SC_BASIC
 

	
 
[SDTG_STR]
 
[SDTG_SSTR]
 
name     = ""videodriver""
 
type     = SLE_STRQ
 
var      = _ini_videodriver
 
def      = nullptr
 
cat      = SC_EXPERT
 

	
 
[SDTG_STR]
 
[SDTG_SSTR]
 
name     = ""musicdriver""
 
type     = SLE_STRQ
 
var      = _ini_musicdriver
 
def      = nullptr
 
cat      = SC_EXPERT
 

	
 
[SDTG_STR]
 
[SDTG_SSTR]
 
name     = ""sounddriver""
 
type     = SLE_STRQ
 
var      = _ini_sounddriver
 
def      = nullptr
 
cat      = SC_EXPERT
 

	
 
[SDTG_STR]
 
[SDTG_SSTR]
 
name     = ""blitter""
 
type     = SLE_STRQ
 
var      = _ini_blitter
 
def      = nullptr
 

	
 
[SDTG_STR]
src/video/allegro_v.cpp
Show inline comments
 
@@ -407,13 +407,13 @@ static void PollEvent()
 
/**
 
 * There are multiple modules that might be using Allegro and
 
 * Allegro can only be initiated once.
 
 */
 
int _allegro_instance_count = 0;
 

	
 
const char *VideoDriver_Allegro::Start(const char * const *parm)
 
const char *VideoDriver_Allegro::Start(const StringList &parm)
 
{
 
	if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
 
		DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
 
		return "Failed to set up Allegro";
 
	}
 
	_allegro_instance_count++;
src/video/allegro_v.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "video_driver.hpp"
 

	
 
/** The allegro video driver. */
 
class VideoDriver_Allegro : public VideoDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	void MainLoop() override;
src/video/cocoa/cocoa_v.h
Show inline comments
 
@@ -11,13 +11,13 @@
 
#define VIDEO_COCOA_H
 

	
 
#include "../video_driver.hpp"
 

	
 
class VideoDriver_Cocoa : public VideoDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	/** Stop the video driver */
 
	void Stop() override;
 

	
 
	/** Mark dirty a screen region
 
	 * @param left x-coordinate of left border
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -393,13 +393,13 @@ void VideoDriver_Cocoa::Stop()
 
	_cocoa_video_started = false;
 
}
 

	
 
/**
 
 * Initialize a cocoa video subdriver.
 
 */
 
const char *VideoDriver_Cocoa::Start(const char * const *parm)
 
const char *VideoDriver_Cocoa::Start(const StringList &parm)
 
{
 
	if (!MacOSVersionIsAtLeast(10, 6, 0)) return "The Cocoa video driver requires Mac OS X 10.6 or later.";
 

	
 
	if (_cocoa_video_started) return "Already started";
 
	_cocoa_video_started = true;
 

	
 
@@ -517,13 +517,13 @@ void CocoaDialog(const char *title, cons
 
{
 
	_cocoa_video_dialog = true;
 

	
 
	bool wasstarted = _cocoa_video_started;
 
	if (VideoDriver::GetInstance() == NULL) {
 
		setupApplication(); // Setup application before showing dialog
 
	} else if (!_cocoa_video_started && VideoDriver::GetInstance()->Start(NULL) != NULL) {
 
	} else if (!_cocoa_video_started && VideoDriver::GetInstance()->Start(StringList()) != NULL) {
 
		fprintf(stderr, "%s: %s\n", title, message);
 
		return;
 
	}
 

	
 
	NSAlert *alert = [ [ NSAlert alloc ] init ];
 
	[ alert setAlertStyle: NSCriticalAlertStyle ];
src/video/dedicated_v.cpp
Show inline comments
 
@@ -130,13 +130,13 @@ bool _dedicated_forks;
 

	
 
extern bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = nullptr);
 

	
 
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
 

	
 

	
 
const char *VideoDriver_Dedicated::Start(const char * const *parm)
 
const char *VideoDriver_Dedicated::Start(const StringList &parm)
 
{
 
	int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
 
	_dedicated_video_mem = (bpp == 0) ? nullptr : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));
 

	
 
	_screen.width  = _screen.pitch = _cur_resolution.width;
 
	_screen.height = _cur_resolution.height;
src/video/dedicated_v.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "video_driver.hpp"
 

	
 
/** The dedicated server video driver. */
 
class VideoDriver_Dedicated : public VideoDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	void MainLoop() override;
src/video/null_v.cpp
Show inline comments
 
@@ -14,13 +14,13 @@
 

	
 
#include "../safeguards.h"
 

	
 
/** Factory for the null video driver. */
 
static FVideoDriver_Null iFVideoDriver_Null;
 

	
 
const char *VideoDriver_Null::Start(const char * const *parm)
 
const char *VideoDriver_Null::Start(const StringList &parm)
 
{
 
#ifdef _MSC_VER
 
	/* Disable the MSVC assertion message box. */
 
	_set_error_mode(_OUT_TO_STDERR);
 
#endif
 

	
src/video/null_v.h
Show inline comments
 
@@ -15,13 +15,13 @@
 
/** The null video driver. */
 
class VideoDriver_Null : public VideoDriver {
 
private:
 
	uint ticks; ///< Amount of ticks to run.
 

	
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	void MainLoop() override;
src/video/sdl2_v.cpp
Show inline comments
 
@@ -623,13 +623,13 @@ int VideoDriver_SDL::PollEvent()
 
			break;
 
		}
 
	}
 
	return -1;
 
}
 

	
 
const char *VideoDriver_SDL::Start(const char * const *parm)
 
const char *VideoDriver_SDL::Start(const StringList &parm)
 
{
 
	/* Explicitly disable hardware acceleration. Enabling this causes
 
	 * UpdateWindowSurface() to update the window's texture instead of
 
	 * its surface. */
 
	SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION , "0");
 

	
 
@@ -649,13 +649,13 @@ const char *VideoDriver_SDL::Start(const
 

	
 
	const char *dname = SDL_GetCurrentVideoDriver();
 
	DEBUG(driver, 1, "SDL2: using driver '%s'", dname);
 

	
 
	MarkWholeScreenDirty();
 

	
 
	_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr;
 
	_draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
 

	
 
	SDL_StopTextInput();
 
	this->edit_box_focused = false;
 

	
 
	return nullptr;
 
}
src/video/sdl2_v.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "video_driver.hpp"
 

	
 
/** The SDL video driver. */
 
class VideoDriver_SDL : public VideoDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	void MainLoop() override;
src/video/sdl_v.cpp
Show inline comments
 
@@ -593,13 +593,13 @@ int VideoDriver_SDL::PollEvent()
 
			break;
 
		}
 
	}
 
	return -1;
 
}
 

	
 
const char *VideoDriver_SDL::Start(const char * const *parm)
 
const char *VideoDriver_SDL::Start(const StringList &parm)
 
{
 
	char buf[30];
 
	_use_hwpalette = GetDriverParamInt(parm, "hw_palette", 2);
 

	
 
	/* Just on the offchance the audio subsystem started before the video system,
 
	 * check whether any part of SDL has been initialised before getting here.
 
@@ -620,13 +620,13 @@ const char *VideoDriver_SDL::Start(const
 
	SDL_VideoDriverName(buf, sizeof buf);
 
	DEBUG(driver, 1, "SDL: using driver '%s'", buf);
 

	
 
	MarkWholeScreenDirty();
 
	SetupKeyboard();
 

	
 
	_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr;
 
	_draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
 

	
 
	return nullptr;
 
}
 

	
 
void VideoDriver_SDL::SetupKeyboard()
 
{
src/video/sdl_v.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "video_driver.hpp"
 

	
 
/** The SDL video driver. */
 
class VideoDriver_SDL : public VideoDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	void MainLoop() override;
src/video/video_driver.hpp
Show inline comments
 
@@ -101,12 +101,12 @@ public:
 
	 */
 
	static VideoDriver *GetInstance() {
 
		return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
 
	}
 
};
 

	
 
extern char *_ini_videodriver;
 
extern std::string _ini_videodriver;
 
extern std::vector<Dimension> _resolutions;
 
extern Dimension _cur_resolution;
 
extern bool _rightclick_emulate;
 

	
 
#endif /* VIDEO_VIDEO_DRIVER_HPP */
src/video/win32_v.cpp
Show inline comments
 
@@ -1108,13 +1108,13 @@ static void FindResolutions()
 

	
 
	SortResolutions();
 
}
 

	
 
static FVideoDriver_Win32 iFVideoDriver_Win32;
 

	
 
const char *VideoDriver_Win32::Start(const char * const *parm)
 
const char *VideoDriver_Win32::Start(const StringList &parm)
 
{
 
	memset(&_wnd, 0, sizeof(_wnd));
 

	
 
	RegisterWndClass();
 

	
 
	MakePalette();
 
@@ -1129,13 +1129,13 @@ const char *VideoDriver_Win32::Start(con
 

	
 
	AllocateDibSection(_cur_resolution.width, _cur_resolution.height);
 
	this->MakeWindow(_fullscreen);
 

	
 
	MarkWholeScreenDirty();
 

	
 
	_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr && std::thread::hardware_concurrency() > 1;
 
	_draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread") && std::thread::hardware_concurrency() > 1;
 

	
 
	return nullptr;
 
}
 

	
 
void VideoDriver_Win32::Stop()
 
{
src/video/win32_v.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "video_driver.hpp"
 

	
 
/** The video driver for windows. */
 
class VideoDriver_Win32 : public VideoDriver {
 
public:
 
	const char *Start(const char * const *param) override;
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	void MainLoop() override;
0 comments (0 inline, 0 general)