File diff r25002:76f645370cb4 → r25003:fdd8312ceea6
src/driver.cpp
Show inline comments
 
@@ -6,16 +6,18 @@
 
 */
 

	
 
/** @file driver.cpp Base for all driver handling. */
 

	
 
#include "stdafx.h"
 
#include "debug.h"
 
#include "error.h"
 
#include "sound/sound_driver.hpp"
 
#include "music/music_driver.hpp"
 
#include "video/video_driver.hpp"
 
#include "string_func.h"
 
#include "table/strings.h"
 
#include <string>
 
#include <sstream>
 

	
 
#include "safeguards.h"
 

	
 
std::string _ini_videodriver;        ///< The video driver a stored in the configuration file.
 
@@ -108,12 +110,14 @@ bool DriverFactoryBase::SelectDriverImpl
 
				DriverFactoryBase *d = (*it).second;
 

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

	
 
				if (type == Driver::DT_VIDEO && !_video_hw_accel && d->UsesHardwareAcceleration()) continue;
 

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

	
 
				const char *err = newd->Start({});
 
				if (err == nullptr) {
 
@@ -122,12 +126,18 @@ bool DriverFactoryBase::SelectDriverImpl
 
					return true;
 
				}
 

	
 
				*GetActiveDriver(type) = oldd;
 
				DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
 
				delete newd;
 

	
 
				if (type == Driver::DT_VIDEO && _video_hw_accel && d->UsesHardwareAcceleration()) {
 
					_video_hw_accel = false;
 
					ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION);
 
					ScheduleErrorMessage(msg);
 
				}
 
			}
 
		}
 
		usererror("Couldn't find any suitable %s driver", GetDriverTypeName(type));
 
	} else {
 
		/* Extract the driver name and put parameter list in parm */
 
		std::istringstream buffer(name);